Skip to content

Commit e96bf46

Browse files
committed
moved most SubstrateAnnotationExtractor logic in com.oracle.svm.util
1 parent 3cce525 commit e96bf46

File tree

33 files changed

+805
-583
lines changed

33 files changed

+805
-583
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@
228228
"compiler:GRAAL",
229229
],
230230
"requiresConcealed" : {
231-
"java.base" : ["jdk.internal.module"],
231+
"java.base" : [
232+
"jdk.internal.module",
233+
"sun.reflect.annotation"
234+
],
232235
"jdk.internal.vm.ci": [
233236
"jdk.vm.ci.meta",
234237
"jdk.vm.ci.meta.annotation",
@@ -1590,6 +1593,7 @@
15901593
"requiresConcealed": {
15911594
"jdk.internal.vm.ci": [
15921595
"jdk.vm.ci.meta",
1596+
"jdk.vm.ci.meta.annotation",
15931597
"jdk.vm.ci.code",
15941598
"jdk.vm.ci.common",
15951599
]
@@ -1639,6 +1643,7 @@
16391643
"requiresConcealed" : {
16401644
"jdk.internal.vm.ci" : [
16411645
"jdk.vm.ci.meta",
1646+
"jdk.vm.ci.meta.annotation",
16421647
"jdk.vm.ci.code",
16431648
],
16441649
"java.base" : [

substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/StandaloneAnnotationExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
package com.oracle.graal.pointsto.standalone;
2828

29-
import org.graalvm.nativeimage.impl.AnnotationExtractor;
30-
3129
import java.lang.annotation.Annotation;
3230
import java.lang.reflect.AnnotatedElement;
3331
import java.util.Arrays;
3432

33+
import org.graalvm.nativeimage.impl.AnnotationExtractor;
34+
3535
public class StandaloneAnnotationExtractor implements AnnotationExtractor {
3636
// Checkstyle: allow direct annotation access
3737
@Override

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/infrastructure/WrappedJavaField.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@
2424
*/
2525
package com.oracle.graal.pointsto.infrastructure;
2626

27+
import com.oracle.svm.util.AnnotatedWrapper;
28+
2729
import jdk.vm.ci.meta.ResolvedJavaField;
30+
import jdk.vm.ci.meta.annotation.Annotated;
2831

29-
public interface WrappedJavaField extends ResolvedJavaField, WrappedElement {
32+
public interface WrappedJavaField extends ResolvedJavaField, WrappedElement, AnnotatedWrapper {
3033

3134
@Override
3235
ResolvedJavaField getWrapped();
36+
37+
@Override
38+
default Annotated getWrappedAnnotated() {
39+
return getWrapped();
40+
}
3341
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/infrastructure/WrappedJavaMethod.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@
2424
*/
2525
package com.oracle.graal.pointsto.infrastructure;
2626

27+
import com.oracle.svm.util.AnnotatedWrapper;
28+
2729
import jdk.vm.ci.meta.ResolvedJavaMethod;
30+
import jdk.vm.ci.meta.annotation.Annotated;
2831

29-
public interface WrappedJavaMethod extends WrappedElement, ResolvedJavaMethod {
32+
public interface WrappedJavaMethod extends WrappedElement, AnnotatedWrapper, ResolvedJavaMethod {
3033

3134
@Override
3235
ResolvedJavaMethod getWrapped();
36+
37+
@Override
38+
default Annotated getWrappedAnnotated() {
39+
return getWrapped();
40+
}
3341
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/infrastructure/WrappedJavaType.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@
2424
*/
2525
package com.oracle.graal.pointsto.infrastructure;
2626

27+
import com.oracle.svm.util.AnnotatedWrapper;
28+
2729
import jdk.vm.ci.meta.ResolvedJavaType;
30+
import jdk.vm.ci.meta.annotation.Annotated;
2831

29-
public interface WrappedJavaType extends WrappedElement, ResolvedJavaType {
32+
public interface WrappedJavaType extends WrappedElement, AnnotatedWrapper, ResolvedJavaType {
3033

3134
@Override
3235
ResolvedJavaType getWrapped();
36+
37+
@Override
38+
default Annotated getWrappedAnnotated() {
39+
return getWrapped();
40+
}
3341
}

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/BaseLayerField.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import java.lang.annotation.Annotation;
2828

29+
import com.oracle.svm.util.AnnotationsContainer;
30+
2931
import jdk.graal.compiler.debug.GraalError;
3032
import jdk.vm.ci.meta.JavaType;
3133
import jdk.vm.ci.meta.ResolvedJavaField;
@@ -37,7 +39,7 @@
3739
* If a field cannot be looked up by name, a {@link BaseLayerField} is created and put in an
3840
* {@link AnalysisField} to represent this missing field, using the information from the base layer.
3941
*/
40-
public class BaseLayerField extends BaseLayerElement implements ResolvedJavaField {
42+
public class BaseLayerField extends AnnotationsContainer implements ResolvedJavaField {
4143
private final int id;
4244
private final String name;
4345
private final ResolvedJavaType declaringClass;

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/BaseLayerMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.lang.reflect.Type;
2929

3030
import com.oracle.graal.pointsto.infrastructure.ResolvedSignature;
31+
import com.oracle.svm.util.AnnotationsContainer;
3132

3233
import jdk.graal.compiler.debug.GraalError;
3334
import jdk.vm.ci.meta.Constant;
@@ -50,7 +51,7 @@
5051
* {@link BaseLayerMethod} is created and put in an {@link AnalysisMethod} to represent this missing
5152
* method, using the information from the base layer.
5253
*/
53-
public class BaseLayerMethod extends BaseLayerElement implements ResolvedJavaMethod {
54+
public class BaseLayerMethod extends AnnotationsContainer implements ResolvedJavaMethod {
5455
private static final String CLINIT = "<clinit>";
5556

5657
private final int id;

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/BaseLayerType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.List;
2929

3030
import com.oracle.graal.pointsto.util.AnalysisError;
31+
import com.oracle.svm.util.AnnotationsContainer;
3132
import com.oracle.svm.util.OriginalClassProvider;
3233

3334
import jdk.vm.ci.meta.Assumptions;
@@ -47,7 +48,7 @@
4748
* this case, a {@link BaseLayerType} is created using information from the base layer and wrapped
4849
* in an {@link AnalysisType} to replace this missing type is the new layer.
4950
*/
50-
public class BaseLayerType extends BaseLayerElement implements ResolvedJavaType, OriginalClassProvider {
51+
public class BaseLayerType extends AnnotationsContainer implements ResolvedJavaType, OriginalClassProvider {
5152
/**
5253
* The type corresponding to this {@link BaseLayerType} can be created later while building the
5354
* new layer. To avoid both types having the same name, the name of the {@link BaseLayerType} is

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/SubstrateField.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import jdk.vm.ci.meta.JavaKind;
4949
import jdk.vm.ci.meta.PrimitiveConstant;
5050
import jdk.vm.ci.meta.ResolvedJavaField;
51+
import jdk.vm.ci.meta.annotation.AnnotationsInfo;
5152

5253
public class SubstrateField implements SharedField {
5354

@@ -157,19 +158,33 @@ public SubstrateType getDeclaringClass() {
157158
return declaringClass;
158159
}
159160

161+
private RuntimeException annotationsUnimplemented() {
162+
return VMError.unimplemented("Annotations are not available for JIT compilation at image run time: " + format("%H.%n"));
163+
}
164+
165+
@Override
166+
public AnnotationsInfo getDeclaredAnnotationInfo() {
167+
throw annotationsUnimplemented();
168+
}
169+
170+
@Override
171+
public AnnotationsInfo getTypeAnnotationInfo() {
172+
throw annotationsUnimplemented();
173+
}
174+
160175
@Override
161176
public Annotation[] getAnnotations() {
162-
throw VMError.unimplemented("Annotations are not available for JIT compilation at image run time");
177+
throw annotationsUnimplemented();
163178
}
164179

165180
@Override
166181
public Annotation[] getDeclaredAnnotations() {
167-
throw VMError.unimplemented("Annotations are not available for JIT compilation at image run time");
182+
throw annotationsUnimplemented();
168183
}
169184

170185
@Override
171186
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
172-
throw VMError.unimplemented("Annotations are not available for JIT compilation at image run time");
187+
throw annotationsUnimplemented();
173188
}
174189

175190
@Override

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/SubstrateMethod.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import jdk.vm.ci.meta.Signature;
7171
import jdk.vm.ci.meta.SpeculationLog;
7272
import jdk.vm.ci.meta.TriState;
73+
import jdk.vm.ci.meta.annotation.AnnotationsInfo;
7374

7475
public class SubstrateMethod implements SharedRuntimeMethod {
7576

@@ -416,19 +417,33 @@ public ConstantPool getConstantPool() {
416417
throw intentionallyUnimplemented(); // ExcludeFromJacocoGeneratedReport
417418
}
418419

420+
private RuntimeException annotationsUnimplemented() {
421+
return VMError.unimplemented("Annotations are not available for JIT compilation at image run time: " + format("%H.%n(%p)"));
422+
}
423+
424+
@Override
425+
public AnnotationsInfo getDeclaredAnnotationInfo() {
426+
throw annotationsUnimplemented();
427+
}
428+
429+
@Override
430+
public AnnotationsInfo getTypeAnnotationInfo() {
431+
throw annotationsUnimplemented();
432+
}
433+
419434
@Override
420435
public Annotation[] getAnnotations() {
421-
throw VMError.unimplemented("Annotations are not available for JIT compilation at image run time");
436+
throw annotationsUnimplemented();
422437
}
423438

424439
@Override
425440
public Annotation[] getDeclaredAnnotations() {
426-
throw VMError.unimplemented("Annotations are not available for JIT compilation at image run time");
441+
throw annotationsUnimplemented();
427442
}
428443

429444
@Override
430445
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
431-
throw VMError.unimplemented("Annotations are not available for JIT compilation at image run time");
446+
throw annotationsUnimplemented();
432447
}
433448

434449
@Override

0 commit comments

Comments
 (0)