类java.lang.NoSuchFieldException源码实例Demo

下面列出了怎么用java.lang.NoSuchFieldException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TencentKona-8   文件: RedefineAnnotations.java
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
源代码2 项目: TencentKona-8   文件: RedefineAnnotations.java
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
源代码3 项目: jdk8u60   文件: RedefineAnnotations.java
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
源代码4 项目: jdk8u60   文件: RedefineAnnotations.java
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
源代码5 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
源代码6 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
源代码9 项目: openjdk-jdk9   文件: RedefineAnnotations.java
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
源代码10 项目: openjdk-jdk9   文件: RedefineAnnotations.java
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
源代码11 项目: hottub   文件: RedefineAnnotations.java
private void verifyArrayFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType at;

    at = c.getDeclaredField("typeAnnotatedArray").getAnnotatedType();
    anno = at.getAnnotations()[0];
    verifyTestAnn(arrayTA[0], anno, "array1");
    arrayTA[0] = anno;

    for (int i = 1; i <= 3; i++) {
        at = ((AnnotatedArrayType) at).getAnnotatedGenericComponentType();
        anno = at.getAnnotations()[0];
        verifyTestAnn(arrayTA[i], anno, "array" + (i + 1));
        arrayTA[i] = anno;
    }
}
 
源代码12 项目: hottub   文件: RedefineAnnotations.java
private void verifyMethodTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {
    Annotation anno;
    Executable typeAnnotatedMethod =
        c.getDeclaredMethod("typeAnnotatedMethod", TypeAnnotatedTestClass.class);

    anno = typeAnnotatedMethod.getAnnotatedReturnType().getAnnotations()[0];
    verifyTestAnn(returnTA, anno, "return");
    returnTA = anno;

    anno = typeAnnotatedMethod.getTypeParameters()[0].getAnnotations()[0];
    verifyTestAnn(methodTypeParameterTA, anno, "methodTypeParameter");
    methodTypeParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedParameterTypes()[0].getAnnotations()[0];
    verifyTestAnn(formalParameterTA, anno, "formalParameter");
    formalParameterTA = anno;

    anno = typeAnnotatedMethod.getAnnotatedExceptionTypes()[0].getAnnotations()[0];
    verifyTestAnn(throwsTA, anno, "throws");
    throwsTA = anno;
}
 
源代码13 项目: TencentKona-8   文件: RedefineAnnotations.java
public static void main(String argv[]) throws NoSuchFieldException, NoSuchMethodException {
    if (argv.length == 1 && argv[0].equals("buildagent")) {
        buildAgent();
        return;
    }

    if (inst == null) {
        throw new RuntimeException("Instrumentation object was null");
    }

    RedefineAnnotations test = new RedefineAnnotations();
    test.testTransformAndVerify();
}
 
源代码14 项目: TencentKona-8   文件: RedefineAnnotations.java
private void testTransformAndVerify()
    throws NoSuchFieldException, NoSuchMethodException {

    Class<TypeAnnotatedTestClass> c = TypeAnnotatedTestClass.class;
    Class<?> myClass = c;

    /*
     * Verify that the expected annotations are where they should be before transform.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);

    try {
        inst.addTransformer(new Transformer(), true);
        inst.retransformClasses(myClass);
    } catch (UnmodifiableClassException e) {
        throw new RuntimeException(e);
    }

    /*
     * Verify that the expected annotations are where they should be after transform.
     * Also verify that before and after are equal.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);
}
 
源代码15 项目: TencentKona-8   文件: RedefineAnnotations.java
private void verifyFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    verifyBasicFieldTypeAnnotations(c);
    verifyInnerFieldTypeAnnotations(c);
    verifyArrayFieldTypeAnnotations(c);
    verifyMapFieldTypeAnnotations(c);
}
 
源代码16 项目: TencentKona-8   文件: RedefineAnnotations.java
private void verifyBasicFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno = c.getDeclaredField("typeAnnotatedBoolean").getAnnotatedType().getAnnotations()[0];
    verifyTestAnn(fieldTA, anno, "field");
    fieldTA = anno;
}
 
源代码17 项目: TencentKona-8   文件: RedefineAnnotations.java
private void verifyInnerFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    AnnotatedType at = c.getDeclaredField("typeAnnotatedInner").getAnnotatedType();
    Annotation anno = at.getAnnotations()[0];
    verifyTestAnn(innerTA, anno, "inner");
    innerTA = anno;
}
 
源代码18 项目: TencentKona-8   文件: RedefineAnnotations.java
private void verifyMapFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType atBase;
    AnnotatedType atParameter;
    atBase = c.getDeclaredField("typeAnnotatedMap").getAnnotatedType();

    anno = atBase.getAnnotations()[0];
    verifyTestAnn(mapTA[0], anno, "map1");
    mapTA[0] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[0];
    anno = ((AnnotatedWildcardType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[1], anno, "map2");
    mapTA[1] = anno;

    anno =
        ((AnnotatedWildcardType) atParameter).
        getAnnotatedUpperBounds()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[2], anno, "map3");
    mapTA[2] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[1];
    anno = ((AnnotatedParameterizedType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[3], anno, "map4");
    mapTA[3] = anno;

    anno =
        ((AnnotatedParameterizedType) atParameter).
        getAnnotatedActualTypeArguments()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[4], anno, "map5");
    mapTA[4] = anno;
}
 
源代码19 项目: jdk8u60   文件: RedefineAnnotations.java
public static void main(String argv[]) throws NoSuchFieldException, NoSuchMethodException {
    if (argv.length == 1 && argv[0].equals("buildagent")) {
        buildAgent();
        return;
    }

    if (inst == null) {
        throw new RuntimeException("Instrumentation object was null");
    }

    RedefineAnnotations test = new RedefineAnnotations();
    test.testTransformAndVerify();
}
 
源代码20 项目: jdk8u60   文件: RedefineAnnotations.java
private void testTransformAndVerify()
    throws NoSuchFieldException, NoSuchMethodException {

    Class<TypeAnnotatedTestClass> c = TypeAnnotatedTestClass.class;
    Class<?> myClass = c;

    /*
     * Verify that the expected annotations are where they should be before transform.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);

    try {
        inst.addTransformer(new Transformer(), true);
        inst.retransformClasses(myClass);
    } catch (UnmodifiableClassException e) {
        throw new RuntimeException(e);
    }

    /*
     * Verify that the expected annotations are where they should be after transform.
     * Also verify that before and after are equal.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);
}
 
源代码21 项目: jdk8u60   文件: RedefineAnnotations.java
private void verifyFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    verifyBasicFieldTypeAnnotations(c);
    verifyInnerFieldTypeAnnotations(c);
    verifyArrayFieldTypeAnnotations(c);
    verifyMapFieldTypeAnnotations(c);
}
 
源代码22 项目: jdk8u60   文件: RedefineAnnotations.java
private void verifyBasicFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno = c.getDeclaredField("typeAnnotatedBoolean").getAnnotatedType().getAnnotations()[0];
    verifyTestAnn(fieldTA, anno, "field");
    fieldTA = anno;
}
 
源代码23 项目: jdk8u60   文件: RedefineAnnotations.java
private void verifyInnerFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    AnnotatedType at = c.getDeclaredField("typeAnnotatedInner").getAnnotatedType();
    Annotation anno = at.getAnnotations()[0];
    verifyTestAnn(innerTA, anno, "inner");
    innerTA = anno;
}
 
源代码24 项目: jdk8u60   文件: RedefineAnnotations.java
private void verifyMapFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType atBase;
    AnnotatedType atParameter;
    atBase = c.getDeclaredField("typeAnnotatedMap").getAnnotatedType();

    anno = atBase.getAnnotations()[0];
    verifyTestAnn(mapTA[0], anno, "map1");
    mapTA[0] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[0];
    anno = ((AnnotatedWildcardType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[1], anno, "map2");
    mapTA[1] = anno;

    anno =
        ((AnnotatedWildcardType) atParameter).
        getAnnotatedUpperBounds()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[2], anno, "map3");
    mapTA[2] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[1];
    anno = ((AnnotatedParameterizedType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[3], anno, "map4");
    mapTA[3] = anno;

    anno =
        ((AnnotatedParameterizedType) atParameter).
        getAnnotatedActualTypeArguments()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[4], anno, "map5");
    mapTA[4] = anno;
}
 
源代码25 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
public static void main(String argv[]) throws NoSuchFieldException, NoSuchMethodException {
    if (argv.length == 1 && argv[0].equals("buildagent")) {
        buildAgent();
        return;
    }

    if (inst == null) {
        throw new RuntimeException("Instrumentation object was null");
    }

    RedefineAnnotations test = new RedefineAnnotations();
    test.testTransformAndVerify();
}
 
源代码26 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void testTransformAndVerify()
    throws NoSuchFieldException, NoSuchMethodException {

    Class<TypeAnnotatedTestClass> c = TypeAnnotatedTestClass.class;
    Class<?> myClass = c;

    /*
     * Verify that the expected annotations are where they should be before transform.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);

    try {
        inst.addTransformer(new Transformer(), true);
        inst.retransformClasses(myClass);
    } catch (UnmodifiableClassException e) {
        throw new RuntimeException(e);
    }

    /*
     * Verify that the expected annotations are where they should be after transform.
     * Also verify that before and after are equal.
     */
    verifyClassTypeAnnotations(c);
    verifyFieldTypeAnnotations(c);
    verifyMethodTypeAnnotations(c);
}
 
源代码27 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void verifyFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    verifyBasicFieldTypeAnnotations(c);
    verifyInnerFieldTypeAnnotations(c);
    verifyArrayFieldTypeAnnotations(c);
    verifyMapFieldTypeAnnotations(c);
}
 
源代码28 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void verifyBasicFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno = c.getDeclaredField("typeAnnotatedBoolean").getAnnotatedType().getAnnotations()[0];
    verifyTestAnn(fieldTA, anno, "field");
    fieldTA = anno;
}
 
源代码29 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void verifyInnerFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    AnnotatedType at = c.getDeclaredField("typeAnnotatedInner").getAnnotatedType();
    Annotation anno = at.getAnnotations()[0];
    verifyTestAnn(innerTA, anno, "inner");
    innerTA = anno;
}
 
源代码30 项目: openjdk-jdk8u   文件: RedefineAnnotations.java
private void verifyMapFieldTypeAnnotations(Class c)
    throws NoSuchFieldException, NoSuchMethodException {

    Annotation anno;
    AnnotatedType atBase;
    AnnotatedType atParameter;
    atBase = c.getDeclaredField("typeAnnotatedMap").getAnnotatedType();

    anno = atBase.getAnnotations()[0];
    verifyTestAnn(mapTA[0], anno, "map1");
    mapTA[0] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[0];
    anno = ((AnnotatedWildcardType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[1], anno, "map2");
    mapTA[1] = anno;

    anno =
        ((AnnotatedWildcardType) atParameter).
        getAnnotatedUpperBounds()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[2], anno, "map3");
    mapTA[2] = anno;

    atParameter =
        ((AnnotatedParameterizedType) atBase).
        getAnnotatedActualTypeArguments()[1];
    anno = ((AnnotatedParameterizedType) atParameter).getAnnotations()[0];
    verifyTestAnn(mapTA[3], anno, "map4");
    mapTA[3] = anno;

    anno =
        ((AnnotatedParameterizedType) atParameter).
        getAnnotatedActualTypeArguments()[0].getAnnotations()[0];
    verifyTestAnn(mapTA[4], anno, "map5");
    mapTA[4] = anno;
}
 
 类所在包
 类方法
 同包方法