8332744: [REDO] 'internal proprietary API' diagnostics if --system is configured to an earlier JDK version
Reviewed-by: vromero
This commit is contained in:
parent
8cb1221194
commit
839de82c31
@ -241,7 +241,7 @@ public class ClassFinder {
|
|||||||
* available from the module system.
|
* available from the module system.
|
||||||
*/
|
*/
|
||||||
long getSupplementaryFlags(ClassSymbol c) {
|
long getSupplementaryFlags(ClassSymbol c) {
|
||||||
if (jrtIndex == null || !jrtIndex.isInJRT(c.classfile) || c.name == names.module_info) {
|
if (c.name == names.module_info) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,17 +257,22 @@ public class ClassFinder {
|
|||||||
try {
|
try {
|
||||||
ModuleSymbol owningModule = packge.modle;
|
ModuleSymbol owningModule = packge.modle;
|
||||||
if (owningModule == syms.noModule) {
|
if (owningModule == syms.noModule) {
|
||||||
JRTIndex.CtSym ctSym = jrtIndex.getCtSym(packge.flatName());
|
if (jrtIndex != null && jrtIndex.isInJRT(c.classfile)) {
|
||||||
Profile minProfile = Profile.DEFAULT;
|
JRTIndex.CtSym ctSym = jrtIndex.getCtSym(packge.flatName());
|
||||||
if (ctSym.proprietary)
|
Profile minProfile = Profile.DEFAULT;
|
||||||
newFlags |= PROPRIETARY;
|
if (ctSym.proprietary)
|
||||||
if (ctSym.minProfile != null)
|
newFlags |= PROPRIETARY;
|
||||||
minProfile = Profile.lookup(ctSym.minProfile);
|
if (ctSym.minProfile != null)
|
||||||
if (profile != Profile.DEFAULT && minProfile.value > profile.value) {
|
minProfile = Profile.lookup(ctSym.minProfile);
|
||||||
newFlags |= NOT_IN_PROFILE;
|
if (profile != Profile.DEFAULT && minProfile.value > profile.value) {
|
||||||
|
newFlags |= NOT_IN_PROFILE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (owningModule.name == names.jdk_unsupported) {
|
} else if (owningModule.name == names.jdk_unsupported) {
|
||||||
newFlags |= PROPRIETARY;
|
newFlags |= PROPRIETARY;
|
||||||
|
} else {
|
||||||
|
// don't accumulate user modules in supplementaryFlags
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Alphabet LLC. 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 8331081
|
||||||
|
* @summary Verify 'internal proprietary API' diagnostics if --system is configured
|
||||||
|
* @library /tools/lib
|
||||||
|
* @modules jdk.compiler/com.sun.tools.javac.api jdk.compiler/com.sun.tools.javac.main
|
||||||
|
* jdk.compiler/com.sun.tools.javac.jvm jdk.jdeps/com.sun.tools.javap
|
||||||
|
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavapTask toolbox.TestRunner
|
||||||
|
* @run main SystemSunProprietary
|
||||||
|
*/
|
||||||
|
import toolbox.JavacTask;
|
||||||
|
import toolbox.Task;
|
||||||
|
import toolbox.Task.Expect;
|
||||||
|
import toolbox.TestRunner;
|
||||||
|
import toolbox.ToolBox;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SystemSunProprietary extends TestRunner {
|
||||||
|
|
||||||
|
private final ToolBox tb = new ToolBox();
|
||||||
|
|
||||||
|
public SystemSunProprietary() {
|
||||||
|
super(System.err);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
|
new SystemSunProprietary().runTests();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUnsafe(Path base) throws IOException {
|
||||||
|
Path src = base.resolve("src");
|
||||||
|
tb.writeJavaFiles(
|
||||||
|
src,
|
||||||
|
"module m { requires jdk.unsupported; }",
|
||||||
|
"package test; public class Test { sun.misc.Unsafe unsafe; } ");
|
||||||
|
Path classes = base.resolve("classes");
|
||||||
|
tb.createDirectories(classes);
|
||||||
|
|
||||||
|
List<String> log;
|
||||||
|
List<String> expected =
|
||||||
|
Arrays.asList(
|
||||||
|
"Test.java:1:43: compiler.warn.sun.proprietary: sun.misc.Unsafe",
|
||||||
|
"1 warning");
|
||||||
|
|
||||||
|
log =
|
||||||
|
new JavacTask(tb)
|
||||||
|
.options("-XDrawDiagnostics")
|
||||||
|
.outdir(classes)
|
||||||
|
.files(tb.findJavaFiles(src))
|
||||||
|
.run(Expect.SUCCESS)
|
||||||
|
.writeAll()
|
||||||
|
.getOutputLines(Task.OutputKind.DIRECT);
|
||||||
|
|
||||||
|
if (!expected.equals(log)) {
|
||||||
|
throw new AssertionError("Unexpected output: " + log);
|
||||||
|
}
|
||||||
|
|
||||||
|
log =
|
||||||
|
new JavacTask(tb)
|
||||||
|
.options("-XDrawDiagnostics", "--system", System.getProperty("java.home"))
|
||||||
|
.outdir(classes)
|
||||||
|
.files(tb.findJavaFiles(src))
|
||||||
|
.run(Expect.SUCCESS)
|
||||||
|
.writeAll()
|
||||||
|
.getOutputLines(Task.OutputKind.DIRECT);
|
||||||
|
|
||||||
|
if (!expected.equals(log)) {
|
||||||
|
throw new AssertionError("Unexpected output: " + log);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a valid argument to system that isn't the current java.home
|
||||||
|
Path originalSystem = Path.of(System.getProperty("java.home"));
|
||||||
|
Path system = base.resolve("system");
|
||||||
|
for (String path : List.of("release", "lib/modules", "lib/jrt-fs.jar")) {
|
||||||
|
Path to = system.resolve(path);
|
||||||
|
Files.createDirectories(to.getParent());
|
||||||
|
Files.copy(originalSystem.resolve(path), to);
|
||||||
|
}
|
||||||
|
|
||||||
|
log =
|
||||||
|
new JavacTask(tb)
|
||||||
|
.options("-XDrawDiagnostics", "--system", system.toString())
|
||||||
|
.outdir(classes)
|
||||||
|
.files(tb.findJavaFiles(src))
|
||||||
|
.run(Expect.SUCCESS)
|
||||||
|
.writeAll()
|
||||||
|
.getOutputLines(Task.OutputKind.DIRECT);
|
||||||
|
|
||||||
|
if (!expected.equals(log)) {
|
||||||
|
throw new AssertionError("Unexpected output: " + log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void runTests() throws Exception {
|
||||||
|
runTests(m -> new Object[] {Paths.get(m.getName())});
|
||||||
|
}
|
||||||
|
}
|
@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.lang.foreign.Arena;
|
import java.lang.foreign.Arena;
|
||||||
import java.lang.foreign.MemorySegment;
|
import java.lang.foreign.MemorySegment;
|
||||||
|
@ -33,7 +33,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.lang.foreign.MemorySegment;
|
import java.lang.foreign.MemorySegment;
|
||||||
import java.lang.foreign.Arena;
|
import java.lang.foreign.Arena;
|
||||||
|
@ -34,7 +34,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -36,7 +36,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.VarHandle;
|
import java.lang.invoke.VarHandle;
|
||||||
|
@ -37,7 +37,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
|
@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
@ -36,7 +36,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
@ -33,7 +33,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.TearDown;
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import org.openjdk.jmh.annotations.OutputTimeUnit;
|
|||||||
import org.openjdk.jmh.annotations.Setup;
|
import org.openjdk.jmh.annotations.Setup;
|
||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import org.openjdk.jmh.annotations.OutputTimeUnit;
|
|||||||
import org.openjdk.jmh.annotations.Setup;
|
import org.openjdk.jmh.annotations.Setup;
|
||||||
import org.openjdk.jmh.annotations.State;
|
import org.openjdk.jmh.annotations.State;
|
||||||
import org.openjdk.jmh.annotations.Warmup;
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
package org.openjdk.bench.java.lang.foreign;
|
package org.openjdk.bench.java.lang.foreign;
|
||||||
|
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
import org.openjdk.jmh.annotations.Benchmark;
|
import org.openjdk.jmh.annotations.Benchmark;
|
||||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||||
import org.openjdk.jmh.annotations.Mode;
|
import org.openjdk.jmh.annotations.Mode;
|
||||||
|
@ -25,7 +25,7 @@ package org.openjdk.bench.java.lang.foreign;
|
|||||||
|
|
||||||
import java.lang.foreign.*;
|
import java.lang.foreign.*;
|
||||||
|
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
import org.openjdk.jmh.annotations.Benchmark;
|
import org.openjdk.jmh.annotations.Benchmark;
|
||||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||||
import org.openjdk.jmh.annotations.Fork;
|
import org.openjdk.jmh.annotations.Fork;
|
||||||
|
@ -30,7 +30,7 @@ import org.openjdk.jmh.annotations.*;
|
|||||||
import org.openjdk.jmh.runner.Runner;
|
import org.openjdk.jmh.runner.Runner;
|
||||||
import org.openjdk.jmh.runner.options.Options;
|
import org.openjdk.jmh.runner.options.Options;
|
||||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static java.lang.foreign.ValueLayout.*;
|
import static java.lang.foreign.ValueLayout.*;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openjdk.bench.java.lang.foreign;
|
package org.openjdk.bench.java.lang.foreign;
|
||||||
|
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.openjdk.bench.java.lang.foreign.xor;
|
package org.openjdk.bench.java.lang.foreign.xor;
|
||||||
|
|
||||||
import org.openjdk.bench.java.lang.foreign.Utils;
|
import org.openjdk.bench.java.lang.foreign.Utils;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
|
|
||||||
import java.lang.foreign.Arena;
|
import java.lang.foreign.Arena;
|
||||||
import java.lang.foreign.FunctionDescriptor;
|
import java.lang.foreign.FunctionDescriptor;
|
||||||
|
@ -24,7 +24,7 @@ package org.openjdk.bench.sun.misc;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import sun.misc.Unsafe;
|
import jdk.internal.misc.Unsafe;
|
||||||
import org.openjdk.jmh.annotations.*;
|
import org.openjdk.jmh.annotations.*;
|
||||||
|
|
||||||
@BenchmarkMode(Mode.AverageTime)
|
@BenchmarkMode(Mode.AverageTime)
|
||||||
|
Loading…
Reference in New Issue
Block a user