upload android base code part3
This commit is contained in:
parent
71b83c22f1
commit
b9e30e05b1
15122 changed files with 2089659 additions and 0 deletions
233
android/art/test/031-class-attributes/expected.txt
Normal file
233
android/art/test/031-class-attributes/expected.txt
Normal file
|
@ -0,0 +1,233 @@
|
|||
public abstract final int
|
||||
public abstract final [I
|
||||
public java.lang.Object
|
||||
public abstract final [Ljava.lang.Object;
|
||||
public ClassAttrs$PublicInnerClass
|
||||
public abstract final [LClassAttrs$PublicInnerClass;
|
||||
protected ClassAttrs$ProtectedInnerClass
|
||||
protected abstract final [LClassAttrs$ProtectedInnerClass;
|
||||
private ClassAttrs$PrivateInnerClass
|
||||
private abstract final [LClassAttrs$PrivateInnerClass;
|
||||
ClassAttrs$PackagePrivateInnerClass
|
||||
abstract final [LClassAttrs$PackagePrivateInnerClass;
|
||||
public abstract interface java.io.Serializable
|
||||
public abstract final [Ljava.io.Serializable;
|
||||
public abstract static interface ClassAttrs$PublicInnerInterface
|
||||
public abstract final [LClassAttrs$PublicInnerInterface;
|
||||
protected abstract static interface ClassAttrs$ProtectedInnerInterface
|
||||
protected abstract final [LClassAttrs$ProtectedInnerInterface;
|
||||
private abstract static interface ClassAttrs$PrivateInnerInterface
|
||||
private abstract final [LClassAttrs$PrivateInnerInterface;
|
||||
abstract static interface ClassAttrs$PackagePrivateInnerInterface
|
||||
abstract final [LClassAttrs$PackagePrivateInnerInterface;
|
||||
***** class ClassAttrs:
|
||||
name: ClassAttrs
|
||||
canonical: ClassAttrs
|
||||
simple: ClassAttrs
|
||||
genericSignature: null
|
||||
super: class java.lang.Object
|
||||
genericSuperclass: class java.lang.Object
|
||||
declaring: null
|
||||
enclosing: null
|
||||
enclosingCon: null
|
||||
enclosingMeth: null
|
||||
modifiers: 1
|
||||
package: null
|
||||
declaredClasses: [10] class ClassAttrs$MemberClass, class ClassAttrs$PackagePrivateInnerClass, class ClassAttrs$PrivateInnerClass, class ClassAttrs$ProtectedInnerClass, class ClassAttrs$PublicInnerClass, class ClassAttrs$PublicMemberClass, interface ClassAttrs$PackagePrivateInnerInterface, interface ClassAttrs$PrivateInnerInterface, interface ClassAttrs$ProtectedInnerInterface, interface ClassAttrs$PublicInnerInterface
|
||||
member classes: [3] class ClassAttrs$PublicInnerClass, class ClassAttrs$PublicMemberClass, interface ClassAttrs$PublicInnerInterface
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: false
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [0]
|
||||
***** class OtherClass:
|
||||
name: OtherClass
|
||||
canonical: OtherClass
|
||||
simple: OtherClass
|
||||
genericSignature: null
|
||||
super: class java.lang.Object
|
||||
genericSuperclass: class java.lang.Object
|
||||
declaring: null
|
||||
enclosing: null
|
||||
enclosingCon: null
|
||||
enclosingMeth: null
|
||||
modifiers: 0
|
||||
package: null
|
||||
declaredClasses: [0]
|
||||
member classes: [0]
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: false
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [0]
|
||||
***** class otherpackage.OtherPackageClass:
|
||||
name: otherpackage.OtherPackageClass
|
||||
canonical: otherpackage.OtherPackageClass
|
||||
simple: OtherPackageClass
|
||||
genericSignature: null
|
||||
super: class java.lang.Object
|
||||
genericSuperclass: class java.lang.Object
|
||||
declaring: null
|
||||
enclosing: null
|
||||
enclosingCon: null
|
||||
enclosingMeth: null
|
||||
modifiers: 1
|
||||
package: package otherpackage, Unknown, version 0.0
|
||||
declaredClasses: [0]
|
||||
member classes: [0]
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: false
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [0]
|
||||
***** class ClassAttrs$1InnerNamed:
|
||||
name: ClassAttrs$1InnerNamed
|
||||
canonical: null
|
||||
simple: InnerNamed
|
||||
genericSignature: null
|
||||
super: class java.lang.Object
|
||||
genericSuperclass: class java.lang.Object
|
||||
declaring: null
|
||||
enclosing: class ClassAttrs
|
||||
enclosingCon: null
|
||||
enclosingMeth: public static void ClassAttrs.main()
|
||||
modifiers: 0
|
||||
package: null
|
||||
declaredClasses: [0]
|
||||
member classes: [0]
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: true
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [0]
|
||||
***** class ClassAttrs$1ConsInnerNamed:
|
||||
name: ClassAttrs$1ConsInnerNamed
|
||||
canonical: null
|
||||
simple: ConsInnerNamed
|
||||
genericSignature: null
|
||||
super: class java.lang.Object
|
||||
genericSuperclass: class java.lang.Object
|
||||
declaring: null
|
||||
enclosing: class ClassAttrs
|
||||
enclosingCon: ClassAttrs()
|
||||
enclosingMeth: null
|
||||
modifiers: 0
|
||||
package: null
|
||||
declaredClasses: [0]
|
||||
member classes: [0]
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: true
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [0]
|
||||
***** class ClassAttrs$1:
|
||||
name: ClassAttrs$1
|
||||
canonical: null
|
||||
simple:
|
||||
genericSignature: null
|
||||
super: class OtherClass
|
||||
genericSuperclass: class OtherClass
|
||||
declaring: null
|
||||
enclosing: class ClassAttrs
|
||||
enclosingCon: null
|
||||
enclosingMeth: public static void ClassAttrs.main()
|
||||
modifiers: 8
|
||||
package: null
|
||||
declaredClasses: [0]
|
||||
member classes: [0]
|
||||
isAnnotation: false
|
||||
isAnonymous: true
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: false
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [0]
|
||||
***** class ClassAttrs$MemberClass:
|
||||
name: ClassAttrs$MemberClass
|
||||
canonical: ClassAttrs.MemberClass
|
||||
simple: MemberClass
|
||||
genericSignature: <XYZ:Ljava/lang/Object;>Ljava/lang/Object;
|
||||
super: class java.lang.Object
|
||||
genericSuperclass: class java.lang.Object
|
||||
declaring: class ClassAttrs
|
||||
enclosing: class ClassAttrs
|
||||
enclosingCon: null
|
||||
enclosingMeth: null
|
||||
modifiers: 8
|
||||
package: null
|
||||
declaredClasses: [0]
|
||||
member classes: [0]
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: false
|
||||
isMemberClass: true
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [0]
|
||||
typeParameters: [1] XYZ
|
||||
***** class FancyClass:
|
||||
name: FancyClass
|
||||
canonical: FancyClass
|
||||
simple: FancyClass
|
||||
genericSignature: <K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/util/HashMap<TK;TV;>;Ljava/util/Map<TK;TV;>;
|
||||
super: class java.util.HashMap
|
||||
genericSuperclass: java.util.HashMap<K, V>
|
||||
declaring: null
|
||||
enclosing: null
|
||||
enclosingCon: null
|
||||
enclosingMeth: null
|
||||
modifiers: 1
|
||||
package: null
|
||||
declaredClasses: [0]
|
||||
member classes: [2] class java.util.AbstractMap$SimpleEntry, class java.util.AbstractMap$SimpleImmutableEntry
|
||||
isAnnotation: false
|
||||
isAnonymous: false
|
||||
isArray: false
|
||||
isEnum: false
|
||||
isInterface: false
|
||||
isLocalClass: false
|
||||
isMemberClass: false
|
||||
isPrimitive: false
|
||||
isSynthetic: false
|
||||
genericInterfaces: [1] java.util.Map<K, V>
|
||||
typeParameters: [2] K, V
|
||||
constructor signature: (LClassAttrs$MemberClass<TXYZ;>;)V
|
||||
method signature: ()Ljava/lang/Class<TXYZ;>;
|
||||
field signature: LClassAttrs$MemberClass<TXYZ;>;
|
6
android/art/test/031-class-attributes/info.txt
Normal file
6
android/art/test/031-class-attributes/info.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
This is a miscellaneous test that was imported into the new-at-the-time
|
||||
runtime test framework. The test is intended to exercise basic features,
|
||||
and as such cannot be build on top of junit, since failure of such basic
|
||||
features might disrupt junit.
|
||||
|
||||
TODO: Real description goes here.
|
356
android/art/test/031-class-attributes/src/ClassAttrs.java
Normal file
356
android/art/test/031-class-attributes/src/ClassAttrs.java
Normal file
|
@ -0,0 +1,356 @@
|
|||
import otherpackage.OtherPackageClass;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ClassAttrs {
|
||||
ClassAttrs() {
|
||||
/* local, not anonymous, not member */
|
||||
class ConsInnerNamed {
|
||||
public void showMe() {
|
||||
printClassAttrs(this.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
ConsInnerNamed cinner = new ConsInnerNamed();
|
||||
cinner.showMe();
|
||||
}
|
||||
|
||||
public class PublicInnerClass {
|
||||
}
|
||||
|
||||
protected class ProtectedInnerClass {
|
||||
}
|
||||
|
||||
private class PrivateInnerClass {
|
||||
}
|
||||
|
||||
class PackagePrivateInnerClass {
|
||||
}
|
||||
|
||||
public interface PublicInnerInterface {
|
||||
}
|
||||
|
||||
protected interface ProtectedInnerInterface {
|
||||
}
|
||||
|
||||
private interface PrivateInnerInterface {
|
||||
}
|
||||
|
||||
interface PackagePrivateInnerInterface {
|
||||
}
|
||||
|
||||
private static void showModifiers(Class<?> c) {
|
||||
System.out.println(Modifier.toString(c.getModifiers()) + " " + c.getName());
|
||||
}
|
||||
|
||||
// https://code.google.com/p/android/issues/detail?id=56267
|
||||
private static void test56267() {
|
||||
// Primitive classes.
|
||||
showModifiers(int.class);
|
||||
showModifiers(int[].class);
|
||||
|
||||
// Regular classes.
|
||||
showModifiers(Object.class);
|
||||
showModifiers(Object[].class);
|
||||
|
||||
// Inner classes.
|
||||
showModifiers(PublicInnerClass.class);
|
||||
showModifiers(PublicInnerClass[].class);
|
||||
showModifiers(ProtectedInnerClass.class);
|
||||
showModifiers(ProtectedInnerClass[].class);
|
||||
showModifiers(PrivateInnerClass.class);
|
||||
showModifiers(PrivateInnerClass[].class);
|
||||
showModifiers(PackagePrivateInnerClass.class);
|
||||
showModifiers(PackagePrivateInnerClass[].class);
|
||||
|
||||
// Regular interfaces.
|
||||
showModifiers(Serializable.class);
|
||||
showModifiers(Serializable[].class);
|
||||
|
||||
// Inner interfaces.
|
||||
showModifiers(PublicInnerInterface.class);
|
||||
showModifiers(PublicInnerInterface[].class);
|
||||
showModifiers(ProtectedInnerInterface.class);
|
||||
showModifiers(ProtectedInnerInterface[].class);
|
||||
showModifiers(PrivateInnerInterface.class);
|
||||
showModifiers(PrivateInnerInterface[].class);
|
||||
showModifiers(PackagePrivateInnerInterface.class);
|
||||
showModifiers(PackagePrivateInnerInterface[].class);
|
||||
}
|
||||
|
||||
public static void main() {
|
||||
test56267();
|
||||
|
||||
printClassAttrs(ClassAttrs.class);
|
||||
printClassAttrs(OtherClass.class);
|
||||
printClassAttrs(OtherPackageClass.class);
|
||||
|
||||
/* local, not anonymous, not member */
|
||||
class InnerNamed {
|
||||
public void showMe() {
|
||||
printClassAttrs(this.getClass());
|
||||
}
|
||||
}
|
||||
InnerNamed inner = new InnerNamed();
|
||||
inner.showMe();
|
||||
|
||||
ClassAttrs attrs = new ClassAttrs();
|
||||
|
||||
/* anonymous, not local, not member */
|
||||
printClassAttrs((new OtherClass() { int i = 5; }).getClass());
|
||||
|
||||
/* member, not anonymous, not local */
|
||||
printClassAttrs(MemberClass.class);
|
||||
|
||||
/* fancy */
|
||||
printClassAttrs(FancyClass.class);
|
||||
|
||||
try {
|
||||
Constructor<?> cons;
|
||||
cons = MemberClass.class.getConstructor(MemberClass.class);
|
||||
System.out.println("constructor signature: "
|
||||
+ getSignatureAttribute(cons));
|
||||
|
||||
Method meth;
|
||||
meth = MemberClass.class.getMethod("foo");
|
||||
System.out.println("method signature: "
|
||||
+ getSignatureAttribute(meth));
|
||||
|
||||
Field field;
|
||||
field = MemberClass.class.getField("mWha");
|
||||
System.out.println("field signature: "
|
||||
+ getSignatureAttribute(field));
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
System.out.println("FAILED: " + nsme);
|
||||
} catch (NoSuchFieldException nsfe) {
|
||||
System.out.println("FAILED: " + nsfe);
|
||||
} catch (RuntimeException re) {
|
||||
System.out.println("FAILED: " + re);
|
||||
re.printStackTrace(System.out);
|
||||
}
|
||||
|
||||
test_isAssignableFrom();
|
||||
test_isInstance();
|
||||
}
|
||||
|
||||
private static void test_isAssignableFrom() {
|
||||
// Can always assign to things of the same type.
|
||||
assertTrue(String.class.isAssignableFrom(String.class));
|
||||
|
||||
// Can assign any reference to java.lang.Object.
|
||||
assertTrue(Object.class.isAssignableFrom(Object.class));
|
||||
assertTrue(Object.class.isAssignableFrom(Class.class));
|
||||
assertTrue(Object.class.isAssignableFrom(String.class));
|
||||
assertFalse(Object.class.isAssignableFrom(int.class));
|
||||
assertFalse(Object.class.isAssignableFrom(long.class));
|
||||
|
||||
// Interfaces.
|
||||
assertTrue(CharSequence.class.isAssignableFrom(String.class));
|
||||
assertFalse(CharSequence.class.isAssignableFrom(Object.class));
|
||||
|
||||
// Superclasses.
|
||||
assertTrue(AccessibleObject.class.isAssignableFrom(Method.class));
|
||||
assertFalse(Method.class.isAssignableFrom(AccessibleObject.class));
|
||||
|
||||
// Arrays.
|
||||
assertTrue(int[].class.isAssignableFrom(int[].class));
|
||||
assertFalse(int[].class.isAssignableFrom(char[].class));
|
||||
assertFalse(char[].class.isAssignableFrom(int[].class));
|
||||
assertTrue(Object.class.isAssignableFrom(int[].class));
|
||||
assertFalse(int[].class.isAssignableFrom(Object.class));
|
||||
|
||||
try {
|
||||
assertFalse(Object.class.isAssignableFrom(null));
|
||||
fail();
|
||||
} catch (NullPointerException expected) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void test_isInstance() {
|
||||
// Can always assign to things of the same type.
|
||||
assertTrue(String.class.isInstance("hello"));
|
||||
|
||||
// Can assign any reference to java.lang.Object.
|
||||
assertTrue(Object.class.isInstance(new Object()));
|
||||
assertTrue(Object.class.isInstance(Class.class));
|
||||
assertTrue(Object.class.isInstance("hello"));
|
||||
|
||||
// Interfaces.
|
||||
assertTrue(CharSequence.class.isInstance("hello"));
|
||||
assertFalse(CharSequence.class.isInstance(new Object()));
|
||||
|
||||
// Superclasses.
|
||||
assertTrue(AccessibleObject.class.isInstance(Method.class.getDeclaredMethods()[0]));
|
||||
assertFalse(Method.class.isInstance(Method.class.getDeclaredFields()[0]));
|
||||
|
||||
// Arrays.
|
||||
assertTrue(int[].class.isInstance(new int[0]));
|
||||
assertFalse(int[].class.isInstance(new char[0]));
|
||||
assertFalse(char[].class.isInstance(new int[0]));
|
||||
assertTrue(Object.class.isInstance(new int[0]));
|
||||
assertFalse(int[].class.isInstance(new Object()));
|
||||
|
||||
assertFalse(Object.class.isInstance(null));
|
||||
}
|
||||
|
||||
private static void assertTrue(boolean b) {
|
||||
if (!b) throw new RuntimeException();
|
||||
}
|
||||
|
||||
private static void assertFalse(boolean b) {
|
||||
if (b) throw new RuntimeException();
|
||||
}
|
||||
|
||||
private static void fail() {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
/* to call the (out-of-scope) <code>getSignatureAttribute</code> methods */
|
||||
public static String getSignatureAttribute(Object obj) {
|
||||
Method method;
|
||||
try {
|
||||
Class<?> c = obj.getClass();
|
||||
if (c == Method.class || c == Constructor.class) {
|
||||
c = Executable.class;
|
||||
}
|
||||
method = c.getDeclaredMethod("getSignatureAttribute");
|
||||
method.setAccessible(true);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
try {
|
||||
return (String) method.invoke(obj);
|
||||
} catch (IllegalAccessException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/* for reflection testing */
|
||||
static class MemberClass<XYZ> {
|
||||
public MemberClass<XYZ> mWha;
|
||||
|
||||
public MemberClass(MemberClass<XYZ> memb) {
|
||||
mWha = memb;
|
||||
}
|
||||
|
||||
public Class<XYZ> foo() throws NoSuchMethodException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* for reflection testing (getClasses vs getDeclaredClasses) */
|
||||
static public class PublicMemberClass {
|
||||
float mBlah;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump a variety of class attributes.
|
||||
*/
|
||||
public static <T> void printClassAttrs(Class<T> clazz) {
|
||||
System.out.println("***** " + clazz + ":");
|
||||
|
||||
System.out.println(" name: "
|
||||
+ clazz.getName());
|
||||
System.out.println(" canonical: "
|
||||
+ clazz.getCanonicalName());
|
||||
System.out.println(" simple: "
|
||||
+ clazz.getSimpleName());
|
||||
System.out.println(" genericSignature: "
|
||||
+ getSignatureAttribute(clazz));
|
||||
|
||||
System.out.println(" super: "
|
||||
+ clazz.getSuperclass());
|
||||
System.out.println(" genericSuperclass: "
|
||||
+ clazz.getGenericSuperclass());
|
||||
System.out.println(" declaring: "
|
||||
+ clazz.getDeclaringClass());
|
||||
System.out.println(" enclosing: "
|
||||
+ clazz.getEnclosingClass());
|
||||
System.out.println(" enclosingCon: "
|
||||
+ clazz.getEnclosingConstructor());
|
||||
System.out.println(" enclosingMeth: "
|
||||
+ clazz.getEnclosingMethod());
|
||||
System.out.println(" modifiers: "
|
||||
+ clazz.getModifiers());
|
||||
System.out.println(" package: "
|
||||
+ clazz.getPackage());
|
||||
|
||||
System.out.println(" declaredClasses: "
|
||||
+ stringifyTypeArray(clazz.getDeclaredClasses()));
|
||||
System.out.println(" member classes: "
|
||||
+ stringifyTypeArray(clazz.getClasses()));
|
||||
|
||||
System.out.println(" isAnnotation: "
|
||||
+ clazz.isAnnotation());
|
||||
System.out.println(" isAnonymous: "
|
||||
+ clazz.isAnonymousClass());
|
||||
System.out.println(" isArray: "
|
||||
+ clazz.isArray());
|
||||
System.out.println(" isEnum: "
|
||||
+ clazz.isEnum());
|
||||
System.out.println(" isInterface: "
|
||||
+ clazz.isInterface());
|
||||
System.out.println(" isLocalClass: "
|
||||
+ clazz.isLocalClass());
|
||||
System.out.println(" isMemberClass: "
|
||||
+ clazz.isMemberClass());
|
||||
System.out.println(" isPrimitive: "
|
||||
+ clazz.isPrimitive());
|
||||
System.out.println(" isSynthetic: "
|
||||
+ clazz.isSynthetic());
|
||||
|
||||
System.out.println(" genericInterfaces: "
|
||||
+ stringifyTypeArray(clazz.getGenericInterfaces()));
|
||||
|
||||
TypeVariable<Class<T>>[] typeParameters = clazz.getTypeParameters();
|
||||
System.out.println(" typeParameters: "
|
||||
+ stringifyTypeArray(typeParameters));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of Type into a string. Start with an array count.
|
||||
*/
|
||||
private static String stringifyTypeArray(Type[] types) {
|
||||
List<String> typeStringList = new ArrayList<String>();
|
||||
for (Type t : types) {
|
||||
typeStringList.add(t.toString());
|
||||
}
|
||||
// Sort types alphabetically so they're always printed in the same order.
|
||||
// For instance, Class.getClasses() does not guarantee any order for the
|
||||
// returned Class[].
|
||||
Collections.sort(typeStringList);
|
||||
|
||||
StringBuilder stb = new StringBuilder();
|
||||
boolean first = true;
|
||||
|
||||
stb.append("[" + types.length + "]");
|
||||
|
||||
for (String typeString : typeStringList) {
|
||||
if (first) {
|
||||
stb.append(" ");
|
||||
first = false;
|
||||
} else {
|
||||
stb.append(", ");
|
||||
}
|
||||
stb.append(typeString);
|
||||
}
|
||||
|
||||
return stb.toString();
|
||||
}
|
||||
}
|
22
android/art/test/031-class-attributes/src/FancyClass.java
Normal file
22
android/art/test/031-class-attributes/src/FancyClass.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FancyClass<K,V> extends HashMap<K,V> implements Map<K,V> {
|
||||
}
|
||||
|
5
android/art/test/031-class-attributes/src/Main.java
Normal file
5
android/art/test/031-class-attributes/src/Main.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
ClassAttrs.main();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
class OtherClass {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package otherpackage;
|
||||
|
||||
public class OtherPackageClass {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue