Skip to content

Commit 89fdc42

Browse files
committed
[GR-38909] Move annotations for substitution system to the SDK module.
PullRequest: graal/11981
2 parents 8206100 + 5aec01f commit 89fdc42

File tree

426 files changed

+1333
-1019
lines changed

Some content is hidden

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

426 files changed

+1333
-1019
lines changed

compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/IntrinsicStubProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private void createStubs(AbstractProcessor processor, TargetVM targetVM, TypeEle
296296
case substrate:
297297
imports.addAll(List.of(
298298
"com.oracle.svm.core.SubstrateTargetDescription",
299-
"com.oracle.svm.core.annotate.Uninterruptible",
299+
"com.oracle.svm.core.Uninterruptible",
300300
"com.oracle.svm.core.snippets.SubstrateForeignCallTarget",
301301
"com.oracle.svm.core.cpufeature.Stubs",
302302
"com.oracle.svm.graal.RuntimeCPUFeatureRegion",

sdk/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
55
## Version 22.3.0
66
* (GR-39852) Native Image API: Added FieldValueTransformer API
77
* (GR-35358) Added `Context.Builder.allowInnerContextOptions(boolean)` which allows the context to spawn inner contexts and modify and override language options. The default value for this privilege is set depending `Context.Builder.allowAllPrivilages(boolean)` is set or not. Do not enable this privilege in security sensitive scenarios.
8+
* (GR-40198) Introduce public API for programmatic JNI / Resource / Proxy / Serialization registration from Feature classes during the image build.
9+
* (GR-38909) Added Native Image com.oracle.svm.core.annotate annotation classes (@Alias, @TargetClass, @Substitute, ...).
810

911
## Version 22.2.0
1012
* (GR-38925) Added `Value.hasMetaParents() and Value.getMetaParents()` that allow lookup of the hierarchy of parents for meta objects (e.g. super class or implemented interface of Java classes).

sdk/mx.sdk/suite.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,16 @@
282282
"javaCompliance" : "11+",
283283
"workingSets" : "API,SDK",
284284
},
285+
"com.oracle.svm.core.annotate" : {
286+
"subDir" : "src",
287+
"sourceDirs" : ["src"],
288+
"dependencies" : [
289+
"org.graalvm.nativeimage",
290+
],
291+
"checkstyle" : "org.graalvm.word",
292+
"javaCompliance" : "11+",
293+
"workingSets" : "API,SDK",
294+
},
285295
"org.graalvm.nativeimage.test" : {
286296
"subDir" : "src",
287297
"sourceDirs" : ["src"],
@@ -395,6 +405,7 @@
395405
"dependencies" : [
396406
"org.graalvm.polyglot",
397407
"org.graalvm.nativeimage",
408+
"com.oracle.svm.core.annotate",
398409
"org.graalvm.collections",
399410
"org.graalvm.home",
400411
],
@@ -407,6 +418,7 @@
407418
"org.graalvm.collections",
408419
"org.graalvm.home",
409420
"org.graalvm.home.impl",
421+
"com.oracle.svm.core.annotate",
410422
"org.graalvm.nativeimage.hosted",
411423
"org.graalvm.nativeimage.c.function",
412424
"org.graalvm.nativeimage.c.struct",

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Alias.java renamed to sdk/src/com.oracle.svm.core.annotate/src/com/oracle/svm/core/annotate/Alias.java

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
11
/*
2-
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
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.
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
2440
*/
2541
package com.oracle.svm.core.annotate;
2642

@@ -53,6 +69,8 @@
5369
* When aliasing *non-static* inner classes the constructors are passed a hidden argument which is
5470
* the outer class. When writing an @Alias for a constructor of a *non-static* inner classes, you
5571
* have to (a) explicitly declare that parameter, and (b) supply it in the calls.
72+
*
73+
* @since 22.3
5674
*/
5775
@Retention(RetentionPolicy.RUNTIME)
5876
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.svm.core.annotate;
42+
43+
import java.lang.annotation.ElementType;
44+
import java.lang.annotation.Retention;
45+
import java.lang.annotation.RetentionPolicy;
46+
import java.lang.annotation.Target;
47+
48+
import org.graalvm.nativeimage.Platform;
49+
import org.graalvm.nativeimage.Platforms;
50+
51+
/**
52+
* This annotation allows to add additional annotations to existing methods but keep the
53+
* implementation as it is.
54+
* <p>
55+
* The element can also be annotated with {@link TargetElement} to specify additional properties.
56+
* See {@link TargetClass} for an overview of the annotation system.
57+
*
58+
* @since 22.3
59+
*/
60+
@Retention(RetentionPolicy.RUNTIME)
61+
@Target(ElementType.METHOD)
62+
@Platforms(Platform.HOSTED_ONLY.class)
63+
public @interface AnnotateOriginal {
64+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.svm.core.annotate;
42+
43+
import java.lang.annotation.ElementType;
44+
import java.lang.annotation.Retention;
45+
import java.lang.annotation.RetentionPolicy;
46+
import java.lang.annotation.Target;
47+
48+
import org.graalvm.nativeimage.Platform;
49+
import org.graalvm.nativeimage.Platforms;
50+
51+
/**
52+
* Supported API is available to replace this non-API annotation: Instead of using this annotation,
53+
* use {@code "--features <fqn.of.FeatureClass>"} in the {@code Args} of a
54+
* {@code native-image.properties} file to ensure a user-provided feature gets processed.
55+
*
56+
* Feature classes can use this annotation are unconditionally added when they are reachable on the
57+
* class path.
58+
*
59+
* @since 22.3
60+
*/
61+
@Retention(RetentionPolicy.RUNTIME)
62+
@Target({ElementType.TYPE})
63+
@Platforms(Platform.HOSTED_ONLY.class)
64+
public @interface AutomaticFeature {
65+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.svm.core.annotate;
42+
43+
import java.lang.annotation.ElementType;
44+
import java.lang.annotation.Retention;
45+
import java.lang.annotation.RetentionPolicy;
46+
import java.lang.annotation.Target;
47+
48+
import org.graalvm.nativeimage.Platform;
49+
import org.graalvm.nativeimage.Platforms;
50+
51+
/**
52+
* Mechanism to ensures that an element is not used.
53+
* <p>
54+
* The element can also be annotated with {@link TargetElement} to specify additional properties.
55+
* See {@link TargetClass} for an overview of the annotation system.
56+
*
57+
* @since 22.3
58+
*/
59+
@Retention(RetentionPolicy.RUNTIME)
60+
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
61+
@Platforms(Platform.HOSTED_ONLY.class)
62+
public @interface Delete {
63+
64+
/**
65+
* Documents the reason why the annotated element is deleted.
66+
*
67+
* @since 22.3
68+
*/
69+
String value() default "";
70+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.svm.core.annotate;
42+
43+
import java.lang.annotation.ElementType;
44+
import java.lang.annotation.Retention;
45+
import java.lang.annotation.RetentionPolicy;
46+
import java.lang.annotation.Target;
47+
48+
import org.graalvm.nativeimage.Platform;
49+
import org.graalvm.nativeimage.Platforms;
50+
51+
/**
52+
* Injects the annotated field into the {@link TargetClass}.
53+
*
54+
* The field must not be declared static. If instances of the target class are in the image heap,
55+
* the field also needs to be annotated with {@link RecomputeFieldValue} to provide a value for the
56+
* injected field.
57+
*
58+
* @since 22.3
59+
*/
60+
@Retention(RetentionPolicy.RUNTIME)
61+
@Target({ElementType.FIELD})
62+
@Platforms(Platform.HOSTED_ONLY.class)
63+
public @interface Inject {
64+
}

0 commit comments

Comments
 (0)