Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <j9build@ca.ibm.com>
  • Loading branch information
j9build committed Oct 5, 2023
2 parents d0c7ea5 + 25e1af1 commit 1336dad
Show file tree
Hide file tree
Showing 33 changed files with 953 additions and 29 deletions.
2 changes: 1 addition & 1 deletion make/modules/java.base/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape
DISABLED_WARNINGS_java += this-escape restricted

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
Expand Down
2 changes: 1 addition & 1 deletion make/test/BuildMicrobenchmark.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
SMALL_JAVA := false, \
CLASSPATH := $(MICROBENCHMARK_CLASSPATH), \
DISABLED_WARNINGS := this-escape processing rawtypes cast serial preview, \
DISABLED_WARNINGS := restricted this-escape processing rawtypes cast serial preview, \
SRC := $(MICROBENCHMARK_SRC), \
BIN := $(MICROBENCHMARK_CLASSES), \
JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,8 @@ MethodHandle setVarargs(MemberName member) throws IllegalAccessException {
try {
return this.withVarargs(true);
} catch (IllegalArgumentException ex) {
throw member.makeAccessException("cannot make variable arity", null);
throw new IllegalAccessException("cannot make variable arity: " + member +
" does not have a trailing array parameter");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,18 @@ public static EnumSet<Flag> asFlagSet(long flags) {
*/
public static final long SEALED = 1L<<62; // ClassSymbols

/**
* Flag to indicate restricted method declaration.
*/
public static final long RESTRICTED = 1L<<62; // MethodSymbols

/**
* Flag to indicate that the class/interface was declared with the non-sealed modifier.
*/
public static final long NON_SEALED = 1L<<63; // ClassSymbols

/**
* Describe modifier flags as they migh appear in source code, i.e.,
* Describe modifier flags as they might appear in source code, i.e.,
* separated by spaces and in the order suggested by JLS 8.1.1.
*/
public static String toSource(long flags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ public enum LintCategory {
/**
* Warn about use of preview features.
*/
PREVIEW("preview");
PREVIEW("preview"),

/**
* Warn about use of restricted methods.
*/
RESTRICTED("restricted");

LintCategory(String option) {
this(option, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public static Symtab instance(Context context) {
public final Type functionalInterfaceType;
public final Type previewFeatureType;
public final Type previewFeatureInternalType;
public final Type restrictedType;
public final Type typeDescriptorType;
public final Type recordType;
public final Type switchBootstrapsType;
Expand Down Expand Up @@ -610,6 +611,7 @@ public <R, P> R accept(ElementVisitor<R, P> v, P p) {
functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
previewFeatureType = enterClass("jdk.internal.javac.PreviewFeature");
previewFeatureInternalType = enterSyntheticAnnotation("jdk.internal.PreviewFeature+Annotation");
restrictedType = enterClass("jdk.internal.javac.Restricted");
typeDescriptorType = enterClass("java.lang.invoke.TypeDescriptor");
recordType = enterClass("java.lang.Record");
switchBootstrapsType = enterClass("java.lang.runtime.SwitchBootstraps");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ private <T extends Attribute.Compound> void annotateNow(Symbol toAnnotate,
&& types.isSameType(c.type, syms.valueBasedType)) {
toAnnotate.flags_field |= Flags.VALUE_BASED;
}

if (!c.type.isErroneous()
&& types.isSameType(c.type, syms.restrictedType)) {
toAnnotate.flags_field |= Flags.RESTRICTED;
}
}

List<T> buf = List.nil();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4742,6 +4742,7 @@ else if (ownOuter.hasTag(CLASS) && site != ownOuter) {
new ResultInfo(resultInfo.pkind, resultInfo.pt.getReturnType(), resultInfo.checkContext, resultInfo.checkMode),
env, TreeInfo.args(env.tree), resultInfo.pt.getParameterTypes(),
resultInfo.pt.getTypeArguments());
chk.checkRestricted(tree.pos(), sym);
break;
}
case PCK: case ERR:
Expand Down
15 changes: 15 additions & 0 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ public void warnDeclaredUsingPreview(DiagnosticPosition pos, Symbol sym) {
preview.reportPreviewWarning(pos, Warnings.DeclaredUsingPreview(kindName(sym), sym));
}

/** Log a preview warning.
* @param pos Position to be used for error reporting.
* @param msg A Warning describing the problem.
*/
public void warnRestrictedAPI(DiagnosticPosition pos, Symbol sym) {
if (lint.isEnabled(LintCategory.RESTRICTED))
log.warning(LintCategory.RESTRICTED, pos, Warnings.RestrictedMethod(sym.enclClass(), sym));
}

/** Warn about unchecked operation.
* @param pos Position to be used for error reporting.
* @param msg A string describing the problem.
Expand Down Expand Up @@ -3850,6 +3859,12 @@ void checkPreview(DiagnosticPosition pos, Symbol other, Symbol s) {
}
}

void checkRestricted(DiagnosticPosition pos, Symbol s) {
if (s.kind == MTH && (s.flags() & RESTRICTED) != 0) {
deferredLintHandler.report(() -> warnRestrictedAPI(pos, s));
}
}

/* *************************************************************************
* Check for recursive annotation elements.
**************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,9 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) {
} else if (proxy.type.tsym.flatName() == syms.valueBasedInternalType.tsym.flatName()) {
Assert.check(sym.kind == TYP);
sym.flags_field |= VALUE_BASED;
} else if (proxy.type.tsym.flatName() == syms.restrictedType.tsym.flatName()) {
Assert.check(sym.kind == MTH);
sym.flags_field |= RESTRICTED;
} else {
if (proxy.type.tsym == syms.annotationTargetType.tsym) {
target = proxy;
Expand All @@ -1522,6 +1525,9 @@ else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) {
setFlagIfAttributeTrue(proxy, sym, names.reflective, PREVIEW_REFLECTIVE);
} else if (proxy.type.tsym == syms.valueBasedType.tsym && sym.kind == TYP) {
sym.flags_field |= VALUE_BASED;
} else if (proxy.type.tsym == syms.restrictedType.tsym) {
Assert.check(sym.kind == MTH);
sym.flags_field |= RESTRICTED;
}
proxies.append(proxy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,11 @@ compiler.err.is.preview=\
compiler.warn.is.preview.reflective=\
{0} is a reflective preview API and may be removed in a future release.

# 0: symbol, 1: symbol
compiler.warn.restricted.method=\
{0}.{1} is a restricted method.\n\
(Restricted methods are unsafe and, if used incorrectly, might crash the Java runtime or corrupt memory)

# 0: symbol
compiler.warn.has.been.deprecated.module=\
module {0} has been deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ javac.opt.Xlint.desc.varargs=\
javac.opt.Xlint.desc.preview=\
Warn about use of preview language features.

javac.opt.Xlint.desc.restricted=\
Warn about use of restricted methods.

javac.opt.Xlint.desc.synchronization=\
Warn about synchronization attempts on instances of value-based classes.

Expand Down
1 change: 1 addition & 0 deletions src/jdk.compiler/share/classes/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
* <tr><th scope="row">{@code preview} <td>use of preview language features
* <tr><th scope="row">{@code rawtypes} <td>use of raw types
* <tr><th scope="row">{@code removal} <td>use of API that has been marked for removal
* <tr><th scope="row">{@code restricted} <td>use of restricted methods
* <tr><th scope="row">{@code requires-automatic} <td>use of automatic modules in the {@code requires} clauses
* <tr><th scope="row">{@code requires-transitive-automatic} <td>automatic modules in {@code requires transitive}
* <tr><th scope="row">{@code serial} <td>{@link java.base/java.io.Serializable Serializable} classes
Expand Down
5 changes: 0 additions & 5 deletions test/hotspot/jtreg/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ gc/stress/TestStressG1Humongous.java 8286554 windows-x64
# :hotspot_runtime


runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64
runtime/handshake/HandshakeSuspendExitTest.java 8294313 generic-all
runtime/os/TestTracePageSizes.java#no-options 8267460 linux-aarch64
runtime/os/TestTracePageSizes.java#explicit-large-page-size 8267460 linux-aarch64
Expand All @@ -101,7 +100,6 @@ runtime/os/TestTracePageSizes.java#G1 8267460 linux-aarch64
runtime/os/TestTracePageSizes.java#Parallel 8267460 linux-aarch64
runtime/os/TestTracePageSizes.java#Serial 8267460 linux-aarch64
runtime/ErrorHandling/CreateCoredumpOnCrash.java 8267433 macosx-x64
runtime/CompressedOops/CompressedClassPointers.java 8305765 generic-all
runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all
runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all
runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le
Expand Down Expand Up @@ -157,9 +155,6 @@ vmTestbase/metaspace/gc/firstGC_99m/TestDescription.java 8208250 generic-all
vmTestbase/metaspace/gc/firstGC_default/TestDescription.java 8208250 generic-all

vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 generic-all
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/TestDescription.java 8073470 linux-all
vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/TestDescription.java 8288911 macosx-all

Expand Down
48 changes: 48 additions & 0 deletions test/hotspot/jtreg/compiler/allocation/TestNewMaxLengthArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8316414
* @summary C2: large byte array clone triggers "failed: malformed control flow" assertion failure on linux-x86
* @run main/othervm -Xcomp -XX:CompileOnly=TestNewMaxLengthArray::createAndClone TestNewMaxLengthArray
*/

public class TestNewMaxLengthArray {

// Maximum length of a byte array on a 32-bits platform using default object
// alignment (8 bytes).
static final int MAX_BYTE_ARRAY_LENGTH = 0x7ffffffc;

public static byte[] createAndClone() {
byte[] array = new byte[MAX_BYTE_ARRAY_LENGTH];
return array.clone();
}

public static void main(String[] a) {
try {
createAndClone();
} catch (OutOfMemoryError oome) {
}
}
}
50 changes: 50 additions & 0 deletions test/hotspot/jtreg/compiler/c2/TestLargeTreeOfSubNodes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2023, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8316396
* @summary Endless loop in C2 compilation triggered by AddNode::IdealIL
* @run main/othervm -XX:CompileCommand=compileonly,*TestLargeTreeOfSubNodes*::test -XX:-TieredCompilation -Xcomp TestLargeTreeOfSubNodes
*/

public class TestLargeTreeOfSubNodes {
public static long res = 0;

public static void test() {
int a = -1, b = 0;
for (int i = 0; i < 100; ++i) {
for (int j = 0; j < 10; ++j) {
for (int k = 0; k < 1; ++k) {
}
b -= a;
a += b;
}
}
res = a;
}

public static void main(String[] args) {
test();
}
}
27 changes: 24 additions & 3 deletions test/hotspot/jtreg/compiler/lib/ir_framework/IR.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,44 @@
*/
String[] applyIf() default {};

/**
* Accepts a single pair composed of a platform string followed by a true/false
* value where a true value necessitates that we are currently testing on that platform and vice-versa.
* IR checks are enforced only if the specified platform constraint is met.
*/
String[] applyIfPlatform() default {};

/**
* Accepts a list of pairs where each pair is composed of a platform string followed by a true/false
* value where a true value necessitates that we are currently testing on that platform and vice-versa.
* IR checks are enforced only if all the specified platform constraints are met.
*/
String[] applyIfPlatformAnd() default {};

/**
* Accepts a list of pairs where each pair is composed of a platform string followed by a true/false
* value where a true value necessitates that we are currently testing on that platform and vice-versa.
* IR checks are enforced if any of the specified platform constraints are met.
*/
String[] applyIfPlatformOr() default {};

/**
* Accepts a single feature pair which is composed of CPU feature string followed by a true/false
* value where a true value necessities existence of CPU feature and vice-versa.
* value where a true value necessitates existence of CPU feature and vice-versa.
* IR verifications checks are enforced only if the specified feature constraint is met.
*/
String[] applyIfCPUFeature() default {};

/**
* Accepts a list of feature pairs where each pair is composed of target feature string followed by a true/false
* value where a true value necessities existence of target feature and vice-versa.
* value where a true value necessitates existence of target feature and vice-versa.
* IR verifications checks are enforced only if all the specified feature constraints are met.
*/
String[] applyIfCPUFeatureAnd() default {};

/**
* Accepts a list of feature pairs where each pair is composed of target feature string followed by a true/false
* value where a true value necessities existence of target feature and vice-versa.
* value where a true value necessitates existence of target feature and vice-versa.
* IR verifications checks are enforced if any of the specified feature constraint is met.
*/
String[] applyIfCPUFeatureOr() default {};
Expand Down
5 changes: 5 additions & 0 deletions test/hotspot/jtreg/compiler/lib/ir_framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ Sometimes, an `@IR` rule should only be applied if a certain CPU feature is pres

If a `@Test` annotated method has multiple preconditions (for example `applyIf` and `applyIfCPUFeature`), they are evaluated as a logical conjunction. It's worth noting that flags in `applyIf` are checked only if the CPU features in `applyIfCPUFeature` are matched when they are both specified. This avoids the VM flag being evaluated on hardware that does not support it. An example with both `applyIfCPUFeatureXXX` and `applyIfXXX` can be found in [TestPreconditions](../../../testlibrary_tests/ir_framework/tests/TestPreconditions.java) (internal framework test).

#### Disable/Enable IR Rules based on Platform
`@IR` rules based on the platform can be specified using `applyIfPlatformXXX` in [@IR](./IR.java). A reference for using these attributes can be found in [TestPlatformChecks](../../../testlibrary_tests/ir_framework/tests/TestPlatformChecks.java) (internal framework test).

Platform attributes are evaluated as a logical conjunction, and take precedence over VM Flag attributes. An example with both `applyIfPlatformXXX` and `applyIfXXX` can be found in [TestPreconditions](../../../testlibrary_tests/ir_framework/tests/TestPreconditions.java) (internal framework test).

#### Implicitly Skipping IR Verification
An IR verification cannot always be performed. Certain VM flags explicitly disable IR verification, change the IR shape in unexpected ways letting IR rules fail or even make IR verification impossible:

Expand Down
Loading

0 comments on commit 1336dad

Please sign in to comment.