@@ -87,7 +87,7 @@ public String getSourceFile() {
87
87
return source ;
88
88
}
89
89
90
- String checkClassUse (Type type , String what , boolean deep , String origInternalName ) {
90
+ String checkClassUse (Type type , String what , boolean isAnnotation , String origInternalName ) {
91
91
while (type .getSort () == Type .ARRAY ) {
92
92
type = type .getElementType (); // unwrap array
93
93
}
@@ -98,7 +98,8 @@ String checkClassUse(Type type, String what, boolean deep, String origInternalNa
98
98
if (violation != null ) {
99
99
return violation ;
100
100
}
101
- if (deep && forbidNonPortableRuntime ) {
101
+ // try best to check for non portable runtime
102
+ if (forbidNonPortableRuntime ) try {
102
103
final String binaryClassName = type .getClassName ();
103
104
final ClassMetadata c = lookup .lookupRelatedClass (type .getInternalName (), origInternalName );
104
105
if (c != null && c .isNonPortableRuntime ) {
@@ -107,12 +108,15 @@ String checkClassUse(Type type, String what, boolean deep, String origInternalNa
107
108
what , binaryClassName
108
109
);
109
110
}
111
+ } catch (RelatedClassLoadingException e ) {
112
+ // only throw exception if it is not an annotation
113
+ if (false == isAnnotation ) throw e ;
110
114
}
111
115
return null ;
112
116
}
113
117
114
118
String checkClassUse (String internalName , String what , String origInternalName ) {
115
- return checkClassUse (Type .getObjectType (internalName ), what , true , origInternalName );
119
+ return checkClassUse (Type .getObjectType (internalName ), what , false , origInternalName );
116
120
}
117
121
118
122
// TODO: @FunctionalInterface from Java 8 on
@@ -209,7 +213,7 @@ String checkType(Type type) {
209
213
switch (type .getSort ()) {
210
214
case Type .OBJECT :
211
215
final String internalName = type .getInternalName ();
212
- violation = checkClassUse (type , "class/interface" , true , internalName );
216
+ violation = checkClassUse (type , "class/interface" , false , internalName );
213
217
if (violation != null ) {
214
218
return violation ;
215
219
}
@@ -257,8 +261,7 @@ String checkDescriptor(String desc) {
257
261
258
262
String checkAnnotationDescriptor (Type type , boolean visible ) {
259
263
// for annotations, we don't need to look into super-classes, interfaces,...
260
- // -> we just check if its disallowed or internal runtime (only if visible)!
261
- return checkClassUse (type , "annotation" , visible , type .getInternalName ());
264
+ return checkClassUse (type , "annotation" , true , type .getInternalName ());
262
265
}
263
266
264
267
void maybeSuppressCurrentGroup (Type annotation ) {
0 commit comments