Skip to content

Commit eeedbeb

Browse files
committed
Parse annotations without initializing them
1 parent a569fd3 commit eeedbeb

File tree

87 files changed

+2518
-1184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2518
-1184
lines changed

compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/StructuredGraph.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.graalvm.compiler.nodes;
2626

27+
import static jdk.vm.ci.services.Services.IS_BUILDING_NATIVE_IMAGE;
2728
import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE;
2829

2930
import java.util.ArrayList;
@@ -506,7 +507,7 @@ private StructuredGraph(String name,
506507
}
507508

508509
private static boolean checkIsSubstitutionInvariants(ResolvedJavaMethod method, boolean isSubstitution) {
509-
if (!IS_IN_NATIVE_IMAGE) {
510+
if (!IS_IN_NATIVE_IMAGE && !IS_BUILDING_NATIVE_IMAGE) {
510511
if (method != null) {
511512
if (method.getAnnotation(Snippet.class) != null) {
512513
assert isSubstitution : "Graph for method " + method.format("%H.%n(%p)") +

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@
439439
"sun.text.spi",
440440
"jdk.internal.reflect",
441441
"sun.util.cldr",
442-
"sun.util.locale"
442+
"sun.util.locale",
443+
"sun.invoke.util",
443444
],
444445
"jdk.internal.vm.ci" : [
445446
"jdk.vm.ci.meta",

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/flow/MethodTypeFlowBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
import org.graalvm.compiler.replacements.nodes.ObjectClone;
106106
import org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode;
107107
import org.graalvm.compiler.word.WordCastNode;
108-
import org.graalvm.util.GuardedAnnotationAccess;
108+
import com.oracle.svm.util.GuardedAnnotationAccess;
109109

110110
import com.oracle.graal.pointsto.PointsToAnalysis;
111111
import com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadInstanceFieldTypeFlow;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.graal.pointsto.infrastructure;
26+
27+
import java.lang.reflect.AnnotatedElement;
28+
29+
import com.oracle.svm.util.AnnotationWrapper;
30+
31+
import jdk.vm.ci.meta.ResolvedJavaField;
32+
33+
public interface WrappedJavaField extends WrappedElement, ResolvedJavaField, AnnotationWrapper {
34+
35+
@Override
36+
ResolvedJavaField getWrapped();
37+
38+
@Override
39+
default AnnotatedElement getAnnotationRoot() {
40+
return getWrapped();
41+
}
42+
}

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

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

27+
import java.lang.reflect.AnnotatedElement;
28+
29+
import com.oracle.svm.util.AnnotationWrapper;
30+
2731
import jdk.vm.ci.meta.ResolvedJavaMethod;
2832

29-
public interface WrappedJavaMethod extends WrappedElement, ResolvedJavaMethod {
33+
public interface WrappedJavaMethod extends WrappedElement, ResolvedJavaMethod, AnnotationWrapper {
3034

3135
@Override
3236
ResolvedJavaMethod getWrapped();
37+
38+
@Override
39+
default AnnotatedElement getAnnotationRoot() {
40+
return getWrapped();
41+
}
3342
}

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

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

27+
import java.lang.reflect.AnnotatedElement;
28+
29+
import com.oracle.svm.util.AnnotationWrapper;
30+
2731
import jdk.vm.ci.meta.ResolvedJavaType;
2832

29-
public interface WrappedJavaType extends WrappedElement, ResolvedJavaType {
33+
public interface WrappedJavaType extends WrappedElement, ResolvedJavaType, AnnotationWrapper {
3034

3135
@Override
3236
ResolvedJavaType getWrapped();
37+
38+
@Override
39+
default AnnotatedElement getAnnotationRoot() {
40+
return getWrapped();
41+
}
3342
}

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
package com.oracle.graal.pointsto.meta;
2626

27-
import java.lang.annotation.Annotation;
27+
import java.lang.reflect.AnnotatedElement;
2828
import java.lang.reflect.Field;
2929
import java.lang.reflect.Modifier;
3030
import java.util.Set;
@@ -34,24 +34,25 @@
3434
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
3535

3636
import org.graalvm.compiler.debug.GraalError;
37-
import org.graalvm.util.GuardedAnnotationAccess;
3837

3938
import com.oracle.graal.pointsto.api.DefaultUnsafePartition;
4039
import com.oracle.graal.pointsto.api.HostVM;
4140
import com.oracle.graal.pointsto.api.PointstoOptions;
4241
import com.oracle.graal.pointsto.flow.ContextInsensitiveFieldTypeFlow;
4342
import com.oracle.graal.pointsto.flow.FieldTypeFlow;
4443
import com.oracle.graal.pointsto.infrastructure.OriginalFieldProvider;
44+
import com.oracle.graal.pointsto.infrastructure.WrappedJavaField;
4545
import com.oracle.graal.pointsto.typestate.TypeState;
4646
import com.oracle.graal.pointsto.util.AtomicUtils;
4747
import com.oracle.graal.pointsto.util.ConcurrentLightHashSet;
48+
import com.oracle.svm.util.AnnotationWrapper;
4849
import com.oracle.svm.util.UnsafePartitionKind;
4950

5051
import jdk.vm.ci.meta.JavaKind;
5152
import jdk.vm.ci.meta.ResolvedJavaField;
5253
import jdk.vm.ci.meta.ResolvedJavaType;
5354

54-
public abstract class AnalysisField extends AnalysisElement implements ResolvedJavaField, OriginalFieldProvider {
55+
public abstract class AnalysisField extends AnalysisElement implements WrappedJavaField, OriginalFieldProvider, AnnotationWrapper {
5556

5657
@SuppressWarnings("rawtypes")//
5758
private static final AtomicReferenceFieldUpdater<AnalysisField, Object> OBSERVERS_UPDATER = //
@@ -167,6 +168,11 @@ private static AnalysisType getDeclaredType(AnalysisUniverse universe, ResolvedJ
167168
return universe.lookup(resolvedType);
168169
}
169170

171+
@Override
172+
public ResolvedJavaField getWrapped() {
173+
return wrapped;
174+
}
175+
170176
public void copyAccessInfos(AnalysisField other) {
171177
isAccessedUpdater.set(this, other.isAccessed);
172178
isUnsafeAccessedUpdater.set(this, other.isUnsafeAccessed);
@@ -482,18 +488,8 @@ public boolean isStatic() {
482488
}
483489

484490
@Override
485-
public Annotation[] getAnnotations() {
486-
return GuardedAnnotationAccess.getAnnotations(wrapped);
487-
}
488-
489-
@Override
490-
public Annotation[] getDeclaredAnnotations() {
491-
return GuardedAnnotationAccess.getDeclaredAnnotations(wrapped);
492-
}
493-
494-
@Override
495-
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
496-
return GuardedAnnotationAccess.getAnnotation(wrapped, annotationClass);
491+
public AnnotatedElement getAnnotationRoot() {
492+
return wrapped;
497493
}
498494

499495
@Override

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.graalvm.compiler.nodes.GraphDecoder;
4646
import org.graalvm.compiler.nodes.StructuredGraph;
4747
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
48-
import org.graalvm.util.GuardedAnnotationAccess;
4948

5049
import com.oracle.graal.pointsto.BigBang;
5150
import com.oracle.graal.pointsto.api.PointstoOptions;
@@ -572,21 +571,6 @@ public ConstantPool getConstantPool() {
572571
return getUniverse().lookup(wrapped.getConstantPool(), getDeclaringClass());
573572
}
574573

575-
@Override
576-
public Annotation[] getAnnotations() {
577-
return GuardedAnnotationAccess.getAnnotations(wrapped);
578-
}
579-
580-
@Override
581-
public Annotation[] getDeclaredAnnotations() {
582-
return GuardedAnnotationAccess.getDeclaredAnnotations(wrapped);
583-
}
584-
585-
@Override
586-
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
587-
return GuardedAnnotationAccess.getAnnotation(wrapped, annotationClass);
588-
}
589-
590574
@Override
591575
public Annotation[][] getParameterAnnotations() {
592576
return wrapped.getParameterAnnotations();

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package com.oracle.graal.pointsto.meta;
2626

27-
import java.lang.annotation.Annotation;
2827
import java.util.ArrayList;
2928
import java.util.Arrays;
3029
import java.util.Collection;
@@ -42,7 +41,6 @@
4241

4342
import org.graalvm.compiler.debug.GraalError;
4443
import org.graalvm.compiler.graph.Node;
45-
import org.graalvm.util.GuardedAnnotationAccess;
4644
import org.graalvm.word.WordBase;
4745

4846
import com.oracle.graal.pointsto.BigBang;
@@ -1100,21 +1098,6 @@ public AnalysisField[] getStaticFields() {
11001098
return convertFields(wrapped.getStaticFields(), new ArrayList<>(), false);
11011099
}
11021100

1103-
@Override
1104-
public Annotation[] getAnnotations() {
1105-
return GuardedAnnotationAccess.getAnnotations(wrapped);
1106-
}
1107-
1108-
@Override
1109-
public Annotation[] getDeclaredAnnotations() {
1110-
return GuardedAnnotationAccess.getDeclaredAnnotations(wrapped);
1111-
}
1112-
1113-
@Override
1114-
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
1115-
return GuardedAnnotationAccess.getAnnotation(wrapped, annotationClass);
1116-
}
1117-
11181101
@Override
11191102
public String getSourceFileName() {
11201103
// getSourceFileName is not implemented for primitive types

substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
8383
import org.graalvm.nativeimage.c.constant.CEnum;
8484
import org.graalvm.nativeimage.c.function.CEntryPoint;
85-
import org.graalvm.util.GuardedAnnotationAccess;
85+
import com.oracle.svm.util.GuardedAnnotationAccess;
8686

8787
import com.oracle.svm.core.FrameAccess;
8888
import com.oracle.svm.core.ReservedRegisters;

0 commit comments

Comments
 (0)