< prev index next >
test/java/lang/annotation/Missing/MissingTest.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 21,39 ****
* questions.
*/
/*
* @test
! * @bug 6322301
* @summary Verify when missing annotation classes cause exceptions
* @author Joseph D. Darcy
! * @compile MissingTest.java A.java B.java C.java D.java Marker.java Missing.java MissingWrapper.java
* @clean Missing
* @run main MissingTest
*/
import java.lang.reflect.*;
/**
* This test verifies that a missing annotation class leads to the
* expected exceptional behavior; a missing directly applied
* annotation is currently ignored but a missing annotation value
--- 21,40 ----
* questions.
*/
/*
* @test
! * @bug 6322301 5041778
* @summary Verify when missing annotation classes cause exceptions
* @author Joseph D. Darcy
! * @compile MissingTest.java A.java B.java C.java D.java Marker.java Missing.java MissingWrapper.java MissingDefault.java
* @clean Missing
* @run main MissingTest
*/
import java.lang.reflect.*;
+ import java.lang.annotation.*;
/**
* This test verifies that a missing annotation class leads to the
* expected exceptional behavior; a missing directly applied
* annotation is currently ignored but a missing annotation value
*** 110,120 ****
throw new RuntimeException(t);
}
}
}
! public static void main(String argv[]) throws Exception {
// Class A has a directly applied annotation whose class is
// missing.
testAnnotation(A.class, false);
// Class B has a directly applied annotation whose value
--- 111,134 ----
throw new RuntimeException(t);
}
}
}
! private static void testMethodGetDefaultValue(Class<?> clazz) throws Exception{
! Method m = clazz.getMethod("value", (Class<?>[])null);
!
! try {
! System.out.println(m.getDefaultValue());
! throw new RuntimeException("Expected exception not thrown");
! } catch (TypeNotPresentException tnpe) {
! ; // Expected
! } catch (AnnotationFormatError afe) {
! throw new RuntimeException(afe);
! }
! }
!
! public static void main(String... args) throws Exception {
// Class A has a directly applied annotation whose class is
// missing.
testAnnotation(A.class, false);
// Class B has a directly applied annotation whose value
*** 129,135 ****
--- 143,151 ----
// Class D has a directly applied parameter annotation whose value
// includes to an annotation class that is missing.
testParameterAnnotation(D.class.getDeclaredMethod("method1", Object.class),
true);
+ // The MissingDefault annotation type has a default value of the Missing class.
+ testMethodGetDefaultValue(MissingDefault.class);
}
}
< prev index next >