Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge
  • Loading branch information
JesperIRL committed Jun 26, 2020
2 parents b87302c + 2534e72 commit 55b472251e9e089ad593975d9bb773a5a3a05e31
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 36 deletions.
@@ -1067,10 +1067,23 @@ private Annotation[][] createParameterAnnotations(List<CPInfo> constantPool, Lis
}

private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) {
String annotationType = desc.annotationType;

if (PREVIEW_FEATURE_ANNOTATION.equals(annotationType)) {
//the non-public PreviewFeature annotation will not be available in ct.sym,
//replace with purely synthetic javac-internal annotation:
annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
}

return new Annotation(null,
addString(constantPool, desc.annotationType),
addString(constantPool, annotationType),
createElementPairs(constantPool, desc.values));
}
//where:
private static final String PREVIEW_FEATURE_ANNOTATION =
"Ljdk/internal/PreviewFeature;";
private static final String PREVIEW_FEATURE_ANNOTATION_INTERNAL =
"Ljdk/internal/PreviewFeature+Annotation;";

private element_value_pair[] createElementPairs(List<CPInfo> constantPool, Map<String, Object> annotationAttributes) {
element_value_pair[] pairs = new element_value_pair[annotationAttributes.size()];
@@ -756,7 +756,9 @@ void CompiledDirectStaticCall::verify_mt_safe(const methodHandle& callee, addres
"a) MT-unsafe modification of inline cache");

address destination = jump->jump_destination();
assert(destination == (address)-1 || destination == entry,
assert(destination == (address)-1 || destination == entry
|| old_method == NULL || !old_method->method_holder()->is_loader_alive() // may have a race due to class unloading.
|| old_method->is_old(), // may be race patching deoptimized nmethod due to redefinition.
"b) MT-unsafe modification of inline cache");
}
#endif // !PRODUCT
@@ -2139,11 +2139,6 @@ private Enum<?> readEnum(boolean unshared) throws IOException {
return result;
}

@SuppressWarnings("preview")
private static boolean isRecord(Class<?> cls) {
return cls.isRecord();
}

/**
* Reads and returns "ordinary" (i.e., not a String, Class,
* ObjectStreamClass, array, or enum constant) object, or null if object's
@@ -2182,7 +2177,7 @@ private Object readOrdinaryObject(boolean unshared)
handles.markException(passHandle, resolveEx);
}

final boolean isRecord = cl != null && isRecord(cl);
final boolean isRecord = desc.isRecord();
if (isRecord) {
assert obj == null;
obj = readRecord(desc);
@@ -747,13 +747,6 @@ void initNonProxy(ObjectStreamClass model,
}

this.cl = cl;
if (cl != null) {
this.isRecord = isRecord(cl);
// canonical record constructor is shared
this.canonicalCtr = osc.canonicalCtr;
// cache of deserialization constructors is shared
this.deserializationCtrs = osc.deserializationCtrs;
}
this.resolveEx = resolveEx;
this.superDesc = superDesc;
name = model.name;
@@ -770,6 +763,11 @@ void initNonProxy(ObjectStreamClass model,

if (osc != null) {
localDesc = osc;
isRecord = localDesc.isRecord;
// canonical record constructor is shared
canonicalCtr = localDesc.canonicalCtr;
// cache of deserialization constructors is shared
deserializationCtrs = localDesc.deserializationCtrs;
writeObjectMethod = localDesc.writeObjectMethod;
readObjectMethod = localDesc.readObjectMethod;
readObjectNoDataMethod = localDesc.readObjectNoDataMethod;
@@ -217,6 +217,7 @@ public static Symtab instance(Context context) {
public final Type elementTypeType;
public final Type functionalInterfaceType;
public final Type previewFeatureType;
public final Type previewFeatureInternalType;
public final Type typeDescriptorType;
public final Type recordType;

@@ -580,6 +581,7 @@ public <R, P> R accept(ElementVisitor<R, P> v, P p) {
stringConcatFactory = enterClass("java.lang.invoke.StringConcatFactory");
functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
previewFeatureType = enterClass("jdk.internal.PreviewFeature");
previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
recordType = enterClass("java.lang.Record");

@@ -1429,6 +1429,9 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) {
}
}
}
} else if (proxy.type.tsym.flatName() == syms.previewFeatureInternalType.tsym.flatName()) {
sym.flags_field |= PREVIEW_API;
setFlagIfAttributeTrue(proxy, sym, names.essentialAPI, PREVIEW_ESSENTIAL_API);
} else {
if (proxy.type.tsym == syms.annotationTargetType.tsym) {
target = proxy;
@@ -3761,15 +3761,7 @@ protected JCClassDecl classDeclaration(JCModifiers mods, Comment dc) {
nextToken();
implementing = typeList();
}
List<JCExpression> permitting = List.nil();
if (allowSealedTypes && token.kind == IDENTIFIER && token.name() == names.permits) {
checkSourceLevel(Feature.SEALED_CLASSES);
if ((mods.flags & Flags.SEALED) == 0) {
log.error(token.pos, Errors.InvalidPermitsClause(Fragments.ClassIsNotSealed("class")));
}
nextToken();
permitting = qualidentList(false);
}
List<JCExpression> permitting = permitsClause(mods, "class");
List<JCTree> defs = classInterfaceOrRecordBody(name, false, false);
JCClassDecl result = toP(F.at(pos).ClassDef(
mods, name, typarams, extending, implementing, permitting, defs));
@@ -3849,15 +3841,7 @@ protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
nextToken();
extending = typeList();
}
List<JCExpression> permitting = List.nil();
if (allowSealedTypes && token.kind == IDENTIFIER && token.name() == names.permits) {
checkSourceLevel(Feature.SEALED_CLASSES);
if ((mods.flags & Flags.SEALED) == 0) {
log.error(token.pos, Errors.InvalidPermitsClause(Fragments.ClassIsNotSealed("interface")));
}
nextToken();
permitting = typeList();
}
List<JCExpression> permitting = permitsClause(mods, "interface");
List<JCTree> defs;
defs = classInterfaceOrRecordBody(name, true, false);
JCClassDecl result = toP(F.at(pos).ClassDef(
@@ -3866,6 +3850,18 @@ protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
return result;
}

List<JCExpression> permitsClause(JCModifiers mods, String classOrInterface) {
if (allowSealedTypes && token.kind == IDENTIFIER && token.name() == names.permits) {
checkSourceLevel(Feature.SEALED_CLASSES);
if ((mods.flags & Flags.SEALED) == 0) {
log.error(token.pos, Errors.InvalidPermitsClause(Fragments.ClassIsNotSealed(classOrInterface)));
}
nextToken();
return qualidentList(false);
}
return List.nil();
}

/** EnumDeclaration = ENUM Ident [IMPLEMENTS TypeList] EnumBody
* @param mods The modifiers starting the enum declaration
* @param dc The documentation comment for the enum, or null.
@@ -104,7 +104,9 @@ JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_linux_amd64_DwarfParser_cr
DwarfParser *parser = new DwarfParser(reinterpret_cast<lib_info *>(lib));
if (!parser->is_parseable()) {
jclass ex_cls = env->FindClass("sun/jvm/hotspot/debugger/DebuggerException");
env->ThrowNew(ex_cls, "DWARF not found");
if (!env->ExceptionOccurred()) {
env->ThrowNew(ex_cls, "DWARF not found");
}
return 0L;
}

@@ -146,7 +148,9 @@ JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_amd64_DwarfParser_pro
DwarfParser *parser = reinterpret_cast<DwarfParser *>(get_dwarf_context(env, this_obj));
if (!parser->process_dwarf(pc)) {
jclass ex_cls = env->FindClass("sun/jvm/hotspot/debugger/DebuggerException");
env->ThrowNew(ex_cls, "Could not find PC in DWARF");
if (!env->ExceptionOccurred()) {
env->ThrowNew(ex_cls, "Could not find PC in DWARF");
}
return;
}
}
@@ -85,5 +85,8 @@ compiler/intrinsics/sha/sanity/TestSHA256Intrinsics.java 8167430 gene
compiler/intrinsics/sha/sanity/TestSHA1MultiBlockIntrinsics.java 8167430 generic-all
compiler/intrinsics/sha/sanity/TestSHA512MultiBlockIntrinsics.java 8167430 generic-all

compiler/ciReplay/TestServerVM.java 8248265 generic-all
compiler/ciReplay/TestVMNoCompLevel.java 8248265 generic-all

vmTestbase/vm/mlvm/indy/stress/java/relinkMutableCallSiteFreq/Test.java 8226689 generic-all
vmTestbase/vm/mlvm/indy/stress/java/relinkVolatileCallSiteFreq/Test.java 8226689 generic-all
@@ -102,6 +102,7 @@ serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all

serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214032 generic-all
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all

#############################################################################

@@ -127,6 +128,7 @@ vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestD
vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java 7034630 generic-all
vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses021/TestDescription.java 8065773 generic-all
vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses023/TestDescription.java 8065773 generic-all
vmTestbase/nsk/jdi/stress/serial/mixed002/TestDescription.java 8246493 generic-all

vmTestbase/nsk/jdb/eval/eval001/eval001.java 8221503 generic-all

@@ -593,6 +593,8 @@ java/io/pathNames/GeneralWin32.java 8180264 windows-
com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all

java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java 8247426 generic-all

sun/management/jdp/JdpDefaultsTest.java 8241865 macosx-all
sun/management/jdp/JdpJmxRemoteDynamicPortTest.java 8241865 macosx-all
sun/management/jdp/JdpSpecificAddressTest.java 8241865 macosx-all
@@ -628,6 +630,8 @@ java/nio/channels/AsynchronousSocketChannel/StressLoopback.java 8211851 aix-ppc6

java/nio/channels/Selector/Wakeup.java 6963118 windows-all

sun/nio/ch/TestMaxCachedBufferSize.java 8212812 macosx-all

############################################################################

# jdk_rmi
@@ -914,6 +918,7 @@ javax/script/Test7.java 8239361 generic-

jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java 8228990,8229370 generic-all
jdk/jfr/event/compiler/TestCodeSweeper.java 8225209 generic-all
jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all

############################################################################

@@ -0,0 +1,15 @@
/**
* @test /nodynamiccopyright/
* @bug 8246704
* @summary Verify preview APIs are reported correctly when using --release.
* @compile/fail/ref=PreviewAPIsWithRelease.out -XDrawDiagnostics --release 14 PreviewAPIsWithRelease.java
*/

import com.sun.source.tree.Tree.Kind;

public class PreviewAPIsWithRelease {
void test() {
"".stripIndent();
Kind r = Kind.RECORD;
}
}
@@ -0,0 +1,4 @@
PreviewAPIsWithRelease.java:12:11: compiler.err.is.preview: stripIndent()
PreviewAPIsWithRelease.java:13:22: compiler.warn.is.preview: RECORD
1 error
1 warning
@@ -768,19 +768,67 @@ sealed class C permits Sub {}
}
}

public void testParameterizedPermitted() {
private static String[] PRIMITIVES_VOID_AND_PRIMITIVE_ARRAYS = new String[] {
"byte", "short", "int", "long", "float", "double", "char", "boolean", "void",
"byte[]", "short[]", "int[]", "long[]", "float[]", "double[]", "char[]", "boolean[]"
};

public void testPermitsClause() {
for (String s : List.of(
// can't include a parameterized type
"""
sealed class C<T> permits Sub<T> {}
final class Sub<T> extends C<T> {}
""",
"""
sealed class C permits Sub<String> {}
final class Sub<T> extends C {}
""",
"""
sealed class C permits Sub<String> {}
non-sealed class Sub<T> extends C {}
""",
"""
sealed interface IC permits ID<String> {}
non-sealed interface ID<T> extends IC {}
""",

// can't include an array type
"""
sealed class C<T> permits Sub[] {}
final class Sub<T> extends C<T> {}
""",
"""
sealed class C permits Sub[] {}
non-sealed class Sub<T> extends C {}
""",
"""
sealed interface IC permits ID[] {}
non-sealed interface ID<T> extends IC {}
"""
)) {
assertFail("compiler.err.expected", s);
}

for (String s : List.of(
// can't include primitives, void or primitive arrays
"""
sealed class C<T> permits # {}
final class Sub<T> extends C<T> {}
""",
"""
sealed class C permits # {}
non-sealed class Sub<T> extends C {}
""",
"""
sealed interface IC permits # {}
non-sealed interface ID<T> extends IC {}
"""
)) {
for (String t: PRIMITIVES_VOID_AND_PRIMITIVE_ARRAYS){
assertFail("compiler.err.expected", s, t);
}
}
}

private Path[] findJavaFiles(Path... paths) throws IOException {

0 comments on commit 55b4722

Please sign in to comment.