Skip to content

Commit 2354882

Browse files
committed
8250768: javac should be adapted to changes in JEP 12
Reviewed-by: mcimadamore, erikj, jjg, ihse
1 parent 18a37f9 commit 2354882

File tree

133 files changed

+3107
-1078
lines changed

Some content is hidden

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

133 files changed

+3107
-1078
lines changed

make/CompileInterimLangtools.gmk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -49,8 +49,8 @@ TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
4949
$(INTERIM_LANGTOOLS_MODULES))
5050

5151
$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
52-
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/PreviewFeature.java, \
53-
DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/, \
52+
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java, \
53+
DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/, \
5454
))
5555

5656
TARGETS += $(COPY_PREVIEW_FEATURES)
@@ -81,8 +81,8 @@ define SetupInterimModule
8181
--module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
8282
$$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
8383
--patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
84-
--add-exports java.base/jdk.internal=java.compiler.interim \
85-
--add-exports java.base/jdk.internal=jdk.compiler.interim, \
84+
--add-exports java.base/jdk.internal.javac=java.compiler.interim \
85+
--add-exports java.base/jdk.internal.javac=jdk.compiler.interim, \
8686
))
8787

8888
$1_DEPS_INTERIM := $$(addsuffix .interim, $$(filter \

make/Docs.gmk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ JAVADOC_TAGS := \
8989
-tag see \
9090
-taglet build.tools.taglet.ExtLink \
9191
-taglet build.tools.taglet.Incubating \
92-
-taglet build.tools.taglet.Preview \
9392
-tagletpath $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
9493
$(CUSTOM_JAVADOC_TAGS) \
9594
#

make/autoconf/spec.gmk.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,16 @@ INTERIM_LANGTOOLS_ADD_EXPORTS := \
658658
--add-exports java.base/jdk.internal.jmod=jdk.compiler.interim \
659659
--add-exports java.base/jdk.internal.misc=jdk.compiler.interim \
660660
--add-exports java.base/sun.invoke.util=jdk.compiler.interim \
661+
--add-exports java.base/jdk.internal.javac=java.compiler.interim \
662+
--add-exports java.base/jdk.internal.javac=jdk.compiler.interim \
661663
#
662664
INTERIM_LANGTOOLS_MODULES_COMMA := $(strip $(subst $(SPACE),$(COMMA),$(strip \
663665
$(INTERIM_LANGTOOLS_MODULES))))
664666
INTERIM_LANGTOOLS_ARGS := \
665667
--limit-modules java.base,jdk.zipfs,$(INTERIM_LANGTOOLS_MODULES_COMMA) \
666668
--add-modules $(INTERIM_LANGTOOLS_MODULES_COMMA) \
667669
--module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
670+
--patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
668671
$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
669672
#
670673
JAVAC_MAIN_CLASS = -m jdk.compiler.interim/com.sun.tools.javac.Main

make/jdk/src/classes/build/tools/taglet/Preview.java

Lines changed: 0 additions & 79 deletions
This file was deleted.

make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,20 +1112,32 @@ private Annotation[][] createParameterAnnotations(List<CPInfo> constantPool, Lis
11121112

11131113
private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) {
11141114
String annotationType = desc.annotationType;
1115+
Map<String, Object> values = desc.values;
11151116

1116-
if (PREVIEW_FEATURE_ANNOTATION.equals(annotationType)) {
1117+
if (PREVIEW_FEATURE_ANNOTATION_NEW.equals(annotationType)) {
11171118
//the non-public PreviewFeature annotation will not be available in ct.sym,
11181119
//replace with purely synthetic javac-internal annotation:
11191120
annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
11201121
}
11211122

1123+
if (PREVIEW_FEATURE_ANNOTATION_OLD.equals(annotationType)) {
1124+
//the non-public PreviewFeature annotation will not be available in ct.sym,
1125+
//replace with purely synthetic javac-internal annotation:
1126+
annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
1127+
values = new HashMap<>(values);
1128+
Boolean essentialAPI = (Boolean) values.remove("essentialAPI");
1129+
values.put("reflective", essentialAPI != null && !essentialAPI);
1130+
}
1131+
11221132
return new Annotation(null,
11231133
addString(constantPool, annotationType),
1124-
createElementPairs(constantPool, desc.values));
1134+
createElementPairs(constantPool, values));
11251135
}
11261136
//where:
1127-
private static final String PREVIEW_FEATURE_ANNOTATION =
1137+
private static final String PREVIEW_FEATURE_ANNOTATION_OLD =
11281138
"Ljdk/internal/PreviewFeature;";
1139+
private static final String PREVIEW_FEATURE_ANNOTATION_NEW =
1140+
"Ljdk/internal/javac/PreviewFeature;";
11291141
private static final String PREVIEW_FEATURE_ANNOTATION_INTERNAL =
11301142
"Ljdk/internal/PreviewFeature+Annotation;";
11311143

make/modules/jdk.compiler/Gendata.gmk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ CT_MODULESOURCEPATH := $(call GetModuleSrcPath)
4444
CT_DATA_DESCRIPTION += $(TOPDIR)/make/data/symbols/symbols
4545

4646
COMPILECREATESYMBOLS_ADD_EXPORTS := \
47-
--add-exports java.base/jdk.internal=java.compiler.interim,jdk.compiler.interim \
47+
--add-exports java.base/jdk.internal.javac=java.compiler.interim,jdk.compiler.interim \
4848
--add-exports jdk.compiler.interim/com.sun.tools.javac.api=ALL-UNNAMED \
4949
--add-exports jdk.compiler.interim/com.sun.tools.javac.code=ALL-UNNAMED \
5050
--add-exports jdk.compiler.interim/com.sun.tools.javac.util=ALL-UNNAMED \
@@ -60,7 +60,6 @@ $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \
6060
DISABLED_WARNINGS := options, \
6161
JAVAC_FLAGS := \
6262
$(INTERIM_LANGTOOLS_ARGS) \
63-
--patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
6463
$(COMPILECREATESYMBOLS_ADD_EXPORTS), \
6564
))
6665

make/modules/jdk.javadoc/Gendata.gmk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,6 @@ $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \
5858
DISABLED_WARNINGS := options, \
5959
JAVAC_FLAGS := \
6060
$(INTERIM_LANGTOOLS_ARGS) \
61-
--patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
6261
$(COMPILECREATESYMBOLS_ADD_EXPORTS), \
6362
))
6463

src/java.base/share/classes/java/lang/Class.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -4387,13 +4387,6 @@ public Optional<ClassDesc> describeConstable() {
43874387
public native boolean isHidden();
43884388

43894389
/**
4390-
* {@preview Associated with sealed classes, a preview feature of the Java language.
4391-
*
4392-
* This method is associated with <i>sealed classes</i>, a preview
4393-
* feature of the Java language. Preview features
4394-
* may be removed in a future release, or upgraded to permanent
4395-
* features of the Java language.}
4396-
*
43974390
* Returns an array containing {@code Class} objects representing the
43984391
* direct subinterfaces or subclasses permitted to extend or
43994392
* implement this class or interface if it is sealed. The order of such elements
@@ -4429,7 +4422,7 @@ public Optional<ClassDesc> describeConstable() {
44294422
* @jls 9.1 Interface Declarations
44304423
* @since 15
44314424
*/
4432-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES, essentialAPI=false)
4425+
@jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES, reflective=true)
44334426
@CallerSensitive
44344427
public Class<?>[] getPermittedSubclasses() {
44354428
Class<?>[] subClasses;
@@ -4469,13 +4462,6 @@ private boolean isDirectSubType(Class<?> c) {
44694462
}
44704463

44714464
/**
4472-
* {@preview Associated with sealed classes, a preview feature of the Java language.
4473-
*
4474-
* This method is associated with <i>sealed classes</i>, a preview
4475-
* feature of the Java language. Preview features
4476-
* may be removed in a future release, or upgraded to permanent
4477-
* features of the Java language.}
4478-
*
44794465
* Returns {@code true} if and only if this {@code Class} object represents
44804466
* a sealed class or interface. If this {@code Class} object represents a
44814467
* primitive type, {@code void}, or an array type, this method returns
@@ -4489,7 +4475,7 @@ private boolean isDirectSubType(Class<?> c) {
44894475
* @jls 9.1 Interface Declarations
44904476
* @since 15
44914477
*/
4492-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES, essentialAPI=false)
4478+
@jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES, reflective=true)
44934479
@SuppressWarnings("preview")
44944480
public boolean isSealed() {
44954481
if (isArray() || isPrimitive()) {

src/java.base/share/classes/jdk/internal/PreviewFeature.java renamed to src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* questions.
2424
*/
2525

26-
package jdk.internal;
26+
package jdk.internal.javac;
2727

2828
import java.lang.annotation.*;
2929

@@ -51,7 +51,7 @@
5151
*/
5252
public Feature feature();
5353

54-
public boolean essentialAPI() default false;
54+
public boolean reflective() default false;
5555

5656
public enum Feature {
5757
// 8242284:
@@ -68,6 +68,10 @@ public enum Feature {
6868
// necessary for PreviewFeature in JDK 16 to declare the enum constant.
6969
RECORDS,
7070
SEALED_CLASSES,
71+
/**
72+
* A key for testing.
73+
*/
74+
TEST,
7175
;
7276
}
7377
}

src/java.base/share/classes/module-info.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -138,10 +138,9 @@
138138
jdk.incubator.foreign;
139139
exports com.sun.security.ntlm to
140140
java.security.sasl;
141-
exports jdk.internal to // for @HotSpotIntrinsicCandidate
141+
exports jdk.internal.javac to
142142
java.compiler,
143143
jdk.compiler,
144-
jdk.incubator.vector,
145144
jdk.jshell;
146145
exports jdk.internal.access to
147146
java.desktop,

src/java.compiler/share/classes/javax/lang/model/element/Modifier.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -66,33 +66,19 @@ public enum Modifier {
6666
/** The modifier {@code static} */ STATIC,
6767

6868
/**
69-
* {@preview Associated with sealed classes, a preview feature of the Java language.
70-
*
71-
* This enum constant is associated with <i>sealed classes</i>, a preview
72-
* feature of the Java language. Preview features
73-
* may be removed in a future release, or upgraded to permanent
74-
* features of the Java language.}
75-
*
7669
* The modifier {@code sealed}
7770
* @since 15
7871
*/
79-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
80-
essentialAPI=false)
72+
@jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES,
73+
reflective=true)
8174
SEALED,
8275

8376
/**
84-
* {@preview Associated with sealed classes, a preview feature of the Java language.
85-
*
86-
* This enum constant is associated with <i>sealed classes</i>, a preview
87-
* feature of the Java language. Preview features
88-
* may be removed in a future release, or upgraded to permanent
89-
* features of the Java language.}
90-
*
9177
* The modifier {@code non-sealed}
9278
* @since 15
9379
*/
94-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
95-
essentialAPI=false)
80+
@jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES,
81+
reflective=true)
9682
NON_SEALED {
9783
public String toString() {
9884
return "non-sealed";

src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -199,12 +199,6 @@ default List<? extends RecordComponentElement> getRecordComponents() {
199199
}
200200

201201
/**
202-
* {@preview Associated with sealed classes, a preview feature of the Java language.
203-
*
204-
* This method is associated with <i>sealed classes</i>, a preview
205-
* feature of the Java language. Preview features
206-
* may be removed in a future release, or upgraded to permanent
207-
* features of the Java language.}
208202
* Returns the permitted classes of this class or interface
209203
* element in declaration order.
210204
*
@@ -215,8 +209,8 @@ default List<? extends RecordComponentElement> getRecordComponents() {
215209
*
216210
* @since 15
217211
*/
218-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
219-
essentialAPI=false)
212+
@jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES,
213+
reflective=true)
220214
default List<? extends TypeMirror> getPermittedSubclasses() {
221215
return List.of();
222216
}

0 commit comments

Comments
 (0)