From 1b5b717f548930f171846c0df3a53b8c235316b0 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 27 May 2016 17:12:09 +0300 Subject: [PATCH 001/191] 8156469: [JITtester] Difference in generated golden output when run with Jigsaw build Reviewed-by: vlivanov --- .../lib/jittester/jtreg/JitTesterDriver.java | 17 ++---- .../test/lib/jittester/utils/FixedTrees.java | 61 ++++++++++++------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java index ca04131baed..d6b7db9ee41 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java @@ -56,24 +56,19 @@ public class JitTesterDriver { Pattern splitOut = Pattern.compile("\\n"); // tests use \n only in stdout Pattern splitErr = Pattern.compile("\\r?\\n"); // can handle both \r\n and \n Path testDir = Paths.get(Utils.TEST_SRC); - String goldOut = formatOutput(streamGoldFile(testDir, args[0], "out"), s -> true); - String anlzOut = formatOutput(Arrays.stream(splitOut.split(oa.getStdout())), s -> true); + String goldOut = formatOutput(streamGoldFile(testDir, args[0], "out")); + String anlzOut = formatOutput(Arrays.stream(splitOut.split(oa.getStdout()))); Asserts.assertEQ(anlzOut, goldOut, "Actual stdout isn't equal to golden one"); - // TODO: add a comment why we skip such lines - Predicate notStartWhitespaces = s -> !(s.startsWith("\t") || s.startsWith(" ")); - String goldErr = formatOutput(streamGoldFile(testDir, args[0], "err"), notStartWhitespaces); - String anlzErr = formatOutput(Arrays.stream(splitErr.split(oa.getStderr())), - notStartWhitespaces); + String goldErr = formatOutput(streamGoldFile(testDir, args[0], "err")); + String anlzErr = formatOutput(Arrays.stream(splitErr.split(oa.getStderr()))); Asserts.assertEQ(anlzErr, goldErr, "Actual stderr isn't equal to golden one"); int exitValue = Integer.parseInt(streamGoldFile(testDir, args[0], "exit").findFirst().get()); oa.shouldHaveExitValue(exitValue); } - private static String formatOutput(Stream stream, Predicate predicate) { - String result = stream - .filter(predicate) - .collect(Collectors.joining(Utils.NEW_LINE)); + private static String formatOutput(Stream stream) { + String result = stream.collect(Collectors.joining(Utils.NEW_LINE)); if (result.length() > 0) { result += Utils.NEW_LINE; } diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/FixedTrees.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/FixedTrees.java index a2c656c75d2..1f25d4a3d41 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/FixedTrees.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/FixedTrees.java @@ -23,9 +23,11 @@ package jdk.test.lib.jittester.utils; +import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; + import jdk.test.lib.jittester.BinaryOperator; import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.CatchBlock; @@ -60,6 +62,8 @@ import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.types.TypeKlass; public class FixedTrees { + private static final Literal EOL = new Literal("\n", TypeList.STRING); + public static FunctionDefinition printVariablesAsFunction(PrintVariables node) { TypeKlass owner = node.getOwner(); @@ -72,7 +76,6 @@ public class FixedTrees { List vars = node.getVars(); TypeKlass printerKlass = new TypeKlass(Printer.class.getName()); - Literal EOL = new Literal("\n", TypeList.STRING); VariableInfo thisInfo = new VariableInfo("this", node.getOwner(), node.getOwner(), VariableInfo.LOCAL | VariableInfo.INITIALIZED); @@ -109,6 +112,7 @@ public class FixedTrees { FunctionInfo toStringInfo = new FunctionInfo("toString", owner, TypeList.STRING, 0L, FunctionInfo.PUBLIC, thisInfo); return new FunctionDefinition(toStringInfo, new ArrayList<>(), block, new Return(resultVar)); } + public static FunctionDefinition generateMainOrExecuteMethod(TypeKlass owner, boolean isMain) { Nothing nothing = new Nothing(); ArrayList testCallNodeContent = new ArrayList<>(); @@ -149,39 +153,50 @@ public class FixedTrees { List throwables = new ArrayList<>(); throwables.add(throwableKlass); - VariableInfo exInfo = new VariableInfo("ex", owner, throwableKlass, - VariableInfo.LOCAL | VariableInfo.INITIALIZED); - FunctionInfo printStackTraceInfo = new FunctionInfo("printStackTrace", throwableKlass, - TypeList.VOID, 0, FunctionInfo.PUBLIC, exInfo); - Function printStackTraceCall = new Function(throwableKlass, printStackTraceInfo, null); - printStackTraceCall.addChild(new LocalVariable(exInfo)); - ArrayList printStackTraceCallBlockContent = new ArrayList<>(); - // { ex.printStackTrace(); } - printStackTraceCallBlockContent.add(new Statement(printStackTraceCall, true)); - - Block printStackTraceCallBlock = new Block(owner, TypeList.VOID, printStackTraceCallBlockContent, 3); - List catchBlocks1 = new ArrayList<>(); - catchBlocks1.add(new CatchBlock(printStackTraceCallBlock, throwables, 3)); - List catchBlocks2 = new ArrayList<>(); - catchBlocks2.add(new CatchBlock(printStackTraceCallBlock, throwables, 3)); - List catchBlocks3 = new ArrayList<>(); - catchBlocks3.add(new CatchBlock(printStackTraceCallBlock, throwables, 2)); - - TryCatchBlock tryCatch1 = new TryCatchBlock(tryNode, nothing, catchBlocks1, 3); TypeKlass printStreamKlass = new TypeKlass("java.io.PrintStream"); - TypeKlass systemKlass = new TypeKlass("java.lang.System"); - FunctionInfo systemOutPrintInfo = new FunctionInfo("print", printStreamKlass, + FunctionInfo printInfo = new FunctionInfo("print", printStreamKlass, TypeList.VOID, 0, FunctionInfo.PUBLIC, new VariableInfo("this", owner, printStreamKlass, VariableInfo.LOCAL | VariableInfo.INITIALIZED), new VariableInfo("t", owner, TypeList.OBJECT, VariableInfo.LOCAL | VariableInfo.INITIALIZED)); + TypeKlass systemKlass = new TypeKlass("java.lang.System"); + StaticMemberVariable systemErrVar = new StaticMemberVariable(owner, + new VariableInfo("err", systemKlass, printStreamKlass, VariableInfo.STATIC | VariableInfo.PUBLIC)); + + LocalVariable exVar = new LocalVariable( + new VariableInfo("ex", owner, throwableKlass, VariableInfo.LOCAL | VariableInfo.INITIALIZED)); + TypeKlass classKlass = new TypeKlass("java.lang.Class"); + FunctionInfo getClassInfo = new FunctionInfo("getClass", TypeList.OBJECT, + classKlass, 0, FunctionInfo.PUBLIC, + new VariableInfo("this", owner, TypeList.OBJECT, VariableInfo.LOCAL | VariableInfo.INITIALIZED)); + Function getClass = new Function(TypeList.OBJECT, getClassInfo, Arrays.asList(exVar)); + FunctionInfo getNameInfo = new FunctionInfo("getName", classKlass, + TypeList.STRING, 0, FunctionInfo.PUBLIC, + new VariableInfo("this", owner, TypeList.OBJECT, VariableInfo.LOCAL | VariableInfo.INITIALIZED)); + Function getName = new Function(classKlass, getNameInfo, Arrays.asList(getClass)); + ArrayList printExceptionBlockContent = new ArrayList<>(); + // { System.err.print(ex.getClass().getName()); System.err.print("\n"); } + printExceptionBlockContent.add(new Statement( + new Function(printStreamKlass, printInfo, Arrays.asList(systemErrVar, getName)), true)); + printExceptionBlockContent.add(new Statement( + new Function(printStreamKlass, printInfo, Arrays.asList(systemErrVar, EOL)), true)); + + Block printExceptionBlock = new Block(owner, TypeList.VOID, printExceptionBlockContent, 3); + List catchBlocks1 = new ArrayList<>(); + catchBlocks1.add(new CatchBlock(printExceptionBlock, throwables, 3)); + List catchBlocks2 = new ArrayList<>(); + catchBlocks2.add(new CatchBlock(printExceptionBlock, throwables, 3)); + List catchBlocks3 = new ArrayList<>(); + catchBlocks3.add(new CatchBlock(printExceptionBlock, throwables, 2)); + + TryCatchBlock tryCatch1 = new TryCatchBlock(tryNode, nothing, catchBlocks1, 3); List printArgs = new ArrayList<>(); VariableInfo systemOutInfo = new VariableInfo("out", systemKlass, printStreamKlass, VariableInfo.STATIC | VariableInfo.PUBLIC); StaticMemberVariable systemOutVar = new StaticMemberVariable(owner, systemOutInfo); printArgs.add(systemOutVar); printArgs.add(tVar); - Function print = new Function(printStreamKlass, systemOutPrintInfo, printArgs); + Function print = new Function(printStreamKlass, printInfo, printArgs); ArrayList printBlockContent = new ArrayList<>(); printBlockContent.add(new Statement(print, true)); Block printBlock = new Block(owner, TypeList.VOID, printBlockContent, 3); From 05540f90da5288a7f665f2e15982af5f169b5d3c Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 27 May 2016 17:12:10 +0300 Subject: [PATCH 002/191] 8157821: [JITtester] OptionResolver and LiteralFactory use deprecated c-tors Reviewed-by: kvn --- .../src/jdk/test/lib/jittester/factories/LiteralFactory.java | 4 ++-- .../src/jdk/test/lib/jittester/utils/OptionResolver.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LiteralFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LiteralFactory.java index 8bdd2c4e38a..e5f213fb8d9 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LiteralFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LiteralFactory.java @@ -51,13 +51,13 @@ class LiteralFactory extends Factory { } else if (resultType.equals(TypeList.LONG)) { literal = new Literal((long) (PseudoRandom.random() * Long.MAX_VALUE), TypeList.LONG); } else if (resultType.equals(TypeList.FLOAT)) { - literal = new Literal(new Float(String.format( + literal = new Literal(Float.valueOf(String.format( (Locale) null, "%." + ProductionParams.floatingPointPrecision.value() + "EF", (float) PseudoRandom.random() * Float.MAX_VALUE)), TypeList.FLOAT); } else if (resultType.equals(TypeList.DOUBLE)) { - literal = new Literal(new Double(String.format( + literal = new Literal(Double.valueOf(String.format( (Locale) null, "%." + 2 * ProductionParams.floatingPointPrecision.value() + "E", PseudoRandom.random() * Double.MAX_VALUE)), diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java index 8b6f8a88ace..09f7f20695c 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java @@ -230,7 +230,7 @@ public class OptionResolver { @Override public Long parseFromString(String arg) { - return new Long(arg); + return Long.valueOf(arg); } } @@ -242,7 +242,7 @@ public class OptionResolver { @Override public Integer parseFromString(String arg) { - return new Integer(arg); + return Integer.valueOf(arg); } } From 066208e3684da83ef69b1a46d4ff6ab557e23a84 Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Mon, 23 May 2016 10:35:51 -0300 Subject: [PATCH 003/191] 8154156: PPC64: improve array copy stubs by using vector instructions Reviewed-by: goetz, mdoerr --- hotspot/src/cpu/ppc/vm/assembler_ppc.hpp | 21 ++++ .../src/cpu/ppc/vm/assembler_ppc.inline.hpp | 4 + hotspot/src/cpu/ppc/vm/register_ppc.cpp | 11 ++ hotspot/src/cpu/ppc/vm/register_ppc.hpp | 100 ++++++++++++++++++ hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp | 75 ++++++++++--- hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp | 25 +++-- hotspot/src/cpu/ppc/vm/vm_version_ppc.hpp | 6 ++ 7 files changed, 214 insertions(+), 28 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp index c5e7087eadc..002f5133234 100644 --- a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp @@ -503,6 +503,10 @@ class Assembler : public AbstractAssembler { LVSL_OPCODE = (31u << OPCODE_SHIFT | 6u << 1), LVSR_OPCODE = (31u << OPCODE_SHIFT | 38u << 1), + // Vector-Scalar (VSX) instruction support. + LXVD2X_OPCODE = (31u << OPCODE_SHIFT | 844u << 1), + STXVD2X_OPCODE = (31u << OPCODE_SHIFT | 972u << 1), + // Vector Permute and Formatting VPKPX_OPCODE = (4u << OPCODE_SHIFT | 782u ), VPKSHSS_OPCODE = (4u << OPCODE_SHIFT | 398u ), @@ -1085,6 +1089,19 @@ class Assembler : public AbstractAssembler { static int vrs( VectorRegister r) { return vrs(r->encoding());} static int vrt( VectorRegister r) { return vrt(r->encoding());} + // Support Vector-Scalar (VSX) instructions. + static int vsra( int x) { return opp_u_field(x, 15, 11); } + static int vsrb( int x) { return opp_u_field(x, 20, 16); } + static int vsrc( int x) { return opp_u_field(x, 25, 21); } + static int vsrs( int x) { return opp_u_field(x, 10, 6); } + static int vsrt( int x) { return opp_u_field(x, 10, 6); } + + static int vsra( VectorSRegister r) { return vsra(r->encoding());} + static int vsrb( VectorSRegister r) { return vsrb(r->encoding());} + static int vsrc( VectorSRegister r) { return vsrc(r->encoding());} + static int vsrs( VectorSRegister r) { return vsrs(r->encoding());} + static int vsrt( VectorSRegister r) { return vsrt(r->encoding());} + static int vsplt_uim( int x) { return opp_u_field(x, 15, 12); } // for vsplt* instructions static int vsplti_sim(int x) { return opp_u_field(x, 15, 11); } // for vsplti* instructions static int vsldoi_shb(int x) { return opp_u_field(x, 25, 22); } // for vsldoi instruction @@ -2065,6 +2082,10 @@ class Assembler : public AbstractAssembler { inline void mtvscr( VectorRegister b); inline void mfvscr( VectorRegister d); + // Vector-Scalar (VSX) instructions. + inline void lxvd2x( VectorSRegister d, Register a, Register b); + inline void stxvd2x( VectorSRegister d, Register a, Register b); + // AES (introduced with Power 8) inline void vcipher( VectorRegister d, VectorRegister a, VectorRegister b); inline void vcipherlast( VectorRegister d, VectorRegister a, VectorRegister b); diff --git a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp index 4e7f7df8f24..220e3a727c8 100644 --- a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp +++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp @@ -721,6 +721,10 @@ inline void Assembler::stvxl( VectorRegister d, Register s1, Register s2) { emit inline void Assembler::lvsl( VectorRegister d, Register s1, Register s2) { emit_int32( LVSL_OPCODE | vrt(d) | ra0mem(s1) | rb(s2)); } inline void Assembler::lvsr( VectorRegister d, Register s1, Register s2) { emit_int32( LVSR_OPCODE | vrt(d) | ra0mem(s1) | rb(s2)); } +// Vector-Scalar (VSX) instructions. +inline void Assembler::lxvd2x (VectorSRegister d, Register s1, Register s2) { emit_int32( LXVD2X_OPCODE | vsrt(d) | ra(s1) | rb(s2)); } +inline void Assembler::stxvd2x(VectorSRegister d, Register s1, Register s2) { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra(s1) | rb(s2)); } + inline void Assembler::vpkpx( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKPX_OPCODE | vrt(d) | vra(a) | vrb(b)); } inline void Assembler::vpkshss( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKSHSS_OPCODE | vrt(d) | vra(a) | vrb(b)); } inline void Assembler::vpkswss( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKSWSS_OPCODE | vrt(d) | vra(a) | vrb(b)); } diff --git a/hotspot/src/cpu/ppc/vm/register_ppc.cpp b/hotspot/src/cpu/ppc/vm/register_ppc.cpp index e0b07c98168..8dcd325ad75 100644 --- a/hotspot/src/cpu/ppc/vm/register_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/register_ppc.cpp @@ -75,3 +75,14 @@ const char* VectorRegisterImpl::name() const { }; return is_valid() ? names[encoding()] : "vnoreg"; } + +const char* VectorSRegisterImpl::name() const { + const char* names[number_of_registers] = { + "VSR0", "VSR1", "VSR2", "VSR3", "VSR4", "VSR5", "VSR6", "VSR7", + "VSR8", "VSR9", "VSR10", "VSR11", "VSR12", "VSR13", "VSR14", "VSR15", + "VSR16", "VSR17", "VSR18", "VSR19", "VSR20", "VSR21", "VSR22", "VSR23", + "VSR24", "VSR25", "VSR26", "VSR27", "VSR28", "VSR29", "VSR30", "VSR31" + }; + return is_valid() ? names[encoding()] : "vsnoreg"; +} + diff --git a/hotspot/src/cpu/ppc/vm/register_ppc.hpp b/hotspot/src/cpu/ppc/vm/register_ppc.hpp index 8f6dda40eea..fffd7dc54a1 100644 --- a/hotspot/src/cpu/ppc/vm/register_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/register_ppc.hpp @@ -491,6 +491,106 @@ CONSTANT_REGISTER_DECLARATION(VectorRegister, VR31, (31)); #endif // DONT_USE_REGISTER_DEFINES +// Use VectorSRegister as a shortcut. +class VectorSRegisterImpl; +typedef VectorSRegisterImpl* VectorSRegister; + +inline VectorSRegister as_VectorSRegister(int encoding) { + return (VectorSRegister)(intptr_t)encoding; +} + +// The implementation of Vector-Scalar (VSX) registers on POWER architecture. +class VectorSRegisterImpl: public AbstractRegisterImpl { + public: + enum { + number_of_registers = 32 + }; + + // construction + inline friend VectorSRegister as_VectorSRegister(int encoding); + + // accessors + int encoding() const { assert(is_valid(), "invalid register"); return value(); } + + // testers + bool is_valid() const { return 0 <= value() && value() < number_of_registers; } + + const char* name() const; +}; + +// The Vector-Scalar (VSX) registers of the POWER architecture. + +CONSTANT_REGISTER_DECLARATION(VectorSRegister, vsnoreg, (-1)); + +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR0, ( 0)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR1, ( 1)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR2, ( 2)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR3, ( 3)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR4, ( 4)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR5, ( 5)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR6, ( 6)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR7, ( 7)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR8, ( 8)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR9, ( 9)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR10, (10)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR11, (11)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR12, (12)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR13, (13)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR14, (14)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR15, (15)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR16, (16)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR17, (17)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR18, (18)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR19, (19)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR20, (20)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR21, (21)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR22, (22)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR23, (23)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR24, (24)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR25, (25)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR26, (26)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR27, (27)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR28, (28)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR29, (29)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR30, (30)); +CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR31, (31)); + +#ifndef DONT_USE_REGISTER_DEFINES +#define vsnoregi ((VectorSRegister)(vsnoreg_VectorSRegisterEnumValue)) +#define VSR0 ((VectorSRegister)( VSR0_VectorSRegisterEnumValue)) +#define VSR1 ((VectorSRegister)( VSR1_VectorSRegisterEnumValue)) +#define VSR2 ((VectorSRegister)( VSR2_VectorSRegisterEnumValue)) +#define VSR3 ((VectorSRegister)( VSR3_VectorSRegisterEnumValue)) +#define VSR4 ((VectorSRegister)( VSR4_VectorSRegisterEnumValue)) +#define VSR5 ((VectorSRegister)( VSR5_VectorSRegisterEnumValue)) +#define VSR6 ((VectorSRegister)( VSR6_VectorSRegisterEnumValue)) +#define VSR7 ((VectorSRegister)( VSR7_VectorSRegisterEnumValue)) +#define VSR8 ((VectorSRegister)( VSR8_VectorSRegisterEnumValue)) +#define VSR9 ((VectorSRegister)( VSR9_VectorSRegisterEnumValue)) +#define VSR10 ((VectorSRegister)( VSR10_VectorSRegisterEnumValue)) +#define VSR11 ((VectorSRegister)( VSR11_VectorSRegisterEnumValue)) +#define VSR12 ((VectorSRegister)( VSR12_VectorSRegisterEnumValue)) +#define VSR13 ((VectorSRegister)( VSR13_VectorSRegisterEnumValue)) +#define VSR14 ((VectorSRegister)( VSR14_VectorSRegisterEnumValue)) +#define VSR15 ((VectorSRegister)( VSR15_VectorSRegisterEnumValue)) +#define VSR16 ((VectorSRegister)( VSR16_VectorSRegisterEnumValue)) +#define VSR17 ((VectorSRegister)( VSR17_VectorSRegisterEnumValue)) +#define VSR18 ((VectorSRegister)( VSR18_VectorSRegisterEnumValue)) +#define VSR19 ((VectorSRegister)( VSR19_VectorSRegisterEnumValue)) +#define VSR20 ((VectorSRegister)( VSR20_VectorSRegisterEnumValue)) +#define VSR21 ((VectorSRegister)( VSR21_VectorSRegisterEnumValue)) +#define VSR22 ((VectorSRegister)( VSR22_VectorSRegisterEnumValue)) +#define VSR23 ((VectorSRegister)( VSR23_VectorSRegisterEnumValue)) +#define VSR24 ((VectorSRegister)( VSR24_VectorSRegisterEnumValue)) +#define VSR25 ((VectorSRegister)( VSR25_VectorSRegisterEnumValue)) +#define VSR26 ((VectorSRegister)( VSR26_VectorSRegisterEnumValue)) +#define VSR27 ((VectorSRegister)( VSR27_VectorSRegisterEnumValue)) +#define VSR28 ((VectorSRegister)( VSR28_VectorSRegisterEnumValue)) +#define VSR29 ((VectorSRegister)( VSR29_VectorSRegisterEnumValue)) +#define VSR30 ((VectorSRegister)( VSR30_VectorSRegisterEnumValue)) +#define VSR31 ((VectorSRegister)( VSR31_VectorSRegisterEnumValue)) +#endif // DONT_USE_REGISTER_DEFINES + // Maximum number of incoming arguments that can be passed in i registers. const int PPC_ARGS_IN_REGS_NUM = 8; diff --git a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp index 58222baa2fa..7ae89abd38f 100644 --- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp @@ -1341,10 +1341,13 @@ class StubGenerator: public StubCodeGenerator { Register tmp3 = R8_ARG6; Register tmp4 = R9_ARG7; + VectorSRegister tmp_vsr1 = VSR1; + VectorSRegister tmp_vsr2 = VSR2; + address start = __ function_entry(); assert_positive_int(R5_ARG3); - Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8; + Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9; // don't try anything fancy if arrays don't have many elements __ li(tmp3, 0); @@ -1403,22 +1406,60 @@ class StubGenerator: public StubCodeGenerator { __ andi_(R5_ARG3, R5_ARG3, 15); __ mtctr(tmp1); - __ bind(l_8); - // Use unrolled version for mass copying (copy 16 elements a time). - // Load feeding store gets zero latency on Power6, however not on Power5. - // Therefore, the following sequence is made for the good of both. - __ ld(tmp1, 0, R3_ARG1); - __ ld(tmp2, 8, R3_ARG1); - __ ld(tmp3, 16, R3_ARG1); - __ ld(tmp4, 24, R3_ARG1); - __ std(tmp1, 0, R4_ARG2); - __ std(tmp2, 8, R4_ARG2); - __ std(tmp3, 16, R4_ARG2); - __ std(tmp4, 24, R4_ARG2); - __ addi(R3_ARG1, R3_ARG1, 32); - __ addi(R4_ARG2, R4_ARG2, 32); - __ bdnz(l_8); - } + if (!VM_Version::has_vsx()) { + + __ bind(l_8); + // Use unrolled version for mass copying (copy 16 elements a time). + // Load feeding store gets zero latency on Power6, however not on Power5. + // Therefore, the following sequence is made for the good of both. + __ ld(tmp1, 0, R3_ARG1); + __ ld(tmp2, 8, R3_ARG1); + __ ld(tmp3, 16, R3_ARG1); + __ ld(tmp4, 24, R3_ARG1); + __ std(tmp1, 0, R4_ARG2); + __ std(tmp2, 8, R4_ARG2); + __ std(tmp3, 16, R4_ARG2); + __ std(tmp4, 24, R4_ARG2); + __ addi(R3_ARG1, R3_ARG1, 32); + __ addi(R4_ARG2, R4_ARG2, 32); + __ bdnz(l_8); + + } else { // Processor supports VSX, so use it to mass copy. + + // Prefetch src data into L2 cache. + __ dcbt(R3_ARG1, 0); + + // If supported set DSCR pre-fetch to deepest. + if (VM_Version::has_mfdscr()) { + __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7); + __ mtdscr(tmp2); + } + __ li(tmp1, 16); + + // Backbranch target aligned to 32-byte. It's not aligned 16-byte + // as loop contains < 8 instructions that fit inside a single + // i-cache sector. + __ align(32); + + __ bind(l_9); + // Use loop with VSX load/store instructions to + // copy 16 elements a time. + __ lxvd2x(tmp_vsr1, 0, R3_ARG1); // Load from src. + __ stxvd2x(tmp_vsr1, 0, R4_ARG2); // Store to dst. + __ lxvd2x(tmp_vsr2, R3_ARG1, tmp1); // Load from src + 16. + __ stxvd2x(tmp_vsr2, R4_ARG2, tmp1); // Store to dst + 16. + __ addi(R3_ARG1, R3_ARG1, 32); // Update src+=32. + __ addi(R4_ARG2, R4_ARG2, 32); // Update dsc+=32. + __ bdnz(l_9); // Dec CTR and loop if not zero. + + // Restore DSCR pre-fetch value. + if (VM_Version::has_mfdscr()) { + __ load_const_optimized(tmp2, VM_Version::_dscr_val); + __ mtdscr(tmp2); + } + + } + } // FasterArrayCopy __ bind(l_6); // copy 2 elements at a time diff --git a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp index 88c03a3dc43..3b0800d6e5f 100644 --- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp @@ -38,7 +38,7 @@ # include bool VM_Version::_is_determine_features_test_running = false; - +uint64_t VM_Version::_dscr_val = 0; #define MSG(flag) \ if (flag && !FLAG_IS_DEFAULT(flag)) \ @@ -111,7 +111,7 @@ void VM_Version::initialize() { // Create and print feature-string. char buf[(num_features+1) * 16]; // Max 16 chars per feature. jio_snprintf(buf, sizeof(buf), - "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s", + "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s", (has_fsqrt() ? " fsqrt" : ""), (has_isel() ? " isel" : ""), (has_lxarxeh() ? " lxarxeh" : ""), @@ -125,7 +125,8 @@ void VM_Version::initialize() { (has_vcipher() ? " aes" : ""), (has_vpmsumb() ? " vpmsumb" : ""), (has_tcheck() ? " tcheck" : ""), - (has_mfdscr() ? " mfdscr" : "") + (has_mfdscr() ? " mfdscr" : ""), + (has_vsx() ? " vsx" : "") // Make sure number of %s matches num_features! ); _features_string = os::strdup(buf); @@ -643,6 +644,7 @@ void VM_Version::determine_features() { a->vpmsumb(VR0, VR1, VR2); // code[11] -> vpmsumb a->tcheck(0); // code[12] -> tcheck a->mfdscr(R0); // code[13] -> mfdscr + a->lxvd2x(VSR0, 0, R3_ARG1); // code[14] -> vsx a->blr(); // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. @@ -691,6 +693,7 @@ void VM_Version::determine_features() { if (code[feature_cntr++]) features |= vpmsumb_m; if (code[feature_cntr++]) features |= tcheck_m; if (code[feature_cntr++]) features |= mfdscr_m; + if (code[feature_cntr++]) features |= vsx_m; // Print the detection code. if (PrintAssembly) { @@ -733,31 +736,31 @@ void VM_Version::config_dscr() { } // Apply the configuration if needed. - uint64_t dscr_val = (*get_dscr)(); + _dscr_val = (*get_dscr)(); if (Verbose) { - tty->print_cr("dscr value was 0x%lx" , dscr_val); + tty->print_cr("dscr value was 0x%lx" , _dscr_val); } bool change_requested = false; if (DSCR_PPC64 != (uintx)-1) { - dscr_val = DSCR_PPC64; + _dscr_val = DSCR_PPC64; change_requested = true; } if (DSCR_DPFD_PPC64 <= 7) { uint64_t mask = 0x7; - if ((dscr_val & mask) != DSCR_DPFD_PPC64) { - dscr_val = (dscr_val & ~mask) | (DSCR_DPFD_PPC64); + if ((_dscr_val & mask) != DSCR_DPFD_PPC64) { + _dscr_val = (_dscr_val & ~mask) | (DSCR_DPFD_PPC64); change_requested = true; } } if (DSCR_URG_PPC64 <= 7) { uint64_t mask = 0x7 << 6; - if ((dscr_val & mask) != DSCR_DPFD_PPC64 << 6) { - dscr_val = (dscr_val & ~mask) | (DSCR_URG_PPC64 << 6); + if ((_dscr_val & mask) != DSCR_DPFD_PPC64 << 6) { + _dscr_val = (_dscr_val & ~mask) | (DSCR_URG_PPC64 << 6); change_requested = true; } } if (change_requested) { - (*set_dscr)(dscr_val); + (*set_dscr)(_dscr_val); if (Verbose) { tty->print_cr("dscr was set to 0x%lx" , (*get_dscr)()); } diff --git a/hotspot/src/cpu/ppc/vm/vm_version_ppc.hpp b/hotspot/src/cpu/ppc/vm/vm_version_ppc.hpp index fccb4e21874..2d1f8db990e 100644 --- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.hpp @@ -46,6 +46,7 @@ protected: vpmsumb, tcheck, mfdscr, + vsx, num_features // last entry to count features }; enum Feature_Flag_Set { @@ -64,6 +65,7 @@ protected: vpmsumb_m = (1 << vpmsumb), tcheck_m = (1 << tcheck ), mfdscr_m = (1 << mfdscr ), + vsx_m = (1 << vsx ), all_features_m = (unsigned long)-1 }; @@ -97,10 +99,14 @@ public: static bool has_vpmsumb() { return (_features & vpmsumb_m) != 0; } static bool has_tcheck() { return (_features & tcheck_m) != 0; } static bool has_mfdscr() { return (_features & mfdscr_m) != 0; } + static bool has_vsx() { return (_features & vsx_m) != 0; } // Assembler testing static void allow_all(); static void revert(); + + // POWER 8: DSCR current value. + static uint64_t _dscr_val; }; #endif // CPU_PPC_VM_VM_VERSION_PPC_HPP From c3d0e73480946e824636879da398e24862ece5f8 Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Wed, 25 May 2016 09:28:20 -0700 Subject: [PATCH 004/191] 8157620: Guarantee in run_task(task, num_workers) fails Reviewed-by: tschatzl, drwhite --- hotspot/src/share/vm/gc/shared/workgroup.cpp | 13 +++++++++---- hotspot/src/share/vm/gc/shared/workgroup.hpp | 6 +++++- hotspot/test/gc/stress/TestGCOld.java | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/workgroup.cpp b/hotspot/src/share/vm/gc/shared/workgroup.cpp index 0dfffcd82e8..f53285d9b26 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.cpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp @@ -60,6 +60,10 @@ AbstractGangWorker* AbstractWorkGang::install_worker(uint worker_id) { } void AbstractWorkGang::add_workers(bool initializing) { + add_workers(_active_workers, initializing); +} + +void AbstractWorkGang::add_workers(uint active_workers, bool initializing) { os::ThreadType worker_type; if (are_ConcurrentGC_threads()) { @@ -69,7 +73,7 @@ void AbstractWorkGang::add_workers(bool initializing) { } _created_workers = WorkerManager::add_workers(this, - _active_workers, + active_workers, _total_workers, _created_workers, worker_type, @@ -268,10 +272,11 @@ void WorkGang::run_task(AbstractGangTask* task) { } void WorkGang::run_task(AbstractGangTask* task, uint num_workers) { - guarantee(num_workers <= active_workers(), - "Trying to execute task %s with %u workers which is more than the amount of active workers %u.", - task->name(), num_workers, active_workers()); + guarantee(num_workers <= total_workers(), + "Trying to execute task %s with %u workers which is more than the amount of total workers %u.", + task->name(), num_workers, total_workers()); guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name()); + add_workers(num_workers, false); _dispatcher->coordinator_execute_on_workers(task, num_workers); } diff --git a/hotspot/src/share/vm/gc/shared/workgroup.hpp b/hotspot/src/share/vm/gc/shared/workgroup.hpp index 388909168be..150365f4e04 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.hpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp @@ -170,6 +170,9 @@ class AbstractWorkGang : public CHeapObj { // Add GC workers as needed. void add_workers(bool initializing); + // Add GC workers as needed to reach the specified number of workers. + void add_workers(uint active_workers, bool initializing); + // Return the Ith worker. AbstractGangWorker* worker(uint i) const; @@ -214,7 +217,8 @@ public: virtual void run_task(AbstractGangTask* task); // Run a task with the given number of workers, returns // when the task is done. The number of workers must be at most the number of - // active workers. + // active workers. Additional workers may be created if an insufficient + // number currently exists. void run_task(AbstractGangTask* task, uint num_workers); protected: diff --git a/hotspot/test/gc/stress/TestGCOld.java b/hotspot/test/gc/stress/TestGCOld.java index 336cb09cca5..23fb60a3113 100644 --- a/hotspot/test/gc/stress/TestGCOld.java +++ b/hotspot/test/gc/stress/TestGCOld.java @@ -32,6 +32,7 @@ * @run main/othervm -Xmx384M -XX:+UseParallelGC -XX:-UseParallelOldGC TestGCOld 50 1 20 10 10000 * @run main/othervm -Xmx384M -XX:+UseConcMarkSweepGC TestGCOld 50 1 20 10 10000 * @run main/othervm -Xmx384M -XX:+UseG1GC TestGCOld 50 1 20 10 10000 + * @run main/othervm -Xms64m -Xmx128m -XX:+UseG1GC -XX:+UseDynamicNumberOfGCThreads -Xlog:gc,gc+task=trace TestGCOld 50 5 20 1 5000 */ import java.text.*; From 60fabf15a76891a4ecc892836a89a4f91566ce4f Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Fri, 27 May 2016 01:02:16 +0800 Subject: [PATCH 005/191] 8156731: aarch64: java/util/Arrays/Correct.java fails due to _generic_arraycopy stub routine Fix address calculation considering compressed oops _generic_arraycopy stub routine Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index 2355579ceab..075bf794650 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -1299,7 +1299,7 @@ class StubGenerator: public StubCodeGenerator { if (VerifyOops) verify_oop_array(size, d, count, r16); __ sub(count, count, 1); // make an inclusive end pointer - __ lea(count, Address(d, count, Address::uxtw(exact_log2(size)))); + __ lea(count, Address(d, count, Address::lsl(exact_log2(size)))); gen_write_ref_array_post_barrier(d, count, rscratch1); } __ leave(); @@ -2002,9 +2002,9 @@ class StubGenerator: public StubCodeGenerator { arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length, rscratch2, L_failed); - __ lea(from, Address(src, src_pos, Address::lsl(3))); + __ lea(from, Address(src, src_pos, Address::lsl(LogBytesPerHeapOop))); __ add(from, from, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); - __ lea(to, Address(dst, dst_pos, Address::lsl(3))); + __ lea(to, Address(dst, dst_pos, Address::lsl(LogBytesPerHeapOop))); __ add(to, to, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); __ movw(count, scratch_length); // length __ BIND(L_plain_copy); @@ -2027,9 +2027,9 @@ class StubGenerator: public StubCodeGenerator { __ load_klass(rscratch2_dst_klass, dst); // reload // Marshal the base address arguments now, freeing registers. - __ lea(from, Address(src, src_pos, Address::lsl(3))); + __ lea(from, Address(src, src_pos, Address::lsl(LogBytesPerHeapOop))); __ add(from, from, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); - __ lea(to, Address(dst, dst_pos, Address::lsl(3))); + __ lea(to, Address(dst, dst_pos, Address::lsl(LogBytesPerHeapOop))); __ add(to, to, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); __ movw(count, length); // length (reloaded) Register sco_temp = c_rarg3; // this register is free now From cf20f6fff82b0e01960314ced836b7d6b2116ea1 Mon Sep 17 00:00:00 2001 From: Teng Lu Date: Fri, 27 May 2016 20:38:38 +0800 Subject: [PATCH 006/191] 8157906: aarch64: some more integer rotate instructions are never emitted Fix wrong definition of source operand of left rotate instructions Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 6db1772b432..1aeae0bf38f 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -12179,21 +12179,21 @@ instruct rolL_rReg_Var_C0(iRegLNoSp dst, iRegL src, iRegI shift, immI0 c0, rFlag %} %} -instruct rolI_rReg_Var_C_32(iRegLNoSp dst, iRegL src, iRegI shift, immI_32 c_32, rFlagsReg cr) +instruct rolI_rReg_Var_C_32(iRegINoSp dst, iRegI src, iRegI shift, immI_32 c_32, rFlagsReg cr) %{ match(Set dst (OrI (LShiftI src shift) (URShiftI src (SubI c_32 shift)))); expand %{ - rolL_rReg(dst, src, shift, cr); + rolI_rReg(dst, src, shift, cr); %} %} -instruct rolI_rReg_Var_C0(iRegLNoSp dst, iRegL src, iRegI shift, immI0 c0, rFlagsReg cr) +instruct rolI_rReg_Var_C0(iRegINoSp dst, iRegI src, iRegI shift, immI0 c0, rFlagsReg cr) %{ match(Set dst (OrI (LShiftI src shift) (URShiftI src (SubI c0 shift)))); expand %{ - rolL_rReg(dst, src, shift, cr); + rolI_rReg(dst, src, shift, cr); %} %} From a0b8f9dc1a49167fcaadc0f0c2a477ba3ba4b969 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 30 May 2016 23:32:59 +0300 Subject: [PATCH 007/191] 8154123: remove commented action from jdk/vm/ci/runtime/test/ConstantTest.java Reviewed-by: shade, kvn --- .../src/jdk/vm/ci/runtime/test/ConstantTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java index c14a69bf724..63230f38955 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java @@ -31,7 +31,6 @@ * @build jdk.vm.ci.runtime.test.ConstantTest * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.ConstantTest */ -// * @compile ConstantTest.java FieldUniverse.java TypeUniverse.java TestMetaAccessProvider.java package jdk.vm.ci.runtime.test; import org.junit.Assert; From 395f9470dfa2be06a96bfd5d9cd20e14b9f5fde5 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 30 May 2016 23:33:00 +0300 Subject: [PATCH 008/191] 8152376: [TESTBUG] compiler/floatingpoint/Test15FloatJNIArgs should use run main/othervm/native Reviewed-by: kvn --- hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java b/hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java index 1425d3da016..9cb924318f5 100644 --- a/hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java +++ b/hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java @@ -25,9 +25,9 @@ * @bug 8139258 * @summary Regression test for 8139258 which failed to properly pass float args * to a jni function on ppc64le. - * @run main/othervm -Xint Test15FloatJNIArgs - * @run main/othervm -XX:+TieredCompilation -Xcomp Test15FloatJNIArgs - * @run main/othervm -XX:-TieredCompilation -Xcomp Test15FloatJNIArgs + * @run main/othervm/native -Xint Test15FloatJNIArgs + * @run main/othervm/native -XX:+TieredCompilation -Xcomp Test15FloatJNIArgs + * @run main/othervm/native -XX:-TieredCompilation -Xcomp Test15FloatJNIArgs */ public class Test15FloatJNIArgs { From 11504c438f03ebde13264a1499f643e5319b5df6 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 31 May 2016 15:12:09 +0300 Subject: [PATCH 009/191] 8073159: improve Test6857159.java Reviewed-by: kvn --- .../test/compiler/c2/6857159/Test6857159.java | 8 +-- .../test/compiler/c2/6857159/Test6857159.sh | 54 ------------------- 2 files changed, 4 insertions(+), 58 deletions(-) delete mode 100644 hotspot/test/compiler/c2/6857159/Test6857159.sh diff --git a/hotspot/test/compiler/c2/6857159/Test6857159.java b/hotspot/test/compiler/c2/6857159/Test6857159.java index 1d4b7520865..f412adf5876 100644 --- a/hotspot/test/compiler/c2/6857159/Test6857159.java +++ b/hotspot/test/compiler/c2/6857159/Test6857159.java @@ -34,12 +34,12 @@ import jdk.test.lib.*; public class Test6857159 { - public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbatch", "-XX:+PrintCompilation", - "-XX:CompileOnly=Test$ct.run", "Test"); - OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); + public static void main(String[] args) throws Throwable { + OutputAnalyzer analyzer = ProcessTools.executeTestJvm("-Xbatch", + "-XX:+PrintCompilation", "-XX:CompileOnly=Test$ct.run", "Test"); analyzer.shouldNotContain("COMPILE SKIPPED"); analyzer.shouldContain("Test$ct0::run (16 bytes)"); + analyzer.shouldHaveExitValue(0); } } diff --git a/hotspot/test/compiler/c2/6857159/Test6857159.sh b/hotspot/test/compiler/c2/6857159/Test6857159.sh deleted file mode 100644 index 0762fe17ca8..00000000000 --- a/hotspot/test/compiler/c2/6857159/Test6857159.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009, 2014, 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. -# -# -## some tests require path to find test source dir -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../../test_env.sh - -set -x - -cp ${TESTSRC}/Test6857159.java . -cp ${TESTSRC}/Test6857159.sh . - -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test6857159.java - -${TESTJAVA}/bin/java ${TESTOPTS} -Xbatch -XX:+PrintCompilation -XX:CompileOnly=Test6857159\$ct.run Test6857159 > test.out 2>&1 - -grep "COMPILE SKIPPED" test.out - -result=$? -if [ $result -eq 1 ] -then - echo "Passed" - exit 0 -else - echo "Failed" - exit 1 -fi From 3f436dc952e3760648b5c61ec6f4b14119da7ddf Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Tue, 31 May 2016 15:48:47 +0300 Subject: [PATCH 010/191] 8158065: [Jittester]: tests generation has tests generators hardcoded, blocking alternative tests generation Reviewed-by: iignatyev --- hotspot/test/testlibrary/jittester/Makefile | 5 + .../jittester/conf/default.properties | 2 + .../src/jdk/test/lib/jittester/Automatic.java | 190 ++++-------------- .../test/lib/jittester/ByteCodeGenerator.java | 63 +++--- .../test/lib/jittester/JavaCodeGenerator.java | 69 ++++--- .../test/lib/jittester/ProductionParams.java | 8 +- .../lib/jittester/TestGeneratorsFactory.java | 49 +++++ .../test/lib/jittester/TestsGenerator.java | 184 +++++++++++++++++ .../lib/jittester/jtreg/JitTesterDriver.java | 13 +- 9 files changed, 365 insertions(+), 218 deletions(-) create mode 100644 hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestGeneratorsFactory.java create mode 100644 hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java diff --git a/hotspot/test/testlibrary/jittester/Makefile b/hotspot/test/testlibrary/jittester/Makefile index 91c996e4b4c..49470f7df71 100644 --- a/hotspot/test/testlibrary/jittester/Makefile +++ b/hotspot/test/testlibrary/jittester/Makefile @@ -44,6 +44,10 @@ ifneq "x$(SEED)" "x" APPLICATION_ARGS += --seed $(SEED) endif +ifneq "x$(EXTRA_SRC_DIR)" "x" + EXTRA_SRC_FILES := $(shell find $(EXTRA_SRC_DIR) -name '*.java') +endif + JAVA = $(JDK_HOME)/bin/java JAVAC = $(JDK_HOME)/bin/javac JAR = $(JDK_HOME)/bin/jar @@ -99,6 +103,7 @@ COMPILE: INIT filelist compile_testlib filelist: $(SRC_FILES) @rm -f $@ @echo $(SRC_FILES) > $@ + @echo $(EXTRA_SRC_FILES) >> $@ INIT: $(DIST_DIR) $(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi) diff --git a/hotspot/test/testlibrary/jittester/conf/default.properties b/hotspot/test/testlibrary/jittester/conf/default.properties index edc980fd36e..e5d8a0bc39f 100644 --- a/hotspot/test/testlibrary/jittester/conf/default.properties +++ b/hotspot/test/testlibrary/jittester/conf/default.properties @@ -9,3 +9,5 @@ exclude-methods-file=conf/exclude.methods.lst print-complexity=true print-hierarchy=true disable-static=true +generatorsFactories=jdk.test.lib.jittester.TestGeneratorsFactory +generators=JavaCode,ByteCode diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java index 3842d01f607..ee81bcf4e60 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java @@ -25,50 +25,19 @@ package jdk.test.lib.jittester; import jdk.test.lib.Pair; import jdk.test.lib.jittester.factories.IRNodeBuilder; -import jdk.test.lib.jittester.jtreg.Printer; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.FixedTrees; import jdk.test.lib.jittester.utils.OptionResolver; import jdk.test.lib.jittester.utils.OptionResolver.Option; import jdk.test.lib.jittester.utils.PseudoRandom; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.time.LocalTime; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; +import java.util.function.Function; public class Automatic { - private static final int MINUTES_TO_WAIT = Integer.getInteger("jdk.test.lib.jittester", 3); - - static String getJtregHeader(String mainClass, boolean addCompile) { - String synopsis = "seed = '" + ProductionParams.seed.value() + "'" - + ", specificSeed = '" + PseudoRandom.getCurrentSeed() + "'"; - StringBuilder header = new StringBuilder(); - header.append("/*\n * @test\n * @summary ") - .append(synopsis) - .append(" \n* @library / ../\n"); - if (addCompile) { - header.append("\n * @compile ") - .append(mainClass) - .append(".java\n"); - } - header.append(" * @run build jdk.test.lib.jittester.jtreg.JitTesterDriver " - + "jdk.test.lib.jittester.jtreg.Printer\n") - .append(" * @run driver jdk.test.lib.jittester.jtreg.JitTesterDriver ") - .append(mainClass) - .append("\n */\n\n"); - if (ProductionParams.printHierarchy.value()) { - header.append("/*\n") - .append(Automatic.printHierarchy()) - .append("*/\n"); - } - return header.toString(); - } + public static final int MINUTES_TO_WAIT = Integer.getInteger("jdk.test.lib.jittester", 3); private static Pair generateIRTree(String name) { SymbolTable.removeAll(); @@ -120,123 +89,48 @@ public class Automatic { } } + private static List getTestGenerators() { + List result = new ArrayList<>(); + Class factoryClass; + Function> factory; + String[] factoryClassNames = ProductionParams.generatorsFactories.value().split(","); + String[] generatorNames = ProductionParams.generators.value().split(","); + for (String factoryClassName : factoryClassNames) { + try { + factoryClass = Class.forName(factoryClassName); + factory = (Function>) factoryClass.newInstance(); + } catch (ReflectiveOperationException roe) { + throw new Error("Can't instantiate generators factory", roe); + } + result.addAll(factory.apply(generatorNames)); + } + return result; + } + public static void main(String[] args) { initializeTestGenerator(args); int counter = 0; - try { - Path testbaseDir = Paths.get(ProductionParams.testbaseDir.value()); - System.out.printf(" %13s | %8s | %8s | %8s |%n", "start time", "count", "generat", - "running"); - System.out.printf(" %13s | %8s | %8s | %8s |%n", "---", "---", "---","---"); - String path = getJavaPath(); - String javacPath = Paths.get(path, "javac").toString(); - String javaPath = Paths.get(path, "java").toString(); - - // compile Printer class first. A common one for all tests - ensureExisting(testbaseDir); - ProcessBuilder pbPrinter = new ProcessBuilder(javacPath, - Paths.get(testbaseDir.toString(), "jdk", "test", "lib", "jittester", - "jtreg", "Printer.java").toString()); - runProcess(pbPrinter, testbaseDir.resolve("Printer").toString()); - do { - double start = System.currentTimeMillis(); - System.out.print("[" + LocalTime.now() + "] |"); - String name = "Test_" + counter; - Pair irTree = generateIRTree(name); - System.out.printf(" %8d |", counter); - double generationTime = System.currentTimeMillis() - start; - System.out.printf(" %8.0f |", generationTime); - if (!ProductionParams.disableJavacodeGeneration.value()) { - JavaCodeGenerator generator = new JavaCodeGenerator(); - String javaFile = generator.apply(irTree.first, irTree.second); - ProcessBuilder pb = new ProcessBuilder(javacPath, "-cp", testbaseDir.toString() - + ":" + generator.getTestbase().toString(), javaFile); - runProcess(pb, generator.getTestbase().resolve(name).toString()); - start = System.currentTimeMillis(); - - // Run compiled class files - pb = new ProcessBuilder(javaPath, "-Xint", "-cp", testbaseDir.toString() - + ":" + generator.getTestbase().toString(), name); - String goldFile = name + ".gold"; - runProcess(pb, generator.getTestbase().resolve(goldFile).toString()); - } - - if (!ProductionParams.disableBytecodeGeneration.value()) { - ByteCodeGenerator generator = new ByteCodeGenerator(); - generator.apply(irTree.first, irTree.second); - generator.writeJtregBytecodeRunner(name); - // Run generated bytecode - ProcessBuilder pb = new ProcessBuilder(javaPath, "-Xint", "-Xverify", "-cp", - testbaseDir.toString() + ":" + generator.getTestbase().toString(), - name); - String goldFile = name + ".gold"; - start = System.currentTimeMillis(); - runProcess(pb, generator.getTestbase().resolve(goldFile).toString()); - } - - double runningTime = System.currentTimeMillis() - start; - System.out.printf(" %8.0f |%n", runningTime); - if (runningTime < TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT)) { - ++counter; - } - } while (counter < ProductionParams.numberOfTests.value()); - } catch (IOException | InterruptedException ex) { - ex.printStackTrace(); - } - } - - private static String getJavaPath() { - String[] env = { "JDK_HOME", "JAVA_HOME", "BOOTDIR" }; - for (String name : env) { - String path = System.getenv(name); - if (path != null) { - return path + "/bin/"; + System.out.printf(" %13s | %8s | %8s | %8s |%n", "start time", "count", "generat", + "running"); + System.out.printf(" %13s | %8s | %8s | %8s |%n", "---", "---", "---", "---"); + List generators = getTestGenerators(); + do { + double start = System.currentTimeMillis(); + System.out.print("[" + LocalTime.now() + "] |"); + String name = "Test_" + counter; + Pair irTree = generateIRTree(name); + System.out.printf(" %8d |", counter); + double generationTime = System.currentTimeMillis() - start; + System.out.printf(" %8.0f |", generationTime); + start = System.currentTimeMillis(); + for (TestsGenerator generator : generators) { + generator.accept(irTree.first, irTree.second); } - } - return ""; - } - - private static int runProcess(ProcessBuilder pb, String name) - throws IOException, InterruptedException { - pb.redirectError(new File(name + ".err")); - pb.redirectOutput(new File(name + ".out")); - Process process = pb.start(); - if (process.waitFor(MINUTES_TO_WAIT, TimeUnit.MINUTES)) { - try (FileWriter file = new FileWriter(name + ".exit")) { - file.write(Integer.toString(process.exitValue())); + double runningTime = System.currentTimeMillis() - start; + System.out.printf(" %8.0f |%n", runningTime); + if (runningTime < TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT)) { + ++counter; } - return process.exitValue(); - } else { - process.destroyForcibly(); - return -1; - } - } - - private static String printHierarchy() { - return TypeList.getAll().stream() - .filter(t -> t instanceof TypeKlass) - .map(t -> typeDescription((TypeKlass) t)) - .collect(Collectors.joining("\n","CLASS HIERARCHY:\n", "\n")); - } - - private static String typeDescription(TypeKlass type) { - StringBuilder result = new StringBuilder(); - String parents = type.getParentsNames().stream().collect(Collectors.joining(",")); - result.append(type.isAbstract() ? "abstract " : "") - .append(type.isFinal() ? "final " : "") - .append(type.isInterface() ? "interface " : "class ") - .append(type.getName()) - .append(parents.isEmpty() ? "" : ": " + parents); - return result.toString(); - } - - static void ensureExisting(Path path) { - if (Files.notExists(path)) { - try { - Files.createDirectories(path); - } catch (IOException ex) { - ex.printStackTrace(); - } - } + } while (counter < ProductionParams.numberOfTests.value()); } } diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java index c13b9fbdf9d..94957ba3202 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java @@ -23,54 +23,60 @@ package jdk.test.lib.jittester; -import jdk.test.lib.jittester.visitors.ByteCodeVisitor; - import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardOpenOption; -import java.util.function.BiFunction; +import java.util.function.Function; +import jdk.test.lib.jittester.visitors.ByteCodeVisitor; /** - * Generates class files from bytecode + * Generates class files from IRTree */ -class ByteCodeGenerator implements BiFunction { - private final Path testbase = Paths.get(ProductionParams.testbaseDir.value(), - "bytecode_tests"); +class ByteCodeGenerator extends TestsGenerator { + private static final String DEFAULT_SUFFIX = "bytecode_tests"; - public void writeJtregBytecodeRunner(String name) { - try (FileWriter file = new FileWriter(testbase.resolve(name + ".java").toFile())) { - file.write(Automatic.getJtregHeader(name, false)); - } catch (IOException e) { - e.printStackTrace(); - } + ByteCodeGenerator() { + super(DEFAULT_SUFFIX); } - public String apply(IRNode mainClass, IRNode privateClasses) { - Automatic.ensureExisting(testbase); + ByteCodeGenerator(String suffix, Function preRunActions, String jtDriverOptions) { + super(suffix, preRunActions, jtDriverOptions); + } + + @Override + public void accept(IRNode mainClass, IRNode privateClasses) { + generateClassFiles(mainClass, privateClasses); + generateSeparateJtregHeader(mainClass); + compilePrinter(); + generateGoldenOut(mainClass.getName()); + } + + private void generateSeparateJtregHeader(IRNode mainClass) { + String mainClassName = mainClass.getName(); + writeFile(generatorDir, mainClassName + ".java", getJtregHeader(mainClassName)); + } + + private void generateClassFiles(IRNode mainClass, IRNode privateClasses) { + String mainClassName = mainClass.getName(); + ensureExisting(generatorDir); try { ByteCodeVisitor vis = new ByteCodeVisitor(); if (privateClasses != null) { privateClasses.accept(vis); } mainClass.accept(vis); - - Path mainClassPath = testbase.resolve(mainClass.getName() + ".class"); - writeToClassFile(mainClassPath, vis.getByteCode(mainClass.getName())); + writeFile(mainClassName + ".class", vis.getByteCode(mainClassName)); if (privateClasses != null) { privateClasses.getChildren().forEach(c -> { String name = c.getName(); - Path classPath = testbase.resolve(name + ".class"); - writeToClassFile(classPath, vis.getByteCode(name)); + writeFile(name + ".class", vis.getByteCode(name)); }); } - return mainClassPath.toString(); } catch (Throwable t) { - Path errFile = testbase.resolve(mainClass.getName() + ".err"); + Path errFile = generatorDir.resolve(mainClassName + ".err"); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(errFile, StandardOpenOption.CREATE_NEW))) { t.printStackTrace(pw); @@ -78,16 +84,11 @@ class ByteCodeGenerator implements BiFunction { t.printStackTrace(); throw new Error("can't write error to error file " + errFile, e); } - return null; } } - public Path getTestbase() { - return testbase; - } - - private void writeToClassFile(Path path, byte[] bytecode) { - try (FileOutputStream file = new FileOutputStream(path.toString())) { + private void writeFile(String fileName, byte[] bytecode) { + try (FileOutputStream file = new FileOutputStream(generatorDir.resolve(fileName).toFile())) { file.write(bytecode); } catch (IOException ex) { ex.printStackTrace(); diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java index 9f9e2a3387f..5c28487ad15 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java @@ -23,48 +23,59 @@ package jdk.test.lib.jittester; +import java.io.File; +import java.io.IOException; +import java.util.function.Function; import jdk.test.lib.jittester.visitors.JavaCodeVisitor; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.function.BiFunction; - /** - * Generates class files from java source code + * Generates java source code from IRTree */ -class JavaCodeGenerator implements BiFunction { - private final Path testbase = Paths.get(ProductionParams.testbaseDir.value(), "java_tests"); +public class JavaCodeGenerator extends TestsGenerator { + private static final String DEFAULT_SUFFIX = "java_tests"; - private String generateJavaCode(IRNode mainClass, IRNode privateClasses) { + JavaCodeGenerator() { + this(DEFAULT_SUFFIX, JavaCodeGenerator::generatePrerunAction, ""); + } + + JavaCodeGenerator(String prefix, Function preRunActions, String jtDriverOptions) { + super(prefix, preRunActions, jtDriverOptions); + } + + @Override + public void accept(IRNode mainClass, IRNode privateClasses) { + String mainClassName = mainClass.getName(); + generateSources(mainClass, privateClasses); + compilePrinter(); + compileJavaFile(mainClassName); + generateGoldenOut(mainClassName); + } + + private void generateSources(IRNode mainClass, IRNode privateClasses) { + String mainClassName = mainClass.getName(); StringBuilder code = new StringBuilder(); JavaCodeVisitor vis = new JavaCodeVisitor(); - - code.append(Automatic.getJtregHeader(mainClass.getName(), true)); + code.append(getJtregHeader(mainClassName)); if (privateClasses != null) { code.append(privateClasses.accept(vis)); } code.append(mainClass.accept(vis)); - - return code.toString(); + ensureExisting(generatorDir); + writeFile(generatorDir, mainClassName + ".java", code.toString()); } - public Path getTestbase() { - return testbase; - } - - @Override - public String apply(IRNode mainClass, IRNode privateClasses) { - String code = generateJavaCode(mainClass, privateClasses); - Automatic.ensureExisting(testbase); - Path fileName = testbase.resolve(mainClass.getName() + ".java"); - try (FileWriter file = new FileWriter(fileName.toFile())) { - file.write(code); - return fileName.toString(); - } catch (IOException ex) { - ex.printStackTrace(); + private void compileJavaFile(String mainClassName) { + String classPath = getRoot() + File.pathSeparator + generatorDir; + ProcessBuilder pb = new ProcessBuilder(JAVAC, "-cp", classPath, + generatorDir.resolve(mainClassName + ".java").toString()); + try { + runProcess(pb, generatorDir.resolve(mainClassName).toString()); + } catch (IOException | InterruptedException e) { + throw new Error("Can't compile sources ", e); } - return ""; + } + + private static String[] generatePrerunAction(String mainClassName) { + return new String[] {"@compile " + mainClassName + ".java"}; } } diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java index f3e7a6329fb..7a8256f0b12 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java @@ -68,8 +68,6 @@ public class ProductionParams { public static Option disableNestedBlocks = null; public static Option disableArrays = null; public static Option enableFinalizers = null; - public static Option disableBytecodeGeneration = null; - public static Option disableJavacodeGeneration = null; // workaraound: to reduce chance throwing ArrayIndexOutOfBoundsException public static Option chanceExpressionIndex = null; public static Option testbaseDir = null; @@ -78,6 +76,8 @@ public class ProductionParams { public static Option specificSeed = null; public static Option classesFile = null; public static Option excludeMethodsFile = null; + public static Option generators = null; + public static Option generatorsFactories = null; public static void register(OptionResolver optionResolver) { productionLimit = optionResolver.addIntegerOption('l', "production-limit", 100, "Limit on steps in the production of an expression"); @@ -120,8 +120,6 @@ public class ProductionParams { disableNestedBlocks = optionResolver.addBooleanOption("disable-nested-blocks", "Disable generation of nested blocks"); disableArrays = optionResolver.addBooleanOption("disable-arrays", "Disable generation of arrays"); enableFinalizers = optionResolver.addBooleanOption("enable-finalizers", "Enable finalizers (for stress testing)"); - disableBytecodeGeneration = optionResolver.addBooleanOption("disable-bytecode-generation", "Disable generation of bytecode output"); - disableJavacodeGeneration = optionResolver.addBooleanOption("disable-javacode-generation", "Disable generation of java source code output"); chanceExpressionIndex = optionResolver.addIntegerOption("chance-expression-index", 0, "A non negative decimal integer used to restrict chane of generating expression in array index while creating or accessing by index"); testbaseDir = optionResolver.addStringOption("testbase-dir", ".", "Testbase dir"); numberOfTests = optionResolver.addIntegerOption('n', "number-of-tests", 0, "Number of test classes to generate"); @@ -129,5 +127,7 @@ public class ProductionParams { specificSeed = optionResolver.addLongOption('z', "specificSeed", 0L, "A seed to be set for specific test generation(regular seed still needed for initialization)"); classesFile = optionResolver.addStringOption('f', "classes-file", "conf/classes.lst", "File to read classes from"); excludeMethodsFile = optionResolver.addStringOption('r', "exclude-methods-file", "conf/exclude.methods.lst", "File to read excluded methods from"); + generators = optionResolver.addStringOption("generators", "", "Comma-separated list of generator names"); + generatorsFactories = optionResolver.addStringOption("generatorsFactories", "", "Comma-separated list of generators factories class names"); } } diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestGeneratorsFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestGeneratorsFactory.java new file mode 100644 index 00000000000..ac4418d7952 --- /dev/null +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestGeneratorsFactory.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, 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. + */ + +package jdk.test.lib.jittester; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +public class TestGeneratorsFactory implements Function> { + + @Override + public List apply(String[] input) { + List result = new ArrayList<>(); + for (String generatorName : input) { + switch (generatorName) { + case "JavaCode": + result.add(new JavaCodeGenerator()); + break; + case "ByteCode": + result.add(new ByteCodeGenerator()); + break; + default: + throw new IllegalArgumentException("Unknown generator: " + generatorName); + } + } + return result; + } +} diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java new file mode 100644 index 00000000000..3974f078d7b --- /dev/null +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2016, 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. + */ + +package jdk.test.lib.jittester; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.stream.Collectors; +import jdk.test.lib.jittester.types.TypeKlass; +import jdk.test.lib.jittester.utils.PseudoRandom; + +public abstract class TestsGenerator implements BiConsumer { + protected static final String JAVA_BIN = getJavaPath(); + protected static final String JAVAC = Paths.get(JAVA_BIN, "javac").toString(); + protected static final String JAVA = Paths.get(JAVA_BIN, "java").toString(); + protected final Path generatorDir; + protected final Function preRunActions; + protected final String jtDriverOptions; + + protected TestsGenerator(String suffix) { + this(suffix, s -> new String[0], ""); + } + + protected TestsGenerator(String suffix, Function preRunActions, + String jtDriverOptions) { + generatorDir = getRoot().resolve(suffix); + this.preRunActions = preRunActions; + this.jtDriverOptions = jtDriverOptions; + } + + protected void generateGoldenOut(String mainClassName) { + String classPath = getRoot() + File.pathSeparator + generatorDir; + ProcessBuilder pb = new ProcessBuilder(JAVA, "-Xint", "-Xverify", "-cp", classPath, + mainClassName); + String goldFile = mainClassName + ".gold"; + try { + runProcess(pb, generatorDir.resolve(goldFile).toString()); + } catch (IOException | InterruptedException e) { + throw new Error("Can't run generated test ", e); + } + } + + protected static int runProcess(ProcessBuilder pb, String name) + throws IOException, InterruptedException { + pb.redirectError(new File(name + ".err")); + pb.redirectOutput(new File(name + ".out")); + Process process = pb.start(); + if (process.waitFor(Automatic.MINUTES_TO_WAIT, TimeUnit.MINUTES)) { + try (FileWriter file = new FileWriter(name + ".exit")) { + file.write(Integer.toString(process.exitValue())); + } + return process.exitValue(); + } else { + process.destroyForcibly(); + return -1; + } + } + + protected static void compilePrinter() { + Path root = getRoot(); + ProcessBuilder pbPrinter = new ProcessBuilder(JAVAC, + root.resolve("jdk") + .resolve("test") + .resolve("lib") + .resolve("jittester") + .resolve("jtreg") + .resolve("Printer.java") + .toString()); + try { + int exitCode = runProcess(pbPrinter, root.resolve("Printer").toString()); + if (exitCode != 0) { + throw new Error("Printer compilation returned exit code " + exitCode); + } + } catch (IOException | InterruptedException e) { + throw new Error("Can't compile printer", e); + } + } + + protected static void ensureExisting(Path path) { + if (Files.notExists(path)) { + try { + Files.createDirectories(path); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + + protected String getJtregHeader(String mainClassName) { + String synopsis = "seed = '" + ProductionParams.seed.value() + "'" + + ", specificSeed = '" + PseudoRandom.getCurrentSeed() + "'"; + StringBuilder header = new StringBuilder(); + header.append("/*\n * @test\n * @summary ") + .append(synopsis) + .append(" \n * @library / ../\n"); + header.append(" * @run build jdk.test.lib.jittester.jtreg.JitTesterDriver " + + "jdk.test.lib.jittester.jtreg.Printer\n"); + for (String action : preRunActions.apply(mainClassName)) { + header.append(" * ") + .append(action) + .append("\n"); + } + header.append(" * @run driver jdk.test.lib.jittester.jtreg.JitTesterDriver ") + .append(jtDriverOptions) + .append(" ") + .append(mainClassName) + .append("\n */\n\n"); + if (ProductionParams.printHierarchy.value()) { + header.append("/*\n") + .append(printHierarchy()) + .append("*/\n"); + } + return header.toString(); + } + + protected static Path getRoot() { + return Paths.get(ProductionParams.testbaseDir.value()); + } + + protected static void writeFile(Path targetDir, String fileName, String content) { + try (FileWriter file = new FileWriter(targetDir.resolve(fileName).toFile())) { + file.write(content); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static String printHierarchy() { + return TypeList.getAll() + .stream() + .filter(t -> t instanceof TypeKlass) + .map(t -> typeDescription((TypeKlass) t)) + .collect(Collectors.joining("\n","CLASS HIERARCHY:\n", "\n")); + } + + private static String typeDescription(TypeKlass type) { + StringBuilder result = new StringBuilder(); + String parents = type.getParentsNames().stream().collect(Collectors.joining(",")); + result.append(type.isAbstract() ? "abstract " : "") + .append(type.isFinal() ? "final " : "") + .append(type.isInterface() ? "interface " : "class ") + .append(type.getName()) + .append(parents.isEmpty() ? "" : ": " + parents); + return result.toString(); + } + + private static String getJavaPath() { + String[] env = { "JDK_HOME", "JAVA_HOME", "BOOTDIR" }; + for (String name : env) { + String path = System.getenv(name); + if (path != null) { + return path + "/bin/"; + } + } + return ""; + } +} diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java index d6b7db9ee41..72613da0049 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java @@ -40,30 +40,31 @@ import java.util.stream.Stream; public class JitTesterDriver { public static void main(String[] args) { - if (args.length != 1) { + if (args.length < 1) { throw new IllegalArgumentException( "[TESTBUG]: wrong number of argument : " + args.length - + ". Expected 1 argument -- jit-tester test name."); + + ". Expected at least 1 argument -- jit-tester test name."); } OutputAnalyzer oa; try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args[0]); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args); oa = new OutputAnalyzer(pb.start()); } catch (Exception e) { throw new Error("Unexpected exception on test jvm start :" + e, e); } + String name = args[args.length - 1]; Pattern splitOut = Pattern.compile("\\n"); // tests use \n only in stdout Pattern splitErr = Pattern.compile("\\r?\\n"); // can handle both \r\n and \n Path testDir = Paths.get(Utils.TEST_SRC); - String goldOut = formatOutput(streamGoldFile(testDir, args[0], "out")); + String goldOut = formatOutput(streamGoldFile(testDir, name, "out")); String anlzOut = formatOutput(Arrays.stream(splitOut.split(oa.getStdout()))); Asserts.assertEQ(anlzOut, goldOut, "Actual stdout isn't equal to golden one"); - String goldErr = formatOutput(streamGoldFile(testDir, args[0], "err")); + String goldErr = formatOutput(streamGoldFile(testDir, name, "err")); String anlzErr = formatOutput(Arrays.stream(splitErr.split(oa.getStderr()))); Asserts.assertEQ(anlzErr, goldErr, "Actual stderr isn't equal to golden one"); - int exitValue = Integer.parseInt(streamGoldFile(testDir, args[0], "exit").findFirst().get()); + int exitValue = Integer.parseInt(streamGoldFile(testDir, name, "exit").findFirst().get()); oa.shouldHaveExitValue(exitValue); } From 7073d102f08b6eeb62463e3b3e1c076bbea50b48 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 31 May 2016 16:29:45 +0300 Subject: [PATCH 011/191] 8158182: remove shell script from compiler/c2/6894807/IsInstanceTest.java Reviewed-by: kvn --- .../compiler/c2/6894807/IsInstanceTest.java | 11 +---- .../test/compiler/c2/6894807/Test6894807.sh | 48 ------------------- 2 files changed, 2 insertions(+), 57 deletions(-) delete mode 100644 hotspot/test/compiler/c2/6894807/Test6894807.sh diff --git a/hotspot/test/compiler/c2/6894807/IsInstanceTest.java b/hotspot/test/compiler/c2/6894807/IsInstanceTest.java index d838c6ec662..6350109404c 100644 --- a/hotspot/test/compiler/c2/6894807/IsInstanceTest.java +++ b/hotspot/test/compiler/c2/6894807/IsInstanceTest.java @@ -25,8 +25,7 @@ * @test * @bug 6894807 * @summary No ClassCastException for HashAttributeSet constructors if run with -Xcomp - * @compile IsInstanceTest.java - * @run shell Test6894807.sh + * @run main IsInstanceTest */ public class IsInstanceTest { @@ -35,13 +34,7 @@ public class IsInstanceTest { BaseInterface baseInterfaceImpl = new BaseInterfaceImpl(); for (int i = 0; i < 100000; i++) { if (isInstanceOf(baseInterfaceImpl, ExtendedInterface.class)) { - System.out.println("Failed at index:" + i); - System.out.println("Arch: "+System.getProperty("os.arch", "")+ - " OS: "+System.getProperty("os.name", "")+ - " OSV: "+System.getProperty("os.version", "")+ - " Cores: "+Runtime.getRuntime().availableProcessors()+ - " JVM: "+System.getProperty("java.version", "")+" "+System.getProperty("sun.arch.data.model", "")); - break; + throw new AssertionError("Failed at index:" + i); } } System.out.println("Done!"); diff --git a/hotspot/test/compiler/c2/6894807/Test6894807.sh b/hotspot/test/compiler/c2/6894807/Test6894807.sh deleted file mode 100644 index bf10ba263bf..00000000000 --- a/hotspot/test/compiler/c2/6894807/Test6894807.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2012, 2014, 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. -# - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" - -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../../test_env.sh - -${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} IsInstanceTest > test.out 2>&1 - -cat test.out - -grep "Failed at index" test.out - -if [ $? = 0 ] -then - echo "Test Failed" - exit 1 -else - echo "Test Passed" - exit 0 -fi From 708d50417ce73193bc4dd564bb24fd70ed026999 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 31 May 2016 16:29:45 +0300 Subject: [PATCH 012/191] 8158185: jdk/test/lib/FileInstaller throws NPE if dst is in current directory Reviewed-by: kvn --- hotspot/test/testlibrary/jdk/test/lib/FileInstaller.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/test/testlibrary/jdk/test/lib/FileInstaller.java b/hotspot/test/testlibrary/jdk/test/lib/FileInstaller.java index c5f92527258..7a8e3b8575c 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/FileInstaller.java +++ b/hotspot/test/testlibrary/jdk/test/lib/FileInstaller.java @@ -45,8 +45,8 @@ public class FileInstaller { if (args.length != 2) { throw new IllegalArgumentException("Unexpected number of arguments for file copy"); } - Path src = Paths.get(Utils.TEST_SRC, args[0]); - Path dst = Paths.get(args[1]); + Path src = Paths.get(Utils.TEST_SRC, args[0]).toAbsolutePath(); + Path dst = Paths.get(args[1]).toAbsolutePath(); if (src.toFile().exists()) { if (src.toFile().isDirectory()) { Files.walkFileTree(src, new CopyFileVisitor(src, dst)); From fe34e32f2b92fe53bd5da55652e692a3ebe8f771 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 31 May 2016 16:29:45 +0300 Subject: [PATCH 013/191] 8158184: remove shell from compiler/c2/7070134/Stemmer.java Reviewed-by: kvn --- hotspot/test/compiler/c2/7070134/Stemmer.java | 8 ++-- .../test/compiler/c2/7070134/Test7070134.sh | 45 ------------------- 2 files changed, 5 insertions(+), 48 deletions(-) delete mode 100644 hotspot/test/compiler/c2/7070134/Test7070134.sh diff --git a/hotspot/test/compiler/c2/7070134/Stemmer.java b/hotspot/test/compiler/c2/7070134/Stemmer.java index 49484f94f2b..b8dbc053c61 100644 --- a/hotspot/test/compiler/c2/7070134/Stemmer.java +++ b/hotspot/test/compiler/c2/7070134/Stemmer.java @@ -2,8 +2,10 @@ * @test * @bug 7070134 * @summary Hotspot crashes with sigsegv from PorterStemmer - * - * @run shell Test7070134.sh + * @modules java.base/jdk.internal.misc + * @library /testlibrary + * @run driver jdk.test.lib.FileInstaller words words + * @run main/othervm -Xbatch Stemmer words */ /* @@ -61,7 +63,7 @@ import java.io.*; * by calling one of the various stem(something) methods. */ -class Stemmer +public class Stemmer { private char[] b; private int i, /* offset into b */ i_end, /* offset to end of stemmed word */ diff --git a/hotspot/test/compiler/c2/7070134/Test7070134.sh b/hotspot/test/compiler/c2/7070134/Test7070134.sh deleted file mode 100644 index b79b5b16e5a..00000000000 --- a/hotspot/test/compiler/c2/7070134/Test7070134.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2011, 2014, 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. -# -# -## some tests require path to find test source dir -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../../test_env.sh - -set -x - -cp ${TESTSRC}/Stemmer.java . -cp ${TESTSRC}/words . - -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Stemmer.java - -${TESTJAVA}/bin/java ${TESTOPTS} -Xbatch Stemmer words > test.out 2>&1 - -exit $? - From 56be0b11f1a0ebf932584a2696b1996eeec345eb Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 31 May 2016 16:30:18 +0300 Subject: [PATCH 014/191] 8153994: Compiler tests should be correctly marked with @module Reviewed-by: kvn --- hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java b/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java index 97b21431caf..5b5ee81c2d0 100644 --- a/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java +++ b/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java @@ -38,6 +38,7 @@ import sun.hotspot.code.BlobType; /* * @test PoolsIndependenceTest * @modules java.base/jdk.internal.misc + * java.management * @library /testlibrary /test/lib * @build PoolsIndependenceTest * @run main ClassFileInstaller sun.hotspot.WhiteBox From 343a9e76a88282cb7e58adfbffbbb8e6e8d8bbab Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Tue, 31 May 2016 17:08:18 +0000 Subject: [PATCH 015/191] 8157292: [JVMCI] add missing test files from 8156034 Reviewed-by: iveresov --- ...ci.hotspot.services.HotSpotVMEventListener | 1 + ...m.ci.runtime.services.JVMCICompilerFactory | 1 + ...mciNotifyBootstrapFinishedEventTest.config | 1 + ...JvmciNotifyBootstrapFinishedEventTest.java | 82 +++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener create mode 100644 hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory create mode 100644 hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config create mode 100644 hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java diff --git a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener b/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener new file mode 100644 index 00000000000..2b70db58445 --- /dev/null +++ b/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener @@ -0,0 +1 @@ +compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener diff --git a/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory b/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory new file mode 100644 index 00000000000..5a88a1f4914 --- /dev/null +++ b/hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory @@ -0,0 +1 @@ +compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config new file mode 100644 index 00000000000..483de30ceab --- /dev/null +++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config @@ -0,0 +1 @@ +compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java new file mode 100644 index 00000000000..d1ed7a11737 --- /dev/null +++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 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 8156034 + * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @library / /testlibrary + * @library ../common/patches + * @modules java.base/jdk.internal.org.objectweb.asm + * java.base/jdk.internal.org.objectweb.asm.tree + * jdk.vm.ci/jdk.vm.ci.hotspot + * jdk.vm.ci/jdk.vm.ci.code + * jdk.vm.ci/jdk.vm.ci.meta + * jdk.vm.ci/jdk.vm.ci.runtime + * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @build compiler.jvmci.common.JVMCIHelpers + * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest + * @run main jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ + * @run main jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config + * ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener + * @run main ClassFileInstaller + * compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler + * compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory + * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest + * jdk.test.lib.Asserts + * jdk.test.lib.Utils + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI + * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. + * -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI + * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=false + * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI + * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. + * -XX:+UseJVMCICompiler -XX:+BootstrapJVMCI + * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=true + * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest + */ + +package compiler.jvmci.events; + +import jdk.test.lib.Asserts; +import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; + +public class JvmciNotifyBootstrapFinishedEventTest extends HotSpotVMEventListener { + private static final boolean BOOTSTRAP = Boolean + .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap"); + private static volatile int gotBoostrapNotification = 0; + + public static void main(String args[]) { + if (BOOTSTRAP) { + Asserts.assertEQ(gotBoostrapNotification, 1, "Did not receive expected number of bootstrap events"); + } else { + Asserts.assertEQ(gotBoostrapNotification, 0, "Got unexpected bootstrap event"); + } + } + + @Override + public void notifyBootstrapFinished() { + gotBoostrapNotification++; + } +} From bc9236dd30c9310f6c880b6a1747addf1638f086 Mon Sep 17 00:00:00 2001 From: Roland Schatz Date: Tue, 31 May 2016 20:43:12 +0000 Subject: [PATCH 016/191] 8157428: [JVMCI] remove MemoryAccessProvider.readUnsafeConstant from API Reviewed-by: iveresov --- .../HotSpotMemoryAccessProviderImpl.java | 14 +++++++++++-- .../jdk/vm/ci/meta/MemoryAccessProvider.java | 13 ------------ .../test/MemoryAccessProviderTest.java | 20 ------------------- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java index bcdd5d2d125..1d8828bb3bf 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java @@ -144,8 +144,18 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider { return ret; } - @Override - public JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) { + /** + * Reads a value of this kind using a base address and a displacement. No bounds checking or + * type checking is performed. Returns {@code null} if the value is not available at this point. + * + * @param baseConstant the base address from which the value is read. + * @param displacement the displacement within the object in bytes + * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the + * value cannot be read. + * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void}, not + * {@link JavaKind#Object} or not {@linkplain JavaKind#isPrimitive() primitive} kind + */ + JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) { if (kind == null) { throw new IllegalArgumentException("null JavaKind"); } diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java index aa9cade9ba9..81c5f395549 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java @@ -27,19 +27,6 @@ package jdk.vm.ci.meta; */ public interface MemoryAccessProvider { - /** - * Reads a value of this kind using a base address and a displacement. No bounds checking or - * type checking is performed. Returns {@code null} if the value is not available at this point. - * - * @param base the base address from which the value is read. - * @param displacement the displacement within the object in bytes - * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the - * value cannot be read. - * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void}, not - * {@link JavaKind#Object} or not {@linkplain JavaKind#isPrimitive() primitive} kind - */ - JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant base, long displacement) throws IllegalArgumentException; - /** * Reads a primitive value using a base address and a displacement. * diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java index ff79b14c9a1..ed07e8af3a1 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java @@ -48,26 +48,6 @@ import jdk.vm.ci.runtime.JVMCI; public class MemoryAccessProviderTest { private static final MemoryAccessProvider PROVIDER = JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection().getMemoryAccessProvider(); - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class) - public void testPositiveReadUnsafeConstant(JavaKind kind, JavaConstant base, Long offset, Object expected, int bitsCount) { - Assert.assertEquals(PROVIDER.readUnsafeConstant(kind, base, offset), expected, "Failed to read constant"); - } - - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testReadUnsafeConstantNullBase(JavaKind kind, JavaConstant base, Long offset, Object expected, int bitsCount) { - PROVIDER.readUnsafeConstant(kind, null, offset); - } - - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testNegativeReadUnsafeConstantNullKind(JavaKind kind, JavaConstant base, Long offset, Object expected, int bitsCount) { - Assert.assertNull(PROVIDER.readUnsafeConstant(null, base, offset), "Expected null return"); - } - - @Test(dataProvider = "negative", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testNegativeReadUnsafeConstant(JavaKind kind, JavaConstant base) { - PROVIDER.readUnsafeConstant(kind, base, 0L); - } - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class) public void testPositiveReadPrimitiveConstant(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { Assert.assertEquals(PROVIDER.readPrimitiveConstant(kind, base, offset, bitsCount), expected, "Failed to read constant"); From d1cfec7f7eaa5cc1b284187060462afc09a8d2fe Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 1 Jun 2016 14:22:18 +0200 Subject: [PATCH 017/191] 8155046: Parse::Block construction using undefined behavior Blocks should be created via constructor and placement new. Reviewed-by: kvn --- hotspot/src/share/vm/opto/parse.hpp | 7 ++----- hotspot/src/share/vm/opto/parse1.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp index cb9a3e3f104..c2b88595333 100644 --- a/hotspot/src/share/vm/opto/parse.hpp +++ b/hotspot/src/share/vm/opto/parse.hpp @@ -166,14 +166,11 @@ class Parse : public GraphKit { int _all_successors; // Include exception paths also. Block** _successors; - // Use init_node/init_graph to initialize Blocks. - // Block() : _live_locals((uintptr_t*)NULL,0) { ShouldNotReachHere(); } - Block() : _live_locals() { ShouldNotReachHere(); } - public: // Set up the block data structure itself. - void init_node(Parse* outer, int po); + Block(Parse* outer, int rpo); + // Set up the block's relations to other blocks. void init_graph(Parse* outer); diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp index 80885d9a836..b2044d3d5e1 100644 --- a/hotspot/src/share/vm/opto/parse1.cpp +++ b/hotspot/src/share/vm/opto/parse1.cpp @@ -1235,29 +1235,33 @@ void Parse::init_blocks() { // Create the blocks. _block_count = flow()->block_count(); _blocks = NEW_RESOURCE_ARRAY(Block, _block_count); - Copy::zero_to_bytes(_blocks, sizeof(Block)*_block_count); - - int rpo; // Initialize the structs. - for (rpo = 0; rpo < block_count(); rpo++) { + for (int rpo = 0; rpo < block_count(); rpo++) { Block* block = rpo_at(rpo); - block->init_node(this, rpo); + new(block) Block(this, rpo); } // Collect predecessor and successor information. - for (rpo = 0; rpo < block_count(); rpo++) { + for (int rpo = 0; rpo < block_count(); rpo++) { Block* block = rpo_at(rpo); block->init_graph(this); } } //-------------------------------init_node------------------------------------- -void Parse::Block::init_node(Parse* outer, int rpo) { +Parse::Block::Block(Parse* outer, int rpo) : _live_locals() { _flow = outer->flow()->rpo_at(rpo); _pred_count = 0; _preds_parsed = 0; _count = 0; + _is_parsed = false; + _is_handler = false; + _has_merged_backedge = false; + _start_map = NULL; + _num_successors = 0; + _all_successors = 0; + _successors = NULL; assert(pred_count() == 0 && preds_parsed() == 0, "sanity"); assert(!(is_merged() || is_parsed() || is_handler() || has_merged_backedge()), "sanity"); assert(_live_locals.size() == 0, "sanity"); From e4102fbe6739a22b6116758578b687ba1549cf04 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 1 Jun 2016 16:36:44 +0200 Subject: [PATCH 018/191] 8157842: indexOfChar intrinsic is not emitted on x86 Matcher::match_rule_supported() should check for !UseSSE42Intrinsics. Reviewed-by: roland, rbackman, shade, kvn --- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 10 ---------- hotspot/src/cpu/x86/vm/x86.ad | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index e3425c400ca..f9b42ec3ea1 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -7046,7 +7046,6 @@ void MacroAssembler::string_indexofC8(Register str1, Register str2, int ae) { ShortBranchVerifier sbv(this); assert(UseSSE42Intrinsics, "SSE4.2 intrinsics are required"); - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); assert(ae != StrIntrinsicNode::LU, "Invalid encoding"); // This method uses the pcmpestri instruction with bound registers @@ -7225,7 +7224,6 @@ void MacroAssembler::string_indexof(Register str1, Register str2, int ae) { ShortBranchVerifier sbv(this); assert(UseSSE42Intrinsics, "SSE4.2 intrinsics are required"); - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); assert(ae != StrIntrinsicNode::LU, "Invalid encoding"); // @@ -7543,7 +7541,6 @@ void MacroAssembler::string_indexof_char(Register str1, Register cnt1, Register XMMRegister vec1, XMMRegister vec2, XMMRegister vec3, Register tmp) { ShortBranchVerifier sbv(this); assert(UseSSE42Intrinsics, "SSE4.2 intrinsics are required"); - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); int stride = 8; @@ -7723,7 +7720,6 @@ void MacroAssembler::string_compare(Register str1, Register str2, } if (UseAVX >= 2 && UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); Label COMPARE_WIDE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_WIDE_TAIL, COMPARE_SMALL_STR; Label COMPARE_WIDE_VECTORS_LOOP, COMPARE_16_CHARS, COMPARE_INDEX_CHAR; Label COMPARE_WIDE_VECTORS_LOOP_AVX2; @@ -7891,7 +7887,6 @@ void MacroAssembler::string_compare(Register str1, Register str2, bind(COMPARE_SMALL_STR); } else if (UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); Label COMPARE_WIDE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL; int pcmpmask = 0x19; // Setup to compare 8-char (16-byte) vectors, @@ -8179,7 +8174,6 @@ void MacroAssembler::has_negatives(Register ary1, Register len, // Fallthru to tail compare } else if (UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be for SSE4.2 intrinsics to be available"); // With SSE4.2, use double quad vector compare Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; @@ -8383,7 +8377,6 @@ void MacroAssembler::arrays_equals(bool is_array_equ, Register ary1, Register ar movl(limit, result); // Fallthru to tail compare } else if (UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); // With SSE4.2, use double quad vector compare Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; @@ -8747,7 +8740,6 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, negptr(len); if (UseSSE42Intrinsics || UseAVX >= 2) { - assert(UseSSE42Intrinsics ? UseSSE >= 4 : true, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); Label L_chars_8_check, L_copy_8_chars, L_copy_8_chars_exit; Label L_chars_16_check, L_copy_16_chars, L_copy_16_chars_exit; @@ -10881,7 +10873,6 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le clear_vector_masking(); // closing of the stub context for programming mask registers } if (UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); Label copy_32_loop, copy_16, copy_tail; bind(below_threshold); @@ -11045,7 +11036,6 @@ void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len clear_vector_masking(); // closing of the stub context for programming mask registers } if (UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); Label copy_16_loop, copy_8_loop, copy_bytes, copy_new_tail, copy_tail; movl(tmp2, len); diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad index ce14f4c742e..17abe70af79 100644 --- a/hotspot/src/cpu/x86/vm/x86.ad +++ b/hotspot/src/cpu/x86/vm/x86.ad @@ -1718,7 +1718,7 @@ const bool Matcher::match_rule_supported(int opcode) { ret_value = false; break; case Op_StrIndexOfChar: - if (!(UseSSE > 4)) + if (!UseSSE42Intrinsics) ret_value = false; break; case Op_OnSpinWait: From 35f9db149b800cce3769e91f2986d6866dfc2085 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 2 Jun 2016 08:46:52 +0200 Subject: [PATCH 019/191] 8156760: VM crashes if -XX:-ReduceInitialCardMarks is set Fixed several compiler crashes with disabled ReduceInitialCardMarks. Reviewed-by: roland, minqi, dlong, tschatzl, kvn --- .../share/vm/gc/g1/g1CollectedHeap.inline.hpp | 2 +- .../src/share/vm/gc/shared/collectedHeap.cpp | 2 +- hotspot/src/share/vm/opto/arraycopynode.cpp | 22 +++-- hotspot/src/share/vm/opto/arraycopynode.hpp | 6 +- hotspot/src/share/vm/opto/graphKit.cpp | 11 ++- hotspot/src/share/vm/opto/macro.cpp | 88 +++++++++++-------- hotspot/src/share/vm/opto/memnode.cpp | 6 +- .../TestEliminatedArrayCopyDeopt.java | 6 +- .../TestInstanceCloneAsLoadsStores.java | 6 +- 9 files changed, 91 insertions(+), 58 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp index 05b24e0bf52..3a66fad03a5 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp @@ -109,7 +109,7 @@ inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) { _old_set.remove(hr); } -// It dirties the cards that cover the block so that so that the post +// It dirties the cards that cover the block so that the post // write barrier never queues anything when updating objects on this // block. It is assumed (and in fact we assert) that the block // belongs to a young region. diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp index e40326066fe..1ad500c890a 100644 --- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp @@ -386,7 +386,7 @@ size_t CollectedHeap::max_tlab_size() const { // initialized by this point, a fact that we assert when doing the // card-mark.) // (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a -// G1 concurrent marking is in progress an SATB (pre-write-)barrier is +// G1 concurrent marking is in progress an SATB (pre-write-)barrier // is used to remember the pre-value of any store. Initializing // stores will not need this barrier, so we need not worry about // compensating for the missing pre-barrier here. Turning now diff --git a/hotspot/src/share/vm/opto/arraycopynode.cpp b/hotspot/src/share/vm/opto/arraycopynode.cpp index c86bbc02ab4..08334b22597 100644 --- a/hotspot/src/share/vm/opto/arraycopynode.cpp +++ b/hotspot/src/share/vm/opto/arraycopynode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -204,7 +204,8 @@ Node* ArrayCopyNode::try_clone_instance(PhaseGVN *phase, bool can_reshape, int c } if (!finish_transform(phase, can_reshape, ctl, mem)) { - return NULL; + // Return NodeSentinel to indicate that the transform failed + return NodeSentinel; } return mem; @@ -222,6 +223,7 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape, Node* dest = in(ArrayCopyNode::Dest); const Type* src_type = phase->type(src); const TypeAryPtr* ary_src = src_type->isa_aryptr(); + assert(ary_src != NULL, "should be an array copy/clone"); if (is_arraycopy() || is_copyofrange() || is_copyof()) { const Type* dest_type = phase->type(dest); @@ -520,7 +522,7 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* mem = try_clone_instance(phase, can_reshape, count); if (mem != NULL) { - return mem; + return (mem == NodeSentinel) ? NULL : mem; } Node* adr_src = NULL; @@ -627,31 +629,37 @@ bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) { return CallNode::may_modify_arraycopy_helper(dest_t, t_oop, phase); } -bool ArrayCopyNode::may_modify_helper(const TypeOopPtr *t_oop, Node* n, PhaseTransform *phase) { +bool ArrayCopyNode::may_modify_helper(const TypeOopPtr *t_oop, Node* n, PhaseTransform *phase, ArrayCopyNode*& ac) { if (n->is_Proj()) { n = n->in(0); if (n->is_Call() && n->as_Call()->may_modify(t_oop, phase)) { + if (n->isa_ArrayCopy() != NULL) { + ac = n->as_ArrayCopy(); + } return true; } } return false; } -bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTransform *phase) { +bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTransform *phase, ArrayCopyNode*& ac) { Node* mem = mb->in(TypeFunc::Memory); if (mem->is_MergeMem()) { Node* n = mem->as_MergeMem()->memory_at(Compile::AliasIdxRaw); - if (may_modify_helper(t_oop, n, phase)) { + if (may_modify_helper(t_oop, n, phase, ac)) { return true; } else if (n->is_Phi()) { for (uint i = 1; i < n->req(); i++) { if (n->in(i) != NULL) { - if (may_modify_helper(t_oop, n->in(i), phase)) { + if (may_modify_helper(t_oop, n->in(i), phase, ac)) { return true; } } } + } else if (n->Opcode() == Op_StoreCM) { + // Ignore card mark stores + return may_modify_helper(t_oop, n->in(MemNode::Memory), phase, ac); } } diff --git a/hotspot/src/share/vm/opto/arraycopynode.hpp b/hotspot/src/share/vm/opto/arraycopynode.hpp index e17ea1f57a6..c0f635eb284 100644 --- a/hotspot/src/share/vm/opto/arraycopynode.hpp +++ b/hotspot/src/share/vm/opto/arraycopynode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -107,7 +107,7 @@ private: BasicType copy_type, const Type* value_type, int count); bool finish_transform(PhaseGVN *phase, bool can_reshape, Node* ctl, Node *mem); - static bool may_modify_helper(const TypeOopPtr *t_oop, Node* n, PhaseTransform *phase); + static bool may_modify_helper(const TypeOopPtr *t_oop, Node* n, PhaseTransform *phase, ArrayCopyNode*& ac); public: @@ -162,7 +162,7 @@ public: bool is_alloc_tightly_coupled() const { return _alloc_tightly_coupled; } - static bool may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTransform *phase); + static bool may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTransform *phase, ArrayCopyNode*& ac); bool modifies(intptr_t offset_lo, intptr_t offset_hi, PhaseTransform* phase, bool must_modify); #ifndef PRODUCT diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index 3a7d21ac897..acb4174bcf1 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -4306,8 +4306,15 @@ void GraphKit::g1_write_barrier_post(Node* oop_store, } __ end_if(); } __ end_if(); } else { - // Object.clone() instrinsic uses this path. - g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); + // The Object.clone() intrinsic uses this path if !ReduceInitialCardMarks. + // We don't need a barrier here if the destination is a newly allocated object + // in Eden. Otherwise, GC verification breaks because we assume that cards in Eden + // are set to 'g1_young_gen' (see G1SATBCardTableModRefBS::verify_g1_young_region()). + assert(!use_ReduceInitialCardMarks(), "can only happen with card marking"); + Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw); + __ if_then(card_val, BoolTest::ne, young_card); { + g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); + } __ end_if(); } // Final sync IdealKit and GraphKit. diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp index 106257aae5b..993f60f7234 100644 --- a/hotspot/src/share/vm/opto/macro.cpp +++ b/hotspot/src/share/vm/opto/macro.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -32,6 +32,7 @@ #include "opto/cfgnode.hpp" #include "opto/compile.hpp" #include "opto/convertnode.hpp" +#include "opto/graphKit.hpp" #include "opto/locknode.hpp" #include "opto/loopnode.hpp" #include "opto/macro.hpp" @@ -263,41 +264,58 @@ void PhaseMacroExpand::eliminate_card_mark(Node* p2x) { // checks if the store done to a different from the value's region. // And replace Cmp with #0 (false) to collapse G1 post barrier. Node* xorx = p2x->find_out_with(Op_XorX); - assert(xorx != NULL, "missing G1 post barrier"); - Node* shift = xorx->unique_out(); - Node* cmpx = shift->unique_out(); - assert(cmpx->is_Cmp() && cmpx->unique_out()->is_Bool() && - cmpx->unique_out()->as_Bool()->_test._test == BoolTest::ne, - "missing region check in G1 post barrier"); - _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ)); + if (xorx != NULL) { + Node* shift = xorx->unique_out(); + Node* cmpx = shift->unique_out(); + assert(cmpx->is_Cmp() && cmpx->unique_out()->is_Bool() && + cmpx->unique_out()->as_Bool()->_test._test == BoolTest::ne, + "missing region check in G1 post barrier"); + _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ)); - // Remove G1 pre barrier. + // Remove G1 pre barrier. - // Search "if (marking != 0)" check and set it to "false". - // There is no G1 pre barrier if previous stored value is NULL - // (for example, after initialization). - if (this_region->is_Region() && this_region->req() == 3) { - int ind = 1; - if (!this_region->in(ind)->is_IfFalse()) { - ind = 2; - } - if (this_region->in(ind)->is_IfFalse()) { - Node* bol = this_region->in(ind)->in(0)->in(1); - assert(bol->is_Bool(), ""); - cmpx = bol->in(1); - if (bol->as_Bool()->_test._test == BoolTest::ne && - cmpx->is_Cmp() && cmpx->in(2) == intcon(0) && - cmpx->in(1)->is_Load()) { - Node* adr = cmpx->in(1)->as_Load()->in(MemNode::Address); - const int marking_offset = in_bytes(JavaThread::satb_mark_queue_offset() + - SATBMarkQueue::byte_offset_of_active()); - if (adr->is_AddP() && adr->in(AddPNode::Base) == top() && - adr->in(AddPNode::Address)->Opcode() == Op_ThreadLocal && - adr->in(AddPNode::Offset) == MakeConX(marking_offset)) { - _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ)); + // Search "if (marking != 0)" check and set it to "false". + // There is no G1 pre barrier if previous stored value is NULL + // (for example, after initialization). + if (this_region->is_Region() && this_region->req() == 3) { + int ind = 1; + if (!this_region->in(ind)->is_IfFalse()) { + ind = 2; + } + if (this_region->in(ind)->is_IfFalse()) { + Node* bol = this_region->in(ind)->in(0)->in(1); + assert(bol->is_Bool(), ""); + cmpx = bol->in(1); + if (bol->as_Bool()->_test._test == BoolTest::ne && + cmpx->is_Cmp() && cmpx->in(2) == intcon(0) && + cmpx->in(1)->is_Load()) { + Node* adr = cmpx->in(1)->as_Load()->in(MemNode::Address); + const int marking_offset = in_bytes(JavaThread::satb_mark_queue_offset() + + SATBMarkQueue::byte_offset_of_active()); + if (adr->is_AddP() && adr->in(AddPNode::Base) == top() && + adr->in(AddPNode::Address)->Opcode() == Op_ThreadLocal && + adr->in(AddPNode::Offset) == MakeConX(marking_offset)) { + _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ)); + } } } } + } else { + assert(!GraphKit::use_ReduceInitialCardMarks(), "can only happen with card marking"); + // This is a G1 post barrier emitted by the Object.clone() intrinsic. + // Search for the CastP2X->URShiftX->AddP->LoadB->Cmp path which checks if the card + // is marked as young_gen and replace the Cmp with 0 (false) to collapse the barrier. + Node* shift = p2x->find_out_with(Op_URShiftX); + assert(shift != NULL, "missing G1 post barrier"); + Node* addp = shift->unique_out(); + Node* load = addp->find_out_with(Op_LoadB); + assert(load != NULL, "missing G1 post barrier"); + Node* cmpx = load->unique_out(); + assert(cmpx->is_Cmp() && cmpx->unique_out()->is_Bool() && + cmpx->unique_out()->as_Bool()->_test._test == BoolTest::ne, + "missing card value check in G1 post barrier"); + _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ)); + // There is no G1 pre barrier in this case } // Now CastP2X can be removed since it is used only on dead path // which currently still alive until igvn optimize it. @@ -326,17 +344,15 @@ static Node *scan_mem_chain(Node *mem, int alias_idx, int offset, Node *start_me CallNode *call = in->as_Call(); if (call->may_modify(tinst, phase)) { assert(call->is_ArrayCopy(), "ArrayCopy is the only call node that doesn't make allocation escape"); - if (call->as_ArrayCopy()->modifies(offset, offset, phase, false)) { return in; } } mem = in->in(TypeFunc::Memory); } else if (in->is_MemBar()) { - if (ArrayCopyNode::may_modify(tinst, in->as_MemBar(), phase)) { - assert(in->in(0)->is_Proj() && in->in(0)->in(0)->is_ArrayCopy(), "should be arraycopy"); - ArrayCopyNode* ac = in->in(0)->in(0)->as_ArrayCopy(); - assert(ac->is_clonebasic(), "Only basic clone is a non escaping clone"); + ArrayCopyNode* ac = NULL; + if (ArrayCopyNode::may_modify(tinst, in->as_MemBar(), phase, ac)) { + assert(ac != NULL && ac->is_clonebasic(), "Only basic clone is a non escaping clone"); return ac; } mem = in->in(TypeFunc::Memory); diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp index d4a4e3ab9e4..f0d588a6d1a 100644 --- a/hotspot/src/share/vm/opto/memnode.cpp +++ b/hotspot/src/share/vm/opto/memnode.cpp @@ -160,7 +160,8 @@ Node *MemNode::optimize_simple_memory_chain(Node *mchain, const TypeOopPtr *t_oo } } } else if (proj_in->is_MemBar()) { - if (ArrayCopyNode::may_modify(t_oop, proj_in->as_MemBar(), phase)) { + ArrayCopyNode* ac = NULL; + if (ArrayCopyNode::may_modify(t_oop, proj_in->as_MemBar(), phase, ac)) { break; } result = proj_in->in(TypeFunc::Memory); @@ -657,7 +658,8 @@ Node* MemNode::find_previous_store(PhaseTransform* phase) { continue; // (a) advance through independent call memory } } else if (mem->is_Proj() && mem->in(0)->is_MemBar()) { - if (ArrayCopyNode::may_modify(addr_t, mem->in(0)->as_MemBar(), phase)) { + ArrayCopyNode* ac = NULL; + if (ArrayCopyNode::may_modify(addr_t, mem->in(0)->as_MemBar(), phase, ac)) { break; } mem = mem->in(0)->in(TypeFunc::Memory); diff --git a/hotspot/test/compiler/arraycopy/TestEliminatedArrayCopyDeopt.java b/hotspot/test/compiler/arraycopy/TestEliminatedArrayCopyDeopt.java index 00e8fed9901..fb98c652c71 100644 --- a/hotspot/test/compiler/arraycopy/TestEliminatedArrayCopyDeopt.java +++ b/hotspot/test/compiler/arraycopy/TestEliminatedArrayCopyDeopt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -23,10 +23,10 @@ /* * @test - * @bug 8130847 + * @bug 8130847 8156760 * @summary Eliminated instance/array written to by an array copy variant must be correctly initialized when reallocated at a deopt * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestEliminatedArrayCopyDeopt - * + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+IgnoreUnrecognizedVMOptions -XX:-ReduceInitialCardMarks TestEliminatedArrayCopyDeopt */ // Test that if an ArrayCopy node is eliminated because it doesn't diff --git a/hotspot/test/compiler/arraycopy/TestInstanceCloneAsLoadsStores.java b/hotspot/test/compiler/arraycopy/TestInstanceCloneAsLoadsStores.java index 8e95036f550..640c6862762 100644 --- a/hotspot/test/compiler/arraycopy/TestInstanceCloneAsLoadsStores.java +++ b/hotspot/test/compiler/arraycopy/TestInstanceCloneAsLoadsStores.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -23,12 +23,12 @@ /* * @test - * @bug 6700100 + * @bug 6700100 8156760 * @summary small instance clone as loads/stores * @compile TestInstanceCloneAsLoadsStores.java TestInstanceCloneUtils.java * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestInstanceCloneAsLoadsStores::m* TestInstanceCloneAsLoadsStores * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestInstanceCloneAsLoadsStores::m* -XX:+IgnoreUnrecognizedVMOptions -XX:+StressArrayCopyMacroNode TestInstanceCloneAsLoadsStores - * + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestInstanceCloneAsLoadsStores::m* -XX:+IgnoreUnrecognizedVMOptions -XX:-ReduceInitialCardMarks TestInstanceCloneAsLoadsStores */ public class TestInstanceCloneAsLoadsStores extends TestInstanceCloneUtils { From f92cc0c83645be1580a5d3400931ab4d30d25a0a Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 2 Jun 2016 13:19:05 +0200 Subject: [PATCH 020/191] 8158214: Crash with "assert(VM_Version::supports_sse4_1()) failed" if UseSSE < 4 is set Do not emit unsupported SSE 4.1 instructions in CRC32 intrinsic. Reviewed-by: kvn, zmajo --- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 8 +++- hotspot/src/cpu/x86/vm/vm_version_x86.cpp | 6 +-- .../compiler/cpuflags/TestSSE4Disabled.java | 37 +++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 hotspot/test/compiler/cpuflags/TestSSE4Disabled.java diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index f9b42ec3ea1..9b52535459a 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -10151,7 +10151,13 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, Regi movdqa(xmm1, Address(buf, 0)); movdl(rax, xmm1); xorl(crc, rax); - pinsrd(xmm1, crc, 0); + if (VM_Version::supports_sse4_1()) { + pinsrd(xmm1, crc, 0); + } else { + pinsrw(xmm1, crc, 0); + shrl(crc, 16); + pinsrw(xmm1, crc, 1); + } addptr(buf, 16); subl(len, 4); // len > 0 jcc(Assembler::less, L_fold_tail); diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp index 65acaffe4cf..ef78e640fd8 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp @@ -658,7 +658,7 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseAESCTRIntrinsics, false); } } else { - if(supports_sse4_1() && UseSSE >= 4) { + if(supports_sse4_1()) { if (FLAG_IS_DEFAULT(UseAESCTRIntrinsics)) { FLAG_SET_DEFAULT(UseAESCTRIntrinsics, true); } @@ -970,7 +970,7 @@ void VM_Version::get_processor_features() { UseXmmI2D = false; } } - if (supports_sse4_2() && UseSSE >= 4) { + if (supports_sse4_2()) { if (FLAG_IS_DEFAULT(UseSSE42Intrinsics)) { FLAG_SET_DEFAULT(UseSSE42Intrinsics, true); } @@ -1050,7 +1050,7 @@ void VM_Version::get_processor_features() { UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus } } - if (supports_sse4_2() && UseSSE >= 4) { + if (supports_sse4_2()) { if (FLAG_IS_DEFAULT(UseSSE42Intrinsics)) { FLAG_SET_DEFAULT(UseSSE42Intrinsics, true); } diff --git a/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java b/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java new file mode 100644 index 00000000000..4bd655f6cac --- /dev/null +++ b/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016, 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 TestSSE4Disabled + * @bug 8158214 + * @requires (os.simpleArch == "x64") + * @summary Test correct execution without SSE 4. + * @run main/othervm -Xcomp -XX:UseSSE=3 TestSSE4Disabled + */ +public class TestSSE4Disabled { + public static void main(String args[]) { + System.out.println("Passed"); + } +} + From 2e85bb45ff98e01846da8434010a32ff65c421ba Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Thu, 2 Jun 2016 21:12:46 +0800 Subject: [PATCH 021/191] 8149418: AArch64: replace tst+br with tbz instruction when tst's constant operand is 2 power Replace tst+br with tbz instruction when tst's constant operand is 2 power Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp | 3 +-- hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp | 13 +++++-------- .../vm/templateInterpreterGenerator_aarch64.cpp | 6 ++---- .../src/cpu/aarch64/vm/templateTable_aarch64.cpp | 3 +-- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp index b1df18ade63..7752e7bfee3 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp @@ -944,8 +944,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Register t = r5; __ load_klass(t, r0); __ ldrw(t, Address(t, Klass::access_flags_offset())); - __ tst(t, JVM_ACC_HAS_FINALIZER); - __ br(Assembler::NE, register_finalizer); + __ tbnz(t, exact_log2(JVM_ACC_HAS_FINALIZER), register_finalizer); __ ret(lr); __ bind(register_finalizer); diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp index 22712102137..bc8699e4a6b 100644 --- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp @@ -93,10 +93,8 @@ void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) // This method is only called just after the call into the vm in // call_VM_base, so the arg registers are available. ldrw(rscratch1, Address(rthread, JavaThread::popframe_condition_offset())); - tstw(rscratch1, JavaThread::popframe_pending_bit); - br(Assembler::EQ, L); - tstw(rscratch1, JavaThread::popframe_processing_bit); - br(Assembler::NE, L); + tbz(rscratch1, exact_log2(JavaThread::popframe_pending_bit), L); + tbnz(rscratch1, exact_log2(JavaThread::popframe_processing_bit), L); // Call Interpreter::remove_activation_preserving_args_entry() to get the // address of the same-named entrypoint in the generated interpreter code. call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry)); @@ -505,8 +503,7 @@ void InterpreterMacroAssembler::remove_activation( // get method access flags ldr(r1, Address(rfp, frame::interpreter_frame_method_offset * wordSize)); ldr(r2, Address(r1, Method::access_flags_offset())); - tst(r2, JVM_ACC_SYNCHRONIZED); - br(Assembler::EQ, unlocked); + tbz(r2, exact_log2(JVM_ACC_SYNCHRONIZED), unlocked); // Don't unlock anything if the _do_not_unlock_if_synchronized flag // is set. @@ -1582,8 +1579,8 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& md // do. The unknown bit may have been // set already but no need to check. - tst(obj, TypeEntries::type_unknown); - br(Assembler::NE, next); // already unknown. Nothing to do anymore. + tbnz(obj, exact_log2(TypeEntries::type_unknown), next); + // already unknown. Nothing to do anymore. ldr(rscratch1, mdo_addr); cbz(rscratch1, none); diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp index e78276ed8a7..f24536daf75 100644 --- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp @@ -1242,8 +1242,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { { Label L; __ ldrw(t, Address(rmethod, Method::access_flags_offset())); - __ tst(t, JVM_ACC_STATIC); - __ br(Assembler::EQ, L); + __ tbz(t, exact_log2(JVM_ACC_STATIC), L); // get mirror __ load_mirror(t, rmethod); // copy mirror into activation frame @@ -1435,8 +1434,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { { Label L; __ ldrw(t, Address(rmethod, Method::access_flags_offset())); - __ tst(t, JVM_ACC_SYNCHRONIZED); - __ br(Assembler::EQ, L); + __ tbz(t, exact_log2(JVM_ACC_SYNCHRONIZED), L); // the code below should be shared with interpreter macro // assembler implementation { diff --git a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp index 5c1a98463bf..68827fc2378 100644 --- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp @@ -2190,9 +2190,8 @@ void TemplateTable::_return(TosState state) __ ldr(c_rarg1, aaddress(0)); __ load_klass(r3, c_rarg1); __ ldrw(r3, Address(r3, Klass::access_flags_offset())); - __ tst(r3, JVM_ACC_HAS_FINALIZER); Label skip_register_finalizer; - __ br(Assembler::EQ, skip_register_finalizer); + __ tbz(r3, exact_log2(JVM_ACC_HAS_FINALIZER), skip_register_finalizer); __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); From fce865ff45ed37769decf1cf1ff60d2939e84397 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 2 Jun 2016 17:52:42 +0000 Subject: [PATCH 022/191] 8158000: [JVMCI] remove unused ParseClosure class Reviewed-by: kvn --- hotspot/src/share/vm/jvmci/jvmciRuntime.hpp | 25 --------------------- 1 file changed, 25 deletions(-) diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp index ebd5d3c72b6..bf7b59e1566 100644 --- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp +++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp @@ -40,31 +40,6 @@ #define JVMCI_ERROR_OK(...) JVMCI_ERROR_(JVMCIEnv::ok, __VA_ARGS__) #define CHECK_OK CHECK_(JVMCIEnv::ok) -class ParseClosure : public StackObj { - int _lineNo; - char* _filename; - bool _abort; -protected: - void abort() { _abort = true; } - void warn_and_abort(const char* message) { - warn(message); - abort(); - } - void warn(const char* message) { - warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message); - } - public: - ParseClosure() : _lineNo(0), _filename(NULL), _abort(false) {} - void parse_line(char* line) { - _lineNo++; - do_line(line); - } - virtual void do_line(char* line) = 0; - int lineNo() { return _lineNo; } - bool is_aborted() { return _abort; } - void set_filename(char* path) {_filename = path; _lineNo = 0;} -}; - class JVMCIRuntime: public AllStatic { public: // Constants describing whether JVMCI wants to be able to adjust the compilation From c82212e143e93dd52300776a869793243a21d4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Mon, 6 Jun 2016 20:48:56 +0200 Subject: [PATCH 023/191] 8149803: Adjust lock rankings for some Event-based tracing locks Reviewed-by: dholmes, acorn --- hotspot/src/share/vm/runtime/mutexLocker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/mutexLocker.cpp b/hotspot/src/share/vm/runtime/mutexLocker.cpp index 219194a4b21..a01b4888500 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.cpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp @@ -274,7 +274,7 @@ void mutex_init() { def(JfrMsg_lock , Monitor, leaf, true, Monitor::_safepoint_check_always); def(JfrBuffer_lock , Mutex, leaf, true, Monitor::_safepoint_check_never); def(JfrThreadGroups_lock , Mutex, leaf, true, Monitor::_safepoint_check_always); - def(JfrStream_lock , Mutex, nonleaf, true, Monitor::_safepoint_check_never); + def(JfrStream_lock , Mutex, leaf+1, true, Monitor::_safepoint_check_never); // ensure to rank lower than 'safepoint' def(JfrStacktrace_lock , Mutex, special, true, Monitor::_safepoint_check_sometimes); #endif From 2137769825992a15cc0a5896220aadd0f620bd15 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 6 Jun 2016 22:34:57 +0300 Subject: [PATCH 024/191] 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size Reviewed-by: coleenp, sspitsyn, sla --- hotspot/src/share/vm/prims/jvmtiEnv.cpp | 10 +--- .../jvmti/GetObjectSizeClass.java | 55 +++++++++++++++++++ .../jvmti/GetObjectSizeClassAgent.java | 51 +++++++++++++++++ 3 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 hotspot/test/serviceability/jvmti/GetObjectSizeClass.java create mode 100644 hotspot/test/serviceability/jvmti/GetObjectSizeClassAgent.java diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index d6f60a28f77..082d531daf1 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -319,15 +319,7 @@ jvmtiError JvmtiEnv::GetObjectSize(jobject object, jlong* size_ptr) { oop mirror = JNIHandles::resolve_external_guard(object); NULL_CHECK(mirror, JVMTI_ERROR_INVALID_OBJECT); - - if (mirror->klass() == SystemDictionary::Class_klass() && - !java_lang_Class::is_primitive(mirror)) { - Klass* k = java_lang_Class::as_Klass(mirror); - assert(k != NULL, "class for non-primitive mirror must exist"); - *size_ptr = (jlong)k->size() * wordSize; - } else { - *size_ptr = (jlong)mirror->size() * wordSize; - } + *size_ptr = (jlong)mirror->size() * wordSize; return JVMTI_ERROR_NONE; } /* end GetObjectSize */ diff --git a/hotspot/test/serviceability/jvmti/GetObjectSizeClass.java b/hotspot/test/serviceability/jvmti/GetObjectSizeClass.java new file mode 100644 index 00000000000..cec03f32947 --- /dev/null +++ b/hotspot/test/serviceability/jvmti/GetObjectSizeClass.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 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. + */ +import java.io.PrintWriter; +import jdk.test.lib.*; + +/* + * @test + * @bug 8075030 + * @summary JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * java.compiler + * java.instrument + * java.management + * jdk.jvmstat/sun.jvmstat.monitor + * @build ClassFileInstaller jdk.test.lib.* GetObjectSizeClassAgent + * @run main ClassFileInstaller GetObjectSizeClassAgent + * @run main GetObjectSizeClass + */ +public class GetObjectSizeClass { + public static void main(String[] args) throws Exception { + PrintWriter pw = new PrintWriter("MANIFEST.MF"); + pw.println("Premain-Class: GetObjectSizeClassAgent"); + pw.close(); + + ProcessBuilder pb = new ProcessBuilder(); + pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeClassAgent.class"}); + pb.start().waitFor(); + + ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-javaagent:agent.jar", "GetObjectSizeClassAgent"); + OutputAnalyzer output = new OutputAnalyzer(pt.start()); + + output.stdoutShouldContain("GetObjectSizeClass passed"); + } +} diff --git a/hotspot/test/serviceability/jvmti/GetObjectSizeClassAgent.java b/hotspot/test/serviceability/jvmti/GetObjectSizeClassAgent.java new file mode 100644 index 00000000000..0b5cac4f07d --- /dev/null +++ b/hotspot/test/serviceability/jvmti/GetObjectSizeClassAgent.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016, 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. + */ +import java.lang.instrument.*; + +public class GetObjectSizeClassAgent { + + static Instrumentation instrumentation; + + public static void premain(String agentArgs, Instrumentation instrumentation) { + GetObjectSizeClassAgent.instrumentation = instrumentation; + } + + public static void main(String[] args) throws Exception { + long sizeA = instrumentation.getObjectSize(A.class); + long sizeB = instrumentation.getObjectSize(B.class); + + if (sizeA != sizeB) { + throw new RuntimeException("java.lang.Class sizes disagree: " + sizeA + " vs. " + sizeB); + } + + System.out.println("GetObjectSizeClass passed"); + } + + static class A { + } + + static class B { + void m() {} + } + +} From 66e3ba7296cfe4dd26f69873cff8df7efd2e3c46 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Mon, 6 Jun 2016 12:51:53 -0700 Subject: [PATCH 025/191] 8153876: Replace 4K stack allocations with Resource allocations Reviewed-by: dholmes, hseigel --- .../src/share/vm/classfile/classLoader.cpp | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 12858cccf28..acc65eb9a8a 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -228,8 +228,9 @@ ClassPathDirEntry::ClassPathDirEntry(const char* dir) : ClassPathEntry() { ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) { // construct full path name - char path[JVM_MAXPATHLEN]; - if (jio_snprintf(path, sizeof(path), "%s%s%s", _dir, os::file_separator(), name) == -1) { + char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); + if (jio_snprintf(path, JVM_MAXPATHLEN, "%s%s%s", _dir, os::file_separator(), name) == -1) { + FREE_RESOURCE_ARRAY(char, path, JVM_MAXPATHLEN); return NULL; } // check if file exists @@ -256,6 +257,7 @@ ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) { if (UsePerfData) { ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read); } + FREE_RESOURCE_ARRAY(char, path, JVM_MAXPATHLEN); // Resource allocated return new ClassFileStream(buffer, st.st_size, @@ -264,6 +266,7 @@ ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) { } } } + FREE_RESOURCE_ARRAY(char, path, JVM_MAXPATHLEN); return NULL; } @@ -344,9 +347,10 @@ u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TR if (is_multi_ver) { int n; - char entry_name[JVM_MAXPATHLEN]; + ResourceMark rm(THREAD); + char* entry_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); if (version > 0) { - n = jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", version, name); + n = jio_snprintf(entry_name, JVM_MAXPATHLEN, "META-INF/versions/%d/%s", version, name); entry_name[n] = '\0'; buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL); if (buffer == NULL) { @@ -355,7 +359,7 @@ u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TR } if (buffer == NULL) { for (int i = cur_ver; i >= base_version; i--) { - n = jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", i, name); + n = jio_snprintf(entry_name, JVM_MAXPATHLEN, "META-INF/versions/%d/%s", i, name); entry_name[n] = '\0'; buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL); if (buffer != NULL) { @@ -508,7 +512,8 @@ bool ctw_visitor(JImageFile* jimage, const char* name, const char* extension, void* arg) { if (strcmp(extension, "class") == 0) { Thread* THREAD = Thread::current(); - char path[JIMAGE_MAX_PATH]; + ResourceMark rm(THREAD); + char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JIMAGE_MAX_PATH); jio_snprintf(path, JIMAGE_MAX_PATH - 1, "%s/%s.class", package, name); ClassLoader::compile_the_world_in(path, *(Handle*)arg, THREAD); return !HAS_PENDING_EXCEPTION; @@ -750,9 +755,10 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str JavaThread* thread = JavaThread::current(); ClassPathEntry* new_entry = NULL; if ((st->st_mode & S_IFREG) == S_IFREG) { + ResourceMark rm(thread); // Regular file, should be a zip or jimage file // Canonicalized filename - char canonical_path[JVM_MAXPATHLEN]; + char* canonical_path = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, JVM_MAXPATHLEN); if (!get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) { // This matches the classic VM if (throw_exception) { @@ -777,14 +783,13 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str if (zip != NULL && error_msg == NULL) { new_entry = new ClassPathZipEntry(zip, path, is_boot_append); } else { - ResourceMark rm(thread); char *msg; if (error_msg == NULL) { - msg = NEW_RESOURCE_ARRAY(char, strlen(path) + 128); ; + msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, strlen(path) + 128); ; jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path); } else { int len = (int)(strlen(path) + strlen(error_msg) + 128); - msg = NEW_RESOURCE_ARRAY(char, len); ; + msg = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, len); ; jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path); } // Don't complain about bad jar files added via -Xbootclasspath/a:. From 39e5b15fdd20d08b49f929bb44f361cb1b45d7ee Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Mon, 6 Jun 2016 16:31:03 -0700 Subject: [PATCH 026/191] 8156587: [JVMCI] remove Unsafe.getJavaMirror and Unsafe.getKlassPointer Reviewed-by: kvn --- hotspot/src/share/vm/prims/unsafe.cpp | 15 ------ .../compilerToVM/GetConstantPoolTest.java | 11 ----- .../compilerToVM/GetResolvedJavaTypeTest.java | 14 +----- .../Unsafe/GetKlassPointerGetJavaMirror.java | 47 ------------------- 4 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 71116760c07..e129fbafc41 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -356,19 +356,6 @@ UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe, return JNIHandles::make_local(env, v); } UNSAFE_END -UNSAFE_ENTRY(jclass, Unsafe_GetJavaMirror(JNIEnv *env, jobject unsafe, jlong metaspace_klass)) { - Klass* klass = (Klass*) (address) metaspace_klass; - - return (jclass) JNIHandles::make_local(klass->java_mirror()); -} UNSAFE_END - -UNSAFE_ENTRY(jlong, Unsafe_GetKlassPointer(JNIEnv *env, jobject unsafe, jobject obj)) { - oop o = JNIHandles::resolve(obj); - jlong klass = (jlong) (address) o->klass(); - - return klass; -} UNSAFE_END - #ifndef SUPPORTS_NATIVE_CX8 // VM_Version::supports_cx8() is a surrogate for 'supports atomic long memory ops'. @@ -1152,8 +1139,6 @@ static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = { {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutObjectVolatile)}, {CC "getUncompressedObject", CC "(" ADR ")" OBJ, FN_PTR(Unsafe_GetUncompressedObject)}, - {CC "getJavaMirror", CC "(" ADR ")" CLS, FN_PTR(Unsafe_GetJavaMirror)}, - {CC "getKlassPointer", CC "(" OBJ ")" ADR, FN_PTR(Unsafe_GetKlassPointer)}, DECLARE_GETPUTOOP(Boolean, Z), DECLARE_GETPUTOOP(Byte, B), diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java index 28463d71e75..c9826c857e3 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java @@ -138,17 +138,6 @@ public class GetConstantPoolTest { return CompilerToVMHelper.getConstantPool(cpInst, ptr); } }, - OBJECT_TYPE_BASE { - @Override - ConstantPool getConstantPool() { - HotSpotResolvedObjectType type - = HotSpotResolvedObjectType.fromObjectClass( - OBJECT_TYPE_BASE.getClass()); - long ptrToClass = UNSAFE.getKlassPointer(OBJECT_TYPE_BASE); - return CompilerToVMHelper.getConstantPool(type, - getPtrToCpAddress() - ptrToClass); - } - }, ; abstract ConstantPool getConstantPool(); } diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java index 1dde0850aad..a648caaac67 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java @@ -24,6 +24,7 @@ /* * @test * @bug 8136421 + * @ignore 8158860 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches @@ -149,25 +150,12 @@ public class GetResolvedJavaTypeTest { ptr, COMPRESSED); } }, - OBJECT_TYPE_BASE { - @Override - HotSpotResolvedObjectType getResolvedJavaType() { - HotSpotResolvedObjectType type - = HotSpotResolvedObjectType.fromObjectClass( - OBJECT_TYPE_BASE.getClass()); - long ptrToClass = UNSAFE.getKlassPointer(OBJECT_TYPE_BASE); - return CompilerToVMHelper.getResolvedJavaType(type, - getPtrToKlass() - ptrToClass, COMPRESSED); - } - }, ; abstract HotSpotResolvedObjectType getResolvedJavaType(); } private static final Unsafe UNSAFE = Utils.getUnsafe(); private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final long PTR = UNSAFE.getKlassPointer( - new GetResolvedJavaTypeTest()); private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class; /* a compressed parameter for tested method is set to false because unsafe.getKlassPointer always returns uncompressed pointer */ diff --git a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java b/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java deleted file mode 100644 index 7a53be5e7e5..00000000000 --- a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2015, 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 8022853 - * @library /testlibrary - * @modules java.base/jdk.internal.misc - * @build jdk.test.lib.* - * @run main GetKlassPointerGetJavaMirror - */ - -import static jdk.test.lib.Asserts.*; - -import jdk.test.lib.*; -import jdk.internal.misc.Unsafe; - -public class GetKlassPointerGetJavaMirror { - - public static void main(String args[]) throws Exception { - Unsafe unsafe = Utils.getUnsafe(); - Object o = new GetKlassPointerGetJavaMirror(); - final long metaspaceKlass = unsafe.getKlassPointer(o); - Class c = unsafe.getJavaMirror(metaspaceKlass); - assertEquals(o.getClass(), c); - } - -} From 9ead05c2dc2fdeaf47d2e86d8cc2523ff5ec8ce7 Mon Sep 17 00:00:00 2001 From: Jamsheed Mohammed C M Date: Mon, 6 Jun 2016 23:24:46 -0700 Subject: [PATCH 027/191] 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized Handle realloc failure pending exception. Reviewed-by: roland --- .../src/share/vm/runtime/deoptimization.cpp | 13 +++ hotspot/src/share/vm/runtime/vframeArray.cpp | 13 ++- .../uncommontrap/DeoptReallocFailure.java | 91 +++++++++++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/compiler/uncommontrap/DeoptReallocFailure.java diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index f926b88eca8..aca59f7ef83 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -498,6 +498,19 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread } #endif + if (thread->frames_to_pop_failed_realloc() > 0 && exec_mode != Unpack_uncommon_trap) { + assert(thread->has_pending_exception(), "should have thrown OOME"); + thread->set_exception_oop(thread->pending_exception()); + thread->clear_pending_exception(); + exec_mode = Unpack_exception; + } + +#if INCLUDE_JVMCI + if (thread->frames_to_pop_failed_realloc() > 0) { + thread->set_pending_monitorenter(false); + } +#endif + UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord, caller_adjustment * BytesPerWord, caller_was_method_handle ? 0 : callee_parameters, diff --git a/hotspot/src/share/vm/runtime/vframeArray.cpp b/hotspot/src/share/vm/runtime/vframeArray.cpp index 483473244eb..abfb5afde82 100644 --- a/hotspot/src/share/vm/runtime/vframeArray.cpp +++ b/hotspot/src/share/vm/runtime/vframeArray.cpp @@ -171,6 +171,8 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters, int exec_mode) { JavaThread* thread = (JavaThread*) Thread::current(); + bool realloc_failure_exception = thread->frames_to_pop_failed_realloc() > 0; + // Look at bci and decide on bcp and continuation pc address bcp; // C++ interpreter doesn't need a pc since it will figure out what to do when it @@ -204,10 +206,12 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters, // // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter, // in which case bcp should point to the monitorenter since it is within the exception's range. + // + // For realloc failure exception we just pop frames, skip the guarantee. assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame"); assert(thread->deopt_compiled_method() != NULL, "compiled method should be known"); - guarantee(!(thread->deopt_compiled_method()->is_compiled_by_c2() && + guarantee(realloc_failure_exception || !(thread->deopt_compiled_method()->is_compiled_by_c2() && *bcp == Bytecodes::_monitorenter && exec_mode == Deoptimization::Unpack_exception), "shouldn't get exception during monitorenter"); @@ -237,12 +241,17 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters, // Deoptimization::fetch_unroll_info_helper popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words()); } - } else if (JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { + } else if (!realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { // Force early return from top frame after deoptimization #ifndef CC_INTERP pc = Interpreter::remove_activation_early_entry(state->earlyret_tos()); #endif } else { + if (realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { + state->clr_earlyret_pending(); + state->set_earlyret_oop(NULL); + state->clr_earlyret_value(); + } // Possibly override the previous pc computation of the top (youngest) frame switch (exec_mode) { case Deoptimization::Unpack_deopt: diff --git a/hotspot/test/compiler/uncommontrap/DeoptReallocFailure.java b/hotspot/test/compiler/uncommontrap/DeoptReallocFailure.java new file mode 100644 index 00000000000..1064527b9da --- /dev/null +++ b/hotspot/test/compiler/uncommontrap/DeoptReallocFailure.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016, 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 8146416 + * @library /test/lib /testlibrary / + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch -XX:CompileCommand=exclude,DeoptReallocFailure::main -Xmx100m DeoptReallocFailure + * + */ +import java.lang.reflect.Method; +import sun.hotspot.WhiteBox; + +class MemoryChunk { + MemoryChunk other; + Object[][] array; + + MemoryChunk(MemoryChunk other) { + this.other = other; + array = new Object[1024 * 256][]; + } +} + +class NoEscape { + long f1; +} + +public class DeoptReallocFailure { + + static MemoryChunk root; + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static synchronized long test() { + NoEscape[] noEscape = new NoEscape[45]; + noEscape[0] = new NoEscape(); + for (int i=0;i<1024*256;i++) { + root.array[i]= new Object[45]; + } + return noEscape[0].f1; + } + + public static void main(String[] args) throws Throwable { + + //Exhaust Memory + root = null; + try { + while (true) { + root = new MemoryChunk(root); + } + } catch (OutOfMemoryError oom) { + } + + if (root == null) { + return; + } + + try { + NoEscape dummy = new NoEscape(); + Method m = DeoptReallocFailure.class.getMethod("test"); + WB.enqueueMethodForCompilation(m, 4); + test(); + } catch (OutOfMemoryError oom) { + root = null; + oom.printStackTrace(); + } + System.out.println("TEST PASSED"); + } +} From f35b70764b31077f257b0ac2bccef40d1cdc497a Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Tue, 7 Jun 2016 12:55:29 +0300 Subject: [PATCH 028/191] 8154209: Remove client VM from default JIB profile on windows-x86 and linux-x86 Reviewed-by: dholmes --- hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java b/hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java index 050b0ff6f27..2fe4753bdbc 100644 --- a/hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java +++ b/hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java @@ -27,6 +27,7 @@ * @library /testlibrary * @modules java.base/jdk.internal.misc * java.management + * @ignore 8154204 * @run main DefaultUseWithClient * @bug 8032224 */ From e45caa8cbaa7888969d53d0213cf743dcc60c485 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 7 Jun 2016 18:20:44 +0200 Subject: [PATCH 029/191] 8158228: C1 incorrectly folds mismatched loads from stable arrays Disable constant folding for mismatched loads from stable arrays. Reviewed-by: vlivanov --- hotspot/src/share/vm/c1/c1_Canonicalizer.cpp | 6 +-- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 4 +- hotspot/src/share/vm/c1/c1_Instruction.hpp | 14 ++++-- .../compiler/stable/TestStableMismatched.java | 50 +++++++++++++++++++ 4 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 hotspot/test/compiler/stable/TestStableMismatched.java diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp index 7e65f3c235f..e3a7af67742 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -264,7 +264,7 @@ void Canonicalizer::do_LoadIndexed (LoadIndexed* x) { assert(array == NULL || FoldStableValues, "not enabled"); // Constant fold loads from stable arrays. - if (array != NULL && index != NULL) { + if (!x->mismatched() && array != NULL && index != NULL) { jint idx = index->value(); if (idx < 0 || idx >= array->value()->length()) { // Leave the load as is. The range check will handle it. @@ -310,8 +310,6 @@ void Canonicalizer::do_StoreIndexed (StoreIndexed* x) { return; } } - - } diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 69d475ac939..0c06df4751c 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -4227,11 +4227,11 @@ void GraphBuilder::append_char_access(ciMethod* callee, bool is_store) { Value index = args->at(1); if (is_store) { Value value = args->at(2); - Instruction* store = append(new StoreIndexed(array, index, NULL, T_CHAR, value, state_before, false)); + Instruction* store = append(new StoreIndexed(array, index, NULL, T_CHAR, value, state_before, false, true)); store->set_flag(Instruction::NeedsRangeCheckFlag, false); _memory->store_value(value); } else { - Instruction* load = append(new LoadIndexed(array, index, NULL, T_CHAR, state_before)); + Instruction* load = append(new LoadIndexed(array, index, NULL, T_CHAR, state_before, true)); load->set_flag(Instruction::NeedsRangeCheckFlag, false); push(load->type(), load); } diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp index 426507d301a..4b01069498c 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.hpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp @@ -912,14 +912,16 @@ BASE(AccessIndexed, AccessArray) Value _index; Value _length; BasicType _elt_type; + bool _mismatched; public: // creation - AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before) + AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched) : AccessArray(as_ValueType(elt_type), array, state_before) , _index(index) , _length(length) , _elt_type(elt_type) + , _mismatched(mismatched) { set_flag(Instruction::NeedsRangeCheckFlag, true); ASSERT_VALUES @@ -929,6 +931,7 @@ BASE(AccessIndexed, AccessArray) Value index() const { return _index; } Value length() const { return _length; } BasicType elt_type() const { return _elt_type; } + bool mismatched() const { return _mismatched; } void clear_length() { _length = NULL; } // perform elimination of range checks involving constants @@ -945,8 +948,8 @@ LEAF(LoadIndexed, AccessIndexed) public: // creation - LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before) - : AccessIndexed(array, index, length, elt_type, state_before) + LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false) + : AccessIndexed(array, index, length, elt_type, state_before, mismatched) , _explicit_null_check(NULL) {} // accessors @@ -974,8 +977,9 @@ LEAF(StoreIndexed, AccessIndexed) public: // creation - StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before, bool check_boolean) - : AccessIndexed(array, index, length, elt_type, state_before) + StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before, + bool check_boolean, bool mismatched = false) + : AccessIndexed(array, index, length, elt_type, state_before, mismatched) , _value(value), _profiled_method(NULL), _profiled_bci(0), _check_boolean(check_boolean) { set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object())); diff --git a/hotspot/test/compiler/stable/TestStableMismatched.java b/hotspot/test/compiler/stable/TestStableMismatched.java new file mode 100644 index 00000000000..a71ee78aa66 --- /dev/null +++ b/hotspot/test/compiler/stable/TestStableMismatched.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016, 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 TestStableMismatched + * @bug 8158228 + * @summary Tests if mismatched char load from stable byte[] returns correct result + * @run main/othervm -XX:-CompactStrings -XX:TieredStopAtLevel=1 -Xcomp + * -XX:CompileOnly=TestStableMismatched::test,::charAt + * TestStableMismatched + * @run main/othervm -XX:-CompactStrings -XX:-TieredCompilation -Xcomp + * -XX:CompileOnly=TestStableMismatched::test,::charAt + * TestStableMismatched + */ +public class TestStableMismatched { + public static void main(String args[]) { + test(); + } + + public static void test() { + String text = "abcdefg"; + // Mismatched char load from @Stable byte[] String.value field + char returned = text.charAt(6); + if (returned != 'g') { + throw new RuntimeException("failed: charAt(6) returned '" + returned + "' instead of 'g'"); + } + } +} + From dafa4695a0e34c461a2024a498627afe2652f3b8 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Tue, 7 Jun 2016 17:16:51 -0700 Subject: [PATCH 030/191] 8158985: [JVMCI] access to HotSpotJVMCIRuntime.vmEventListeners must be thread safe Reviewed-by: iveresov, kvn --- .../vm/ci/hotspot/HotSpotJVMCIRuntime.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java index 5cf038e0bf8..c8b12aefe32 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java @@ -31,10 +31,13 @@ import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ServiceLoader; import java.util.TreeMap; import jdk.internal.misc.VM; @@ -213,7 +216,22 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider { private final Map, JVMCIBackend> backends = new HashMap<>(); - private final Iterable vmEventListeners; + private volatile List vmEventListeners; + + private Iterable getVmEventListeners() { + if (vmEventListeners == null) { + synchronized (this) { + if (vmEventListeners == null) { + List listeners = new ArrayList<>(); + for (HotSpotVMEventListener vmEventListener : ServiceLoader.load(HotSpotVMEventListener.class)) { + listeners.add(vmEventListener); + } + vmEventListeners = listeners; + } + } + } + return vmEventListeners; + } /** * Stores the result of {@link HotSpotJVMCICompilerFactory#getTrivialPrefixes()} so that it can @@ -240,8 +258,6 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider { hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); } - vmEventListeners = Services.load(HotSpotVMEventListener.class); - metaAccessContext = new HotSpotJVMCIMetaAccessContext(); boolean printFlags = Option.PrintFlags.getBoolean(); @@ -370,7 +386,7 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider { */ @SuppressWarnings({"unused"}) private void shutdown() throws Exception { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) { vmEventListener.notifyShutdown(); } } @@ -382,7 +398,7 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider { */ @SuppressWarnings({"unused"}) private void bootstrapFinished() throws Exception { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) { vmEventListener.notifyBootstrapFinished(); } } @@ -395,7 +411,7 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider { * @param compiledCode */ void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + for (HotSpotVMEventListener vmEventListener : getVmEventListeners()) { vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode); } } From 067e915c50e30997297854914cd013f2458a0417 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Tue, 7 Jun 2016 10:17:28 +0000 Subject: [PATCH 031/191] 8158913: aarch64: SEGV running Spark terasort Use signed instead of unsigned test for end of loop in gen_write_ref_array_post_barrier Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index 075bf794650..b93e9b19bdd 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -710,7 +710,7 @@ class StubGenerator: public StubCodeGenerator { __ BIND(L_loop); __ strb(zr, Address(start, count)); __ subs(count, count, 1); - __ br(Assembler::HS, L_loop); + __ br(Assembler::GE, L_loop); } break; default: From 7bd006dd5a608ae891f199a1e7fb588a8bdb1b56 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Jun 2016 16:08:25 +0200 Subject: [PATCH 032/191] 8158929: [TESTBUG] CommitOverlappingRegions.java can not deal with pages > 32K Reviewed-by: mockner, dholmes --- .../runtime/NMT/CommitOverlappingRegions.java | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/hotspot/test/runtime/NMT/CommitOverlappingRegions.java b/hotspot/test/runtime/NMT/CommitOverlappingRegions.java index 212a9930fd3..773378ce7e8 100644 --- a/hotspot/test/runtime/NMT/CommitOverlappingRegions.java +++ b/hotspot/test/runtime/NMT/CommitOverlappingRegions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -41,7 +41,12 @@ public class CommitOverlappingRegions { public static WhiteBox wb = WhiteBox.getWhiteBox(); public static void main(String args[]) throws Exception { OutputAnalyzer output; + long size = 32 * 1024; + int pagesize = wb.getVMPageSize(); + if (size < pagesize) { size = pagesize; } // Should be aligned. + long sizek = size / 1024; + long addr = wb.NMTReserveMemory(8*size); String pid = Long.toString(ProcessTools.getProcessId()); @@ -52,93 +57,93 @@ public class CommitOverlappingRegions { // Start: . . . . . . . . output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=0KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=0KB)"); // Committing: * * * . . . . . // Region: * * * . . . . . - // Expected Total: 3 x 32KB = 96KB + // Expected Total: 3 x sizek KB wb.NMTCommitMemory(addr + 0*size, 3*size); // Committing: . . . . * * * . // Region: * * * . * * * . - // Expected Total: 6 x 32KB = 192KB + // Expected Total: 6 x sizek KB wb.NMTCommitMemory(addr + 4*size, 3*size); // Check output after first 2 commits. output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=192KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 6*sizek + "KB)"); // Committing: . . * * * . . . // Region: * * * * * * * . - // Expected Total: 7 x 32KB = 224KB + // Expected Total: 7 x sizek KB wb.NMTCommitMemory(addr + 2*size, 3*size); // Check output after overlapping commit. output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=224KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 7*sizek + "KB)"); // Uncommitting: * * * * * * * * // Region: . . . . . . . . - // Expected Total: 0 x 32KB = 0KB + // Expected Total: 0 x sizek KB wb.NMTUncommitMemory(addr + 0*size, 8*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=0KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=0KB)"); // Committing: * * . . . . . . // Region: * * . . . . . . - // Expected Total: 2 x 32KB = 64KB + // Expected Total: 2 x sizek KB wb.NMTCommitMemory(addr + 0*size, 2*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=64KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 2*sizek + "KB)"); // Committing: . * * * . . . . // Region: * * * * . . . . - // Expected Total: 4 x 32KB = 128KB + // Expected Total: 4 x sizek KB wb.NMTCommitMemory(addr + 1*size, 3*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=128KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 4*sizek + "KB)"); // Uncommitting: * * * . . . . . // Region: . . . * . . . . - // Expected Total: 1 x 32KB = 32KB + // Expected Total: 1 x sizek KB wb.NMTUncommitMemory(addr + 0*size, 3*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=32KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 1*sizek + "KB)"); // Committing: . . . * * . . . // Region: . . . * * . . . - // Expected Total: 2 x 32KB = 64KB + // Expected Total: 2 x sizek KB wb.NMTCommitMemory(addr + 3*size, 2*size); System.out.println("Address is " + Long.toHexString(addr + 3*size)); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=64KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 2*sizek + "KB)"); // Committing: . . . . * * . . // Region: . . . * * * . . - // Expected Total: 3 x 32KB = 96KB + // Expected Total: 3 x sizek KB wb.NMTCommitMemory(addr + 4*size, 2*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=96KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 3*sizek + "KB)"); // Committing: . . . . . * * . // Region: . . . * * * * . - // Expected Total: 4 x 32KB = 128KB + // Expected Total: 4 x sizek KB wb.NMTCommitMemory(addr + 5*size, 2*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=128KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 4*sizek + "KB)"); // Committing: . . . . . . * * // Region: . . . * * * * * - // Expected Total: 5 x 32KB = 160KB + // Expected Total: 5 x sizek KB wb.NMTCommitMemory(addr + 6*size, 2*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=160KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=" + 5*sizek + "KB)"); // Uncommitting: * * * * * * * * // Region: . . . . . . . . - // Expected Total: 0 x 32KB = 32KB + // Expected Total: 0 x sizek KB wb.NMTUncommitMemory(addr + 0*size, 8*size); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Test (reserved=256KB, committed=0KB)"); + output.shouldContain("Test (reserved=" + 8*sizek + "KB, committed=0KB)"); } } From e956abefe67ae320cbf908a4f8d80900cb647696 Mon Sep 17 00:00:00 2001 From: Rachel Protacio Date: Tue, 7 Jun 2016 11:39:47 -0400 Subject: [PATCH 033/191] 8153858: Clean up needed when obtaining the package name from a fully qualified class name Consolidated and refactored code parsing fully qualified names. Includes gtest. Reviewed-by: dholmes, coleenp --- .../src/share/vm/classfile/classLoader.cpp | 65 +++++++++---- .../src/share/vm/classfile/classLoader.hpp | 4 +- .../share/vm/classfile/systemDictionary.cpp | 30 +++--- .../vm/classfile/systemDictionaryShared.hpp | 4 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 69 +++++--------- hotspot/src/share/vm/oops/instanceKlass.hpp | 2 +- hotspot/src/share/vm/oops/method.hpp | 2 +- .../test/native/runtime/test_classLoader.cpp | 92 +++++++++++++++++++ .../native/runtime/test_instanceKlass.cpp | 35 +++++++ 9 files changed, 218 insertions(+), 85 deletions(-) create mode 100644 hotspot/test/native/runtime/test_classLoader.cpp create mode 100644 hotspot/test/native/runtime/test_instanceKlass.cpp diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index acc65eb9a8a..265b485c7d9 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -181,26 +181,59 @@ bool ClassLoader::string_ends_with(const char* str, const char* str_to_find) { } // Used to obtain the package name from a fully qualified class name. -// It is the responsibility of the caller to establish ResourceMark. -const char* ClassLoader::package_from_name(const char* class_name) { - const char* last_slash = strrchr(class_name, '/'); +// It is the responsibility of the caller to establish a ResourceMark. +const char* ClassLoader::package_from_name(const char* const class_name, bool* bad_class_name) { + if (class_name == NULL) { + if (bad_class_name != NULL) { + *bad_class_name = true; + } + return NULL; + } + + if (bad_class_name != NULL) { + *bad_class_name = false; + } + + const char* const last_slash = strrchr(class_name, '/'); if (last_slash == NULL) { // No package name return NULL; } - int length = last_slash - class_name; - // A class name could have just the slash character in the name, - // resulting in a negative length. + char* class_name_ptr = (char*) class_name; + // Skip over '['s + if (*class_name_ptr == '[') { + do { + class_name_ptr++; + } while (*class_name_ptr == '['); + + // Fully qualified class names should not contain a 'L'. + // Set bad_class_name to true to indicate that the package name + // could not be obtained due to an error condition. + // In this situation, is_same_class_package returns false. + if (*class_name_ptr == 'L') { + if (bad_class_name != NULL) { + *bad_class_name = true; + } + return NULL; + } + } + + int length = last_slash - class_name_ptr; + + // A class name could have just the slash character in the name. if (length <= 0) { // No package name + if (bad_class_name != NULL) { + *bad_class_name = true; + } return NULL; } // drop name after last slash (including slash) // Ex., "java/lang/String.class" => "java/lang" char* pkg_name = NEW_RESOURCE_ARRAY(char, length + 1); - strncpy(pkg_name, class_name, length); + strncpy(pkg_name, class_name_ptr, length); *(pkg_name+length) = '\0'; return (const char *)pkg_name; @@ -1117,13 +1150,11 @@ bool ClassLoader::add_package(const char *fullq_class_name, s2 classpath_index, assert(fullq_class_name != NULL, "just checking"); // Get package name from fully qualified class name. - const char *cp = strrchr(fullq_class_name, '/'); + ResourceMark rm; + const char *cp = package_from_name(fullq_class_name); if (cp != NULL) { - int len = cp - fullq_class_name; - PackageEntryTable* pkg_entry_tbl = - ClassLoaderData::the_null_class_loader_data()->packages(); - TempNewSymbol pkg_symbol = - SymbolTable::new_symbol(fullq_class_name, len, CHECK_false); + PackageEntryTable* pkg_entry_tbl = ClassLoaderData::the_null_class_loader_data()->packages(); + TempNewSymbol pkg_symbol = SymbolTable::new_symbol(cp, CHECK_false); PackageEntry* pkg_entry = pkg_entry_tbl->lookup_only(pkg_symbol); if (pkg_entry != NULL) { assert(classpath_index != -1, "Unexpected classpath_index"); @@ -1231,11 +1262,9 @@ s2 ClassLoader::classloader_type(Symbol* class_name, ClassPathEntry* e, int clas // jimage, it is determined by the class path entry. jshort loader_type = ClassLoader::APP_LOADER; if (e->is_jrt()) { - int length = 0; - const jbyte* pkg_string = InstanceKlass::package_from_name(class_name, length); - if (pkg_string != NULL) { - ResourceMark rm; - TempNewSymbol pkg_name = SymbolTable::new_symbol((const char*)pkg_string, length, THREAD); + ResourceMark rm; + TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK_0); + if (pkg_name != NULL) { const char* pkg_name_C_string = (const char*)(pkg_name->as_C_string()); ClassPathImageEntry* cpie = (ClassPathImageEntry*)e; JImageFile* jimage = cpie->jimage(); diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp index 1688373f2cc..c59697c52cd 100644 --- a/hotspot/src/share/vm/classfile/classLoader.hpp +++ b/hotspot/src/share/vm/classfile/classLoader.hpp @@ -444,7 +444,9 @@ class ClassLoader: AllStatic { static bool string_ends_with(const char* str, const char* str_to_find); // obtain package name from a fully qualified class name - static const char* package_from_name(const char* class_name); + // *bad_class_name is set to true if there's a problem with parsing class_name, to + // distinguish from a class_name with no package name, as both cases have a NULL return value + static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL); static bool is_jrt(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); } diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 28b79768fa5..aaa2ad5dda1 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -70,6 +70,7 @@ #include "services/threadService.hpp" #include "trace/traceMacros.hpp" #include "utilities/macros.hpp" +#include "utilities/stringUtils.hpp" #include "utilities/ticks.hpp" #if INCLUDE_CDS #include "classfile/sharedClassUtil.hpp" @@ -1154,12 +1155,10 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name, // It is illegal to define classes in the "java." package from // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader ResourceMark rm(THREAD); - char* name = parsed_name->as_C_string(); - char* index = strrchr(name, '/'); - *index = '\0'; // chop to just the package name - while ((index = strchr(name, '/')) != NULL) { - *index = '.'; // replace '/' with '.' in package name - } + TempNewSymbol pkg_name = InstanceKlass::package_from_name(parsed_name, CHECK_NULL); + assert(pkg_name != NULL, "Error in parsing package name starting with 'java/'"); + char* name = pkg_name->as_C_string(); + StringUtils::replace_no_expand(name, "/", "."); const char* msg_text = "Prohibited package name: "; size_t len = strlen(msg_text) + strlen(name) + 1; char* message = NEW_RESOURCE_ARRAY(char, len); @@ -1257,6 +1256,7 @@ instanceKlassHandle SystemDictionary::load_shared_class( bool SystemDictionary::is_shared_class_visible(Symbol* class_name, instanceKlassHandle ik, Handle class_loader, TRAPS) { + ResourceMark rm; int path_index = ik->shared_classpath_index(); SharedClassPathEntry* ent = (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index); @@ -1270,12 +1270,11 @@ bool SystemDictionary::is_shared_class_visible(Symbol* class_name, TempNewSymbol pkg_name = NULL; PackageEntry* pkg_entry = NULL; ModuleEntry* mod_entry = NULL; - int length = 0; + const char* pkg_string = NULL; ClassLoaderData* loader_data = class_loader_data(class_loader); - const jbyte* pkg_string = InstanceKlass::package_from_name(class_name, length); - if (pkg_string != NULL) { - pkg_name = SymbolTable::new_symbol((const char*)pkg_string, - length, CHECK_(false)); + pkg_name = InstanceKlass::package_from_name(class_name, CHECK_false); + if (pkg_name != NULL) { + pkg_string = pkg_name->as_C_string(); if (loader_data != NULL) { pkg_entry = loader_data->packages()->lookup_only(pkg_name); } @@ -1432,15 +1431,14 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha instanceKlassHandle nh = instanceKlassHandle(); // null Handle if (class_loader.is_null()) { - int length = 0; + ResourceMark rm; PackageEntry* pkg_entry = NULL; bool search_only_bootloader_append = false; ClassLoaderData *loader_data = class_loader_data(class_loader); // Find the package in the boot loader's package entry table. - const jbyte* pkg_string = InstanceKlass::package_from_name(class_name, length); - if (pkg_string != NULL) { - TempNewSymbol pkg_name = SymbolTable::new_symbol((const char*)pkg_string, length, CHECK_(nh)); + TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK_NULL); + if (pkg_name != NULL) { pkg_entry = loader_data->packages()->lookup_only(pkg_name); } @@ -1477,7 +1475,7 @@ instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Ha assert(!DumpSharedSpaces, "Archive dumped after module system initialization"); // After the module system has been initialized, check if the class' // package is in a module defined to the boot loader. - if (pkg_string == NULL || pkg_entry == NULL || pkg_entry->in_unnamed_module()) { + if (pkg_name == NULL || pkg_entry == NULL || pkg_entry->in_unnamed_module()) { // Class is either in the unnamed package, in a named package // within a module not defined to the boot loader or in a // a named package within the unnamed module. In all cases, diff --git a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp index 51db47c3387..44815e72930 100644 --- a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -48,7 +48,7 @@ public: static bool is_shared_class_visible_for_classloader( instanceKlassHandle ik, Handle class_loader, - const jbyte* pkg_string, + const char* pkg_string, Symbol* pkg_name, PackageEntry* pkg_entry, ModuleEntry* mod_entry, diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 02161471b01..58135b4a5ff 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2182,39 +2182,21 @@ const char* InstanceKlass::signature_name() const { return dest; } -const jbyte* InstanceKlass::package_from_name(const Symbol* name, int& length) { - ResourceMark rm; - length = 0; +// Used to obtain the package name from a fully qualified class name. +Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) { if (name == NULL) { return NULL; } else { - const jbyte* base_name = name->base(); - const jbyte* last_slash = UTF8::strrchr(base_name, name->utf8_length(), '/'); - - if (last_slash == NULL) { - // No package name + if (name->utf8_length() <= 0) { return NULL; - } else { - // Skip over '['s - if (*base_name == '[') { - do { - base_name++; - } while (*base_name == '['); - if (*base_name != 'L') { - // Fully qualified class names should not contain a 'L'. - // Set length to -1 to indicate that the package name - // could not be obtained due to an error condition. - // In this situtation, is_same_class_package returns false. - length = -1; - return NULL; - } - } - - // Found the package name, look it up in the symbol table. - length = last_slash - base_name; - assert(length > 0, "Bad length for package name"); - return base_name; } + ResourceMark rm; + const char* package_name = ClassLoader::package_from_name((const char*) name->as_C_string()); + if (package_name == NULL) { + return NULL; + } + Symbol* pkg_name = SymbolTable::new_symbol(package_name, THREAD); + return pkg_name; } } @@ -2230,12 +2212,9 @@ ModuleEntry* InstanceKlass::module() const { } void InstanceKlass::set_package(ClassLoaderData* loader_data, TRAPS) { - int length = 0; - const jbyte* base_name = package_from_name(name(), length); - - if (base_name != NULL && loader_data != NULL) { - TempNewSymbol pkg_name = SymbolTable::new_symbol((const char*)base_name, length, CHECK); + TempNewSymbol pkg_name = package_from_name(name(), CHECK); + if (pkg_name != NULL && loader_data != NULL) { // Find in class loader's package entry table. _package_entry = loader_data->packages()->lookup_only(pkg_name); @@ -2331,20 +2310,18 @@ bool InstanceKlass::is_same_class_package(oop class_loader1, const Symbol* class if (class_loader1 != class_loader2) { return false; } else if (class_name1 == class_name2) { - return true; // skip painful bytewise comparison + return true; } else { ResourceMark rm; - // The Symbol*'s are in UTF8 encoding. Since we only need to check explicitly - // for ASCII characters ('/', 'L', '['), we can keep them in UTF8 encoding. - // Otherwise, we just compare jbyte values between the strings. - int length1 = 0; - int length2 = 0; - const jbyte *name1 = package_from_name(class_name1, length1); - const jbyte *name2 = package_from_name(class_name2, length2); + bool bad_class_name = false; + const char* name1 = ClassLoader::package_from_name((const char*) class_name1->as_C_string(), &bad_class_name); + if (bad_class_name) { + return false; + } - if ((length1 < 0) || (length2 < 0)) { - // error occurred parsing package name. + const char* name2 = ClassLoader::package_from_name((const char*) class_name2->as_C_string(), &bad_class_name); + if (bad_class_name) { return false; } @@ -2354,13 +2331,13 @@ bool InstanceKlass::is_same_class_package(oop class_loader1, const Symbol* class return name1 == name2; } - // Check that package part is identical - return UTF8::equal(name1, length1, name2, length2); + // Check that package is identical + return (strcmp(name1, name2) == 0); } } // Returns true iff super_method can be overridden by a method in targetclassname -// See JSL 3rd edition 8.4.6.1 +// See JLS 3rd edition 8.4.6.1 // Assumes name-signature match // "this" is InstanceKlass of super_method which must exist // note that the InstanceKlass of the method in the targetclassname has not always been created yet diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 494173b3ded..000215d14a0 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -1108,7 +1108,7 @@ public: // Naming const char* signature_name() const; - static const jbyte* package_from_name(const Symbol* name, int& length); + static Symbol* package_from_name(const Symbol* name, TRAPS); // GC specific object visitors // diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp index 6b852d37502..f1bbf9ea84f 100644 --- a/hotspot/src/share/vm/oops/method.hpp +++ b/hotspot/src/share/vm/oops/method.hpp @@ -246,7 +246,7 @@ class Method : public Metadata { int code_size() const { return constMethod()->code_size(); } // method size in words - int method_size() const { return sizeof(Method)/wordSize + is_native() ? 2 : 0; } + int method_size() const { return sizeof(Method)/wordSize + ( is_native() ? 2 : 0 ); } // constant pool for Klass* holding this method ConstantPool* constants() const { return constMethod()->constants(); } diff --git a/hotspot/test/native/runtime/test_classLoader.cpp b/hotspot/test/native/runtime/test_classLoader.cpp new file mode 100644 index 00000000000..8ca5ba303d0 --- /dev/null +++ b/hotspot/test/native/runtime/test_classLoader.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +#include "classfile/classLoader.hpp" +#include "memory/resourceArea.hpp" +#include "unittest.hpp" + +// Tests ClassLoader::package_from_name() +TEST_VM(classLoader, null_class_name) { + ResourceMark rm; + bool bad_class_name = false; + const char* retval= ClassLoader::package_from_name(NULL, &bad_class_name); + ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with NULL class name"; + ASSERT_STREQ(retval, NULL) << "Wrong package for NULL class name pointer"; +} + +TEST_VM(classLoader, empty_class_name) { + ResourceMark rm; + const char* retval = ClassLoader::package_from_name(""); + ASSERT_STREQ(retval, NULL) << "Wrong package for empty string"; +} + +TEST_VM(classLoader, no_slash) { + ResourceMark rm; + const char* retval = ClassLoader::package_from_name("L"); + ASSERT_STREQ(retval, NULL) << "Wrong package for class with no slashes"; +} + +TEST_VM(classLoader, just_slash) { + ResourceMark rm; + bool bad_class_name = false; + const char* retval = ClassLoader::package_from_name("/", &bad_class_name); + ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with package of length 0"; + ASSERT_STREQ(retval, NULL) << "Wrong package for class with just slash"; +} + +TEST_VM(classLoader, multiple_slashes) { + ResourceMark rm; + const char* retval = ClassLoader::package_from_name("///"); + ASSERT_STREQ(retval, "//") << "Wrong package for class with just slashes"; +} + +TEST_VM(classLoader, standard_case_1) { + ResourceMark rm; + bool bad_class_name = true; + const char* retval = ClassLoader::package_from_name("package/class", &bad_class_name); + ASSERT_FALSE(bad_class_name) << "Function did not reset bad_class_name"; + ASSERT_STREQ(retval, "package") << "Wrong package for class with one slash"; +} + +TEST_VM(classLoader, standard_case_2) { + ResourceMark rm; + const char* retval = ClassLoader::package_from_name("package/folder/class"); + ASSERT_STREQ(retval, "package/folder") << "Wrong package for class with multiple slashes"; +} + +TEST_VM(classLoader, class_array) { + ResourceMark rm; + bool bad_class_name = false; + const char* retval = ClassLoader::package_from_name("[package/class", &bad_class_name); + ASSERT_FALSE(bad_class_name) << "Function set bad_class_name with class array"; + ASSERT_STREQ(retval, "package") << "Wrong package for class with leading bracket"; +} + +TEST_VM(classLoader, class_object_array) { + ResourceMark rm; + bool bad_class_name = false; + const char* retval = ClassLoader::package_from_name("[Lpackage/class", &bad_class_name); + ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with array of class objects"; + ASSERT_STREQ(retval, NULL) << "Wrong package for class with leading '[L'"; +} diff --git a/hotspot/test/native/runtime/test_instanceKlass.cpp b/hotspot/test/native/runtime/test_instanceKlass.cpp new file mode 100644 index 00000000000..179aae5b854 --- /dev/null +++ b/hotspot/test/native/runtime/test_instanceKlass.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +#include "classfile/symbolTable.hpp" +#include "memory/resourceArea.hpp" +#include "oops/instanceKlass.hpp" +#include "unittest.hpp" + +// Tests InstanceKlass::package_from_name() +TEST_VM(instanceKlass, null_symbol) { + ResourceMark rm; + TempNewSymbol package_sym = InstanceKlass::package_from_name(NULL, NULL); + ASSERT_TRUE(package_sym == NULL) << "Wrong package for NULL symbol"; +} From 4a9d6dcbba789bc9fd9c9d5e3e72b85ebc12cf8e Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Tue, 7 Jun 2016 18:26:10 +0200 Subject: [PATCH 034/191] 8158938: AIX: some more new hotspot build fixes Reviewed-by: erikj --- hotspot/make/lib/JvmOverrideFiles.gmk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hotspot/make/lib/JvmOverrideFiles.gmk b/hotspot/make/lib/JvmOverrideFiles.gmk index 1ffcb7455ce..78a007cc39d 100644 --- a/hotspot/make/lib/JvmOverrideFiles.gmk +++ b/hotspot/make/lib/JvmOverrideFiles.gmk @@ -153,6 +153,13 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) # mode, so don't optimize sharedRuntimeTrig.cpp at all. BUILD_LIBJVM_sharedRuntimeTrig.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE) + ifneq ($(DEBUG_LEVEL),slowdebug) + # Compiling jvmtiEnterTrace.cpp with full optimization needs more than 30min + # (mostly because of '-qhot=level=1' and the more than 1300 'log_trace' calls + # which cause a lot of template expansion). + BUILD_LIBJVM_jvmtiEnterTrace.cpp_OPTIMIZATION := LOW + endif + # Disable ELF decoder on AIX (AIX uses XCOFF). JVM_EXCLUDE_PATTERNS += elf From 47309c37159d560086a27d4b5ac7f05958f373e0 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 7 Jun 2016 15:34:22 -0400 Subject: [PATCH 035/191] 8158297: Lack of proper checking of non-well formed elements in CONSTANT_Utf8_info's structure Disallow // in class file names during parsing and throw ClassNotFoundException Reviewed-by: sspitsyn, rehn, gtriantafill --- .../share/vm/classfile/classFileParser.cpp | 13 +- .../classFileParserBug/TestBadClassName.java | 57 +++++++++ .../classFileParserBug/UseBadInterface1.jcod | 120 ++++++++++++++++++ .../classFileParserBug/UseBadInterface2.jcod | 120 ++++++++++++++++++ .../classFileParserBug/p1/BadInterface1.jcod | 62 +++++++++ .../classFileParserBug/p1/BadInterface2.jcod | 62 +++++++++ 6 files changed, 432 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/runtime/classFileParserBug/TestBadClassName.java create mode 100644 hotspot/test/runtime/classFileParserBug/UseBadInterface1.jcod create mode 100644 hotspot/test/runtime/classFileParserBug/UseBadInterface2.jcod create mode 100644 hotspot/test/runtime/classFileParserBug/p1/BadInterface1.jcod create mode 100644 hotspot/test/runtime/classFileParserBug/p1/BadInterface2.jcod diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 1d5f4e4c042..a09fc8e14d0 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -4673,6 +4673,7 @@ void ClassFileParser::verify_legal_utf8(const unsigned char* buffer, } // Unqualified names may not contain the characters '.', ';', '[', or '/'. +// In class names, '/' separates unqualified names. This is verified in this function also. // Method names also may not contain the characters '<' or '>', unless // or . Note that method names may not be or in this // method. Because these names have been checked as special cases before @@ -4698,8 +4699,16 @@ bool ClassFileParser::verify_unqualified_name(const char* name, if (ch == ';' || ch == '[' ) { return false; // do not permit '.', ';', or '[' } - if (type != ClassFileParser::LegalClass && ch == '/') { - return false; // do not permit '/' unless it's class name + if (ch == '/') { + // check for '//' or leading or trailing '/' which are not legal + // unqualified name must not be empty + if (type == ClassFileParser::LegalClass) { + if (p == name || p+1 >= name+length || *(p+1) == '/') { + return false; + } + } else { + return false; // do not permit '/' unless it's class name + } } if (type == ClassFileParser::LegalMethod && (ch == '<' || ch == '>')) { return false; // do not permit '<' or '>' in method names diff --git a/hotspot/test/runtime/classFileParserBug/TestBadClassName.java b/hotspot/test/runtime/classFileParserBug/TestBadClassName.java new file mode 100644 index 00000000000..d742711b7f1 --- /dev/null +++ b/hotspot/test/runtime/classFileParserBug/TestBadClassName.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, 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 8158297 + * @summary Constant pool utf8 entry for class name cannot have empty qualified name '//' + * @compile p1/BadInterface1.jcod + * @compile p1/BadInterface2.jcod + * @compile UseBadInterface1.jcod + * @compile UseBadInterface2.jcod + * @run main/othervm -Xverify:all TestBadClassName + */ + +public class TestBadClassName { + public static void main(String args[]) throws Throwable { + + System.out.println("Regression test for bug 8042660"); + + // Test class name with p1//BadInterface2 + try { + Class newClass = Class.forName("UseBadInterface1"); + throw new RuntimeException("Expected ClassFormatError exception not thrown"); + } catch (java.lang.ClassFormatError e) { + System.out.println("Test UseBadInterface1 passed test case with illegal class name"); + } + + // Test class name with p1/BadInterface2/ + try { + Class newClass = Class.forName("UseBadInterface2"); + throw new RuntimeException("Expected ClassFormatError exception not thrown"); + } catch (java.lang.ClassFormatError e) { + System.out.println("Test UseBadInterface1 passed test case with illegal class name"); + } + } +} diff --git a/hotspot/test/runtime/classFileParserBug/UseBadInterface1.jcod b/hotspot/test/runtime/classFileParserBug/UseBadInterface1.jcod new file mode 100644 index 00000000000..243d47f7472 --- /dev/null +++ b/hotspot/test/runtime/classFileParserBug/UseBadInterface1.jcod @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +// jcod file for UseBadInterface1.java +// class UseBadInterface1 implements p1.BadInterface1 { +// int i; +// UseBadInterface1() {} +// public static void main(java.lang.String[] unused) { } +// } + +class UseBadInterface1 { + 0xCAFEBABE; + 0; // minor version + 53; // version + [] { // Constant Pool + ; // first element is empty + Method #3 #10; // #1 + Utf8 "UseBadInterface1.java"; // #2 + class #4; // #3 + Utf8 "java/lang/Object"; // #4 + class #8; // #5 + Utf8 "([Ljava/lang/String;)V"; // #6 + class #11; // #7 + Utf8 "UseBadInterface1"; // #8 + Utf8 "main"; // #9 + NameAndType #17 #13; // #10 + Utf8 "p1//BadInterface1"; // #11 + Utf8 "SourceFile"; // #12 + Utf8 "()V"; // #13 + Utf8 "I"; // #14 + Utf8 "Code"; // #15 + Utf8 "i"; // #16 + Utf8 ""; // #17 + } // Constant Pool + + 0x0020; // access + #5;// this_cpx + #3;// super_cpx + + [] { // Interfaces + #7; + } // Interfaces + + [] { // fields + { // Member + 0x0000; // access + #16; // name_cpx + #14; // sig_cpx + [] { // Attributes + } // Attributes + } // Member + } // fields + + [] { // methods + { // Member + 0x0000; // access + #17; // name_cpx + #13; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #9; // name_cpx + #6; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 0; // max_stack + 1; // max_locals + Bytes[]{ + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#12) { // SourceFile + #2; + } // end SourceFile + } // Attributes +} // end class UseBadInterface1 diff --git a/hotspot/test/runtime/classFileParserBug/UseBadInterface2.jcod b/hotspot/test/runtime/classFileParserBug/UseBadInterface2.jcod new file mode 100644 index 00000000000..903d31cddd6 --- /dev/null +++ b/hotspot/test/runtime/classFileParserBug/UseBadInterface2.jcod @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +// jcod file for UseBadInterface2.java +// class UseBadInterface2 implements p1.BadInterface2 { +// int i; +// UseBadInterface2() {} +// public static void main(java.lang.String[] unused) { } +// } + +class UseBadInterface2 { + 0xCAFEBABE; + 0; // minor version + 53; // version + [] { // Constant Pool + ; // first element is empty + Method #3 #10; // #1 + Utf8 "UseBadInterface2.java"; // #2 + class #4; // #3 + Utf8 "java/lang/Object"; // #4 + class #8; // #5 + Utf8 "([Ljava/lang/String;)V"; // #6 + class #11; // #7 + Utf8 "UseBadInterface2"; // #8 + Utf8 "main"; // #9 + NameAndType #17 #13; // #10 + Utf8 "p1/BadInterface2/"; // #11 + Utf8 "SourceFile"; // #12 + Utf8 "()V"; // #13 + Utf8 "I"; // #14 + Utf8 "Code"; // #15 + Utf8 "i"; // #16 + Utf8 ""; // #17 + } // Constant Pool + + 0x0020; // access + #5;// this_cpx + #3;// super_cpx + + [] { // Interfaces + #7; + } // Interfaces + + [] { // fields + { // Member + 0x0000; // access + #16; // name_cpx + #14; // sig_cpx + [] { // Attributes + } // Attributes + } // Member + } // fields + + [] { // methods + { // Member + 0x0000; // access + #17; // name_cpx + #13; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0009; // access + #9; // name_cpx + #6; // sig_cpx + [] { // Attributes + Attr(#15) { // Code + 0; // max_stack + 1; // max_locals + Bytes[]{ + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#12) { // SourceFile + #2; + } // end SourceFile + } // Attributes +} // end class UseBadInterface2 diff --git a/hotspot/test/runtime/classFileParserBug/p1/BadInterface1.jcod b/hotspot/test/runtime/classFileParserBug/p1/BadInterface1.jcod new file mode 100644 index 00000000000..f19a2653e5a --- /dev/null +++ b/hotspot/test/runtime/classFileParserBug/p1/BadInterface1.jcod @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +// Interface that should get a ClassFormatException for the "//" in the name + +// package p1; +// public interface cls1 {} + +class p1//BadInterface1 { + 0xCAFEBABE; + 0; // minor version + 53; // version + [] { // Constant Pool + ; // first element is empty + class #5; // #1 + class #6; // #2 + Utf8 "SourceFile"; // #3 + Utf8 "BadInterface1.java"; // #4 + Utf8 "p1//BadInterface1"; // #5 + Utf8 "java/lang/Object"; // #6 + } // Constant Pool + + 0x0601; // access + #1;// this_cpx + #2;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + } // methods + + [] { // Attributes + Attr(#3) { // SourceFile + #4; + } // end SourceFile + } // Attributes +} // end class p1//BadInterface1 diff --git a/hotspot/test/runtime/classFileParserBug/p1/BadInterface2.jcod b/hotspot/test/runtime/classFileParserBug/p1/BadInterface2.jcod new file mode 100644 index 00000000000..33c34f5944d --- /dev/null +++ b/hotspot/test/runtime/classFileParserBug/p1/BadInterface2.jcod @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +// Interface that should get a ClassFormatException for the trailing "/" in the name + +// package p1; +// public interface cls1 {} + +class p1/BadInterface2/ { + 0xCAFEBABE; + 0; // minor version + 53; // version + [] { // Constant Pool + ; // first element is empty + class #5; // #1 + class #6; // #2 + Utf8 "SourceFile"; // #3 + Utf8 "BadInterface2.java"; // #4 + Utf8 "p1/BadInterface2/"; // #5 + Utf8 "java/lang/Object"; // #6 + } // Constant Pool + + 0x0601; // access + #1;// this_cpx + #2;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + } // methods + + [] { // Attributes + Attr(#3) { // SourceFile + #4; + } // end SourceFile + } // Attributes +} // end class p1/BadInterface2 From 23e05cabc57f46c5102541616d00d881c7e1511f Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 8 Jun 2016 11:15:49 +0200 Subject: [PATCH 036/191] 8155638: Resource allocated BitMaps are often cleared twice Reviewed-by: neliasso, kvn --- hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp | 1 - hotspot/src/share/vm/c1/c1_IR.cpp | 8 ++------ hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 1 - hotspot/src/share/vm/c1/c1_LinearScan.cpp | 18 +++++++----------- hotspot/src/share/vm/c1/c1_ValueSet.hpp | 1 - hotspot/src/share/vm/ci/ciMethod.cpp | 1 - .../src/share/vm/compiler/methodLiveness.cpp | 14 -------------- hotspot/src/share/vm/utilities/bitMap.hpp | 1 - .../src/share/vm/utilities/bitMap.inline.hpp | 4 ---- 9 files changed, 9 insertions(+), 40 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp index 5c411814df7..e291000eab0 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -68,7 +68,6 @@ void LinearScan::allocate_fpu_stack() { if (b->number_of_preds() > 1) { int id = b->first_lir_instruction_id(); ResourceBitMap regs(FrameMap::nof_fpu_regs); - regs.clear(); iw.walk_to(id); // walk after the first instruction (always a label) of the block assert(iw.current_position() == id, "did not walk completely to id"); diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp index c1c72cf74f5..69d4ec1291f 100644 --- a/hotspot/src/share/vm/c1/c1_IR.cpp +++ b/hotspot/src/share/vm/c1/c1_IR.cpp @@ -147,10 +147,8 @@ IRScope::IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMe _wrote_volatile = false; _start = NULL; - if (osr_bci == -1) { - _requires_phi_function.clear(); - } else { - // selective creation of phi functions is not possibel in osr-methods + if (osr_bci != -1) { + // selective creation of phi functions is not possibel in osr-methods _requires_phi_function.set_range(0, method->max_locals()); } @@ -540,7 +538,6 @@ ComputeLinearScanOrder::ComputeLinearScanOrder(Compilation* c, BlockBegin* start { TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order")); - init_visited(); count_edges(start_block, NULL); if (compilation()->is_profiling()) { @@ -646,7 +643,6 @@ void ComputeLinearScanOrder::mark_loops() { TRACE_LINEAR_SCAN(3, tty->print_cr("----- marking loops")); _loop_map = BitMap2D(_num_loops, _max_block_id); - _loop_map.clear(); for (int i = _loop_end_blocks.length() - 1; i >= 0; i--) { BlockBegin* loop_end = _loop_end_blocks.at(i); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index ae49fc36878..53701de2b3e 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1387,7 +1387,6 @@ Instruction* LIRGenerator::instruction_for_vreg(int reg_num) { void LIRGenerator::set_vreg_flag(int vreg_num, VregFlag f) { if (_vreg_flags.size_in_bits() == 0) { BitMap2D temp(100, num_vreg_flags); - temp.clear(); _vreg_flags = temp; } _vreg_flags.at_put_grow(vreg_num, f, true); diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index dd45f5bf3b9..18397d6118f 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -562,14 +562,13 @@ void LinearScan::compute_local_live_sets() { LIR_OpVisitState visitor; BitMap2D local_interval_in_loop = BitMap2D(_num_virtual_regs, num_loops()); - local_interval_in_loop.clear(); // iterate all blocks for (int i = 0; i < num_blocks; i++) { BlockBegin* block = block_at(i); - ResourceBitMap live_gen(live_size); live_gen.clear(); - ResourceBitMap live_kill(live_size); live_kill.clear(); + ResourceBitMap live_gen(live_size); + ResourceBitMap live_kill(live_size); if (block->is_set(BlockBegin::exception_entry_flag)) { // Phi functions at the begin of an exception handler are @@ -715,8 +714,8 @@ void LinearScan::compute_local_live_sets() { block->set_live_gen (live_gen); block->set_live_kill(live_kill); - block->set_live_in (ResourceBitMap(live_size)); block->live_in().clear(); - block->set_live_out (ResourceBitMap(live_size)); block->live_out().clear(); + block->set_live_in (ResourceBitMap(live_size)); + block->set_live_out (ResourceBitMap(live_size)); TRACE_LINEAR_SCAN(4, tty->print("live_gen B%d ", block->block_id()); print_bitmap(block->live_gen())); TRACE_LINEAR_SCAN(4, tty->print("live_kill B%d ", block->block_id()); print_bitmap(block->live_kill())); @@ -741,7 +740,7 @@ void LinearScan::compute_global_live_sets() { bool change_occurred; bool change_occurred_in_block; int iteration_count = 0; - ResourceBitMap live_out(live_set_size()); live_out.clear(); // scratch set for calculations + ResourceBitMap live_out(live_set_size()); // scratch set for calculations // Perform a backward dataflow analysis to compute live_out and live_in for each block. // The loop is executed until a fixpoint is reached (no changes in an iteration) @@ -827,7 +826,6 @@ void LinearScan::compute_global_live_sets() { // check that the live_in set of the first block is empty ResourceBitMap live_in_args(ir()->start()->live_in().size()); - live_in_args.clear(); if (!ir()->start()->live_in().is_same(live_in_args)) { #ifdef ASSERT tty->print_cr("Error: live_in set of first block must be empty (when this fails, virtual registers are used before they are defined)"); @@ -1774,8 +1772,8 @@ void LinearScan::resolve_data_flow() { int num_blocks = block_count(); MoveResolver move_resolver(this); - ResourceBitMap block_completed(num_blocks); block_completed.clear(); - ResourceBitMap already_resolved(num_blocks); already_resolved.clear(); + ResourceBitMap block_completed(num_blocks); + ResourceBitMap already_resolved(num_blocks); int i; for (i = 0; i < num_blocks; i++) { @@ -3750,7 +3748,6 @@ void MoveResolver::verify_before_resolve() { ResourceBitMap used_regs(LinearScan::nof_regs + allocator()->frame_map()->argcount() + allocator()->max_spills()); - used_regs.clear(); if (!_multiple_reads_allowed) { for (i = 0; i < _mapping_from.length(); i++) { Interval* it = _mapping_from.at(i); @@ -6319,7 +6316,6 @@ void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) { void ControlFlowOptimizer::delete_jumps_to_return(BlockList* code) { #ifdef ASSERT ResourceBitMap return_converted(BlockBegin::number_of_blocks()); - return_converted.clear(); #endif for (int i = code->length() - 1; i >= 0; i--) { diff --git a/hotspot/src/share/vm/c1/c1_ValueSet.hpp b/hotspot/src/share/vm/c1/c1_ValueSet.hpp index 50538121cf8..69802a85c1a 100644 --- a/hotspot/src/share/vm/c1/c1_ValueSet.hpp +++ b/hotspot/src/share/vm/c1/c1_ValueSet.hpp @@ -53,7 +53,6 @@ class ValueSet: public CompilationResourceObj { }; inline ValueSet::ValueSet() : _map(Instruction::number_of_instructions()) { - _map.clear(); } diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index 2a4484850bb..a54c0a724de 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -449,7 +449,6 @@ ResourceBitMap ciMethod::live_local_oops_at_bci(int bci) { OopMapCache::compute_one_oop_map(get_Method(), bci, &mask); int mask_size = max_locals(); ResourceBitMap result(mask_size); - result.clear(); int i; for (i = 0; i < mask_size ; i++ ) { if (mask.is_oop(i)) result.set_bit(i); diff --git a/hotspot/src/share/vm/compiler/methodLiveness.cpp b/hotspot/src/share/vm/compiler/methodLiveness.cpp index e68d1244f75..8d82cc18175 100644 --- a/hotspot/src/share/vm/compiler/methodLiveness.cpp +++ b/hotspot/src/share/vm/compiler/methodLiveness.cpp @@ -137,11 +137,6 @@ MethodLiveness::MethodLiveness(Arena* arena, ciMethod* method) _arena = arena; _method = method; _bit_map_size_bits = method->max_locals(); - - -#ifdef COMPILER1 - _bci_block_start.clear(); -#endif } void MethodLiveness::compute_liveness() { @@ -587,14 +582,6 @@ MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int new (analyzer->arena()) GrowableArray(analyzer->arena(), 5, 0, NULL); _exception_predecessors = new (analyzer->arena()) GrowableArray(analyzer->arena(), 5, 0, NULL); - _normal_exit.clear(); - _exception_exit.clear(); - _entry.clear(); - - // this initialization is not strictly necessary. - // _gen and _kill are cleared at the beginning of compute_gen_kill_range() - _gen.clear(); - _kill.clear(); } @@ -1020,7 +1007,6 @@ MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* metho _last_bci = bci; } - answer.clear(); answer.set_union(_normal_exit); answer.set_difference(_kill); answer.set_union(_gen); diff --git a/hotspot/src/share/vm/utilities/bitMap.hpp b/hotspot/src/share/vm/utilities/bitMap.hpp index bc5cb589929..01c94dae19c 100644 --- a/hotspot/src/share/vm/utilities/bitMap.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.hpp @@ -435,7 +435,6 @@ class BitMap2D VALUE_OBJ_CLASS_SPEC { void clear_bit(idx_t slot_index, idx_t bit_within_slot_index); void at_put(idx_t slot_index, idx_t bit_within_slot_index, bool value); void at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value); - void clear(); }; // Closure for iterating over BitMaps diff --git a/hotspot/src/share/vm/utilities/bitMap.inline.hpp b/hotspot/src/share/vm/utilities/bitMap.inline.hpp index 49521d8b149..1b3a9bb11f0 100644 --- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp @@ -367,8 +367,4 @@ inline void BitMap2D::at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, _map.at_put(bit, value); } -inline void BitMap2D::clear() { - _map.clear(); -} - #endif // SHARE_VM_UTILITIES_BITMAP_INLINE_HPP From 09caec497d8a0a71e29a59cc6ae76c20a9c47eea Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Wed, 8 Jun 2016 16:29:12 +0200 Subject: [PATCH 037/191] 8149085: IntegrationTest1.java fails intermittently due to use of semi-initialized TLAB Reviewed-by: ehelin, mgerdin --- .../src/share/vm/gc/shared/threadLocalAllocBuffer.hpp | 1 + hotspot/src/share/vm/runtime/thread.inline.hpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp index 6a5ab498bf6..1ee892e8469 100644 --- a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp +++ b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp @@ -110,6 +110,7 @@ public: static const size_t min_size() { return align_object_size(MinTLABSize / HeapWordSize) + alignment_reserve(); } static const size_t max_size() { assert(_max_size != 0, "max_size not set up"); return _max_size; } + static const size_t max_size_in_bytes() { return max_size() * BytesPerWord; } static void set_max_size(size_t max_size) { _max_size = max_size; } HeapWord* start() const { return _start; } diff --git a/hotspot/src/share/vm/runtime/thread.inline.hpp b/hotspot/src/share/vm/runtime/thread.inline.hpp index 4510bf2695f..b8c7a142612 100644 --- a/hotspot/src/share/vm/runtime/thread.inline.hpp +++ b/hotspot/src/share/vm/runtime/thread.inline.hpp @@ -71,9 +71,12 @@ inline jlong Thread::cooked_allocated_bytes() { jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes); if (UseTLAB) { size_t used_bytes = tlab().used_bytes(); - if ((ssize_t)used_bytes > 0) { - // More-or-less valid tlab. The load_acquire above should ensure - // that the result of the add is <= the instantaneous value. + if (used_bytes <= ThreadLocalAllocBuffer::max_size_in_bytes()) { + // Comparing used_bytes with the maximum allowed size will ensure + // that we don't add the used bytes from a semi-initialized TLAB + // ending up with incorrect values. There is still a race between + // incrementing _allocated_bytes and clearing the TLAB, that might + // cause double counting in rare cases. return allocated_bytes + used_bytes; } } From 27f9eddfc2ac0d313628f54a0d593a257e2eb913 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Wed, 8 Jun 2016 12:50:23 -0700 Subject: [PATCH 038/191] 8159019: ResourceMark in ClassLoader::open_versioned_entry() is being used incorrectly Call FREE_RESOURCE_ARRAY instead of declaring a ResourceMark Reviewed-by: hseigel, jiangli --- hotspot/src/share/vm/classfile/classLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 265b485c7d9..1186067c242 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -380,7 +380,6 @@ u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TR if (is_multi_ver) { int n; - ResourceMark rm(THREAD); char* entry_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, JVM_MAXPATHLEN); if (version > 0) { n = jio_snprintf(entry_name, JVM_MAXPATHLEN, "META-INF/versions/%d/%s", version, name); @@ -400,6 +399,7 @@ u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TR } } } + FREE_RESOURCE_ARRAY(char, entry_name, JVM_MAXPATHLEN); } } return buffer; From 81ff3b7d935903483d01a643497000020d9da928 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Wed, 8 Jun 2016 18:47:05 -0400 Subject: [PATCH 039/191] 8158681: ClassLoader::classloader_type() is called from code not included under #if INCLUDE_CDS Place CDS related code under #if INCLUDE_CDS. Reviewed-by: lfoltan, gtriantafill, coleenp --- hotspot/src/share/vm/classfile/classLoaderExt.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hotspot/src/share/vm/classfile/classLoaderExt.hpp b/hotspot/src/share/vm/classfile/classLoaderExt.hpp index 24426d10552..6ce2275cc3b 100644 --- a/hotspot/src/share/vm/classfile/classLoaderExt.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderExt.hpp @@ -54,12 +54,14 @@ public: const s2 classpath_index, instanceKlassHandle result, TRAPS) { if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) { +#if INCLUDE_CDS if (DumpSharedSpaces) { s2 classloader_type = ClassLoader::classloader_type( class_name, e, classpath_index, CHECK_(result)); result->set_shared_classpath_index(classpath_index); result->set_class_loader_type(classloader_type); } +#endif return result; } else { return instanceKlassHandle(); // NULL From ec6f427ecc084cbf694688a9993592fae404783e Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Thu, 9 Jun 2016 13:24:44 +0200 Subject: [PATCH 040/191] 8146530: [testbug] some tests fail because the compiler is using Java heap memory Reviewed-by: jwilhelm, jmasa, kvn --- hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java index aadb620ef9d..e2df1d7e866 100644 --- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -1,5 +1,5 @@ /* -* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2015, 2016, 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 @@ -25,6 +25,8 @@ * @test TestTargetSurvivorRatioFlag * @key gc * @summary Verify that option TargetSurvivorRatio affects survivor space occupancy after minor GC. + * @requires (vm.opt.ExplicitGCInvokesConcurrent == null) | (vm.opt.ExplicitGCInvokesConcurrent == false) + * @requires (vm.opt.UseJVMCICompiler == null) | (vm.opt.UseJVMCICompiler == false) * @library /testlibrary /test/lib * @modules java.base/jdk.internal.misc * java.management From aa9857b6e245f97c2ffabac47d4168f314b1fe3d Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Wed, 8 Jun 2016 16:26:11 +0200 Subject: [PATCH 041/191] 8157243: JMap heap test fail when used with external heap Reviewed-by: dsamersoff, ehelin --- .../sun/jvm/hotspot/memory/Universe.java | 4 ++- .../sun/jvm/hotspot/memory/UniverseExt.java | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/UniverseExt.java diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java index f26fc452c94..637bdc5ecd5 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -96,6 +96,8 @@ public class Universe { narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); narrowKlassBaseField = type.getAddressField("_narrow_klass._base"); narrowKlassShiftField = type.getCIntegerField("_narrow_klass._shift"); + + UniverseExt.initialize(heapConstructor); } public Universe() { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/UniverseExt.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/UniverseExt.java new file mode 100644 index 00000000000..54734c31736 --- /dev/null +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/UniverseExt.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016, 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. + * + */ + +package sun.jvm.hotspot.memory; + +import sun.jvm.hotspot.runtime.*; + +public class UniverseExt { + public static void initialize(VirtualConstructor heapConstructor) { } +} From 84cab6c56f4eab4ed16b9f8bfeb72cab6631b3a8 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Thu, 9 Jun 2016 16:52:32 +0300 Subject: [PATCH 042/191] 8156032: Clean up parallel GC specific code from vm/gc/shared/preservedMarks.cpp Reviewed-by: stefank, tschatzl --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 3 +- .../vm/gc/parallel/psPromotionManager.cpp | 48 ++++++++++- .../share/vm/gc/serial/defNewGeneration.cpp | 3 +- .../src/share/vm/gc/shared/preservedMarks.cpp | 80 ++++++------------- .../src/share/vm/gc/shared/preservedMarks.hpp | 41 ++++++---- .../vm/gc/shared/preservedMarks.inline.hpp | 15 +--- 6 files changed, 101 insertions(+), 89 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 90a7d35c144..de81be328d3 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -3474,7 +3474,8 @@ void G1CollectedHeap::restore_after_evac_failure() { double remove_self_forwards_start = os::elapsedTime(); remove_self_forwarding_pointers(); - _preserved_marks_set.restore(workers()); + SharedRestorePreservedMarksTaskExecutor task_executor(workers()); + _preserved_marks_set.restore(&task_executor); g1_policy()->phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0); } diff --git a/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp b/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp index bdd965bd5b6..5a4ce68e176 100644 --- a/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp +++ b/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "gc/parallel/gcTaskManager.hpp" #include "gc/parallel/mutableSpace.hpp" #include "gc/parallel/parallelScavengeHeap.hpp" #include "gc/parallel/psOldGen.hpp" @@ -237,8 +238,53 @@ void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_mark _preserved_marks = preserved_marks; } +class ParRestoreGCTask : public GCTask { +private: + const uint _id; + PreservedMarksSet* const _preserved_marks_set; + volatile size_t* const _total_size_addr; + +public: + virtual char* name() { + return (char*) "preserved mark restoration task"; + } + + virtual void do_it(GCTaskManager* manager, uint which){ + _preserved_marks_set->get(_id)->restore_and_increment(_total_size_addr); + } + + ParRestoreGCTask(uint id, + PreservedMarksSet* preserved_marks_set, + volatile size_t* total_size_addr) + : _id(id), + _preserved_marks_set(preserved_marks_set), + _total_size_addr(total_size_addr) { } +}; + +class PSRestorePreservedMarksTaskExecutor : public RestorePreservedMarksTaskExecutor { +private: + GCTaskManager* _gc_task_manager; + +public: + PSRestorePreservedMarksTaskExecutor(GCTaskManager* gc_task_manager) + : _gc_task_manager(gc_task_manager) { } + + void restore(PreservedMarksSet* preserved_marks_set, + volatile size_t* total_size_addr) { + // GCTask / GCTaskQueue are ResourceObjs + ResourceMark rm; + + GCTaskQueue* q = GCTaskQueue::create(); + for (uint i = 0; i < preserved_marks_set->num(); i += 1) { + q->enqueue(new ParRestoreGCTask(i, preserved_marks_set, total_size_addr)); + } + _gc_task_manager->execute_and_wait(q); + } +}; + void PSPromotionManager::restore_preserved_marks() { - _preserved_marks_set->restore(PSScavenge::gc_task_manager()); + PSRestorePreservedMarksTaskExecutor task_executor(PSScavenge::gc_task_manager()); + _preserved_marks_set->restore(&task_executor); } void PSPromotionManager::drain_stacks_depth(bool totally_drain) { diff --git a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp index c8d3e0f3894..a10a9f18c62 100644 --- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp @@ -739,7 +739,8 @@ void DefNewGeneration::remove_forwarding_pointers() { eden()->object_iterate(&rspc); from()->object_iterate(&rspc); - _preserved_marks_set.restore(GenCollectedHeap::heap()->workers()); + SharedRestorePreservedMarksTaskExecutor task_executor(GenCollectedHeap::heap()->workers()); + _preserved_marks_set.restore(&task_executor); } void DefNewGeneration::handle_promotion_failure(oop old) { diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp index 9312c198483..5f7381efa65 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp @@ -28,9 +28,6 @@ #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/parallel/gcTaskManager.hpp" -#endif void PreservedMarks::restore() { while (!_stack.is_empty()) { @@ -40,6 +37,15 @@ void PreservedMarks::restore() { assert_empty(); } +void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) { + const size_t stack_size = size(); + restore(); + // Only do the atomic add if the size is > 0. + if (stack_size > 0) { + Atomic::add(stack_size, total_size_addr); + } +} + #ifndef PRODUCT void PreservedMarks::assert_empty() { assert(_stack.is_empty(), "stack expected to be empty, size = "SIZE_FORMAT, @@ -82,13 +88,7 @@ public: virtual void work(uint worker_id) { uint task_id = 0; while (!_sub_tasks.is_task_claimed(/* reference */ task_id)) { - PreservedMarks* const preserved_marks = _preserved_marks_set->get(task_id); - const size_t size = preserved_marks->size(); - preserved_marks->restore(); - // Only do the atomic add if the size is > 0. - if (size > 0) { - Atomic::add(size, _total_size_addr); - } + _preserved_marks_set->get(task_id)->restore_and_increment(_total_size_addr); } _sub_tasks.all_tasks_completed(); } @@ -104,53 +104,6 @@ public: } }; -void PreservedMarksSet::restore_internal(WorkGang* workers, - volatile size_t* total_size_addr) { - assert(workers != NULL, "pre-condition"); - ParRestoreTask task(workers->active_workers(), this, total_size_addr); - workers->run_task(&task); -} - -#if INCLUDE_ALL_GCS -class ParRestoreGCTask : public GCTask { -private: - const uint _id; - PreservedMarksSet* const _preserved_marks_set; - volatile size_t* const _total_size_addr; - -public: - virtual char* name() { return (char*) "preserved mark restoration task"; } - - virtual void do_it(GCTaskManager* manager, uint which) { - PreservedMarks* const preserved_marks = _preserved_marks_set->get(_id); - const size_t size = preserved_marks->size(); - preserved_marks->restore(); - // Only do the atomic add if the size is > 0. - if (size > 0) { - Atomic::add(size, _total_size_addr); - } - } - - ParRestoreGCTask(uint id, - PreservedMarksSet* preserved_marks_set, - volatile size_t* total_size_addr) - : _id(id), - _preserved_marks_set(preserved_marks_set), - _total_size_addr(total_size_addr) { } -}; - -void PreservedMarksSet::restore_internal(GCTaskManager* gc_task_manager, - volatile size_t* total_size_addr) { - // GCTask / GCTaskQueue are ResourceObjs - ResourceMark rm; - - GCTaskQueue* q = GCTaskQueue::create(); - for (uint i = 0; i < num(); i += 1) { - q->enqueue(new ParRestoreGCTask(i, this, total_size_addr)); - } - gc_task_manager->execute_and_wait(q); -} -#endif void PreservedMarksSet::reclaim() { assert_empty(); @@ -176,3 +129,16 @@ void PreservedMarksSet::assert_empty() { } } #endif // ndef PRODUCT + +void SharedRestorePreservedMarksTaskExecutor::restore(PreservedMarksSet* preserved_marks_set, + volatile size_t* total_size_addr) { + if (_workers == NULL) { + for (uint i = 0; i < preserved_marks_set->num(); i += 1) { + total_size_addr += preserved_marks_set->get(i)->size(); + preserved_marks_set->get(i)->restore(); + } + } else { + ParRestoreTask task(_workers->active_workers(), preserved_marks_set, total_size_addr); + _workers->run_task(&task); + } +} diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp index 3c8ebd87cab..29fe7af25f7 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp @@ -30,7 +30,7 @@ #include "oops/oop.hpp" #include "utilities/stack.hpp" -class GCTaskManager; +class PreservedMarksSet; class WorkGang; class PreservedMarks VALUE_OBJ_CLASS_SPEC { @@ -61,6 +61,7 @@ public: // reclaim the memory taken up by the stack segments. void restore(); + void restore_and_increment(volatile size_t* const _total_size_addr); inline static void init_forwarded_mark(oop obj); // Assert the stack is empty and has no cached segments. @@ -75,6 +76,24 @@ public: virtual void do_object(oop obj); }; +class RestorePreservedMarksTaskExecutor { +public: + void virtual restore(PreservedMarksSet* preserved_marks_set, + volatile size_t* total_size_addr) = 0; +}; + +class SharedRestorePreservedMarksTaskExecutor : public RestorePreservedMarksTaskExecutor { +private: + WorkGang* _workers; + +public: + SharedRestorePreservedMarksTaskExecutor(WorkGang* workers) : _workers(workers) { } + + void restore(PreservedMarksSet* preserved_marks_set, + volatile size_t* total_size_addr); + +}; + class PreservedMarksSet : public CHeapObj { private: // true -> _stacks will be allocated in the C heap @@ -91,13 +110,6 @@ private: // or == NULL if they have not. Padded* _stacks; - // Internal version of restore() that uses a WorkGang for parallelism. - void restore_internal(WorkGang* workers, volatile size_t* total_size_addr); - - // Internal version of restore() that uses a GCTaskManager for parallelism. - void restore_internal(GCTaskManager* gc_task_manager, - volatile size_t* total_size_addr); - public: uint num() const { return _num; } @@ -111,14 +123,11 @@ public: // Allocate stack array. void init(uint num); - // Itrerate over all stacks, restore all presered marks, and reclaim - // the memory taken up by the stack segments. If the executor is - // NULL, restoration will be done serially. If the executor is not - // NULL, restoration could be done in parallel (when it makes - // sense). Supported executors: WorkGang (Serial, CMS, G1), - // GCTaskManager (PS). - template - inline void restore(E* executor); + // Iterate over all stacks, restore all preserved marks, and reclaim + // the memory taken up by the stack segments. + // Supported executors: SharedRestorePreservedMarksTaskExecutor (Serial, CMS, G1), + // PSRestorePreservedMarksTaskExecutor (PS). + inline void restore(RestorePreservedMarksTaskExecutor* executor); // Reclaim stack array. void reclaim(); diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.inline.hpp b/hotspot/src/share/vm/gc/shared/preservedMarks.inline.hpp index fc1039ad40b..7ed933002d8 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.inline.hpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.inline.hpp @@ -49,8 +49,7 @@ inline void PreservedMarks::init_forwarded_mark(oop obj) { obj->init_mark(); } -template -inline void PreservedMarksSet::restore(E* executor) { +inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) { volatile size_t total_size = 0; #ifdef ASSERT @@ -61,17 +60,7 @@ inline void PreservedMarksSet::restore(E* executor) { } #endif // def ASSERT - if (executor == NULL) { - for (uint i = 0; i < _num; i += 1) { - total_size += get(i)->size(); - get(i)->restore(); - } - } else { - // Right now, if the executor is not NULL we do the work in - // parallel. In the future we might want to do the restoration - // serially, if there's only a small number of marks per stack. - restore_internal(executor, &total_size); - } + executor->restore(this, &total_size); assert_empty(); assert(total_size == total_size_before, From 59e58442196a75e81c67c50d1b92172e72581c70 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 8 Jun 2016 16:07:49 +0200 Subject: [PATCH 043/191] 8159056: [aix] Compressed class space not allocated in lower regions Reviewed-by: dholmes, enevill --- hotspot/src/share/vm/memory/metaspace.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index aa04201ad2e..a87292241b1 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -2933,7 +2933,7 @@ void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, a // Don't use large pages for the class space. bool large_pages = false; -#ifndef AARCH64 +#if !(defined(AARCH64) || defined(AIX)) ReservedSpace metaspace_rs = ReservedSpace(compressed_class_space_size(), _reserve_alignment, large_pages, @@ -2945,18 +2945,25 @@ void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, a // bits. if ((uint64_t)requested_addr + compressed_class_space_size() < 4*G) { metaspace_rs = ReservedSpace(compressed_class_space_size(), - _reserve_alignment, - large_pages, - requested_addr); + _reserve_alignment, + large_pages, + requested_addr); } if (! metaspace_rs.is_reserved()) { - // Try to align metaspace so that we can decode a compressed klass - // with a single MOVK instruction. We can do this iff the + // Aarch64: Try to align metaspace so that we can decode a compressed + // klass with a single MOVK instruction. We can do this iff the // compressed class base is a multiple of 4G. - for (char *a = (char*)align_ptr_up(requested_addr, 4*G); + // Aix: Search for a place where we can find memory. If we need to load + // the base, 4G alignment is helpful, too. + size_t increment = AARCH64_ONLY(4*)G; + for (char *a = (char*)align_ptr_up(requested_addr, increment); a < (char*)(1024*G); - a += 4*G) { + a += increment) { + if (a == (char *)(32*G)) { + // Go faster from here on. Zero-based is no longer possible. + increment = 4*G; + } #if INCLUDE_CDS if (UseSharedSpaces From 62a2685b4b07dca639d35e499b458d0e192c4dee Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 10 Jun 2016 02:43:53 +0000 Subject: [PATCH 044/191] 8158351: [JVMCI] NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI Reviewed-by: kvn, vlivanov --- .../jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java index d1ed7a11737..20177c3de6c 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java @@ -27,7 +27,8 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches - * @modules java.base/jdk.internal.org.objectweb.asm + * @modules java.base/jdk.internal.misc + java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code From d019f340778f5513b705ae4533b1156dd339be12 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 10 Jun 2016 14:06:36 +0200 Subject: [PATCH 045/191] 8159237: PreservedMarks verification code fails Reviewed-by: lmesnik, jwilhelm --- hotspot/src/share/vm/gc/shared/preservedMarks.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp index 5f7381efa65..7a1078ebb34 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp @@ -131,10 +131,10 @@ void PreservedMarksSet::assert_empty() { #endif // ndef PRODUCT void SharedRestorePreservedMarksTaskExecutor::restore(PreservedMarksSet* preserved_marks_set, - volatile size_t* total_size_addr) { + volatile size_t* total_size_addr) { if (_workers == NULL) { for (uint i = 0; i < preserved_marks_set->num(); i += 1) { - total_size_addr += preserved_marks_set->get(i)->size(); + *total_size_addr += preserved_marks_set->get(i)->size(); preserved_marks_set->get(i)->restore(); } } else { From 35ba62637ef1a831486ff414eae52b8ab1f7c763 Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Fri, 10 Jun 2016 09:22:09 -0700 Subject: [PATCH 046/191] 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC Reviewed-by: sjohanss, sangheki --- .../gc/cms/concurrentMarkSweepGeneration.cpp | 3 + hotspot/src/share/vm/prims/whitebox.cpp | 5 ++ .../gc/metaspace/TestMetaspaceCMSCancel.java | 70 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 hotspot/test/gc/metaspace/TestMetaspaceCMSCancel.java diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp index bf11ad86915..1df96bd5826 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp @@ -1605,6 +1605,9 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) { _inter_sweep_timer.reset(); _inter_sweep_timer.start(); + // No longer a need to do a concurrent collection for Metaspace. + MetaspaceGC::set_should_concurrent_collect(false); + gch->post_full_gc_dump(gc_timer); gc_timer->register_gc_end(); diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index a55fd6340c6..e1a83af6739 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -1433,6 +1433,10 @@ WB_ENTRY(jlong, WB_MetaspaceCapacityUntilGC(JNIEnv* env, jobject wb)) return (jlong) MetaspaceGC::capacity_until_GC(); WB_END +WB_ENTRY(jboolean, WB_MetaspaceShouldConcurrentCollect(JNIEnv* env, jobject wb)) + return MetaspaceGC::should_concurrent_collect(); +WB_END + WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue)) Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ? @@ -1813,6 +1817,7 @@ static JNINativeMethod methods[] = { CC"(Ljava/lang/ClassLoader;JJ)V", (void*)&WB_FreeMetaspace }, {CC"incMetaspaceCapacityUntilGC", CC"(J)J", (void*)&WB_IncMetaspaceCapacityUntilGC }, {CC"metaspaceCapacityUntilGC", CC"()J", (void*)&WB_MetaspaceCapacityUntilGC }, + {CC"metaspaceShouldConcurrentCollect", CC"()Z", (void*)&WB_MetaspaceShouldConcurrentCollect }, {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures }, {CC"getNMethod0", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;", (void*)&WB_GetNMethod }, diff --git a/hotspot/test/gc/metaspace/TestMetaspaceCMSCancel.java b/hotspot/test/gc/metaspace/TestMetaspaceCMSCancel.java new file mode 100644 index 00000000000..42357ff03dd --- /dev/null +++ b/hotspot/test/gc/metaspace/TestMetaspaceCMSCancel.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016, 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. + */ +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.Asserts; +import sun.hotspot.WhiteBox; + +/* @test TestMetaspaceCMSCancel + * @bug 8026752 + * @summary Tests cancel of CMS concurrent cycle for Metaspace after a full GC + * @library /testlibrary /test/lib /test/lib/share/classes + * @modules java.base/jdk.internal.misc + * @build TestMetaspaceCMSCancel + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm TestMetaspaceCMSCancel + */ + + +public class TestMetaspaceCMSCancel { + + public static void main(String[] args) throws Exception { + // Set a small MetaspaceSize so that a CMS concurrent collection will be + // scheduled. Set CMSWaitDuration to 5s so that the concurrent collection + // start may be delayed. It does not guarantee 5s before the start of the + // concurrent collection but does increase the probability that it will + // be started later. System.gc() is used to invoke a full collection. Set + // ExplicitGCInvokesConcurrent to off so it is a STW collection. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:+UseConcMarkSweepGC", + "-XX:MetaspaceSize=2m", + "-XX:CMSWaitDuration=5000", + "-XX:-ExplicitGCInvokesConcurrent", + "-Xlog:gc*=debug", + MetaspaceGCTest.class.getName()); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Concurrent Reset"); + output.shouldHaveExitValue(0); + } + + static class MetaspaceGCTest { + public static void main(String [] args) { + WhiteBox wb = WhiteBox.getWhiteBox(); + System.gc(); + Asserts.assertFalse(wb.metaspaceShouldConcurrentCollect()); + } + } +} From 08962e6714b7f50d44aaa57ca219cae2488a80ec Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Thu, 19 May 2016 14:53:18 -0700 Subject: [PATCH 047/191] 8157373: Active workers should not be reset in AbstractWorkGang initialize() Reviewed-by: kbarrett, tschatzl, jwilhelm --- hotspot/src/share/vm/gc/shared/workgroup.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/workgroup.cpp b/hotspot/src/share/vm/gc/shared/workgroup.cpp index f53285d9b26..053c8a1b8cf 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.cpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp @@ -44,11 +44,6 @@ void AbstractWorkGang::initialize_workers() { vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array."); } - _active_workers = ParallelGCThreads; - if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) { - _active_workers = 1U; - } - add_workers(true); } From 93043ecb8f90c20bfe7d3582032a7c8a14adc3aa Mon Sep 17 00:00:00 2001 From: Cheleswer Sahu Date: Tue, 24 May 2016 16:02:45 +0530 Subject: [PATCH 048/191] 8150900: Implement diagnostic_pd Reviewed-by: twisti, gziemski, kevinw --- hotspot/src/os/aix/vm/globals_aix.hpp | 1 + hotspot/src/os/bsd/vm/globals_bsd.hpp | 1 + hotspot/src/os/linux/vm/globals_linux.hpp | 1 + hotspot/src/os/solaris/vm/globals_solaris.hpp | 1 + hotspot/src/os/windows/vm/globals_windows.hpp | 1 + hotspot/src/share/vm/c1/c1_globals.cpp | 1 + hotspot/src/share/vm/c1/c1_globals.hpp | 2 ++ hotspot/src/share/vm/gc/g1/g1_globals.cpp | 1 + hotspot/src/share/vm/gc/g1/g1_globals.hpp | 2 ++ hotspot/src/share/vm/jvmci/jvmci_globals.cpp | 7 +++++++ hotspot/src/share/vm/jvmci/jvmci_globals.hpp | 2 ++ hotspot/src/share/vm/opto/c2_globals.cpp | 1 + hotspot/src/share/vm/opto/c2_globals.hpp | 4 +++- .../runtime/commandLineFlagConstraintList.cpp | 5 +++++ .../vm/runtime/commandLineFlagRangeList.cpp | 6 ++++++ .../runtime/commandLineFlagWriteableList.cpp | 6 ++++++ hotspot/src/share/vm/runtime/globals.cpp | 14 +++++++++++++ hotspot/src/share/vm/runtime/globals.hpp | 11 +++++++--- .../share/vm/runtime/globals_extension.hpp | 20 +++++++++++++++++++ hotspot/src/share/vm/shark/shark_globals.hpp | 7 ++++--- 20 files changed, 87 insertions(+), 7 deletions(-) diff --git a/hotspot/src/os/aix/vm/globals_aix.hpp b/hotspot/src/os/aix/vm/globals_aix.hpp index 21f250bd161..8f42e1305fe 100644 --- a/hotspot/src/os/aix/vm/globals_aix.hpp +++ b/hotspot/src/os/aix/vm/globals_aix.hpp @@ -35,6 +35,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff --git a/hotspot/src/os/bsd/vm/globals_bsd.hpp b/hotspot/src/os/bsd/vm/globals_bsd.hpp index f3b076e825e..237a7e2c8e1 100644 --- a/hotspot/src/os/bsd/vm/globals_bsd.hpp +++ b/hotspot/src/os/bsd/vm/globals_bsd.hpp @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff --git a/hotspot/src/os/linux/vm/globals_linux.hpp b/hotspot/src/os/linux/vm/globals_linux.hpp index 39bedf3ff59..0b119908479 100644 --- a/hotspot/src/os/linux/vm/globals_linux.hpp +++ b/hotspot/src/os/linux/vm/globals_linux.hpp @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff --git a/hotspot/src/os/solaris/vm/globals_solaris.hpp b/hotspot/src/os/solaris/vm/globals_solaris.hpp index b3e2e34a314..685fd4f5c4c 100644 --- a/hotspot/src/os/solaris/vm/globals_solaris.hpp +++ b/hotspot/src/os/solaris/vm/globals_solaris.hpp @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff --git a/hotspot/src/os/windows/vm/globals_windows.hpp b/hotspot/src/os/windows/vm/globals_windows.hpp index 3d831ec1257..1c374e8a520 100644 --- a/hotspot/src/os/windows/vm/globals_windows.hpp +++ b/hotspot/src/os/windows/vm/globals_windows.hpp @@ -33,6 +33,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ diff --git a/hotspot/src/share/vm/c1/c1_globals.cpp b/hotspot/src/share/vm/c1/c1_globals.cpp index 58bd059520f..77e3dd61237 100644 --- a/hotspot/src/share/vm/c1/c1_globals.cpp +++ b/hotspot/src/share/vm/c1/c1_globals.cpp @@ -30,6 +30,7 @@ C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index a1e8ce45655..a7a0f2eb33d 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -65,6 +65,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ notproduct, \ range, \ constraint, \ @@ -356,6 +357,7 @@ C1_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.cpp b/hotspot/src/share/vm/gc/g1/g1_globals.cpp index 0b25b03f2b2..1b7fa792eb4 100644 --- a/hotspot/src/share/vm/gc/g1/g1_globals.cpp +++ b/hotspot/src/share/vm/gc/g1/g1_globals.cpp @@ -30,6 +30,7 @@ G1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ MATERIALIZE_MANAGEABLE_FLAG, \ diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.hpp b/hotspot/src/share/vm/gc/g1/g1_globals.hpp index 3abcba4df9e..e2e7a3bb2b2 100644 --- a/hotspot/src/share/vm/gc/g1/g1_globals.hpp +++ b/hotspot/src/share/vm/gc/g1/g1_globals.hpp @@ -36,6 +36,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ manageable, \ @@ -323,6 +324,7 @@ G1_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ DECLARE_MANAGEABLE_FLAG, \ diff --git a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp index 2b2155a969a..12dd0c1eeca 100644 --- a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp +++ b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp @@ -32,6 +32,7 @@ JVMCI_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, IGNORE_RANGE, \ @@ -89,6 +90,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_DIAGNOSTIC_FLAG_VALUE_CHANGED_CHECK_CODE, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -104,6 +106,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_EXPERIMENTAL_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -129,6 +132,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { JVMCI_PRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_PD_PRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_NOTPRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ IGNORE_RANGE, \ @@ -168,6 +172,7 @@ void JVMCIGlobals::print_jvmci_args_inconsistency_error_message() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_DIAGNOSTIC_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -181,6 +186,7 @@ void JVMCIGlobals::print_jvmci_args_inconsistency_error_message() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_EXPERIMENTAL_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ @@ -206,6 +212,7 @@ void JVMCIGlobals::print_jvmci_args_inconsistency_error_message() { JVMCI_PRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_PD_PRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ + JVMCI_IGNORE_FLAG_THREE_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_NOTPRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ IGNORE_RANGE, \ diff --git a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp index d42e09cc0b1..0a19e616e2a 100644 --- a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp +++ b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp @@ -37,6 +37,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ range, \ @@ -102,6 +103,7 @@ JVMCI_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ diff --git a/hotspot/src/share/vm/opto/c2_globals.cpp b/hotspot/src/share/vm/opto/c2_globals.cpp index d0a1bae95aa..4b3aab044cb 100644 --- a/hotspot/src/share/vm/opto/c2_globals.cpp +++ b/hotspot/src/share/vm/opto/c2_globals.cpp @@ -30,6 +30,7 @@ C2_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index 9b276301cda..83229dd7b27 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -66,6 +66,7 @@ product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ range, \ @@ -203,7 +204,7 @@ "Map number of unrolls for main loop via " \ "Superword Level Parallelism analysis") \ \ - product_pd(bool, PostLoopMultiversioning, \ + diagnostic_pd(bool, PostLoopMultiversioning, \ "Multi versioned post loops to eliminate range checks") \ \ notproduct(bool, TraceSuperWordLoopUnrollAnalysis, false, \ @@ -764,6 +765,7 @@ C2_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp index 27d7a3291ba..005222962b9 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp @@ -211,6 +211,7 @@ void emit_constraint_double(const char* name, CommandLineFlagConstraintFunc_doub #define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name +#define EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name @@ -233,6 +234,7 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, EMIT_CONSTRAINT_MANAGEABLE_FLAG, @@ -260,6 +262,7 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, EMIT_CONSTRAINT_CHECK, @@ -272,6 +275,7 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, @@ -285,6 +289,7 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_PRODUCT_FLAG, EMIT_CONSTRAINT_PD_PRODUCT_FLAG, EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, EMIT_CONSTRAINT_MANAGEABLE_FLAG, diff --git a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp index ba9d8f11358..b6cc08e4f60 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp @@ -278,6 +278,7 @@ void emit_range_double(const char* name, double min, double max) { #define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_range_##type(#name #define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_range_##type(#name #define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc) ); emit_range_##type(#name +#define EMIT_RANGE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_range_##type(#name #define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc) ); emit_range_##type(#name #define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_range_##type(#name #define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name @@ -299,6 +300,7 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_MANAGEABLE_FLAG, @@ -325,6 +327,7 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, @@ -338,6 +341,7 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, IGNORE_CONSTRAINT, @@ -350,6 +354,7 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, @@ -363,6 +368,7 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_PRODUCT_FLAG, EMIT_RANGE_PD_PRODUCT_FLAG, EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_MANAGEABLE_FLAG, diff --git a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp index 51b0117d8d7..3f760692799 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp @@ -108,6 +108,7 @@ void emit_writeable_double(const char* name, CommandLineFlagWriteable::Writeable #define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name #define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name @@ -126,6 +127,7 @@ void CommandLineFlagWriteableList::init(void) { EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, EMIT_WRITEABLE_MANAGEABLE_FLAG, @@ -152,6 +154,7 @@ void CommandLineFlagWriteableList::init(void) { EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, IGNORE_RANGE, @@ -165,6 +168,7 @@ void CommandLineFlagWriteableList::init(void) { EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, IGNORE_RANGE, IGNORE_CONSTRAINT, @@ -177,6 +181,7 @@ void CommandLineFlagWriteableList::init(void) { EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, IGNORE_RANGE, @@ -190,6 +195,7 @@ void CommandLineFlagWriteableList::init(void) { EMIT_WRITEABLE_PRODUCT_FLAG, EMIT_WRITEABLE_PD_PRODUCT_FLAG, EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, EMIT_WRITEABLE_EXPERIMENTAL_FLAG, EMIT_WRITEABLE_NOTPRODUCT_FLAG, EMIT_WRITEABLE_MANAGEABLE_FLAG, diff --git a/hotspot/src/share/vm/runtime/globals.cpp b/hotspot/src/share/vm/runtime/globals.cpp index 06742212f19..c878da34740 100644 --- a/hotspot/src/share/vm/runtime/globals.cpp +++ b/hotspot/src/share/vm/runtime/globals.cpp @@ -58,6 +58,7 @@ RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ MATERIALIZE_MANAGEABLE_FLAG, \ @@ -72,6 +73,7 @@ RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ MATERIALIZE_PD_PRODUCT_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_PD_DIAGNOSTIC_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -650,6 +652,7 @@ const char* Flag::flag_error_str(Flag::Error error) { #define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) }, #define RUNTIME_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) }, +#define RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) }, #define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) }, #define RUNTIME_PRODUCT_RW_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_READ_WRITE) }, @@ -660,6 +663,7 @@ const char* Flag::flag_error_str(Flag::Error error) { #define JVMCI_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT) }, #define JVMCI_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define JVMCI_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DIAGNOSTIC) }, +#define JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define JVMCI_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_EXPERIMENTAL) }, #define JVMCI_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP) }, #define JVMCI_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, @@ -674,6 +678,7 @@ const char* Flag::flag_error_str(Flag::Error error) { #define C1_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT) }, #define C1_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC) }, +#define C1_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP) }, #define C1_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_NOT_PRODUCT) }, @@ -681,6 +686,7 @@ const char* Flag::flag_error_str(Flag::Error error) { #define C2_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT) }, #define C2_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define C2_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC) }, +#define C2_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define C2_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_EXPERIMENTAL) }, #define C2_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP) }, #define C2_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, @@ -695,6 +701,7 @@ const char* Flag::flag_error_str(Flag::Error error) { #define SHARK_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT) }, #define SHARK_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, #define SHARK_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DIAGNOSTIC) }, +#define SHARK_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) }, #define SHARK_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP) }, #define SHARK_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, #define SHARK_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_NOT_PRODUCT) }, @@ -705,6 +712,7 @@ static Flag flagTable[] = { RUNTIME_PRODUCT_FLAG_STRUCT, \ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ RUNTIME_MANAGEABLE_FLAG_STRUCT, \ @@ -718,6 +726,7 @@ static Flag flagTable[] = { RUNTIME_PRODUCT_FLAG_STRUCT, \ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -728,6 +737,7 @@ static Flag flagTable[] = { RUNTIME_PRODUCT_FLAG_STRUCT, \ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ RUNTIME_MANAGEABLE_FLAG_STRUCT, \ @@ -742,6 +752,7 @@ static Flag flagTable[] = { JVMCI_PRODUCT_FLAG_STRUCT, \ JVMCI_PD_PRODUCT_FLAG_STRUCT, \ JVMCI_DIAGNOSTIC_FLAG_STRUCT, \ + JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT, \ JVMCI_EXPERIMENTAL_FLAG_STRUCT, \ JVMCI_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ @@ -754,6 +765,7 @@ static Flag flagTable[] = { C1_PRODUCT_FLAG_STRUCT, \ C1_PD_PRODUCT_FLAG_STRUCT, \ C1_DIAGNOSTIC_FLAG_STRUCT, \ + C1_PD_DIAGNOSTIC_FLAG_STRUCT, \ C1_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -765,6 +777,7 @@ static Flag flagTable[] = { C2_PRODUCT_FLAG_STRUCT, \ C2_PD_PRODUCT_FLAG_STRUCT, \ C2_DIAGNOSTIC_FLAG_STRUCT, \ + C2_PD_DIAGNOSTIC_FLAG_STRUCT, \ C2_EXPERIMENTAL_FLAG_STRUCT, \ C2_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ @@ -777,6 +790,7 @@ static Flag flagTable[] = { SHARK_PRODUCT_FLAG_STRUCT, \ SHARK_PD_PRODUCT_FLAG_STRUCT, \ SHARK_DIAGNOSTIC_FLAG_STRUCT, \ + SHARK_PD_DIAGNOSTIC_FLAG_STRUCT, \ SHARK_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 54cd9c01956..e72826b7df6 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -644,6 +644,7 @@ public: product, \ product_pd, \ diagnostic, \ + diagnostic_pd, \ experimental, \ notproduct, \ manageable, \ @@ -2529,7 +2530,7 @@ public: develop(bool, GenerateRangeChecks, true, \ "Generate range checks for array accesses") \ \ - develop_pd(bool, ImplicitNullChecks, \ + diagnostic_pd(bool, ImplicitNullChecks, \ "Generate code for implicit null checks") \ \ product_pd(bool, TrapBasedNullChecks, \ @@ -3163,7 +3164,7 @@ public: "Ratio of call site execution to caller method invocation") \ range(0, max_jint) \ \ - develop_pd(intx, InlineFrequencyCount, \ + diagnostic_pd(intx, InlineFrequencyCount, \ "Count of call site execution necessary to trigger frequent " \ "inlining") \ range(0, max_jint) \ @@ -4144,7 +4145,7 @@ public: "in the loaded class C. " \ "Check (3) is available only in debug builds.") \ \ - develop_pd(intx, InitArrayShortSize, \ + diagnostic_pd(intx, InitArrayShortSize, \ "Threshold small size (in bytes) for clearing arrays. " \ "Anything this size or smaller may get converted to discrete " \ "scalar stores.") \ @@ -4168,6 +4169,7 @@ public: #define DECLARE_PRODUCT_FLAG(type, name, value, doc) extern "C" type name; #define DECLARE_PD_PRODUCT_FLAG(type, name, doc) extern "C" type name; #define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name; +#define DECLARE_PD_DIAGNOSTIC_FLAG(type, name, doc) extern "C" type name; #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name; #define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name; #define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name; @@ -4191,6 +4193,7 @@ public: #define MATERIALIZE_PRODUCT_FLAG(type, name, value, doc) type name = value; #define MATERIALIZE_PD_PRODUCT_FLAG(type, name, doc) type name = pd_##name; #define MATERIALIZE_DIAGNOSTIC_FLAG(type, name, value, doc) type name = value; +#define MATERIALIZE_PD_DIAGNOSTIC_FLAG(type, name, doc) type name = pd_##name; #define MATERIALIZE_EXPERIMENTAL_FLAG(type, name, value, doc) type name = value; #define MATERIALIZE_MANAGEABLE_FLAG(type, name, value, doc) type name = value; #define MATERIALIZE_PRODUCT_RW_FLAG(type, name, value, doc) type name = value; @@ -4221,6 +4224,7 @@ RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ DECLARE_MANAGEABLE_FLAG, \ @@ -4235,6 +4239,7 @@ RUNTIME_OS_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ DECLARE_PD_PRODUCT_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ + DECLARE_PD_DIAGNOSTIC_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ diff --git a/hotspot/src/share/vm/runtime/globals_extension.hpp b/hotspot/src/share/vm/runtime/globals_extension.hpp index 810fcd7a73f..881d3eff258 100644 --- a/hotspot/src/share/vm/runtime/globals_extension.hpp +++ b/hotspot/src/share/vm/runtime/globals_extension.hpp @@ -49,6 +49,7 @@ #define RUNTIME_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define RUNTIME_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define RUNTIME_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define RUNTIME_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define RUNTIME_MANAGEABLE_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define RUNTIME_PRODUCT_RW_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), @@ -61,6 +62,7 @@ #define JVMCI_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define JVMCI_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define JVMCI_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define JVMCI_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define JVMCI_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), @@ -73,6 +75,7 @@ #define C1_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C1_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define C1_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C1_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), @@ -80,6 +83,7 @@ #define C2_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C2_DIAGNOSTIC_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define C2_PD_DIAGNOSTIC_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C2_EXPERIMENTAL_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), @@ -97,6 +101,7 @@ typedef enum { RUNTIME_PRODUCT_FLAG_MEMBER, \ RUNTIME_PD_PRODUCT_FLAG_MEMBER, \ RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_EXPERIMENTAL_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ RUNTIME_MANAGEABLE_FLAG_MEMBER, \ @@ -110,6 +115,7 @@ typedef enum { RUNTIME_PRODUCT_FLAG_MEMBER, \ RUNTIME_PD_PRODUCT_FLAG_MEMBER, \ RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -120,6 +126,7 @@ typedef enum { RUNTIME_PRODUCT_FLAG_MEMBER, \ RUNTIME_PD_PRODUCT_FLAG_MEMBER, \ RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_EXPERIMENTAL_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ RUNTIME_MANAGEABLE_FLAG_MEMBER, \ @@ -134,6 +141,7 @@ typedef enum { JVMCI_PRODUCT_FLAG_MEMBER, \ JVMCI_PD_PRODUCT_FLAG_MEMBER, \ JVMCI_DIAGNOSTIC_FLAG_MEMBER, \ + JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER, \ JVMCI_EXPERIMENTAL_FLAG_MEMBER, \ JVMCI_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ @@ -146,6 +154,7 @@ typedef enum { C1_PRODUCT_FLAG_MEMBER, \ C1_PD_PRODUCT_FLAG_MEMBER, \ C1_DIAGNOSTIC_FLAG_MEMBER, \ + C1_PD_DIAGNOSTIC_FLAG_MEMBER, \ C1_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ IGNORE_CONSTRAINT, \ @@ -157,6 +166,7 @@ typedef enum { C2_PRODUCT_FLAG_MEMBER, \ C2_PD_PRODUCT_FLAG_MEMBER, \ C2_DIAGNOSTIC_FLAG_MEMBER, \ + C2_PD_DIAGNOSTIC_FLAG_MEMBER, \ C2_EXPERIMENTAL_FLAG_MEMBER, \ C2_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ @@ -182,6 +192,7 @@ typedef enum { #define RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -194,12 +205,14 @@ typedef enum { #define JVMCI_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define C1_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -213,6 +226,7 @@ typedef enum { #define C2_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define C2_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C2_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -230,6 +244,7 @@ typedef enum { RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE, @@ -243,6 +258,7 @@ typedef enum { RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, IGNORE_CONSTRAINT, @@ -253,6 +269,7 @@ typedef enum { RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + RUNTIME_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE, @@ -267,6 +284,7 @@ typedef enum { JVMCI_PRODUCT_FLAG_MEMBER_WITH_TYPE, JVMCI_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, JVMCI_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + JVMCI_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, JVMCI_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, @@ -279,6 +297,7 @@ typedef enum { C1_PRODUCT_FLAG_MEMBER_WITH_TYPE, C1_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + C1_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, IGNORE_CONSTRAINT, @@ -290,6 +309,7 @@ typedef enum { C2_PRODUCT_FLAG_MEMBER_WITH_TYPE, C2_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, C2_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, + C2_PD_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, diff --git a/hotspot/src/share/vm/shark/shark_globals.hpp b/hotspot/src/share/vm/shark/shark_globals.hpp index 9ab174d654b..1c33fd31384 100644 --- a/hotspot/src/share/vm/shark/shark_globals.hpp +++ b/hotspot/src/share/vm/shark/shark_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,7 @@ # include "shark_globals_zero.hpp" #endif -#define SHARK_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct) \ +#define SHARK_FLAGS(develop, develop_pd, product, product_pd, diagnostic, diagnostic_pd, notproduct) \ \ product(intx, MaxNodeLimit, 65000, \ "Maximum number of nodes") \ @@ -69,6 +69,7 @@ "Runs LLVM verify over LLVM IR") \ -SHARK_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_NOTPRODUCT_FLAG) +SHARK_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_PD_DIAGNOSTIC_FLAG, + DECLARE_NOTPRODUCT_FLAG) #endif // SHARE_VM_SHARK_SHARK_GLOBALS_HPP From de17002b7c423d938b35521516146cc1b3585f54 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Mon, 6 Jun 2016 16:18:01 -0700 Subject: [PATCH 049/191] 8156587: [JVMCI] remove Unsafe.getJavaMirror and Unsafe.getKlassPointer Reviewed-by: kvn --- .../classes/jdk/internal/misc/Unsafe.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index f4e11a3378a..77bdf2db106 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -318,24 +318,6 @@ public final class Unsafe { */ public native Object getUncompressedObject(long address); - /** - * Fetches the {@link java.lang.Class} Java mirror for the given native - * metaspace {@code Klass} pointer. - * - * @param metaspaceKlass a native metaspace {@code Klass} pointer - * @return the {@link java.lang.Class} Java mirror - */ - public native Class getJavaMirror(long metaspaceKlass); - - /** - * Fetches a native metaspace {@code Klass} pointer for the given Java - * object. - * - * @param o Java heap object for which to fetch the class pointer - * @return a native metaspace {@code Klass} pointer - */ - public native long getKlassPointer(Object o); - // These work on values in the C heap. /** From 19c8ab3cdbfa0e36e13b31b522a709099f58cefd Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Wed, 8 Jun 2016 13:24:36 +0200 Subject: [PATCH 050/191] 8159045: Remove const from methods returning size_t in threadLocalAllocBuffer.hpp Reviewed-by: sjohanss, jmasa --- hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp index 1ee892e8469..5edda5a834f 100644 --- a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp +++ b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp @@ -108,9 +108,9 @@ public: // do nothing. tlabs must be inited by initialize() calls } - static const size_t min_size() { return align_object_size(MinTLABSize / HeapWordSize) + alignment_reserve(); } - static const size_t max_size() { assert(_max_size != 0, "max_size not set up"); return _max_size; } - static const size_t max_size_in_bytes() { return max_size() * BytesPerWord; } + static size_t min_size() { return align_object_size(MinTLABSize / HeapWordSize) + alignment_reserve(); } + static size_t max_size() { assert(_max_size != 0, "max_size not set up"); return _max_size; } + static size_t max_size_in_bytes() { return max_size() * BytesPerWord; } static void set_max_size(size_t max_size) { _max_size = max_size; } HeapWord* start() const { return _start; } From 8bb3799029d34e7f5bbc3d9e5bc6da7068360bc7 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 9 Jun 2016 15:17:18 +0200 Subject: [PATCH 051/191] 8159156: [TESTBUG] ReserveMemory test is not useful on Aix Reviewed-by: dholmes --- hotspot/test/runtime/memory/ReserveMemory.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/hotspot/test/runtime/memory/ReserveMemory.java b/hotspot/test/runtime/memory/ReserveMemory.java index b6fadfd0bcf..c9d80302174 100644 --- a/hotspot/test/runtime/memory/ReserveMemory.java +++ b/hotspot/test/runtime/memory/ReserveMemory.java @@ -21,10 +21,12 @@ * questions. */ +// Aix commits on touch, so this test won't work. /* * @test * @key regression * @bug 8012015 + * @requires !(os.family == "aix") * @summary Make sure reserved (but uncommitted) memory is not accessible * @library /testlibrary /test/lib * @modules java.base/jdk.internal.misc @@ -36,18 +38,11 @@ */ import jdk.test.lib.*; +import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; public class ReserveMemory { - private static boolean isWindows() { - return System.getProperty("os.name").toLowerCase().startsWith("win"); - } - - private static boolean isOsx() { - return System.getProperty("os.name").toLowerCase().startsWith("mac"); - } - public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().readReservedMemory(); @@ -66,9 +61,9 @@ public class ReserveMemory { "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - if (isWindows()) { + if (Platform.isWindows()) { output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); - } else if (isOsx()) { + } else if (Platform.isOSX()) { output.shouldContain("SIGBUS"); } else { output.shouldContain("SIGSEGV"); From 6223e843f9e43bbd442fe74927628a5c8d7e1fdb Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Mon, 27 Jun 2016 13:57:24 -0700 Subject: [PATCH 052/191] 8160312: ArrayIndexOutOfBoundsException when comparing strings case insensitive Reviewed-by: rriggs --- jdk/src/java.base/share/classes/java/lang/StringLatin1.java | 4 ++-- jdk/test/java/lang/String/CompareIC.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/StringLatin1.java b/jdk/src/java.base/share/classes/java/lang/StringLatin1.java index e4901dd69ad..b307bee6d46 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringLatin1.java +++ b/jdk/src/java.base/share/classes/java/lang/StringLatin1.java @@ -137,8 +137,8 @@ final class StringLatin1 { char c1 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(value, k)); char c2 = (char) CharacterDataLatin1.instance.toUpperCase(getChar(other, k)); if (c1 != c2) { - c1 = (char) CharacterDataLatin1.instance.toLowerCase(c1); - c2 = (char) CharacterDataLatin1.instance.toLowerCase(c2); + c1 = Character.toLowerCase(c1); + c2 = Character.toLowerCase(c2); if (c1 != c2) { return c1 - c2; } diff --git a/jdk/test/java/lang/String/CompareIC.java b/jdk/test/java/lang/String/CompareIC.java index da06ded3894..ebe3056c972 100644 --- a/jdk/test/java/lang/String/CompareIC.java +++ b/jdk/test/java/lang/String/CompareIC.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4124769 + * @bug 4124769 8160312 * @summary Test ignore-case comparison * */ @@ -45,6 +45,10 @@ public class CompareIC { comparer.testTriplet(test1, test2, test3); test2 = test2.toLowerCase(); comparer.testTriplet(test1, test2, test3); + + // toLowerCase -> non-latin1 + if ("\u00b5".compareToIgnoreCase("X") < 0) + throw new RuntimeException("Comparison failure1"); } private void testTriplet(String one, String two, String three) From a2ed88900265042ea00d534988fa21edca857e3d Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Tue, 28 Jun 2016 00:39:26 +0200 Subject: [PATCH 053/191] 8160000: Runtime.version() cause startup regressions in 9+119 Reviewed-by: mchung, psandoz, erikj, forax, iris --- jdk/make/gensrc/GensrcMisc.gmk | 6 +- .../share/classes/java/lang/Runtime.java | 179 +++++++++--------- .../java/lang/VersionProps.java.template | 55 +++++- 3 files changed, 151 insertions(+), 89 deletions(-) diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk index 0ce43ff4f8d..475b8f1d033 100644 --- a/jdk/make/gensrc/GensrcMisc.gmk +++ b/jdk/make/gensrc/GensrcMisc.gmk @@ -34,7 +34,11 @@ $(eval $(call SetupTextFileProcessing, BUILD_VERSION_JAVA, \ @@LAUNCHER_NAME@@ => $(LAUNCHER_NAME) ; \ @@RUNTIME_NAME@@ => $(RUNTIME_NAME) ; \ @@VERSION_SHORT@@ => $(VERSION_SHORT) ; \ - @@VERSION_STRING@@ => $(VERSION_STRING), \ + @@VERSION_STRING@@ => $(VERSION_STRING) ; \ + @@VERSION_NUMBER@@ => $(VERSION_NUMBER) ; \ + @@VERSION_PRE@@ => $(VERSION_PRE) ; \ + @@VERSION_BUILD@@ => $(VERSION_BUILD) ; \ + @@VERSION_OPT@@ => $(VERSION_OPT), \ )) GENSRC_JAVA_BASE += $(BUILD_VERSION_JAVA) diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java index 1533130017b..fd5cb88a7d6 100644 --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java @@ -27,8 +27,6 @@ package java.lang; import java.io.*; import java.math.BigInteger; -import java.util.AbstractList; -import java.util.Arrays; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,11 +34,9 @@ import java.util.stream.Collectors; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.RandomAccess; import java.util.StringTokenizer; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; -import sun.security.action.GetPropertyAction; /** * Every Java application has a single instance of class @@ -941,8 +937,9 @@ public class Runtime { */ public static Version version() { if (version == null) { - version = Version.parse( - GetPropertyAction.privilegedGetProperty("java.runtime.version")); + version = new Version(VersionProps.versionNumbers(), + VersionProps.pre(), VersionProps.build(), + VersionProps.optional()); } return version; } @@ -1084,86 +1081,12 @@ public class Runtime { private final Optional build; private final Optional optional; - - // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)? - // RE limits the format of version strings - // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))? - - private static final String VNUM - = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)"; - private static final String VNUM_GROUP = "VNUM"; - - private static final String PRE = "(?:-(?
[a-zA-Z0-9]+))?";
-        private static final String PRE_GROUP   = "PRE";
-
-        private static final String BUILD
-            = "(?:(?\\+)(?0|[1-9][0-9]*)?)?";
-        private static final String PLUS_GROUP  = "PLUS";
-        private static final String BUILD_GROUP = "BUILD";
-
-        private static final String OPT      = "(?:-(?[-a-zA-Z0-9.]+))?";
-        private static final String OPT_GROUP   = "OPT";
-
-        private static final String VSTR_FORMAT
-            = "^" + VNUM + PRE + BUILD + OPT + "$";
-        private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
-
-        /**
-         * Constructs a valid version string containing
-         * a version number followed by pre-release and
-         * build information.
-         *
-         * @param  s
-         *         A string to be interpreted as a version
-         *
-         * @throws  IllegalArgumentException
-         *          If the given string cannot be interpreted as a valid
-         *          version
-         *
-         * @throws  NullPointerException
-         *          If {@code s} is {@code null}
-         *
-         * @throws  NumberFormatException
-         *          If an element of the version number or the build number
-         *          cannot be represented as an {@link Integer}
-         */
-        private Version(String s) {
-            if (s == null)
-                throw new NullPointerException();
-
-            Matcher m = VSTR_PATTERN.matcher(s);
-            if (!m.matches())
-                throw new IllegalArgumentException("Invalid version string: '"
-                                                   + s + "'");
-
-            // $VNUM is a dot-separated list of integers of arbitrary length
-            List list = new ArrayList<>();
-            for (String i : m.group(VNUM_GROUP).split("\\."))
-                list.add(Integer.parseInt(i));
-            version = Collections.unmodifiableList(list);
-
-            pre = Optional.ofNullable(m.group(PRE_GROUP));
-
-            String b = m.group(BUILD_GROUP);
-            // $BUILD is an integer
-            build = (b == null)
-                ? Optional.empty()
-                : Optional.ofNullable(Integer.parseInt(b));
-
-            optional = Optional.ofNullable(m.group(OPT_GROUP));
-
-            // empty '+'
-            if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
-                if (optional.isPresent()) {
-                    if (pre.isPresent())
-                        throw new IllegalArgumentException("'+' found with"
-                            + " pre-release and optional components:'" + s
-                            + "'");
-                } else {
-                    throw new IllegalArgumentException("'+' found with neither"
-                        + " build or optional components: '" + s + "'");
-                }
-            }
+        Version(List version, Optional pre,
+                Optional build, Optional optional) {
+            this.version = Collections.unmodifiableList(version);
+            this.pre = pre;
+            this.build = build;
+            this.optional = optional;
         }
 
         /**
@@ -1189,7 +1112,7 @@ public class Runtime {
          * @return  The Version of the given string
          */
         public static Version parse(String s) {
-            return new Version(s);
+            return VersionBuilder.parse(s);
         }
 
         /**
@@ -1518,4 +1441,86 @@ public class Runtime {
         }
     }
 
+    private static class VersionBuilder {
+        // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
+        // RE limits the format of version strings
+        // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
+
+        private static final String VNUM
+            = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
+        private static final String VNUM_GROUP  = "VNUM";
+
+        private static final String PRE      = "(?:-(?
[a-zA-Z0-9]+))?";
+        private static final String PRE_GROUP   = "PRE";
+
+        private static final String BUILD
+            = "(?:(?\\+)(?0|[1-9][0-9]*)?)?";
+        private static final String PLUS_GROUP  = "PLUS";
+        private static final String BUILD_GROUP = "BUILD";
+
+        private static final String OPT      = "(?:-(?[-a-zA-Z0-9.]+))?";
+        private static final String OPT_GROUP   = "OPT";
+
+        private static final String VSTR_FORMAT
+            = "^" + VNUM + PRE + BUILD + OPT + "$";
+        private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
+
+        /**
+         * Constructs a valid version string containing
+         * a version number followed by pre-release and
+         * build information.
+         *
+         * @param  s
+         *         A string to be interpreted as a version
+         *
+         * @throws  IllegalArgumentException
+         *          If the given string cannot be interpreted as a valid
+         *          version
+         *
+         * @throws  NullPointerException
+         *          If {@code s} is {@code null}
+         *
+         * @throws  NumberFormatException
+         *          If an element of the version number or the build number
+         *          cannot be represented as an {@link Integer}
+         */
+        static Version parse(String s) {
+            if (s == null)
+                throw new NullPointerException();
+
+            Matcher m = VSTR_PATTERN.matcher(s);
+            if (!m.matches())
+                throw new IllegalArgumentException("Invalid version string: '"
+                                                   + s + "'");
+
+            // $VNUM is a dot-separated list of integers of arbitrary length
+            List version = new ArrayList<>();
+            for (String i : m.group(VNUM_GROUP).split("\\."))
+                version.add(Integer.parseInt(i));
+
+            Optional pre = Optional.ofNullable(m.group(PRE_GROUP));
+
+            String b = m.group(BUILD_GROUP);
+            // $BUILD is an integer
+            Optional build = (b == null)
+                ? Optional.empty()
+                : Optional.of(Integer.parseInt(b));
+
+            Optional optional = Optional.ofNullable(m.group(OPT_GROUP));
+
+            // empty '+'
+            if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
+                if (optional.isPresent()) {
+                    if (pre.isPresent())
+                        throw new IllegalArgumentException("'+' found with"
+                            + " pre-release and optional components:'" + s
+                            + "'");
+                } else {
+                    throw new IllegalArgumentException("'+' found with neither"
+                        + " build or optional components: '" + s + "'");
+                }
+            }
+            return new Version(version, pre, build, optional);
+        }
+    }
 }
diff --git a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template
index dd0e038936d..c5e7b754e6d 100644
--- a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template
@@ -26,6 +26,9 @@
 package java.lang;
 
 import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
 
 class VersionProps {
 
@@ -42,6 +45,18 @@ class VersionProps {
     private static final String java_runtime_version =
         "@@VERSION_STRING@@";
 
+    private static final String VERSION_NUMBER =
+        "@@VERSION_NUMBER@@";
+
+    private static final String VERSION_BUILD =
+        "@@VERSION_BUILD@@";
+
+    private static final String VERSION_PRE =
+        "@@VERSION_PRE@@";
+
+    private static final String VERSION_OPT =
+        "@@VERSION_OPT@@";
+
     static {
         init();
     }
@@ -52,6 +67,44 @@ class VersionProps {
         System.setProperty("java.runtime.name", java_runtime_name);
     }
 
+    static List versionNumbers() {
+        List versionNumbers = new ArrayList<>(4);
+        int prevIndex = 0;
+        int index = VERSION_NUMBER.indexOf('.');
+        while (index > 0) {
+            versionNumbers.add(
+                    Integer.parseInt(VERSION_NUMBER, prevIndex, index, 10));
+            prevIndex = index;
+            index = VERSION_NUMBER.indexOf('.', prevIndex);
+        }
+        versionNumbers.add(Integer.parseInt(VERSION_NUMBER,
+                prevIndex, VERSION_NUMBER.length(), 10));
+        return versionNumbers;
+    }
+
+    static Optional pre() {
+        return optionalOf(VERSION_PRE);
+    }
+
+    static Optional build() {
+        return VERSION_BUILD.isEmpty() ?
+                Optional.empty() :
+                Optional.of(Integer.parseInt(VERSION_BUILD));
+    }
+
+    static Optional optional() {
+        return optionalOf(VERSION_OPT);
+    }
+
+    // Treat empty strings as value not being present
+    private static Optional optionalOf(String value) {
+        if (!value.isEmpty()) {
+            return Optional.of(value);
+        } else {
+            return Optional.empty();
+        }
+    }
+
     /**
      * In case you were wondering this method is called by java -version.
      * Sad that it prints to stderr; would be nicer if default printed on
@@ -111,4 +164,4 @@ class VersionProps {
                    java_vm_info + ")");
     }
 
-}
\ No newline at end of file
+}

From 23264135ec1b9fbbb11017bfdd6fa1189e8019e7 Mon Sep 17 00:00:00 2001
From: Mandy Chung 
Date: Mon, 27 Jun 2016 20:22:04 -0700
Subject: [PATCH 054/191] 8159596: Add java --dry-run

Reviewed-by: alanb, ksrini
---
 .../launcher/resources/launcher.properties    |   3 +
 jdk/src/java.base/share/native/libjli/java.c  |  21 +-
 .../launcher/modules/dryrun/DryRunTest.java   | 199 ++++++++++++++++++
 .../modules/dryrun/src/m/module-info.java     |  26 +++
 .../launcher/modules/dryrun/src/m/p/Lib.java  |  30 +++
 .../dryrun/src/test/jdk/test/Main.java        |  30 +++
 .../modules/dryrun/src/test/module-info.java  |  26 +++
 7 files changed, 328 insertions(+), 7 deletions(-)
 create mode 100644 jdk/test/tools/launcher/modules/dryrun/DryRunTest.java
 create mode 100644 jdk/test/tools/launcher/modules/dryrun/src/m/module-info.java
 create mode 100644 jdk/test/tools/launcher/modules/dryrun/src/m/p/Lib.java
 create mode 100644 jdk/test/tools/launcher/modules/dryrun/src/test/jdk/test/Main.java
 create mode 100644 jdk/test/tools/launcher/modules/dryrun/src/test/module-info.java

diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
index 32aa8ec65b3..83b328d7de8 100644
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
@@ -60,6 +60,9 @@ java.launcher.opt.footer     =\    -cp [,...]]\n\
 \                  list the observable modules and exit\n\
+\    --dry-run     create VM but do not execute main method.\n\
+\                  This --dry-run option may be useful for validating the\n\
+\                  command-line options such as the module system configuration.\n\
 \    -D=\n\
 \                  set a system property\n\
 \    -verbose:[class|gc|jni]\n\
diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c
index c771d993bfe..ffd60727128 100644
--- a/jdk/src/java.base/share/native/libjli/java.c
+++ b/jdk/src/java.base/share/native/libjli/java.c
@@ -68,6 +68,7 @@ static jboolean printVersion = JNI_FALSE; /* print and exit */
 static jboolean showVersion = JNI_FALSE;  /* print but continue */
 static jboolean printUsage = JNI_FALSE;   /* print and exit*/
 static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
+static jboolean dryRun = JNI_FALSE;       /* initialize VM and exit */
 static char     *showSettings = NULL;      /* print but continue */
 static char     *listModules = NULL;
 
@@ -489,14 +490,18 @@ JavaMain(void * _args)
     mainArgs = CreateApplicationArgs(env, argv, argc);
     CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
 
-    /* Invoke main method. */
-    (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
+    if (dryRun) {
+        ret = 0;
+    } else {
+        /* Invoke main method. */
+        (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
 
-    /*
-     * The launcher's exit code (in the absence of calls to
-     * System.exit) will be non-zero if main threw an exception.
-     */
-    ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
+        /*
+         * The launcher's exit code (in the absence of calls to
+         * System.exit) will be non-zero if main threw an exception.
+         */
+        ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
+    }
     LEAVE();
 }
 
@@ -1203,6 +1208,8 @@ ParseArguments(int *pargc, char ***pargv,
             return JNI_TRUE;
         } else if (JLI_StrCmp(arg, "-showversion") == 0) {
             showVersion = JNI_TRUE;
+        } else if (JLI_StrCmp(arg, "--dry-run") == 0) {
+            dryRun = JNI_TRUE;
         } else if (JLI_StrCmp(arg, "-X") == 0) {
             printXUsage = JNI_TRUE;
             return JNI_TRUE;
diff --git a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java
new file mode 100644
index 00000000000..ca87bf88679
--- /dev/null
+++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2016, 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 8159596
+ * @library /lib/testlibrary
+ * @modules jdk.compiler
+ *          jdk.jartool/sun.tools.jar
+ * @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools
+ * @run testng DryRunTest
+ * @summary Test java --dry-run
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import jdk.testlibrary.ProcessTools;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+
+@Test
+public class DryRunTest {
+
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path LIBS_DIR = Paths.get("libs");
+
+    // the module name of the test module
+    private static final String TEST_MODULE = "test";
+    private static final String M_MODULE = "m";
+
+    // the module main class
+    private static final String MAIN_CLASS = "jdk.test.Main";
+
+
+    @BeforeTest
+    public void compileTestModule() throws Exception {
+
+        // javac -d mods/$TESTMODULE src/$TESTMODULE/**
+        assertTrue(CompilerUtils.compile(SRC_DIR.resolve(M_MODULE),
+                                         MODS_DIR,
+                                         "-modulesourcepath", SRC_DIR.toString()));
+
+        assertTrue(CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE),
+                                         MODS_DIR,
+                                         "-modulesourcepath", SRC_DIR.toString()));
+
+        Files.createDirectories(LIBS_DIR);
+
+        // create JAR files with no module-info.class
+        assertTrue(jar(M_MODULE, "p/Lib.class"));
+        assertTrue(jar(TEST_MODULE, "jdk/test/Main.class"));
+    }
+
+    /**
+     * Execute "java" with the given arguments, returning the exit code.
+     */
+    private int exec(String... args) throws Exception {
+       return ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+    }
+
+
+    /**
+     * Launch module main
+     */
+    public void testModule() throws Exception {
+        String dir = MODS_DIR.toString();
+        String mid = TEST_MODULE + "/" + MAIN_CLASS;
+
+        // java -modulepath mods -module $TESTMODULE/$MAINCLASS
+        // no resolution failure
+        int exitValue = exec("--dry-run", "-modulepath", dir, "-m", mid);
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test non-existence module in -addmods
+     */
+    public void testNonExistAddModules() throws Exception {
+        String dir = MODS_DIR.toString();
+        String mid = TEST_MODULE + "/" + MAIN_CLASS;
+
+        int exitValue = exec("--dry-run", "-modulepath", dir,
+                             "-addmods", "non.existence",
+                             "-m", mid);
+        assertTrue(exitValue != 0);
+    }
+
+    /**
+     * Launch main class from class path
+     */
+    public void testClassPath() throws Exception {
+        Path testJar = LIBS_DIR.resolve(TEST_MODULE + ".jar");
+        String libs = testJar.toString() + File.pathSeparator +
+                        LIBS_DIR.resolve(M_MODULE + ".jar").toString();
+
+        // test pass with m.jar:test.jar
+        int exitValue = exec("-classpath", libs, MAIN_CLASS);
+        assertTrue(exitValue == 0);
+
+        // m.jar is not on classpath and fails with p.Lib not found
+        exitValue = exec("-classpath", testJar.toString(), MAIN_CLASS);
+        assertTrue(exitValue != 0);
+
+        // dry pass passes since main is not executed
+        exitValue = exec("--dry-run", "-classpath", testJar.toString(), MAIN_CLASS);
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test automatic modules
+     */
+    public void testAutomaticModule() throws Exception {
+        String libs = LIBS_DIR.resolve(M_MODULE + ".jar").toString() +
+                        File.pathSeparator +
+                        LIBS_DIR.resolve(TEST_MODULE + ".jar").toString();
+        String mid = TEST_MODULE + "/" + MAIN_CLASS;
+
+        // test main method with and without -addmods mm
+        int exitValue = exec("-modulepath", LIBS_DIR.toString(),
+                             "-m", mid);
+        assertTrue(exitValue != 0);
+
+        exitValue = exec("-modulepath", LIBS_DIR.toString(),
+                         "-addmods", M_MODULE,
+                         "-m", mid);
+        assertTrue(exitValue == 0);
+
+        // test dry run with and without -addmods m
+        // no resolution failure
+        exitValue = exec("--dry-run", "-modulepath", LIBS_DIR.toString(),
+                         "-m", mid);
+        assertTrue(exitValue == 0);
+
+        exitValue = exec("--dry-run", "-modulepath", LIBS_DIR.toString(),
+                         "-addmods", M_MODULE,
+                         "-m", mid);
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * module m not found
+     */
+    public void testMissingModule() throws Exception {
+        String subdir = MODS_DIR.resolve(TEST_MODULE).toString();
+        String mid = TEST_MODULE + "/" + MAIN_CLASS;
+
+        // resolution failure
+        int exitValue = exec("--dry-run", "-modulepath", subdir, "-m", mid);
+        assertTrue(exitValue != 0);
+    }
+
+    private static boolean jar(String name, String entries) throws IOException {
+        Path jar = LIBS_DIR.resolve(name + ".jar");
+
+        // jar --create ...
+        String classes = MODS_DIR.resolve(name).toString();
+        String[] args = {
+            "--create",
+            "--file=" + jar,
+            "-C", classes, entries
+        };
+        boolean success
+            = new sun.tools.jar.Main(System.out, System.out, "jar").run(args);
+        return success;
+    }
+}
diff --git a/jdk/test/tools/launcher/modules/dryrun/src/m/module-info.java b/jdk/test/tools/launcher/modules/dryrun/src/m/module-info.java
new file mode 100644
index 00000000000..6ebed006a4b
--- /dev/null
+++ b/jdk/test/tools/launcher/modules/dryrun/src/m/module-info.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+module m {
+    exports p;
+}
diff --git a/jdk/test/tools/launcher/modules/dryrun/src/m/p/Lib.java b/jdk/test/tools/launcher/modules/dryrun/src/m/p/Lib.java
new file mode 100644
index 00000000000..1c8159b7b13
--- /dev/null
+++ b/jdk/test/tools/launcher/modules/dryrun/src/m/p/Lib.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+package p;
+
+public class Lib {
+    public static void sayHi() {
+        System.out.println("Hello world");
+    }
+}
diff --git a/jdk/test/tools/launcher/modules/dryrun/src/test/jdk/test/Main.java b/jdk/test/tools/launcher/modules/dryrun/src/test/jdk/test/Main.java
new file mode 100644
index 00000000000..547e8eb53b0
--- /dev/null
+++ b/jdk/test/tools/launcher/modules/dryrun/src/test/jdk/test/Main.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+package jdk.test;
+
+public class Main {
+    public static void main(String[] args) {
+        p.Lib.sayHi();
+    }
+}
diff --git a/jdk/test/tools/launcher/modules/dryrun/src/test/module-info.java b/jdk/test/tools/launcher/modules/dryrun/src/test/module-info.java
new file mode 100644
index 00000000000..bc5cd5d4e14
--- /dev/null
+++ b/jdk/test/tools/launcher/modules/dryrun/src/test/module-info.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+module test {
+    requires m;
+}

From 8576b106b756eb682b00c0f36b7083346eb10849 Mon Sep 17 00:00:00 2001
From: Athijegannathan Sundararajan 
Date: Tue, 28 Jun 2016 09:57:09 +0530
Subject: [PATCH 055/191] 8160346: JLinkTest.java should compute exact number
 of plugins from jdk.jlink module

Reviewed-by: jlaskey, mchung
---
 jdk/test/tools/jlink/JLinkTest.java | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/jdk/test/tools/jlink/JLinkTest.java b/jdk/test/tools/jlink/JLinkTest.java
index 9c95fbf6f67..19b6e6a59d9 100644
--- a/jdk/test/tools/jlink/JLinkTest.java
+++ b/jdk/test/tools/jlink/JLinkTest.java
@@ -53,7 +53,7 @@ import tests.JImageGenerator.InMemoryFile;
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
  * @build tests.*
- * @run main/othervm -verbose:gc -Xmx1g JLinkTest
+ * @run main/othervm -Xmx1g JLinkTest
  */
 public class JLinkTest {
     // number of built-in plugins from jdk.jlink module
@@ -64,6 +64,10 @@ public class JLinkTest {
                     providers().size();
     }
 
+    private static boolean isOfJLinkModule(Plugin p) {
+        return p.getClass().getModule() == Plugin.class.getModule();
+    }
+
     public static void main(String[] args) throws Exception {
 
         Helper helper = Helper.newHelper();
@@ -72,20 +76,27 @@ public class JLinkTest {
             return;
         }
         helper.generateDefaultModules();
-        int numPlugins = getNumJlinkPlugins();
+        // expected num. of plugins from jdk.jlink module
+        int expectedJLinkPlugins = getNumJlinkPlugins();
+        int totalPlugins = 0;
         {
             // number of built-in plugins
             List builtInPlugins = new ArrayList<>();
             builtInPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
+            totalPlugins = builtInPlugins.size();
+            // actual num. of plugins loaded from jdk.jlink module
+            int actualJLinkPlugins = 0;
             for (Plugin p : builtInPlugins) {
                 p.getState();
                 p.getType();
+                if (isOfJLinkModule(p)) {
+                    actualJLinkPlugins++;
+                }
             }
-            // Note: other boot layer modules may provide jlink plugins.
-            // We should at least see the builtin plugins from jdk.jlink.
-            if (builtInPlugins.size() < numPlugins) {
-                throw new AssertionError("Found plugins doesn't match expected number : " +
-                        numPlugins + "\n" + builtInPlugins);
+            if (expectedJLinkPlugins != actualJLinkPlugins) {
+                throw new AssertionError("Actual plugins loaded from jdk.jlink: " +
+                        actualJLinkPlugins + " which doesn't match expected number : " +
+                        expectedJLinkPlugins);
             }
         }
 
@@ -150,9 +161,9 @@ public class JLinkTest {
             long number = Stream.of(output.split("\\R"))
                     .filter((s) -> s.matches("Plugin Name:.*"))
                     .count();
-            if (number != numPlugins) {
+            if (number != totalPlugins) {
                 System.err.println(output);
-                throw new AssertionError("Found: " + number + " expected " + numPlugins);
+                throw new AssertionError("Found: " + number + " expected " + totalPlugins);
             }
         }
 

From 0304fe9931b1d2cc1c6b0ad7c580f3460e6ddaad Mon Sep 17 00:00:00 2001
From: Rachna Goel 
Date: Tue, 28 Jun 2016 13:47:01 +0900
Subject: [PATCH 056/191] 8158504:
 test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included
 in available locales

Reviewed-by: okutsu, naoto
---
 .../sun/util/locale/provider/Bug8038436.java  | 26 +++++++++++--------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/jdk/test/sun/util/locale/provider/Bug8038436.java b/jdk/test/sun/util/locale/provider/Bug8038436.java
index 59931d4969c..3f8179ba0d2 100644
--- a/jdk/test/sun/util/locale/provider/Bug8038436.java
+++ b/jdk/test/sun/util/locale/provider/Bug8038436.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016 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
@@ -23,24 +23,25 @@
 
 /*
  * @test
- * @bug 8038436
+ * @bug 8038436 8158504
  * @summary Test for changes in 8038436
  * @modules java.base/sun.util.locale.provider
  *          java.base/sun.util.spi
  * @compile -XDignore.symbol.file Bug8038436.java
- * @run main/othervm Bug8038436 -Djava.ext.dirs=foo security
- * @run main/othervm Bug8038436 -Djava.locale.providers=JRE availlocs
+ * @run main/othervm  -limitmods java.base           Bug8038436  security
+ * @run main/othervm  -Djava.locale.providers=COMPAT Bug8038436  availlocs
  */
 
 import java.security.*;
-import java.text.*;
 import java.util.*;
 import java.util.stream.*;
 import sun.util.locale.provider.*;
 
 public class Bug8038436 {
     public static void main(String[] args) {
-        switch (args[1]) {
+
+        switch (args[0]) {
+
         case "security":
             securityTests();
             break;
@@ -50,6 +51,7 @@ public class Bug8038436 {
         default:
             throw new RuntimeException("no test was specified.");
         }
+
     }
 
     private static void securityTests() {
@@ -67,12 +69,14 @@ public class Bug8038436 {
 
         /*
          * Check only English/ROOT locales are returned if the jdk.localedata
-         * module is not installed (implied by "java.ext.dirs" set to "foo").
+         * module is not loaded (implied by "-limitmods java.base").
          */
-        if (Arrays.asList(Locale.getAvailableLocales())
-                .stream()
-                .anyMatch(l -> l != Locale.ROOT && l.getLanguage() != "en")) {
-            throw new RuntimeException("non English locale(s) included in available locales");
+        List nonEnglishLocales= (Arrays.stream(Locale.getAvailableLocales())
+                .filter(l -> (l != Locale.ROOT && !(l.getLanguage() == "en" && (l.getCountry() == "US" || l.getCountry() == "" ))))
+                .collect(Collectors.toList()));
+
+        if (!nonEnglishLocales.isEmpty()) {
+            throw new RuntimeException("non English locale(s)" + nonEnglishLocales + " included in available locales");
         }
     }
 

From e926c778457b2c849b91e76f29bb178a30daafb6 Mon Sep 17 00:00:00 2001
From: Amy Lu 
Date: Tue, 28 Jun 2016 14:39:09 +0800
Subject: [PATCH 057/191] 8156536: Remove intermittent key from TreeTest.java
 and move back to tier1

Reviewed-by: darcy
---
 jdk/test/TEST.groups                           | 2 --
 jdk/test/java/lang/ProcessHandle/TreeTest.java | 1 -
 2 files changed, 3 deletions(-)

diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups
index 027a139c9bd..be1540695df 100644
--- a/jdk/test/TEST.groups
+++ b/jdk/test/TEST.groups
@@ -27,7 +27,6 @@
 
 tier1 = \
     :jdk_lang \
-    -java/lang/ProcessHandle/TreeTest.java \
     :jdk_util \
     -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
     -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
@@ -38,7 +37,6 @@ tier1 = \
     tools/pack200
 
 tier2 = \
-    java/lang/ProcessHandle/TreeTest.java \
     java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
     java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
     :jdk_io \
diff --git a/jdk/test/java/lang/ProcessHandle/TreeTest.java b/jdk/test/java/lang/ProcessHandle/TreeTest.java
index 7ff580053e0..bb62d06353c 100644
--- a/jdk/test/java/lang/ProcessHandle/TreeTest.java
+++ b/jdk/test/java/lang/ProcessHandle/TreeTest.java
@@ -50,7 +50,6 @@ import org.testng.annotations.Test;
  * @build jdk.test.lib.Utils
  * @run testng/othervm TreeTest
  * @summary Test counting and JavaChild.spawning and counting of Processes.
- * @key intermittent
  * @author Roger Riggs
  */
 public class TreeTest extends ProcessUtil {

From 78f385b79a9742ee6a3401b655676909e4af9445 Mon Sep 17 00:00:00 2001
From: Ramanand Patil 
Date: Mon, 27 Jun 2016 11:52:49 +0530
Subject: [PATCH 058/191] 8153955: increase java.util.logging.FileHandler
 MAX_LOCKS limit

This patch adds a new configurable property "java.util.logging.FileHandler.maxLocks" to java.util.logging.FileHandler which can be defined in the logging configuration file and makes it possible to configure the maximum number of concurrent log file locks a FileHandler can handle. If not overridden, the default value of maxLocks (100) remains unchanged.

Reviewed-by: dfuchs, coffeys
---
 .../java/util/logging/FileHandler.java        |  12 +-
 .../share/conf/logging.properties             |   4 +
 .../util/logging/FileHandlerMaxLocksTest.java | 114 ++++++++++++++++++
 3 files changed, 129 insertions(+), 1 deletion(-)
 create mode 100644 jdk/test/java/util/logging/FileHandlerMaxLocksTest.java

diff --git a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
index 0778571d3f5..f7d2660b94c 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
@@ -94,6 +94,9 @@ import java.util.Set;
  * 
  • <handler-name>.append * specifies whether the FileHandler should append onto * any existing files (defaults to false).
  • + *
  • <handler-name>.maxLocks + * specifies the maximum number of concurrent locks held by + * FileHandler (defaults to 100).
  • * *

    * For example, the properties for {@code FileHandler} would be: @@ -157,6 +160,7 @@ public class FileHandler extends StreamHandler { private FileChannel lockFileChannel; private File files[]; private static final int MAX_LOCKS = 100; + private int maxLocks = MAX_LOCKS; private static final Set locks = new HashSet<>(); /** @@ -235,6 +239,12 @@ public class FileHandler extends StreamHandler { setLevel(manager.getLevelProperty(cname + ".level", Level.ALL)); setFilter(manager.getFilterProperty(cname + ".filter", null)); setFormatter(manager.getFormatterProperty(cname + ".formatter", new XMLFormatter())); + // Initialize maxLocks from the logging.properties file. + // If invalid/no property is provided 100 will be used as a default value. + maxLocks = manager.getIntProperty(cname + ".maxLocks", MAX_LOCKS); + if(maxLocks <= 0) { + maxLocks = MAX_LOCKS; + } try { setEncoding(manager.getStringProperty(cname +".encoding", null)); } catch (Exception ex) { @@ -476,7 +486,7 @@ public class FileHandler extends StreamHandler { int unique = -1; for (;;) { unique++; - if (unique > MAX_LOCKS) { + if (unique > maxLocks) { throw new IOException("Couldn't get lock for " + pattern); } // Generate a lock file name from the "unique" int. diff --git a/jdk/src/java.logging/share/conf/logging.properties b/jdk/src/java.logging/share/conf/logging.properties index 65cf1b1b7dc..58997e5ff2f 100644 --- a/jdk/src/java.logging/share/conf/logging.properties +++ b/jdk/src/java.logging/share/conf/logging.properties @@ -37,6 +37,10 @@ handlers= java.util.logging.ConsoleHandler java.util.logging.FileHandler.pattern = %h/java%u.log java.util.logging.FileHandler.limit = 50000 java.util.logging.FileHandler.count = 1 +# Default number of locks FileHandler can obtain synchronously. +# This specifies maximum number of attempts to obtain lock file by FileHandler +# implemented by incrementing the unique field %u as per FileHandler API documentation. +java.util.logging.FileHandler.maxLocks = 100 java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter # Limit the message that are printed on the console to INFO and above. diff --git a/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java b/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java new file mode 100644 index 00000000000..fef03b2ef89 --- /dev/null +++ b/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2016, 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 8153955 + * @summary test the FileHandler's new property + * "java.util.logging.FileHandler.maxLocks" which will be present in + * "logging.properties" file with default value of 100. This property can be + * overriden by specifying this property in the custom config file. + * @library /lib/testlibrary + * @build jdk.testlibrary.FileUtils + * @author rpatil + * @run main/othervm FileHandlerMaxLocksTest + */ +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.FileHandler; +import jdk.testlibrary.FileUtils; + +public class FileHandlerMaxLocksTest { + + private static final String LOGGER_DIR = "logger-dir"; + private static final String MAX_LOCK_PROPERTY = "java.util.logging.FileHandler.maxLocks = 200"; + private static final String CONFIG_FILE_NAME = "logging.properties"; + + public static void main(String[] args) throws Exception { + File loggerDir = createLoggerDir(); + String configFilePath = loggerDir.getPath() + File.separator + CONFIG_FILE_NAME; + File configFile = new File(configFilePath); + createFile(configFile, false); + System.setProperty("java.util.logging.config.file", configFilePath); + List fileHandlers = new ArrayList<>(); + try (FileWriter writer = new FileWriter(configFile)) { + writer.write(MAX_LOCK_PROPERTY); + writer.flush(); + // 200 raises the default limit of 100, we try 102 times + for (int i = 0; i < 102; i++) { + fileHandlers.add(new FileHandler(loggerDir.getPath() + File.separator + "test_%u.log")); + } + } catch (IOException ie) { + throw new RuntimeException("Test Failed: " + ie.getMessage()); + } finally { + for (FileHandler fh : fileHandlers) { + fh.close(); + } + FileUtils.deleteFileTreeWithRetry(Paths.get(loggerDir.getPath())); + } + } + + /** + * Create a writable directory in user directory for the test + * + * @return writable directory created that needs to be deleted when done + * @throws RuntimeException + */ + private static File createLoggerDir() throws RuntimeException { + String userDir = System.getProperty("user.dir", "."); + File loggerDir = new File(userDir, LOGGER_DIR); + if (!createFile(loggerDir, true)) { + throw new RuntimeException("Test failed: unable to create" + + " writable working directory " + + loggerDir.getAbsolutePath()); + } + // System.out.println("Created Logger Directory: " + loggerDir.getPath()); + return loggerDir; + } + + /** + * @param newFile File to be created + * @param makeDirectory is File to be created is directory + * @return true if file already exists or creation succeeded + */ + private static boolean createFile(File newFile, boolean makeDirectory) { + if (newFile.exists()) { + return true; + } + if (makeDirectory) { + return newFile.mkdir(); + } else { + try { + return newFile.createNewFile(); + } catch (IOException ie) { + System.err.println("Not able to create file: " + newFile + + ", IOException: " + ie.getMessage()); + return false; + } + } + } +} From ef2abc8eff64e9e4cf05bab0ab393d473675312e Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Tue, 28 Jun 2016 16:07:23 -0300 Subject: [PATCH 059/191] 8160459: jlink minor code clean up Reviewed-by: mchung --- .../jlink/internal/AbstractModuleEntry.java | 5 +-- .../jdk/tools/jlink/internal/Archive.java | 27 ++++++------- .../internal/ArchiveEntryModuleEntry.java | 4 +- .../jlink/internal/BasicImageWriter.java | 7 ++-- .../jlink/internal/ByteArrayModuleEntry.java | 1 - .../jdk/tools/jlink/internal/DirArchive.java | 4 +- .../jlink/internal/ImageFileCreator.java | 24 ++---------- .../internal/ImagePluginConfiguration.java | 36 ++++++++--------- .../jlink/internal/ImagePluginStack.java | 39 +++++++++---------- .../jlink/internal/ImageResourcesTree.java | 12 ++---- .../jlink/internal/ImageStringsWriter.java | 18 +++++++-- .../jdk/tools/jlink/internal/JarArchive.java | 6 +-- .../jdk/tools/jlink/internal/JlinkTask.java | 3 +- .../jdk/tools/jlink/internal/JmodArchive.java | 7 ++-- .../jlink/internal/ModularJarArchive.java | 3 +- .../jlink/internal/ModuleEntryFactory.java | 1 - .../tools/jlink/internal/ModulePoolImpl.java | 6 +-- .../tools/jlink/internal/PathModuleEntry.java | 5 +-- .../jlink/internal/ResourcePrevisitor.java | 1 - .../jdk/tools/jlink/internal/Utils.java | 1 - .../packager/AppRuntimeImageBuilder.java | 2 +- .../plugins/DefaultCompressPlugin.java | 1 - .../internal/plugins/ExcludeFilesPlugin.java | 3 -- .../jlink/internal/plugins/ExcludePlugin.java | 1 - .../internal/plugins/ExcludeVMPlugin.java | 2 - .../internal/plugins/FileCopierPlugin.java | 2 - .../plugins/GenerateJLIClassesPlugin.java | 2 - .../plugins/IncludeLocalesPlugin.java | 2 - .../internal/plugins/OptimizationPlugin.java | 1 - .../plugins/OrderResourcesPlugin.java | 2 - .../internal/plugins/ReleaseInfoPlugin.java | 1 - .../internal/plugins/StringSharingPlugin.java | 1 - .../internal/plugins/StripDebugPlugin.java | 3 -- .../plugins/StripNativeCommandsPlugin.java | 1 - .../jlink/internal/plugins/ZipPlugin.java | 1 - .../internal/plugins/optim/ControlFlow.java | 8 +--- 36 files changed, 90 insertions(+), 153 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java index 19a76ee36b6..25a0c98bbd6 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java @@ -25,7 +25,6 @@ package jdk.tools.jlink.internal; -import java.io.InputStream; import java.util.Objects; import jdk.tools.jlink.plugin.ModuleEntry; @@ -77,9 +76,7 @@ abstract class AbstractModuleEntry implements ModuleEntry { @Override public int hashCode() { - int hash = 7; - hash = 89 * hash + Objects.hashCode(this.path); - return hash; + return Objects.hashCode(this.path); } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java index 82571d355e3..5cf159104e0 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Archive.java @@ -42,7 +42,6 @@ public interface Archive { public abstract class Entry { public static enum EntryType { - MODULE_NAME, CLASS_OR_RESOURCE, NATIVE_LIB, @@ -57,14 +56,10 @@ public interface Archive { private final String path; public Entry(Archive archive, String path, String name, EntryType type) { - Objects.requireNonNull(archive); - Objects.requireNonNull(path); - Objects.requireNonNull(name); - Objects.requireNonNull(type); - this.archive = archive; - this.path = path; - this.name = name; - this.type = type; + this.archive = Objects.requireNonNull(archive); + this.path = Objects.requireNonNull(path); + this.name = Objects.requireNonNull(name); + this.type = Objects.requireNonNull(type); } public Archive archive() { @@ -79,7 +74,7 @@ public interface Archive { return type; } - /** + /* * Returns the name of this entry. */ public String name() { @@ -91,7 +86,7 @@ public interface Archive { return "type " + type.name() + " path " + path; } - /** + /* * Returns the number of uncompressed bytes for this entry. */ public abstract long size(); @@ -99,17 +94,17 @@ public interface Archive { public abstract InputStream stream() throws IOException; } - /** + /* * The module name. */ String moduleName(); - /** + /* * Returns the path to this module's content */ Path getPath(); - /** + /* * Stream of Entry. * The stream of entries needs to be closed after use * since it might cover lazy I/O based resources. @@ -117,12 +112,12 @@ public interface Archive { */ Stream entries(); - /** + /* * Open the archive */ void open() throws IOException; - /** + /* * Close the archive */ void close() throws IOException; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java index 6656c935101..f2d15505200 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java @@ -25,7 +25,6 @@ package jdk.tools.jlink.internal; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; @@ -46,7 +45,7 @@ final class ArchiveEntryModuleEntry extends AbstractModuleEntry { * @param entry The archive Entry. */ ArchiveEntryModuleEntry(String module, String path, Archive.Entry entry) { - super(module, path, getImageFileType(entry)); + super(module, path, getImageFileType(Objects.requireNonNull(entry))); this.entry = entry; } @@ -65,7 +64,6 @@ final class ArchiveEntryModuleEntry extends AbstractModuleEntry { } private static ModuleEntry.Type getImageFileType(Archive.Entry entry) { - Objects.requireNonNull(entry); switch(entry.type()) { case CLASS_OR_RESOURCE: return ModuleEntry.Type.CLASS_OR_RESOURCE; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java index 559cf690cbb..f499749682d 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java @@ -28,6 +28,7 @@ package jdk.tools.jlink.internal; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import jdk.internal.jimage.ImageHeader; import jdk.internal.jimage.ImageStream; import jdk.internal.jimage.ImageStringsReader; @@ -54,7 +55,7 @@ public final class BasicImageWriter { } public BasicImageWriter(ByteOrder byteOrder) { - this.byteOrder = byteOrder; + this.byteOrder = Objects.requireNonNull(byteOrder); this.input = new ArrayList<>(); this.strings = new ImageStringsWriter(); this.headerStream = new ImageStream(byteOrder); @@ -96,8 +97,8 @@ public final class BasicImageWriter { private void generatePerfectHash() { PerfectHashBuilder builder = new PerfectHashBuilder<>( - PerfectHashBuilder.Entry.class, // PerfectHashBuilder.Entry().getClass() - PerfectHashBuilder.Bucket.class); // PerfectHashBuilder.Bucket().getClass() + PerfectHashBuilder.Entry.class, + PerfectHashBuilder.Bucket.class); input.forEach((location) -> { builder.put(location.getFullName(), location); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java index 20a016817c4..c40a1d8d387 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java @@ -31,7 +31,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.UncheckedIOException; import java.util.Objects; -import jdk.tools.jlink.plugin.ModuleEntry; /** * A ModuleEntry backed by a given byte[]. diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java index 48fd1d5c954..326417c925d 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java @@ -112,13 +112,11 @@ public class DirArchive implements Archive { @Override public Stream entries() { - Stream ret = null; try { - ret = Files.walk(dirPath).map(this::toEntry).filter(n -> n != null); + return Files.walk(dirPath).map(this::toEntry).filter(n -> n != null); } catch (IOException ex) { throw new RuntimeException(ex); } - return ret; } private Archive.Entry toEntry(Path p) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java index 182ce68d538..d492c09f1d5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java @@ -25,10 +25,8 @@ package jdk.tools.jlink.internal; import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteOrder; import java.nio.file.Files; @@ -47,7 +45,6 @@ import jdk.tools.jlink.internal.Archive.Entry.EntryType; import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData; import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; /** @@ -73,7 +70,7 @@ public final class ImageFileCreator { private final Map> entriesForModule = new HashMap<>(); private final ImagePluginStack plugins; private ImageFileCreator(ImagePluginStack plugins) { - this.plugins = plugins; + this.plugins = Objects.requireNonNull(plugins); } public static ExecutableImage create(Set archives, @@ -232,9 +229,9 @@ public final class ImageFileCreator { out.write(bytes, 0, bytes.length); // write module content - for (ModuleEntry res : content) { + content.stream().forEach((res) -> { res.write(out); - } + }); tree.addContent(out); @@ -283,21 +280,6 @@ public final class ImageFileCreator { return resources; } - private static final int BUF_SIZE = 8192; - - private static byte[] readAllBytes(InputStream is) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buf = new byte[BUF_SIZE]; - while (true) { - int n = is.read(buf); - if (n < 0) { - break; - } - baos.write(buf, 0, n); - } - return baos.toByteArray(); - } - /** * Helper method that splits a Resource path onto 3 items: module, parent * and resource name. diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java index 422029e07d4..a5bd7bf41f8 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java @@ -47,18 +47,18 @@ import jdk.tools.jlink.plugin.TransformerPlugin; */ public final class ImagePluginConfiguration { - private static final List CATEGORIES_ORDER = new ArrayList<>(); + private static final List CATEGORIES_ORDER = new ArrayList<>(); static { - CATEGORIES_ORDER.add(Plugin.Category.FILTER); - CATEGORIES_ORDER.add(Plugin.Category.TRANSFORMER); - CATEGORIES_ORDER.add(Plugin.Category.MODULEINFO_TRANSFORMER); - CATEGORIES_ORDER.add(Plugin.Category.SORTER); - CATEGORIES_ORDER.add(Plugin.Category.COMPRESSOR); - CATEGORIES_ORDER.add(Plugin.Category.METAINFO_ADDER); - CATEGORIES_ORDER.add(Plugin.Category.VERIFIER); - CATEGORIES_ORDER.add(Plugin.Category.PROCESSOR); - CATEGORIES_ORDER.add(Plugin.Category.PACKAGER); + CATEGORIES_ORDER.add(Category.FILTER); + CATEGORIES_ORDER.add(Category.TRANSFORMER); + CATEGORIES_ORDER.add(Category.MODULEINFO_TRANSFORMER); + CATEGORIES_ORDER.add(Category.SORTER); + CATEGORIES_ORDER.add(Category.COMPRESSOR); + CATEGORIES_ORDER.add(Category.METAINFO_ADDER); + CATEGORIES_ORDER.add(Category.VERIFIER); + CATEGORIES_ORDER.add(Category.PROCESSOR); + CATEGORIES_ORDER.add(Category.PACKAGER); } private ImagePluginConfiguration() { @@ -72,8 +72,8 @@ public final class ImagePluginConfiguration { if (pluginsConfiguration == null) { return new ImagePluginStack(); } - Map> plugins = new LinkedHashMap<>(); - for (Plugin.Category cat : CATEGORIES_ORDER) { + Map> plugins = new LinkedHashMap<>(); + for (Category cat : CATEGORIES_ORDER) { plugins.put(cat, new ArrayList<>()); } @@ -96,22 +96,22 @@ public final class ImagePluginConfiguration { List transformerPlugins = new ArrayList<>(); List postProcessingPlugins = new ArrayList<>(); - for (Entry> entry : plugins.entrySet()) { + plugins.entrySet().stream().forEach((entry) -> { // Sort according to plugin constraints List orderedPlugins = PluginOrderingGraph.sort(entry.getValue()); Category category = entry.getKey(); - for (Plugin p : orderedPlugins) { + orderedPlugins.stream().forEach((p) -> { if (category.isPostProcessor()) { @SuppressWarnings("unchecked") - PostProcessorPlugin pp = (PostProcessorPlugin) p; + PostProcessorPlugin pp = (PostProcessorPlugin) p; postProcessingPlugins.add(pp); } else { @SuppressWarnings("unchecked") - TransformerPlugin trans = (TransformerPlugin) p; + TransformerPlugin trans = (TransformerPlugin) p; transformerPlugins.add(trans); } - } - } + }); + }); Plugin lastSorter = null; for (Plugin plugin : transformerPlugins) { if (plugin.getName().equals(pluginsConfiguration.getLastSorterPluginName())) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java index 5b78f5ba696..7d3dd182739 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal; -import java.io.ByteArrayInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.module.ModuleDescriptor; @@ -96,7 +95,7 @@ public final class ImagePluginStack { public CheckOrderResourcePool(ByteOrder order, List orderedList, StringTable table) { super(order, table); - this.orderedList = orderedList; + this.orderedList = Objects.requireNonNull(orderedList); } /** @@ -119,7 +118,6 @@ public final class ImagePluginStack { private int currentid = 0; private final Map stringsUsage = new HashMap<>(); - private final Map stringsMap = new HashMap<>(); private final Map reverseMap = new HashMap<>(); @@ -161,12 +159,12 @@ public final class ImagePluginStack { } } + private final ImageBuilder imageBuilder; private final Plugin lastSorter; private final List contentPlugins = new ArrayList<>(); private final List postProcessingPlugins = new ArrayList<>(); private final List resourcePrevisitors = new ArrayList<>(); - private final ImageBuilder imageBuilder; public ImagePluginStack() { this(null, Collections.emptyList(), null, @@ -177,31 +175,32 @@ public final class ImagePluginStack { List contentPlugins, Plugin lastSorter, List postprocessingPlugins) { - Objects.requireNonNull(contentPlugins); + this.imageBuilder = Objects.requireNonNull(imageBuilder); this.lastSorter = lastSorter; - for (TransformerPlugin p : contentPlugins) { + Objects.requireNonNull(contentPlugins); + Objects.requireNonNull(postprocessingPlugins); + contentPlugins.stream().forEach((p) -> { Objects.requireNonNull(p); if (p instanceof ResourcePrevisitor) { resourcePrevisitors.add((ResourcePrevisitor) p); } this.contentPlugins.add(p); - } - for (PostProcessorPlugin p : postprocessingPlugins) { + }); + postprocessingPlugins.stream().forEach((p) -> { Objects.requireNonNull(p); this.postProcessingPlugins.add(p); - } - this.imageBuilder = imageBuilder; + }); } public void operate(ImageProvider provider) throws Exception { ExecutableImage img = provider.retrieve(this); List arguments = new ArrayList<>(); - for (PostProcessorPlugin plugin : postProcessingPlugins) { - List lst = plugin.process(img); - if (lst != null) { - arguments.addAll(lst); - } - } + postProcessingPlugins.stream() + .map((plugin) -> plugin.process(img)) + .filter((lst) -> (lst != null)) + .forEach((lst) -> { + arguments.addAll(lst); + }); img.storeLaunchArgs(arguments); } @@ -230,15 +229,15 @@ public final class ImagePluginStack { resources.getStringTable()); } PreVisitStrings previsit = new PreVisitStrings(); - for (ResourcePrevisitor p : resourcePrevisitors) { + resourcePrevisitors.stream().forEach((p) -> { p.previsit(resources, previsit); - } + }); // Store the strings resulting from the previsit. List sorted = previsit.getSortedStrings(); - for (String s : sorted) { + sorted.stream().forEach((s) -> { resources.getStringTable().addString(s); - } + }); ModulePoolImpl current = resources; List frozenOrder = null; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java index 5f64f25baae..2bfaaec5df3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java @@ -113,8 +113,7 @@ public final class ImageResourcesTree { private final boolean isEmpty; PackageReference(String name, boolean isEmpty) { - Objects.requireNonNull(name); - this.name = name; + this.name = Objects.requireNonNull(name); this.isEmpty = isEmpty; } @@ -132,12 +131,8 @@ public final class ImageResourcesTree { private void addReference(String name, boolean isEmpty) { PackageReference ref = references.get(name); - if (ref == null) { + if (ref == null || ref.isEmpty) { references.put(name, new PackageReference(name, isEmpty)); - } else { - if (ref.isEmpty) { // replace with new one incase non empty. - references.put(name, new PackageReference(name, isEmpty)); - } } } @@ -267,8 +262,7 @@ public final class ImageResourcesTree { } // Validate that the packages are well formed. for (Node n : packages.children.values()) { - PackageNode pkg = (PackageNode) n; - pkg.validate(); + ((PackageNode)n).validate(); } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java index 30a15a6e458..7ba9b7db72e 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java @@ -44,9 +44,15 @@ class ImageStringsWriter implements ImageStrings { // Reserve 0 offset for empty string. int offset = addString(""); - assert offset == 0 : "Empty string not zero offset"; + if (offset != 0) { + throw new InternalError("Empty string not offset zero"); + } + // Reserve 1 offset for frequently used ".class". - addString("class"); + offset = addString("class"); + if (offset != 1) { + throw new InternalError("'class' string not offset one"); + } } private int addString(final String string) { @@ -76,7 +82,9 @@ class ImageStringsWriter implements ImageStrings { public String get(int offset) { ByteBuffer buffer = stream.getBuffer(); int capacity = buffer.capacity(); - assert 0 <= offset && offset < capacity : "String buffer offset out of range"; + if (offset < 0 || offset >= capacity) { + throw new InternalError("String buffer offset out of range"); + } int zero = NOT_FOUND; for (int i = offset; i < capacity; i++) { if (buffer.get(i) == '\0') { @@ -84,7 +92,9 @@ class ImageStringsWriter implements ImageStrings { break; } } - assert zero != NOT_FOUND; + if (zero == NOT_FOUND) { + throw new InternalError("String zero terminator not found"); + } int length = zero - offset; byte[] bytes = new byte[length]; int mark = buffer.position(); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java index 579746f95ce..c7c70dad584 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java @@ -30,8 +30,6 @@ import java.io.InputStream; import java.io.UncheckedIOException; import java.nio.file.Path; import java.util.Objects; -import java.util.function.Consumer; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -53,8 +51,8 @@ public abstract class JarArchive implements Archive { JarEntry(String path, String name, EntryType type, ZipFile file, ZipEntry entry) { super(JarArchive.this, path, name, type); - this.entry = entry; - this.file = file; + this.entry = Objects.requireNonNull(entry); + this.file = Objects.requireNonNull(file); size = entry.getSize(); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java index 44c1b43eb5c..c6732081cf1 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java @@ -82,7 +82,7 @@ public class JlinkTask { private static final TaskHelper taskHelper = new TaskHelper(JLINK_BUNDLE); - static Option[] recognizedOptions = { + private static final Option[] recognizedOptions = { new Option(false, (task, opt, arg) -> { task.options.help = true; }, "--help"), @@ -325,7 +325,6 @@ public class JlinkTask { Set limitMods, Set addMods) { - ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0])); // jmods are located at link-time diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java index 39a17347e51..5997ea03379 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java @@ -25,7 +25,6 @@ package jdk.tools.jlink.internal; -import jdk.tools.jlink.internal.JarArchive; import java.nio.file.Path; import java.util.Objects; import jdk.tools.jlink.internal.Archive.Entry.EntryType; @@ -35,7 +34,7 @@ import jdk.tools.jlink.internal.Archive.Entry.EntryType; */ public class JmodArchive extends JarArchive { - private static final String JMOD_EXT = ".jmod"; + private static final String JMOD_EXT = ".jmod"; private static final String MODULE_NAME = "module"; private static final String MODULE_INFO = "module-info.class"; private static final String CLASSES = "classes"; @@ -46,8 +45,9 @@ public class JmodArchive extends JarArchive { public JmodArchive(String mn, Path jmod) { super(mn, jmod); String filename = Objects.requireNonNull(jmod.getFileName()).toString(); - if (!filename.endsWith(JMOD_EXT)) + if (!filename.endsWith(JMOD_EXT)) { throw new UnsupportedOperationException("Unsupported format: " + filename); + } } @Override @@ -65,7 +65,6 @@ public class JmodArchive extends JarArchive { case MODULE_NAME: return EntryType.MODULE_NAME; default: - //throw new InternalError("unexpected entry: " + name + " " + zipfile.toString()); //TODO throw new InternalError("unexpected entry: " + section); } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java index 3afcfe4947d..0c005fe52e8 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModularJarArchive.java @@ -39,8 +39,9 @@ public class ModularJarArchive extends JarArchive { public ModularJarArchive(String mn, Path jmod) { super(mn, jmod); String filename = Objects.requireNonNull(jmod.getFileName()).toString(); - if (!filename.endsWith(JAR_EXT)) + if (!filename.endsWith(JAR_EXT)) { throw new UnsupportedOperationException("Unsupported format: " + filename); + } } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java index 61c22ffc457..620e8ffef0b 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal; -import java.io.InputStream; import java.nio.file.Path; import java.util.Objects; import jdk.tools.jlink.plugin.ModuleEntry; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java index dabdb5bb972..467da23ae68 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java @@ -24,8 +24,6 @@ */ package jdk.tools.jlink.internal; -import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.lang.module.ModuleDescriptor; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -168,8 +166,8 @@ public class ModulePoolImpl implements ModulePool { } public ModulePoolImpl(ByteOrder order, StringTable table) { - this.order = order; - this.table = table; + this.order = Objects.requireNonNull(order); + this.table = Objects.requireNonNull(table); } /** diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java index 28c56391193..df068cdd65f 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java @@ -31,7 +31,6 @@ import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; -import jdk.tools.jlink.plugin.ModuleEntry; /** * A ModuleEntry backed by a given nio Path. @@ -43,9 +42,9 @@ public class PathModuleEntry extends AbstractModuleEntry { * Create a new PathModuleEntry. * * @param module The module name. - * @param file The data file identifier. + * @param path The path for the resource content. * @param type The data type. - * @param file The Path for the resource content. + * @param file The data file identifier. */ public PathModuleEntry(String module, String path, Type type, Path file) { super(module, path, type); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java index c8b8bc79ed6..c233326ec1f 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java @@ -42,7 +42,6 @@ public interface ResourcePrevisitor { * @param resources Read only resources. * @param strings StringTable instance. Add string to the StringTable to track string * usage. - * @throws PluginException */ public void previsit(ModulePool resources, StringTable strings); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java index f48665e4a57..7a166e1c82c 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.Plugin.Category; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java index 7272a6ad5d1..6b05145f278 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java @@ -127,7 +127,7 @@ public final class AppRuntimeImageBuilder { jlink.build(jlinkConfig, pluginConfig); } - /** + /* * Returns a ModuleFinder that limits observability to the given root * modules, their transitive dependences, plus a set of other modules. */ diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java index d78ae453dda..bc753cfb8cd 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal.plugins; -import java.util.Collections; import java.util.Map; import jdk.tools.jlink.internal.ModulePoolImpl; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java index eeb454af0c4..b243ce684ef 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java @@ -24,14 +24,11 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.UncheckedIOException; -import java.util.Collections; import java.util.Map; import java.util.function.Predicate; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.ModuleEntry; -import jdk.tools.jlink.internal.Utils; /** * diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java index b3a84ffa853..d193473197e 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal.plugins; -import java.util.Collections; import java.util.Map; import java.util.function.Predicate; import jdk.tools.jlink.plugin.TransformerPlugin; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java index 6b34a5da436..8553e1a4026 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java @@ -25,12 +25,10 @@ package jdk.tools.jlink.internal.plugins; import java.io.BufferedReader; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; -import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java index 8bbd02cdb79..195b596bf72 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java @@ -26,7 +26,6 @@ package jdk.tools.jlink.internal.plugins; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.UncheckedIOException; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; @@ -35,7 +34,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index 0fe662a0bb9..b9a60ad564a 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -24,10 +24,8 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.ByteArrayInputStream; import java.lang.reflect.Method; import java.util.Arrays; -import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Map; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index 6742d695cc6..fd7a37cf7b0 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -24,10 +24,8 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.IllformedLocaleException; import java.util.Locale; import java.util.List; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java index d5e9c25be09..d522fa0c7e5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java @@ -30,7 +30,6 @@ import java.io.OutputStream; import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java index 3041f4ac1d2..ac67a5f6413 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java @@ -30,11 +30,9 @@ import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.PathMatcher; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.ToIntFunction; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModuleEntry; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java index 1fbf0fbff36..155243a2ebd 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java @@ -26,7 +26,6 @@ package jdk.tools.jlink.internal.plugins; import java.io.FileInputStream; import java.io.IOException; -import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java index cec1de1a4a1..98cccd12051 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java @@ -46,7 +46,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java index 62d89651869..65eb1bb7404 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java @@ -24,9 +24,6 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.ByteArrayInputStream; -import java.util.Arrays; -import java.util.Collections; import java.util.function.Predicate; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java index 44e3ec52bc8..f70af29558a 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal.plugins; -import java.util.Collections; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java index b44f2e81e64..366ac079f4c 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java @@ -28,7 +28,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; -import java.util.Collections; import java.util.Map; import java.util.function.Predicate; import java.util.zip.Deflater; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java index 977e044373b..d8806666039 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/optim/ControlFlow.java @@ -76,9 +76,7 @@ public final class ControlFlow { @Override public int hashCode() { - int hash = 3; - hash = 79 * hash + Objects.hashCode(this.firstInstruction); - return hash; + return Objects.hashCode(this.firstInstruction); } @Override @@ -214,9 +212,7 @@ public final class ControlFlow { @Override public int hashCode() { - int hash = 3; - hash = 89 * hash + this.getIndex(); - return hash; + return this.getIndex(); } @Override From ed73972cdafeca4daca965a452dcd49cafa3b1c9 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Tue, 28 Jun 2016 20:03:29 +0100 Subject: [PATCH 060/191] 8143640: Showing incorrect result while passing specific argument in the Java launcher tools Reviewed-by: ksrini --- jdk/src/java.base/windows/native/libjli/cmdtoargs.c | 1 + jdk/test/tools/launcher/Arrrghs.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c index 80d66a9e324..02c5adf81c9 100644 --- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c +++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c @@ -155,6 +155,7 @@ static char* next_arg(char* cmdline, char* arg, jboolean* wildcard) { } } dest += copyCh(ch, dest); + slashes = 0; break; default: diff --git a/jdk/test/tools/launcher/Arrrghs.java b/jdk/test/tools/launcher/Arrrghs.java index 9045e010473..4d799f35efe 100644 --- a/jdk/test/tools/launcher/Arrrghs.java +++ b/jdk/test/tools/launcher/Arrrghs.java @@ -24,7 +24,7 @@ /** * @test * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 - * 6894719 6968053 7151434 7146424 8007333 8077822 + * 6894719 6968053 7151434 7146424 8007333 8077822 8143640 * @summary Argument parsing validation. * @compile -XDignore.symbol.file Arrrghs.java * @run main/othervm Arrrghs @@ -197,6 +197,8 @@ public class Arrrghs extends TestHelper { // more treatment of mixed slashes checkArgumentParsing("f1/ f3\\ f4/", "f1/", "f3\\", "f4/"); checkArgumentParsing("f1/ f2\' ' f3/ f4/", "f1/", "f2\'", "'", "f3/", "f4/"); + + checkArgumentParsing("a\\*\\b", "a\\*\\b"); } private void initEmptyDir(File emptyDir) throws IOException { From c19f3e0db256aeafca34017e6322f022d1e14e45 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Tue, 28 Jun 2016 15:36:15 -0700 Subject: [PATCH 061/191] 6233323: ZipEntry.isDirectory() may return false incorrectly 8144977: Class.getResourceAsStream("directory") in JAR returns broken InputStream Reviewed-by: rriggs --- .../share/classes/java/util/zip/ZipFile.java | 16 +++++---- jdk/test/java/util/zip/ZipFile/ReadZip.java | 36 ++++++++++++++++++- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java index cc9153608e2..ef26d1784cc 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -295,13 +295,13 @@ class ZipFile implements ZipConstants, Closeable { * @throws IllegalStateException if the zip file has been closed */ public ZipEntry getEntry(String name) { - Objects.requireNonNull(name, "name"); synchronized (this) { ensureOpen(); - int pos = zsrc.getEntryPos(zc.getBytes(name), true); + byte[] bname = zc.getBytes(name); + int pos = zsrc.getEntryPos(bname, true); if (pos != -1) { - return getZipEntry(name, pos); + return getZipEntry(name, bname, pos); } } return null; @@ -492,7 +492,7 @@ class ZipFile implements ZipConstants, Closeable { throw new NoSuchElementException(); } // each "entry" has 3 ints in table entries - return getZipEntry(null, zsrc.getEntryPos(i++ * 3)); + return getZipEntry(null, null, zsrc.getEntryPos(i++ * 3)); } } @@ -527,13 +527,17 @@ class ZipFile implements ZipConstants, Closeable { } /* Checks ensureOpen() before invoke this method */ - private ZipEntry getZipEntry(String name, int pos) { + private ZipEntry getZipEntry(String name, byte[] bname, int pos) { byte[] cen = zsrc.cen; int nlen = CENNAM(cen, pos); int elen = CENEXT(cen, pos); int clen = CENCOM(cen, pos); int flag = CENFLG(cen, pos); - if (name == null) { + if (name == null || bname.length != nlen) { + // to use the entry name stored in cen, if the passed in name is + // (1) null, invoked from iterator, or + // (2) not equal to the name stored, a slash is appended during + // getEntryPos() search. if (!zc.isUTF8() && (flag & EFS) != 0) { name = zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { diff --git a/jdk/test/java/util/zip/ZipFile/ReadZip.java b/jdk/test/java/util/zip/ZipFile/ReadZip.java index fe923e81eee..465f1ce3731 100644 --- a/jdk/test/java/util/zip/ZipFile/ReadZip.java +++ b/jdk/test/java/util/zip/ZipFile/ReadZip.java @@ -22,7 +22,7 @@ */ /* @test - @bug 4241361 4842702 4985614 6646605 5032358 6923692 + @bug 4241361 4842702 4985614 6646605 5032358 6923692 6233323 8144977 @summary Make sure we can read a zip file. @key randomness */ @@ -105,6 +105,40 @@ public class ReadZip { newZip.delete(); } + // Read directory entry + try { + try (FileOutputStream fos = new FileOutputStream(newZip); + ZipOutputStream zos = new ZipOutputStream(fos)) + { + ZipEntry ze = new ZipEntry("directory/"); + zos.putNextEntry(ze); + zos.closeEntry(); + } + try (ZipFile zf = new ZipFile(newZip)) { + ZipEntry ze = zf.getEntry("directory/"); + if (ze == null || !ze.isDirectory()) + throw new RuntimeException("read entry \"directory/\" failed"); + try (InputStream is = zf.getInputStream(ze)) { + is.available(); + } catch (Exception x) { + x.printStackTrace(); + } + + ze = zf.getEntry("directory"); + if (ze == null || !ze.isDirectory()) + throw new RuntimeException("read entry \"directory\" failed"); + try (InputStream is = zf.getInputStream(ze)) { + is.available(); + } catch (Exception x) { + x.printStackTrace(); + } + } + } finally { + newZip.delete(); + } + + + // Throw a FNF exception when read a non-existing zip file try { unreached (new ZipFile( new File(System.getProperty("test.src", "."), From 7a7b5b32cfe41a26aa81c100d4dca94465684348 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 28 Jun 2016 16:57:27 -0700 Subject: [PATCH 062/191] 8160502: Problem listing of several http2 tests Reviewed-by: lancea --- jdk/test/ProblemList.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 99cf992ccf1..f46c820671e 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -164,6 +164,10 @@ java/net/MulticastSocket/Test.java 7145658 macosx-a java/net/DatagramSocket/SendDatagramToBadAddress.java 7143960 macosx-all +java/net/httpclient/http2/BasicTest.java 8157408 linux-all +java/net/httpclient/http2/ErrorTest.java 8158127 solaris-all,windows-all +java/net/httpclient/http2/TLSConnection.java 8157482 macosx-all + ############################################################################ # jdk_nio From 7dd146f0728a7c1e7597484c2b16086a46d1a13c Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Wed, 29 Jun 2016 08:30:49 +0200 Subject: [PATCH 063/191] 8160439: Replace asserts in VarHandle.AccessMode with tests Reviewed-by: vlivanov, rriggs, martin --- .../classes/java/lang/invoke/VarHandle.java | 12 ---- .../VarHandleTestAccessModeMethodNames.java | 61 +++++++++++++++++++ 2 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessModeMethodNames.java diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index ee7be4096bf..f55acf251e2 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -1275,8 +1275,6 @@ public abstract class VarHandle { this.methodName = methodName; this.at = at; - // Assert method name is correctly derived from value name - assert methodName.equals(toMethodName(name())); // Assert that return type is correct // Otherwise, when disabled avoid using reflection assert at.returnType == getReturnType(methodName); @@ -1311,16 +1309,6 @@ public abstract class VarHandle { throw new IllegalArgumentException("No AccessMode value for method name " + methodName); } - private static String toMethodName(String name) { - StringBuilder s = new StringBuilder(name.toLowerCase()); - int i; - while ((i = s.indexOf("_")) != -1) { - s.deleteCharAt(i); - s.setCharAt(i, Character.toUpperCase(s.charAt(i))); - } - return s.toString(); - } - private static Class getReturnType(String name) { try { Method m = VarHandle.class.getMethod(name, Object[].class); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessModeMethodNames.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessModeMethodNames.java new file mode 100644 index 00000000000..dc86cc643bc --- /dev/null +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessModeMethodNames.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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 + * @run testng VarHandleTestAccessModeMethodNames + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.invoke.VarHandle; +import java.util.stream.Stream; + +import static org.testng.Assert.assertEquals; + +public class VarHandleTestAccessModeMethodNames { + + @DataProvider + public static Object[][] accessModesProvider() { + return Stream.of(VarHandle.AccessMode.values()). + map(am -> new Object[]{am}). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "accessModesProvider") + public void testMethodName(VarHandle.AccessMode am) { + assertEquals(am.methodName(), toMethodName(am.name())); + } + + private static String toMethodName(String name) { + StringBuilder s = new StringBuilder(name.toLowerCase()); + int i; + while ((i = s.indexOf("_")) != -1) { + s.deleteCharAt(i); + s.setCharAt(i, Character.toUpperCase(s.charAt(i))); + } + return s.toString(); + } +} From 9f0c345f7f88b0c4db9553d7923734beea345e7a Mon Sep 17 00:00:00 2001 From: Steve Drach Date: Fri, 10 Jun 2016 13:57:51 -0700 Subject: [PATCH 064/191] 8114827: JDK 9 multi-release enabled jar tool Reviewed-by: chegar --- .../jdk/internal/util/jar/JarIndex.java | 3 +- .../share/classes/sun/tools/jar/Main.java | 248 ++++++++---- .../sun/tools/jar/resources/jar.properties | 30 +- .../tools/jar/compat/CLICompatibility.java | 4 +- jdk/test/tools/jar/multiRelease/Basic.java | 354 ++++++++++++++++++ .../data/test01/base/version/Main.java | 8 + .../data/test01/base/version/Version.java | 13 + .../data/test01/v10/version/Version.java | 13 + .../data/test01/v9/version/Version.java | 13 + 9 files changed, 602 insertions(+), 84 deletions(-) create mode 100644 jdk/test/tools/jar/multiRelease/Basic.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test01/base/version/Main.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test01/base/version/Version.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test01/v10/version/Version.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test01/v9/version/Version.java diff --git a/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java index fd92b13bdb9..367ac31b07a 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java +++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java @@ -222,7 +222,8 @@ public class JarIndex { // Any files in META-INF/ will be indexed explicitly if (fileName.equals("META-INF/") || fileName.equals(INDEX_NAME) || - fileName.equals(JarFile.MANIFEST_NAME)) + fileName.equals(JarFile.MANIFEST_NAME) || + fileName.startsWith("META-INF/versions/")) continue; if (!metaInfFilenames || !fileName.startsWith("META-INF/")) { diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index 85381b79ecc..f33bcf711ce 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -48,6 +48,7 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.*; import java.util.jar.*; import java.util.jar.Pack200.*; @@ -77,24 +78,82 @@ class Main { PrintStream out, err; String fname, mname, ename; String zname = ""; - String[] files; String rootjar = null; - // An entryName(path)->File map generated during "expand", it helps to + private static final int BASE_VERSION = 0; + + class Entry { + final String basename; + final String entryname; + final File file; + final boolean isDir; + + Entry(int version, File file) { + this.file = file; + String path = file.getPath(); + if (file.isDirectory()) { + isDir = true; + path = path.endsWith(File.separator) ? path : + path + File.separator; + } else { + isDir = false; + } + EntryName en = new EntryName(path, version); + basename = en.baseName; + entryname = en.entryName; + } + } + + class EntryName { + final String baseName; + final String entryName; + + EntryName(String name, int version) { + name = name.replace(File.separatorChar, '/'); + String matchPath = ""; + for (String path : pathsMap.get(version)) { + if (name.startsWith(path) + && (path.length() > matchPath.length())) { + matchPath = path; + } + } + name = safeName(name.substring(matchPath.length())); + // the old implementaton doesn't remove + // "./" if it was led by "/" (?) + if (name.startsWith("./")) { + name = name.substring(2); + } + this.baseName = name; + this.entryName = (version > BASE_VERSION) + ? VERSIONS_DIR + version + "/" + this.baseName + : this.baseName; + } + } + + // An entryName(path)->Entry map generated during "expand", it helps to // decide whether or not an existing entry in a jar file needs to be // replaced, during the "update" operation. - Map entryMap = new HashMap(); + Map entryMap = new HashMap<>(); + + // All entries need to be added/updated. + Map entries = new LinkedHashMap<>(); - // All files need to be added/updated. - Set entries = new LinkedHashSet(); // All packages. Set packages = new HashSet<>(); // All actual entries added, or existing, in the jar file ( excl manifest // and module-info.class ). Populated during create or update. Set jarEntries = new HashSet<>(); - // Directories specified by "-C" operation. - Set paths = new HashSet(); + // A paths Set for each version, where each Set contains directories + // specified by the "-C" operation. + Map> pathsMap = new HashMap<>(); + + // There's also a files array per version + Map filesMap = new HashMap<>(); + + // Do we think this is a multi-release jar? Set to true + // if --release option found followed by at least file + boolean isMultiRelease; /* * cflag: create @@ -241,10 +300,15 @@ class Main { if (ename != null) { addMainClass(manifest, ename); } + if (isMultiRelease) { + addMultiRelease(manifest); + } } Map moduleInfoPaths = new HashMap<>(); - expand(null, files, false, moduleInfoPaths); - + for (int version : filesMap.keySet()) { + String[] files = filesMap.get(version); + expand(null, files, false, moduleInfoPaths, version); + } Map moduleInfos = new LinkedHashMap<>(); if (!moduleInfoPaths.isEmpty()) { if (!checkModuleInfos(moduleInfoPaths)) @@ -348,7 +412,10 @@ class Main { (new FileInputStream(mname)) : null; Map moduleInfoPaths = new HashMap<>(); - expand(null, files, true, moduleInfoPaths); + for (int version : filesMap.keySet()) { + String[] files = filesMap.get(version); + expand(null, files, true, moduleInfoPaths, version); + } Map moduleInfos = new HashMap<>(); for (Map.Entry e : moduleInfoPaths.entrySet()) @@ -381,10 +448,11 @@ class Main { tmpFile.delete(); } } else if (tflag) { - replaceFSC(files); + replaceFSC(filesMap); // For the "list table contents" action, access using the // ZipFile class is always most efficient since only a // "one-finger" scan through the central directory is required. + String[] files = filesMapToFiles(filesMap); if (fname != null) { list(fname, files); } else { @@ -396,7 +464,7 @@ class Main { } } } else if (xflag) { - replaceFSC(files); + replaceFSC(filesMap); // For the extract action, when extracting all the entries, // access using the ZipInputStream class is most efficient, // since only a single sequential scan through the zip file is @@ -406,6 +474,8 @@ class Main { // "leading garbage", we fall back from the ZipInputStream // implementation to the ZipFile implementation, since only the // latter can handle it. + + String[] files = filesMapToFiles(filesMap); if (fname != null && files != null) { extract(fname, files); } else { @@ -421,6 +491,7 @@ class Main { } } } else if (iflag) { + String[] files = filesMap.get(BASE_VERSION); // base entries only, can be null genIndex(rootjar, files); } else if (printModuleDescriptor) { boolean found; @@ -449,6 +520,20 @@ class Main { return ok; } + private String[] filesMapToFiles(Map filesMap) { + if (filesMap.isEmpty()) return null; + return filesMap.entrySet() + .stream() + .flatMap(this::filesToEntryNames) + .toArray(String[]::new); + } + + Stream filesToEntryNames(Map.Entry fileEntries) { + int version = fileEntries.getKey(); + return Stream.of(fileEntries.getValue()) + .map(f -> (new EntryName(f, version)).entryName); + } + /** * Parses command line arguments. */ @@ -579,8 +664,10 @@ class Main { /* parse file arguments */ int n = args.length - count; if (n > 0) { + int version = BASE_VERSION; int k = 0; String[] nameBuf = new String[n]; + pathsMap.put(version, new HashSet<>()); try { for (int i = count; i < args.length; i++) { if (args[i].equals("-C")) { @@ -592,8 +679,33 @@ class Main { while (dir.indexOf("//") > -1) { dir = dir.replace("//", "/"); } - paths.add(dir.replace(File.separatorChar, '/')); + pathsMap.get(version).add(dir.replace(File.separatorChar, '/')); nameBuf[k++] = dir + args[++i]; + } else if (args[i].startsWith("--release")) { + int v = BASE_VERSION; + try { + v = Integer.valueOf(args[++i]); + } catch (NumberFormatException x) { + error(formatMsg("error.release.value.notnumber", args[i])); + // this will fall into the next error, thus returning false + } + if (v < 9) { + error(formatMsg("error.release.value.toosmall", String.valueOf(v))); + usageError(); + return false; + } + // associate the files, if any, with the previous version number + if (k > 0) { + String[] files = new String[k]; + System.arraycopy(nameBuf, 0, files, 0, k); + filesMap.put(version, files); + isMultiRelease = version > BASE_VERSION; + } + // reset the counters and start with the new version number + k = 0; + nameBuf = new String[n]; + version = v; + pathsMap.put(version, new HashSet<>()); } else { nameBuf[k++] = args[i]; } @@ -602,8 +714,13 @@ class Main { usageError(); return false; } - files = new String[k]; - System.arraycopy(nameBuf, 0, files, 0, k); + // associate remaining files, if any, with a version + if (k > 0) { + String[] files = new String[k]; + System.arraycopy(nameBuf, 0, files, 0, k); + filesMap.put(version, files); + isMultiRelease = version > BASE_VERSION; + } } else if (cflag && (mname == null)) { error(getMsg("error.bad.cflag")); usageError(); @@ -651,7 +768,8 @@ class Main { void expand(File dir, String[] files, boolean isUpdate, - Map moduleInfoPaths) + Map moduleInfoPaths, + int version) throws IOException { if (files == null) @@ -664,29 +782,29 @@ class Main { else f = new File(dir, files[i]); + Entry entry = new Entry(version, f); + String entryName = entry.entryname; + if (f.isFile()) { - String path = f.getPath(); - String entryName = entryName(path); if (entryName.endsWith(MODULE_INFO)) { moduleInfoPaths.put(entryName, f.toPath()); if (isUpdate) - entryMap.put(entryName, f); - } else if (entries.add(f)) { + entryMap.put(entryName, entry); + } else if (!entries.containsKey(entryName)) { + entries.put(entryName, entry); jarEntries.add(entryName); - if (path.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR)) - packages.add(toPackageName(entryName)); + if (entry.basename.endsWith(".class") && !entryName.startsWith(VERSIONS_DIR)) + packages.add(toPackageName(entry.basename)); if (isUpdate) - entryMap.put(entryName, f); + entryMap.put(entryName, entry); } } else if (f.isDirectory()) { - if (entries.add(f)) { + if (!entries.containsKey(entryName)) { + entries.put(entryName, entry); if (isUpdate) { - String dirPath = f.getPath(); - dirPath = (dirPath.endsWith(File.separator)) ? dirPath : - (dirPath + File.separator); - entryMap.put(entryName(dirPath), f); + entryMap.put(entryName, entry); } - expand(f, f.list(), isUpdate, moduleInfoPaths); + expand(f, f.list(), isUpdate, moduleInfoPaths, version); } } else { error(formatMsg("error.nosuch.fileordir", String.valueOf(f))); @@ -740,8 +858,9 @@ class Main { in.transferTo(zos); zos.closeEntry(); } - for (File file: entries) { - addFile(zos, file); + for (String entryname : entries.keySet()) { + Entry entry = entries.get(entryname); + addFile(zos, entry); } zos.close(); } @@ -823,7 +942,7 @@ class Main { || (Mflag && isManifestEntry)) { continue; } else if (isManifestEntry && ((newManifest != null) || - (ename != null))) { + (ename != null) || isMultiRelease)) { foundManifest = true; if (newManifest != null) { // Don't read from the newManifest InputStream, as we @@ -862,21 +981,21 @@ class Main { zos.putNextEntry(e2); copy(zis, zos); } else { // replace with the new files - File f = entryMap.get(name); - addFile(zos, f); + Entry ent = entryMap.get(name); + addFile(zos, ent); entryMap.remove(name); - entries.remove(f); + entries.remove(name); } jarEntries.add(name); - if (name.endsWith(".class")) + if (name.endsWith(".class") && !(name.startsWith(VERSIONS_DIR))) packages.add(toPackageName(name)); } } // add the remaining new files - for (File f: entries) { - addFile(zos, f); + for (String entryname : entries.keySet()) { + addFile(zos, entries.get(entryname)); } if (!foundManifest) { if (newManifest != null) { @@ -961,6 +1080,9 @@ class Main { if (ename != null) { addMainClass(m, ename); } + if (isMultiRelease) { + addMultiRelease(m); + } ZipEntry e = new ZipEntry(MANIFEST_NAME); e.setTime(System.currentTimeMillis()); if (flag0) { @@ -1016,24 +1138,6 @@ class Main { return name; } - private String entryName(String name) { - name = name.replace(File.separatorChar, '/'); - String matchPath = ""; - for (String path : paths) { - if (name.startsWith(path) - && (path.length() > matchPath.length())) { - matchPath = path; - } - } - name = safeName(name.substring(matchPath.length())); - // the old implementaton doesn't remove - // "./" if it was led by "/" (?) - if (name.startsWith("./")) { - name = name.substring(2); - } - return name; - } - private void addVersion(Manifest m) { Attributes global = m.getMainAttributes(); if (global.getValue(Attributes.Name.MANIFEST_VERSION) == null) { @@ -1058,6 +1162,11 @@ class Main { global.put(Attributes.Name.MAIN_CLASS, mainApp); } + private void addMultiRelease(Manifest m) { + Attributes global = m.getMainAttributes(); + global.put(Attributes.Name.MULTI_RELEASE, "true"); + } + private boolean isAmbiguousMainClass(Manifest m) { if (ename != null) { Attributes global = m.getMainAttributes(); @@ -1073,14 +1182,10 @@ class Main { /** * Adds a new file entry to the ZIP output stream. */ - void addFile(ZipOutputStream zos, File file) throws IOException { - String name = file.getPath(); - boolean isDir = file.isDirectory(); - if (isDir) { - name = name.endsWith(File.separator) ? name : - (name + File.separator); - } - name = entryName(name); + void addFile(ZipOutputStream zos, Entry entry) throws IOException { + File file = entry.file; + String name = entry.entryname; + boolean isDir = entry.isDir; if (name.equals("") || name.equals(".") || name.equals(zname)) { return; @@ -1221,12 +1326,15 @@ class Main { os.updateEntry(e); } - void replaceFSC(String files[]) { - if (files != null) { - for (int i = 0; i < files.length; i++) { - files[i] = files[i].replace(File.separatorChar, '/'); + void replaceFSC(Map filesMap) { + filesMap.keySet().forEach(version -> { + String[] files = filesMap.get(version); + if (files != null) { + for (int i = 0; i < files.length; i++) { + files[i] = files[i].replace(File.separatorChar, '/'); + } } - } + }); } @SuppressWarnings("serial") @@ -1566,7 +1674,7 @@ class Main { /** * Print an error message; like something is broken */ - protected void error(String s) { + void error(String s) { err.println(s); } diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties index 85316dfb00b..e00ee76610d 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties @@ -63,24 +63,28 @@ error.unexpected.module-info=\ error.module.descriptor.not.found=\ Module descriptor not found error.versioned.info.without.root=\ - module-info.class found in versioned section without module-info.class \ + module-info.class found in a versioned directory without module-info.class \ in the root error.versioned.info.name.notequal=\ - module-info.class in versioned section contains incorrect name + module-info.class in a versioned directory contains incorrect name error.versioned.info.requires.public=\ - module-info.class in versioned section contains additional requires public + module-info.class in a versioned directory contains additional requires public error.versioned.info.requires.added=\ - module-info.class in versioned section contains additional requires + module-info.class in a versioned directory contains additional requires error.versioned.info.requires.dropped=\ - module-info.class in versioned section contains missing requires + module-info.class in a versioned directory contains missing requires error.versioned.info.exports.notequal=\ - module-info.class in versioned section contains different exports + module-info.class in a versioned directory contains different exports error.versioned.info.provides.notequal=\ - module-info.class in versioned section contains different provides + module-info.class in a versioned directory contains different provides error.invalid.versioned.module.attribute=\ Invalid module descriptor attribute {0} error.missing.provider=\ Service provider not found: {0} +error.release.value.notnumber=\ + release {0} not valid +error.release.value.toosmall=\ + release {0} not valid, must be >= 9 out.added.manifest=\ added manifest out.added.module-info=\ @@ -109,7 +113,7 @@ out.size=\ usage.compat=\ \Compatibility Interface:\ \n\ -Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...\n\ +Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files] ...\n\ Options:\n\ \ \ -c create new archive\n\ \ \ -t list table of contents for archive\n\ @@ -141,7 +145,7 @@ main.usage.summary.try=\ Try `jar --help' for more information. main.help.preopt=\ -Usage: jar [OPTION...] [-C dir] files ...\n\ +Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files] ...\n\ jar creates an archive for classes and resources, and can manipulate or\n\ restore individual classes or resources from an archive.\n\ \n\ @@ -156,7 +160,9 @@ restore individual classes or resources from an archive.\n\ \ -C foo/ classes resources\n\ \ # Update an existing non-modular jar to a modular jar:\n\ \ jar --update --file foo.jar --main-class com.foo.Main --module-version 1.0\n\ -\ -C foo/ module-info.class +\ -C foo/ module-info.class\n\ +\ # Create a multi-release jar, placing some files in the META-INF/versions/9 directory:\n\ +\ jar --create --file mr.jar -C foo classes --release 9 -C foo9 classes main.help.opt.main=\ \ Main operation mode:\n main.help.opt.main.create=\ @@ -178,7 +184,9 @@ main.help.opt.any=\ \ -C DIR Change to the specified directory and include the\n\ \ following file main.help.opt.any.file=\ -\ -f, --file=FILE The archive file name +\ -f, --file=FILE The archive file name\n\ +\ --release VERSION Places all following files in a versioned directory\n\ +\ of the jar (i.e. META-INF/versions/VERSION/) main.help.opt.any.verbose=\ \ -v, --verbose Generate verbose output on standard output main.help.opt.create.update=\ diff --git a/jdk/test/tools/jar/compat/CLICompatibility.java b/jdk/test/tools/jar/compat/CLICompatibility.java index 1dd3589362c..75dd1393d99 100644 --- a/jdk/test/tools/jar/compat/CLICompatibility.java +++ b/jdk/test/tools/jar/compat/CLICompatibility.java @@ -415,14 +415,14 @@ public class CLICompatibility { jar("-h") .assertSuccess() .resultChecker(r -> - assertTrue(r.output.startsWith("Usage: jar [OPTION...] [-C dir] files"), + assertTrue(r.output.startsWith("Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files]"), "Failed, got [" + r.output + "]") ); jar("--help") .assertSuccess() .resultChecker(r -> - assertTrue(r.output.startsWith("Usage: jar [OPTION...] [-C dir] files"), + assertTrue(r.output.startsWith("Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files]"), "Failed, got [" + r.output + "]") ); diff --git a/jdk/test/tools/jar/multiRelease/Basic.java b/jdk/test/tools/jar/multiRelease/Basic.java new file mode 100644 index 00000000000..a1b595338e0 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/Basic.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2016, 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 + * @library /test/lib/share/classes + * @modules java.base/jdk.internal.misc + * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Platform + * @run testng Basic + */ + +import static org.testng.Assert.*; + +import org.testng.annotations.*; + +import java.io.*; +import java.nio.file.*; +import java.nio.file.attribute.*; +import java.util.*; +import java.util.function.Consumer; +import java.util.jar.*; +import java.util.stream.Stream; +import java.util.zip.*; + +import jdk.test.lib.JDKToolFinder; + +import static java.lang.String.format; +import static java.lang.System.out; + +public class Basic { + private final String src = System.getProperty("test.src", "."); + private final String usr = System.getProperty("user.dir", "."); + + @Test + // create a regular, non-multi-release jar + public void test00() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, false); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"} + ); + + compare(jarfile, names); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // create a multi-release jar + public void test01() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".", + "--release", "10", "-C", classes.resolve("v10").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v9", "version", "Version.class"}, + + "META-INF/versions/10/version/Version.class", + new String[] {"v10", "version", "Version.class"} + ); + + compare(jarfile, names); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // update a regular jar to a multi-release jar + public void test02() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, false); + + jar("uf", jarfile, "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v9", "version", "Version.class"} + ); + + compare(jarfile, names); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // replace a base entry and a versioned entry + public void test03() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + Map names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"base", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v9", "version", "Version.class"} + ); + + compare(jarfile, names); + + // write the v9 version/Version.class entry in base and the v10 + // version/Version.class entry in versions/9 section + jar("uf", jarfile, "-C", classes.resolve("v9").toString(), "version", + "--release", "9", "-C", classes.resolve("v10").toString(), ".") + .assertSuccess(); + + checkMultiRelease(jarfile, true); + + names = Map.of( + "version/Main.class", + new String[] {"base", "version", "Main.class"}, + + "version/Version.class", + new String[] {"v9", "version", "Version.class"}, + + "META-INF/versions/9/version/Version.class", + new String[] {"v10", "version", "Version.class"} + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + /* + * Test Infrastructure + */ + private void compile(String test) throws IOException { + Path classes = Paths.get(usr, "classes", "base"); + Files.createDirectories(classes); + Path source = Paths.get(src, "data", test, "base", "version"); + javac(classes, source.resolve("Main.java"), source.resolve("Version.java")); + + classes = Paths.get(usr, "classes", "v9"); + Files.createDirectories(classes); + source = Paths.get(src, "data", test, "v9", "version"); + javac(classes, source.resolve("Version.java")); + + classes = Paths.get(usr, "classes", "v10"); + Files.createDirectories(classes); + source = Paths.get(src, "data", test, "v10", "version"); + javac(classes, source.resolve("Version.java")); + } + + private void checkMultiRelease(String jarFile, boolean expected) throws IOException { + try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ, + JarFile.Release.RUNTIME)) { + assertEquals(jf.isMultiRelease(), expected); + } + } + + // compares the bytes found in the jar entries with the bytes found in the + // corresponding data files used to create the entries + private void compare(String jarfile, Map names) throws IOException { + try (JarFile jf = new JarFile(jarfile)) { + for (String name : names.keySet()) { + Path path = Paths.get("classes", names.get(name)); + byte[] b1 = Files.readAllBytes(path); + byte[] b2; + JarEntry je = jf.getJarEntry(name); + try (InputStream is = jf.getInputStream(je)) { + b2 = is.readAllBytes(); + } + assertEquals(b1,b2); + } + } + } + + private void delete(String name) throws IOException { + Files.delete(Paths.get(usr, name)); + } + + private void deleteDir(Path dir) throws IOException { + Files.walkFileTree(dir, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } + + /* + * The following methods were taken from modular jar and other jar tests + */ + + void javac(Path dest, Path... sourceFiles) throws IOException { + String javac = JDKToolFinder.getJDKTool("javac"); + + List commands = new ArrayList<>(); + commands.add(javac); + commands.add("-d"); + commands.add(dest.toString()); + Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x)); + + quickFail(run(new ProcessBuilder(commands))); + } + + Result jarWithStdin(File stdinSource, String... args) { + String jar = JDKToolFinder.getJDKTool("jar"); + List commands = new ArrayList<>(); + commands.add(jar); + Stream.of(args).forEach(x -> commands.add(x)); + ProcessBuilder p = new ProcessBuilder(commands); + if (stdinSource != null) + p.redirectInput(stdinSource); + return run(p); + } + + Result jar(String... args) { + return jarWithStdin(null, args); + } + + void quickFail(Result r) { + if (r.ec != 0) + throw new RuntimeException(r.output); + } + + Result run(ProcessBuilder pb) { + Process p; + out.printf("Running: %s%n", pb.command()); + try { + p = pb.start(); + } catch (IOException e) { + throw new RuntimeException( + format("Couldn't start process '%s'", pb.command()), e); + } + + String output; + try { + output = toString(p.getInputStream(), p.getErrorStream()); + } catch (IOException e) { + throw new RuntimeException( + format("Couldn't read process output '%s'", pb.command()), e); + } + + try { + p.waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException( + format("Process hasn't finished '%s'", pb.command()), e); + } + return new Result(p.exitValue(), output); + } + + String toString(InputStream in1, InputStream in2) throws IOException { + try (ByteArrayOutputStream dst = new ByteArrayOutputStream(); + InputStream concatenated = new SequenceInputStream(in1, in2)) { + concatenated.transferTo(dst); + return new String(dst.toByteArray(), "UTF-8"); + } + } + + static class Result { + final int ec; + final String output; + + private Result(int ec, String output) { + this.ec = ec; + this.output = output; + } + Result assertSuccess() { + assertTrue(ec == 0, format("ec: %d, output: %s", ec, output)); + return this; + } + Result assertFailure() { + assertTrue(ec != 0, format("ec: %d, output: %s", ec, output)); + return this; + } + Result resultChecker(Consumer r) { r.accept(this); return this; } + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test01/base/version/Main.java b/jdk/test/tools/jar/multiRelease/data/test01/base/version/Main.java new file mode 100644 index 00000000000..4fae52482a6 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test01/base/version/Main.java @@ -0,0 +1,8 @@ +package version; + +public class Main { + public static void main(String[] args) { + Version v = new Version(); + System.out.println("I am running on version " + v.getVersion()); + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test01/base/version/Version.java b/jdk/test/tools/jar/multiRelease/data/test01/base/version/Version.java new file mode 100644 index 00000000000..71bd392e821 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test01/base/version/Version.java @@ -0,0 +1,13 @@ +package version; + +public class Version { + public int getVersion() { + return 8; + } + + protected void doNothing() { + } + + private void reallyDoNothing() { + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test01/v10/version/Version.java b/jdk/test/tools/jar/multiRelease/data/test01/v10/version/Version.java new file mode 100644 index 00000000000..571d5b4914f --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test01/v10/version/Version.java @@ -0,0 +1,13 @@ +package version; + +public class Version { + public int getVersion() { + return 10; + } + + protected void doNothing() { + } + + private void someName() { + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test01/v9/version/Version.java b/jdk/test/tools/jar/multiRelease/data/test01/v9/version/Version.java new file mode 100644 index 00000000000..db45a5c8b58 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test01/v9/version/Version.java @@ -0,0 +1,13 @@ +package version; + +public class Version { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + private void anyName() { + } +} From 9eeb285818a10683ca7c8b68d59a7df89f364271 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Mon, 13 Jun 2016 10:10:35 +0200 Subject: [PATCH 065/191] 8072440: serviceability/dcmd/ tests timeout Reviewed-by: sla, mlarsson --- hotspot/test/serviceability/dcmd/framework/HelpTest.java | 1 - .../test/serviceability/dcmd/framework/InvalidCommandTest.java | 1 - hotspot/test/serviceability/dcmd/framework/VMVersionTest.java | 1 - 3 files changed, 3 deletions(-) diff --git a/hotspot/test/serviceability/dcmd/framework/HelpTest.java b/hotspot/test/serviceability/dcmd/framework/HelpTest.java index d03091ef27d..012bcf878ca 100644 --- a/hotspot/test/serviceability/dcmd/framework/HelpTest.java +++ b/hotspot/test/serviceability/dcmd/framework/HelpTest.java @@ -37,7 +37,6 @@ import org.testng.annotations.Test; * java.compiler * java.management * jdk.jvmstat/sun.jvmstat.monitor - * @ignore 8072440 * @build jdk.test.lib.* * @build jdk.test.lib.dcmd.* * @run testng/othervm -XX:+UsePerfData HelpTest diff --git a/hotspot/test/serviceability/dcmd/framework/InvalidCommandTest.java b/hotspot/test/serviceability/dcmd/framework/InvalidCommandTest.java index e05da42c499..afd3755714b 100644 --- a/hotspot/test/serviceability/dcmd/framework/InvalidCommandTest.java +++ b/hotspot/test/serviceability/dcmd/framework/InvalidCommandTest.java @@ -37,7 +37,6 @@ import org.testng.annotations.Test; * java.compiler * java.management * jdk.jvmstat/sun.jvmstat.monitor - * @ignore 8072440 * @build jdk.test.lib.* * @build jdk.test.lib.dcmd.* * @run testng/othervm -XX:+UsePerfData InvalidCommandTest diff --git a/hotspot/test/serviceability/dcmd/framework/VMVersionTest.java b/hotspot/test/serviceability/dcmd/framework/VMVersionTest.java index 63a3fa73399..7daa95fcaf5 100644 --- a/hotspot/test/serviceability/dcmd/framework/VMVersionTest.java +++ b/hotspot/test/serviceability/dcmd/framework/VMVersionTest.java @@ -38,7 +38,6 @@ import org.testng.annotations.Test; * java.compiler * java.management * jdk.jvmstat/sun.jvmstat.monitor - * @ignore 8072440 * @build jdk.test.lib.* * @build jdk.test.lib.dcmd.* * @run testng/othervm -XX:+UsePerfData VMVersionTest From de7ab979ecc6feceb456f1486bf47ab1f58d64ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Mon, 13 Jun 2016 11:48:11 +0200 Subject: [PATCH 066/191] 8158033: Notify_tracing() misplaced for intended purpose Reviewed-by: egahlin, dholmes --- hotspot/src/share/vm/runtime/java.cpp | 15 ++++++++------- hotspot/src/share/vm/trace/traceBackend.hpp | 3 --- hotspot/src/share/vm/trace/traceMacros.hpp | 2 ++ hotspot/src/share/vm/utilities/debug.cpp | 11 ----------- hotspot/src/share/vm/utilities/vmError.cpp | 3 +++ 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index c84153a9157..b854623a8aa 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -446,6 +446,14 @@ void before_exit(JavaThread* thread) { os::infinite_sleep(); } + EventThreadEnd event; + if (event.should_commit()) { + event.set_thread(THREAD_TRACE_ID(thread)); + event.commit(); + } + + TRACE_VM_EXIT(); + // Stop the WatcherThread. We do this before disenrolling various // PeriodicTasks to reduce the likelihood of races. if (PeriodicTask::num_tasks() > 0) { @@ -484,13 +492,6 @@ void before_exit(JavaThread* thread) { JvmtiExport::post_thread_end(thread); } - - EventThreadEnd event; - if (event.should_commit()) { - event.set_thread(THREAD_TRACE_ID(thread)); - event.commit(); - } - // Always call even when there are not JVMTI environments yet, since environments // may be attached late and JVMTI must track phases of VM execution JvmtiExport::post_vm_death(); diff --git a/hotspot/src/share/vm/trace/traceBackend.hpp b/hotspot/src/share/vm/trace/traceBackend.hpp index 36635321ad6..57b80ffda34 100644 --- a/hotspot/src/share/vm/trace/traceBackend.hpp +++ b/hotspot/src/share/vm/trace/traceBackend.hpp @@ -48,9 +48,6 @@ public: static void on_unloading_classes(void) { } - static void on_vm_error(bool) { - } - }; class TraceThreadData { diff --git a/hotspot/src/share/vm/trace/traceMacros.hpp b/hotspot/src/share/vm/trace/traceMacros.hpp index 89f14c3691d..63c49630473 100644 --- a/hotspot/src/share/vm/trace/traceMacros.hpp +++ b/hotspot/src/share/vm/trace/traceMacros.hpp @@ -43,6 +43,8 @@ extern "C" void JNICALL trace_register_natives(JNIEnv*, jclass); #define TRACE_REGISTER_NATIVES ((void*)((address_word)(&trace_register_natives))) #define TRACE_START() JNI_OK #define TRACE_INITIALIZE() JNI_OK +#define TRACE_VM_EXIT() +#define TRACE_VM_ERROR() #define TRACE_DEFINE_TRACE_ID_METHODS typedef int ___IGNORED_hs_trace_type1 #define TRACE_DEFINE_TRACE_ID_FIELD typedef int ___IGNORED_hs_trace_type2 diff --git a/hotspot/src/share/vm/utilities/debug.cpp b/hotspot/src/share/vm/utilities/debug.cpp index b2844487530..95fd3b67e44 100644 --- a/hotspot/src/share/vm/utilities/debug.cpp +++ b/hotspot/src/share/vm/utilities/debug.cpp @@ -54,10 +54,6 @@ #include "utilities/macros.hpp" #include "utilities/vmError.hpp" -#if INCLUDE_TRACE -#include "trace/tracing.hpp" -#endif - #include #ifndef ASSERT @@ -306,11 +302,6 @@ void report_out_of_shared_space(SharedSpaceType shared_space) { exit(2); } -static void notify_tracing() { -#if INCLUDE_TRACE - Tracing::on_vm_error(true); -#endif -} void report_insufficient_metaspace(size_t required_size) { warning("\nThe MaxMetaspaceSize of " SIZE_FORMAT " bytes is not large enough.\n" @@ -334,8 +325,6 @@ void report_java_out_of_memory(const char* message) { HeapDumper::dump_heap_from_oome(); } - notify_tracing(); - if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { VMError::report_java_out_of_memory(message); } diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index 095cc8bbb26..12ed963d17f 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -39,6 +39,7 @@ #include "runtime/vmThread.hpp" #include "runtime/vm_operations.hpp" #include "services/memTracker.hpp" +#include "trace/traceMacros.hpp" #include "utilities/debug.hpp" #include "utilities/decoder.hpp" #include "utilities/defaultStream.hpp" @@ -1165,6 +1166,8 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt // are handled properly. reset_signal_handlers(); + TRACE_VM_ERROR(); + } else { // If UseOsErrorReporting we call this for each level of the call stack // while searching for the exception handler. Only the first level needs From fea4ad3fefef78a63b20df839f59099585daa95d Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Mon, 13 Jun 2016 09:02:47 -0400 Subject: [PATCH 067/191] 8158237: JVMTI hides critical debug information for memory leak tracing Remove _backtrace as hidden field, original problem no longer exists Reviewed-by: sspitsyn, jiangli --- hotspot/src/share/vm/runtime/reflectionUtils.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/runtime/reflectionUtils.cpp b/hotspot/src/share/vm/runtime/reflectionUtils.cpp index fbab2e0fd60..b32d083d7e4 100644 --- a/hotspot/src/share/vm/runtime/reflectionUtils.cpp +++ b/hotspot/src/share/vm/runtime/reflectionUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -73,10 +73,7 @@ GrowableArray *FilteredFieldsMap::_filtered_fields = void FilteredFieldsMap::initialize() { - int offset; - offset = java_lang_Throwable::get_backtrace_offset(); - _filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset)); - offset = reflect_ConstantPool::oop_offset(); + int offset = reflect_ConstantPool::oop_offset(); _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset)); offset = reflect_UnsafeStaticFieldAccessorImpl::base_offset(); _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); From 0d886c8179d1925d81338084dce28baa63985877 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Mon, 13 Jun 2016 09:03:32 -0400 Subject: [PATCH 068/191] 8158237: JVMTI hides critical debug information for memory leak tracing Remove _backtrace as hidden field, original problem no longer exists Reviewed-by: sspitsyn, jiangli --- jdk/test/com/sun/jdi/BacktraceFieldTest.java | 48 +++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/jdk/test/com/sun/jdi/BacktraceFieldTest.java b/jdk/test/com/sun/jdi/BacktraceFieldTest.java index b993a68ecb1..7136eb97121 100644 --- a/jdk/test/com/sun/jdi/BacktraceFieldTest.java +++ b/jdk/test/com/sun/jdi/BacktraceFieldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -24,7 +24,8 @@ /** * @test * @bug 4446677 - * @summary debuggee crashes when debugging under jbuilder + * @bug 8158237 + * @summary debuggee used to crash when debugging under jbuilder * * @author jjh * @@ -101,6 +102,16 @@ public class BacktraceFieldTest extends TestScaffold { new BacktraceFieldTest(args).startTests(); } + private void printval(ArrayReference backTraceVal, int index) throws Exception { + ArrayReference val = (ArrayReference)backTraceVal.getValue(index); + println("BT: val at " + index + " = " + val); + + // The segv used to happen here for index = 0 + // Now all objects in the backtrace are objects. + Object xVal = (Object)val.getValue(0); + println("BT: xVal = " + xVal); + } + /********** test core **********/ protected void runTests() throws Exception { @@ -128,42 +139,45 @@ public class BacktraceFieldTest extends TestScaffold { * Search through the fields of ee to verify that * java.lang.Throwable.backtrace isn't there. */ + boolean backtrace_found = false; Iterator iter = allFields.iterator(); while(iter.hasNext()) { Field ff = (Field)iter.next(); if (ff.toString().equals("java.lang.Throwable.backtrace")) { - failure("ERROR: java.lang.Throwable.backtrace field not filtered out."); + backtrace_found = true; + println("java.lang.Throwable.backtrace field not filtered out."); /* * If you want to experience the segv this bug causes, change * this test to 1 == 1 and run it with jdk 1.4, build 74 or earlier */ - if (1 == 0) { + if (1 == 1) { // The following code will show the segv that this can cause. ObjectReference myVal = (ObjectReference)myFrame.getValue(lv); println("BT: myVal = " + myVal); - ArrayReference backTraceVal = null; - backTraceVal = (ArrayReference)myVal.getValue(ff); + ArrayReference backTraceVal = (ArrayReference)myVal.getValue(ff); println("BT: backTraceVal = " + backTraceVal); - ArrayReference secondVal = (ArrayReference)backTraceVal.getValue(1); - println("BT: secondVal = " + secondVal); + printval(backTraceVal, 0); + printval(backTraceVal, 1); + printval(backTraceVal, 2); + printval(backTraceVal, 3); // backtrace has 4 elements - Object x2Val = (Object)secondVal.getValue(0); - println("BT: x2Val = " + x2Val); - - ArrayReference firstVal = (ArrayReference)backTraceVal.getValue(0); - println("BT: firstVal = " + firstVal); - - // The segv happens here. - Object xVal = (Object)firstVal.getValue(0); - println("BT: xVal = " + xVal); + try { + printval(backTraceVal, 4); + } catch (Exception e) { + println("Exception " + e); + } } break; } } + if (!backtrace_found) { + failure("ERROR: java.lang.Throwable.backtrace field filtered out."); + } + // Next, verify that we don't accidently discard a field that we shouldn't if (!testFailed) { From 680e1a3a2870f726d0f1fd3206de9bb5fc2e8667 Mon Sep 17 00:00:00 2001 From: Max Ockner Date: Mon, 13 Jun 2016 13:47:21 -0400 Subject: [PATCH 069/191] 8157490: JCK test vm/jni/DefineClass/dfcl001/dfcl00101m1/dfcl00101m1 crashes when run with -Xlog:classload=info Null stream->source() no longer causes error with -Xlog:class+load Reviewed-by: lfoltan, coleenp --- hotspot/src/share/vm/classfile/classFileParser.cpp | 10 +--------- hotspot/src/share/vm/oops/instanceKlass.cpp | 6 +++++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index a09fc8e14d0..c6155dd6560 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -5356,15 +5356,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa if (!is_internal()) { if (log_is_enabled(Info, class, load)) { ResourceMark rm; - const char* module_name = NULL; - static const size_t modules_image_name_len = strlen(MODULES_IMAGE_NAME); - size_t stream_len = strlen(_stream->source()); - // See if _stream->source() ends in "modules" - if (module_entry->is_named() && modules_image_name_len < stream_len && - (strncmp(_stream->source() + stream_len - modules_image_name_len, - MODULES_IMAGE_NAME, modules_image_name_len) == 0)) { - module_name = module_entry->name()->as_C_string(); - } + const char* module_name = (module_entry->name() == NULL) ? UNNAMED_MODULE : module_entry->name()->as_C_string(); if (log_is_enabled(Info, class, load)) { ik->print_loading_log(LogLevel::Info, _loader_data, module_name, _stream); diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 58135b4a5ff..23d885a991f 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -3004,7 +3004,11 @@ void InstanceKlass::print_loading_log(LogLevel::type type, if (cfs != NULL) { if (cfs->source() != NULL) { if (module_name != NULL) { - log->print(" source: jrt:/%s", module_name); + if (ClassLoader::is_jrt(cfs->source())) { + log->print(" source: jrt:/%s", module_name); + } else { + log->print(" source: %s", cfs->source()); + } } else { log->print(" source: %s", cfs->source()); } From 0f8af0955ce8fdbf3c7e439e1641214bdf56ce3a Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Tue, 14 Jun 2016 19:15:27 +0300 Subject: [PATCH 070/191] 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle Reviewed-by: tschatzl, dfazunen --- .../humongousObjects/objectGraphTest/GC.java | 56 +++++++++++++++++++ .../humongousObjects/objectGraphTest/README | 7 +++ .../TestObjectGraphAfterGC.java | 8 +++ 3 files changed, 71 insertions(+) diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java index 17aa97413eb..8da879dec5e 100644 --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java @@ -38,6 +38,61 @@ import java.util.function.Consumer; * referenced objects after GCs */ public enum GC { + CMC { + @Override + public Runnable get() { + return () -> { + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + WHITE_BOX.g1StartConcMarkCycle(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + }; + } + + public Consumer> getChecker() { + return getCheckerImpl(false, false, true, false); + } + + @Override + public List shouldContain() { + return Arrays.asList(GCTokens.WB_INITIATED_CMC); + } + + @Override + public List shouldNotContain() { + return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC, + GCTokens.FULL_GC, GCTokens.YOUNG_GC); + } + }, + + CMC_NO_SURV_ROOTS { + @Override + public Runnable get() { + return () -> { + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + + WHITE_BOX.g1StartConcMarkCycle(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + }; + } + + public Consumer> getChecker() { + return getCheckerImpl(true, false, true, false); + } + + @Override + public List shouldContain() { + return Arrays.asList(GCTokens.WB_INITIATED_CMC); + } + + @Override + public List shouldNotContain() { + return Arrays.asList(GCTokens.WB_INITIATED_MIXED_GC, + GCTokens.FULL_GC, GCTokens.YOUNG_GC); + } + }, YOUNG_GC { @Override @@ -60,6 +115,7 @@ public enum GC { GCTokens.CMC, GCTokens.YOUNG_GC); } }, + FULL_GC { @Override public Runnable get() { diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README index 1c3522e6ff3..4ec9f0d3792 100644 --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README @@ -31,6 +31,13 @@ The test checks that after different type of GC unreachable objects behave as ex 3. Full GC with memory pressure - weakly and softly referenced non-humongous and humongous objects are collected. +4. CMC - weakly referenced non-humongous objects are collected, other objects are not collected since weak references + from Young Gen is handled as strong during CMC. + +5. CMC_NO_SURV_ROOTS - weakly referenced non-humongous and humongous objects are collected, softly referenced + non-humongous and humongous objects are not collected since we make 2 Young GC to promote all + weak references to Old Gen. + The test gets gc type as a command line argument. Then the test allocates object graph in heap (currently testing scenarios are pre-generated and stored in TestcaseData.getPregeneratedTestcases()) with TestObjectGraphAfterGC::allocateObjectGraph. diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java index 53c58b49c09..8e028973547 100644 --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java @@ -77,6 +77,14 @@ import java.util.stream.Collectors; * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_FULL_GC_MEMORY_PRESSURE.gc.log * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC FULL_GC_MEMORY_PRESSURE * + * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_CMC.gc.log -XX:MaxTenuringThreshold=16 + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC CMC + * + * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_CMC_NO_SURV_ROOTS.gc.log -XX:MaxTenuringThreshold=1 + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC CMC_NO_SURV_ROOTS + * */ /** From ada2d6579395f2f2cb315f5a2163bf9e8bfabb2a Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Tue, 14 Jun 2016 14:35:34 -0400 Subject: [PATCH 071/191] 8159255: [TESTBUG] XpatchJavaBase.java compilation failure Reviewed-by: lfoltan, hseigel, ddmitriev --- hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java b/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java index 53a056e760c..3c0e50a58fb 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java +++ b/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java @@ -25,6 +25,7 @@ * @test * @bug 8130399 * @summary Make sure -Xpatch works for java.base. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile XpatchMain.java * @run main XpatchJavaBase From 69bdc4f2475606e96b3f5572feb3c1850674e4dc Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Tue, 14 Jun 2016 14:31:36 -0400 Subject: [PATCH 072/191] 8159328: [TESTBUG] ProblematicFrameTest.java throws an exception (due to trying to access Unsafe) but still passes Reviewed-by: hseigel, ddmitriev --- hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java index df6b9cea1fe..117c4839207 100644 --- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -48,8 +48,9 @@ public class ProblematicFrameTest { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); + "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Exception in thread"); output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)"); } } From f5b4d9e51f56c67396dc49f20c8330ffda250c96 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 15 Jun 2016 09:43:42 +0200 Subject: [PATCH 073/191] 8149778: serviceability/tmtools/jstat/GcCapacityTest.java causes JVM to hang during GC Reviewed-by: pliden, stefank --- .../test/serviceability/tmtools/jstat/GcCapacityTest.java | 1 - .../serviceability/tmtools/jstat/utils/GcProvokerImpl.java | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java b/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java index 2ed5c0576fd..8e2f56e8b37 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java @@ -33,7 +33,6 @@ import utils.*; * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @build common.* * @build utils.* - * @ignore 8149778 * @run main/othervm -XX:+UsePerfData -Xmx128M GcCapacityTest */ public class GcCapacityTest { diff --git a/hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java b/hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java index 388b53c5256..f04cdf6a375 100644 --- a/hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java +++ b/hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java @@ -42,8 +42,9 @@ public class GcProvokerImpl implements GcProvoker { // uses fixed small objects to avoid Humongous objects allocation in G1 int memoryChunk = 2048; List list = new ArrayList<>(); - float used = 0; - while (used < targetUsage * maxMemory) { + long used = 0; + long target = (long) (maxMemory * targetUsage); + while (used < target) { try { list.add(new byte[memoryChunk]); used += memoryChunk; From 048538542ac367bd327ff42cbf5a248bdcb5d574 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 15 Jun 2016 09:54:12 +0200 Subject: [PATCH 074/191] 8154106: UL Xlog:help regd'g 'rt' tag Reviewed-by: mlarsson, mockner, gtriantafill --- hotspot/src/share/vm/logging/logConfiguration.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 922d4b53c06..ecc1ead0105 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -484,13 +484,13 @@ void LogConfiguration::print_command_line_help(FILE* out) { " -Xlog:gc::uptime,tid\n" "\t Log messages tagged with 'gc' tag using 'info' level to output 'stdout', using 'uptime' and 'tid' decorations.\n\n" - " -Xlog:gc*=info,rt*=off\n" - "\t Log messages tagged with at least 'gc' using 'info' level, but turn off logging of messages tagged with 'rt'.\n" - "\t (Messages tagged with both 'gc' and 'rt' will not be logged.)\n\n" + " -Xlog:gc*=info,safepoint*=off\n" + "\t Log messages tagged with at least 'gc' using 'info' level, but turn off logging of messages tagged with 'safepoint'.\n" + "\t (Messages tagged with both 'gc' and 'safepoint' will not be logged.)\n\n" - " -Xlog:disable -Xlog:rt=trace:rttrace.txt\n" + " -Xlog:disable -Xlog:safepoint=trace:safepointtrace.txt\n" "\t Turn off all logging, including warnings and errors,\n" - "\t and then enable messages tagged with 'rt' using 'trace' level to file 'rttrace.txt'.\n"); + "\t and then enable messages tagged with 'safepoint' using 'trace' level to file 'safepointtrace.txt'.\n"); } void LogConfiguration::rotate_all_outputs() { From 9707ae0c4e14d0c18b2c6bd930a6ffa9115d4d68 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Wed, 15 Jun 2016 11:24:12 +0300 Subject: [PATCH 075/191] 8153278: sun/tools/jps/TestJpsJar.java fails in hs nightly Refactor the test to take pwd right before the check Reviewed-by: dholmes --- jdk/test/sun/tools/jps/JpsBase.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/jdk/test/sun/tools/jps/JpsBase.java b/jdk/test/sun/tools/jps/JpsBase.java index f119f613951..d13a4053bd8 100644 --- a/jdk/test/sun/tools/jps/JpsBase.java +++ b/jdk/test/sun/tools/jps/JpsBase.java @@ -35,27 +35,28 @@ import jdk.testlibrary.ProcessTools; */ public final class JpsBase { - private static final String shortProcessName; - private static final String fullProcessName; - /** * The jps output should contain processes' names * (except when jps is started in quite mode). * The expected name of the test process is prepared here. */ - static { + + private static String getShortProcessName() { URL url = JpsBase.class.getResource("JpsBase.class"); boolean isJar = url.getProtocol().equals("jar"); + return (isJar) ? JpsBase.class.getSimpleName() + ".jar" : JpsBase.class.getSimpleName(); + } + private static String getFullProcessName() { + URL url = JpsBase.class.getResource("JpsBase.class"); + boolean isJar = url.getProtocol().equals("jar"); if (isJar) { - shortProcessName = JpsBase.class.getSimpleName() + ".jar"; String urlPath = url.getPath(); File jar = new File(urlPath.substring(urlPath.indexOf("file:") + 5, urlPath.indexOf("jar!") + 3)); - fullProcessName = jar.getAbsolutePath(); - } else { - shortProcessName = JpsBase.class.getSimpleName(); - fullProcessName = JpsBase.class.getName(); + return jar.getAbsolutePath(); } + + return JpsBase.class.getName(); } public static void main(String[] args) throws Exception { @@ -83,6 +84,7 @@ public final class JpsBase { // or the full path name to the application's JAR file: // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ... isFull = true; + String fullProcessName = getFullProcessName(); pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*"; output.shouldMatch(pattern); break; @@ -120,6 +122,7 @@ public final class JpsBase { // Output should only contain lines with pids after the first line with pid. JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*"); if (!isFull) { + String shortProcessName = getShortProcessName(); pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName); if (combination.isEmpty()) { // If no arguments are specified output should only contain From b8668ac945679fd330df45bbfc9a06c0e97aa4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Lid=C3=A9n?= Date: Wed, 15 Jun 2016 10:46:20 +0200 Subject: [PATCH 076/191] 8159350: G1 String deduplication logging malformed Reviewed-by: stefank, sjohanss --- hotspot/src/share/vm/gc/g1/g1StringDedupStat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1StringDedupStat.cpp b/hotspot/src/share/vm/gc/g1/g1StringDedupStat.cpp index a90515e8693..4c3349acae5 100644 --- a/hotspot/src/share/vm/gc/g1/g1StringDedupStat.cpp +++ b/hotspot/src/share/vm/gc/g1/g1StringDedupStat.cpp @@ -80,7 +80,7 @@ void G1StringDedupStat::print_summary(const G1StringDedupStat& last_stat, const log_info(gc, stringdedup)( "Concurrent String Deduplication " G1_STRDEDUP_BYTES_FORMAT_NS "->" G1_STRDEDUP_BYTES_FORMAT_NS "(" G1_STRDEDUP_BYTES_FORMAT_NS "), avg " - G1_STRDEDUP_PERCENT_FORMAT_NS ", " G1_STRDEDUP_TIME_FORMAT "]", + G1_STRDEDUP_PERCENT_FORMAT_NS ", " G1_STRDEDUP_TIME_FORMAT, G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes), G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes - last_stat._deduped_bytes), G1_STRDEDUP_BYTES_PARAM(last_stat._deduped_bytes), From eba25b33b9f8e0343a3d8b8fd7f2ebc722f35ac1 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 15 Jun 2016 09:48:24 -0400 Subject: [PATCH 077/191] 8152271: MemberNameTable doesn't purge stale entries Intern MemberNames in table instead of allocating new entries Reviewed-by: vlivanov, sspitsyn, dholmes --- .../src/share/vm/classfile/javaClasses.cpp | 9 ++++ .../src/share/vm/classfile/javaClasses.hpp | 2 + hotspot/src/share/vm/oops/instanceKlass.cpp | 11 +++-- hotspot/src/share/vm/oops/instanceKlass.hpp | 2 +- hotspot/src/share/vm/prims/jvm.cpp | 2 +- hotspot/src/share/vm/prims/methodHandles.cpp | 41 ++++++++++++++----- hotspot/src/share/vm/prims/methodHandles.hpp | 7 ++-- 7 files changed, 55 insertions(+), 19 deletions(-) diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 4c24c7349c0..4ea507532ea 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -3245,6 +3245,15 @@ void java_lang_invoke_MemberName::set_vmindex(oop mname, intptr_t index) { mname->address_field_put(_vmindex_offset, (address) index); } +bool java_lang_invoke_MemberName::equals(oop mn1, oop mn2) { + if (mn1 == mn2) { + return true; + } + return (vmtarget(mn1) == vmtarget(mn2) && flags(mn1) == flags(mn2) && + vmindex(mn1) == vmindex(mn2) && + clazz(mn1) == clazz(mn2)); +} + oop java_lang_invoke_LambdaForm::vmentry(oop lform) { assert(is_instance(lform), "wrong type"); return lform->obj_field(_vmentry_offset); diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 2cf71baf2c7..d9113adc4e7 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -1114,6 +1114,8 @@ class java_lang_invoke_MemberName: AllStatic { static int flags_offset_in_bytes() { return _flags_offset; } static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } static int vmindex_offset_in_bytes() { return _vmindex_offset; } + + static bool equals(oop mt1, oop mt2); }; diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 23d885a991f..eb2d48e8900 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2693,7 +2693,7 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le return NULL; } -bool InstanceKlass::add_member_name(Handle mem_name) { +oop InstanceKlass::add_member_name(Handle mem_name, bool intern) { jweak mem_name_wref = JNIHandles::make_weak_global(mem_name); MutexLocker ml(MemberNameTable_lock); DEBUG_ONLY(NoSafepointVerifier nsv); @@ -2703,7 +2703,7 @@ bool InstanceKlass::add_member_name(Handle mem_name) { // is called! Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name()); if (method->is_obsolete()) { - return false; + return NULL; } else if (method->is_old()) { // Replace method with redefined version java_lang_invoke_MemberName::set_vmtarget(mem_name(), method_with_idnum(method->method_idnum())); @@ -2712,8 +2712,11 @@ bool InstanceKlass::add_member_name(Handle mem_name) { if (_member_names == NULL) { _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count()); } - _member_names->add_member_name(mem_name_wref); - return true; + if (intern) { + return _member_names->find_or_add_member_name(mem_name_wref); + } else { + return _member_names->add_member_name(mem_name_wref); + } } // ----------------------------------------------------------------------------------------------------- diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 000215d14a0..9a690392908 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -1298,7 +1298,7 @@ public: // JSR-292 support MemberNameTable* member_names() { return _member_names; } void set_member_names(MemberNameTable* member_names) { _member_names = member_names; } - bool add_member_name(Handle member_name); + oop add_member_name(Handle member_name, bool intern); public: // JVMTI support diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index a0cb1185487..4da3a6492e5 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -695,7 +695,7 @@ JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) // This can safepoint and redefine method, so need both new_obj and method // in a handle, for two different reasons. new_obj can move, method can be // deleted if nothing is using it on the stack. - m->method_holder()->add_member_name(new_obj()); + m->method_holder()->add_member_name(new_obj(), false); } } diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index d21c0fa30e4..f91cf0dd4d3 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -178,7 +178,7 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target) { return NULL; } -oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { +oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, bool intern) { assert(info.resolved_appendix().is_null(), "only normal methods here"); methodHandle m = info.resolved_method(); assert(m.not_null(), "null method handle"); @@ -279,13 +279,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { // If relevant, the vtable or itable value is stored as vmindex. // This is done eagerly, since it is readily available without // constructing any new objects. - // TO DO: maybe intern mname_oop - if (m->method_holder()->add_member_name(mname)) { - return mname(); - } else { - // Redefinition caused this to fail. Return NULL (and an exception?) - return NULL; - } + return m->method_holder()->add_member_name(mname, intern); } oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) { @@ -975,7 +969,9 @@ int MethodHandles::find_MemberNames(KlassHandle k, if (!java_lang_invoke_MemberName::is_instance(result())) return -99; // caller bug! CallInfo info(m); - oop saved = MethodHandles::init_method_MemberName(result, info); + // Since this is going through the methods to create MemberNames, don't search + // for matching methods already in the table + oop saved = MethodHandles::init_method_MemberName(result, info, /*intern*/false); if (saved != result()) results->obj_at_put(rfill-1, saved); // show saved instance to user } else if (++overflow >= overflow_limit) { @@ -1056,9 +1052,34 @@ MemberNameTable::~MemberNameTable() { } } -void MemberNameTable::add_member_name(jweak mem_name_wref) { +oop MemberNameTable::add_member_name(jweak mem_name_wref) { assert_locked_or_safepoint(MemberNameTable_lock); this->push(mem_name_wref); + return JNIHandles::resolve(mem_name_wref); +} + +oop MemberNameTable::find_or_add_member_name(jweak mem_name_wref) { + assert_locked_or_safepoint(MemberNameTable_lock); + oop new_mem_name = JNIHandles::resolve(mem_name_wref); + + // Find matching member name in the list. + // This is linear because these because these are short lists. + int len = this->length(); + int new_index = len; + for (int idx = 0; idx < len; idx++) { + oop mname = JNIHandles::resolve(this->at(idx)); + if (mname == NULL) { + new_index = idx; + continue; + } + if (java_lang_invoke_MemberName::equals(new_mem_name, mname)) { + JNIHandles::destroy_weak_global(mem_name_wref); + return mname; + } + } + // Not found, push the new one, or reuse empty slot + this->at_put_grow(new_index, mem_name_wref); + return new_mem_name; } #if INCLUDE_JVMTI diff --git a/hotspot/src/share/vm/prims/methodHandles.hpp b/hotspot/src/share/vm/prims/methodHandles.hpp index 3a2bcae1a12..b6bc97ea94d 100644 --- a/hotspot/src/share/vm/prims/methodHandles.hpp +++ b/hotspot/src/share/vm/prims/methodHandles.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ -66,7 +66,7 @@ class MethodHandles: AllStatic { static Handle new_MemberName(TRAPS); // must be followed by init_MemberName static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false); - static oop init_method_MemberName(Handle mname_h, CallInfo& info); + static oop init_method_MemberName(Handle mname_h, CallInfo& info, bool intern = true); static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true); static int find_MemberNames(KlassHandle k, Symbol* name, Symbol* sig, int mflags, KlassHandle caller, @@ -253,7 +253,8 @@ class MemberNameTable : public GrowableArray { public: MemberNameTable(int methods_cnt); ~MemberNameTable(); - void add_member_name(jweak mem_name_ref); + oop add_member_name(jweak mem_name_ref); + oop find_or_add_member_name(jweak mem_name_ref); #if INCLUDE_JVMTI // RedefineClasses() API support: From 6fdbed7699231ead198228038f567c6e98209189 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Wed, 15 Jun 2016 20:43:53 +0300 Subject: [PATCH 078/191] 8156226: DiagnosticCommandImpl::invoke throws not very comprehensive message in case if method exists but signature or parameters are wrong Reviewed-by: mchung, dholmes, dfuchs --- .../management/internal/DiagnosticCommandImpl.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java b/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java index 5e149633dcd..62cbf5da9f4 100644 --- a/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java +++ b/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java @@ -259,9 +259,20 @@ public class DiagnosticCommandImpl extends NotificationEmitterSupport && signature[0] != null && signature[0].compareTo(strArrayClassName) == 0)) { return w.execute((String[]) params[0]); + } else { + throw new ReflectionException( + new NoSuchMethodException(actionName + + ": mismatched signature " + + (signature != null ? Arrays.toString(signature) : "[]") + + " or parameters")); } + } else { + throw new ReflectionException( + new NoSuchMethodException("Method " + actionName + + " with signature " + + (signature != null ? Arrays.toString(signature) : "[]") + + " not found")); } - throw new ReflectionException(new NoSuchMethodException(actionName)); } private static String transform(String name) { From f3741800fe03279e9852afc796e1fa6f1f0eba01 Mon Sep 17 00:00:00 2001 From: Lois Foltan Date: Thu, 16 Jun 2016 13:34:32 -0400 Subject: [PATCH 079/191] 8156871: Possible concurrency issue with JVM_AddModuleExports Need for single PackageEntry flag to determine a package's unqualifed export state. Reviewed-by: acorn, ctornqvi, dholmes, jiangli --- .../src/share/vm/classfile/moduleEntry.cpp | 10 +- hotspot/src/share/vm/classfile/modules.cpp | 4 +- .../src/share/vm/classfile/packageEntry.cpp | 8 +- .../src/share/vm/classfile/packageEntry.hpp | 7 +- .../test/runtime/modules/CompilerUtils.java | 79 +++++++++++++ .../ModuleStress/ExportModuleStressTest.java | 80 +++++++++++++ .../src/jdk.test/module-info.java | 25 +++++ .../ModuleStress/src/jdk.test/test/Main.java | 105 ++++++++++++++++++ .../src/jdk.translet/module-info.java | 27 +++++ .../src/jdk.translet/translet/Main.java | 30 +++++ 10 files changed, 359 insertions(+), 16 deletions(-) create mode 100644 hotspot/test/runtime/modules/CompilerUtils.java create mode 100644 hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java create mode 100644 hotspot/test/runtime/modules/ModuleStress/src/jdk.test/module-info.java create mode 100644 hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/Main.java create mode 100644 hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/module-info.java create mode 100644 hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/translet/Main.java diff --git a/hotspot/src/share/vm/classfile/moduleEntry.cpp b/hotspot/src/share/vm/classfile/moduleEntry.cpp index 6d31b8210b6..c507584c712 100644 --- a/hotspot/src/share/vm/classfile/moduleEntry.cpp +++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp @@ -201,7 +201,7 @@ ModuleEntryTable::~ModuleEntryTable() { } void ModuleEntryTable::create_unnamed_module(ClassLoaderData* loader_data) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); // Each ModuleEntryTable has exactly one unnamed module if (loader_data->is_the_null_class_loader_data()) { @@ -227,7 +227,7 @@ void ModuleEntryTable::create_unnamed_module(ClassLoaderData* loader_data) { ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle, Symbol* name, Symbol* version, Symbol* location, ClassLoaderData* loader_data) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtModule); // Initialize everything BasicHashtable would @@ -258,7 +258,7 @@ ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle } void ModuleEntryTable::add_entry(int index, ModuleEntry* new_entry) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); Hashtable::add_entry(index, (HashtableEntry*)new_entry); } @@ -268,7 +268,7 @@ ModuleEntry* ModuleEntryTable::locked_create_entry_or_null(Handle module_handle, Symbol* module_location, ClassLoaderData* loader_data) { assert(module_name != NULL, "ModuleEntryTable locked_create_entry_or_null should never be called for unnamed module."); - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); // Check if module already exists. if (lookup_only(module_name) != NULL) { return NULL; @@ -309,7 +309,7 @@ void ModuleEntryTable::purge_all_module_reads() { } void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version, Symbol* location) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); ClassLoaderData* boot_loader_data = ClassLoaderData::the_null_class_loader_data(); ModuleEntryTable* module_table = boot_loader_data->modules(); diff --git a/hotspot/src/share/vm/classfile/modules.cpp b/hotspot/src/share/vm/classfile/modules.cpp index 313310047b3..de8aac056b7 100644 --- a/hotspot/src/share/vm/classfile/modules.cpp +++ b/hotspot/src/share/vm/classfile/modules.cpp @@ -568,8 +568,8 @@ void Modules::add_module_exports(jobject from_module, jstring package, jobject t to_module_entry->is_named() ? to_module_entry->name()->as_C_string() : UNNAMED_MODULE); - // Do nothing if modules are the same or if package is already exported unqualifiedly. - if (from_module_entry != to_module_entry && !package_entry->is_unqual_exported()) { + // Do nothing if modules are the same. + if (from_module_entry != to_module_entry) { package_entry->set_exported(to_module_entry); } } diff --git a/hotspot/src/share/vm/classfile/packageEntry.cpp b/hotspot/src/share/vm/classfile/packageEntry.cpp index b7d18756fe1..11cc5ea71aa 100644 --- a/hotspot/src/share/vm/classfile/packageEntry.cpp +++ b/hotspot/src/share/vm/classfile/packageEntry.cpp @@ -49,7 +49,7 @@ bool PackageEntry::is_qexported_to(ModuleEntry* m) const { // Add a module to the package's qualified export list. void PackageEntry::add_qexport(ModuleEntry* m) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); if (!has_qual_exports_list()) { // Lazily create a package's qualified exports list. // Initial size is small, do not anticipate export lists to be large. @@ -157,7 +157,7 @@ PackageEntryTable::~PackageEntryTable() { } PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, ModuleEntry* module) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); PackageEntry* entry = (PackageEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtModule); // Initialize everything BasicHashtable would @@ -180,14 +180,14 @@ PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, Modu } void PackageEntryTable::add_entry(int index, PackageEntry* new_entry) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); Hashtable::add_entry(index, (HashtableEntry*)new_entry); } // Create package in loader's package entry table and return the entry. // If entry already exists, return null. Assume Module lock was taken by caller. PackageEntry* PackageEntryTable::locked_create_entry_or_null(Symbol* name, ModuleEntry* module) { - assert_locked_or_safepoint(Module_lock); + assert(Module_lock->owned_by_self(), "should have the Module_lock"); // Check if package already exists. Return NULL if it does. if (lookup_only(name) != NULL) { return NULL; diff --git a/hotspot/src/share/vm/classfile/packageEntry.hpp b/hotspot/src/share/vm/classfile/packageEntry.hpp index 7e19908af07..e1bf62b3aa4 100644 --- a/hotspot/src/share/vm/classfile/packageEntry.hpp +++ b/hotspot/src/share/vm/classfile/packageEntry.hpp @@ -40,11 +40,7 @@ // package is exported to. // // Packages can be exported in the following 3 ways: -// - not exported: the package has not been explicitly qualified to a -// particular module nor has it been specified to be -// unqualifiedly exported to all modules. If all states -// of exportedness are false, the package is considered -// not exported. +// - not exported: the package does not have qualified or unqualified exports. // - qualified exports: the package has been explicitly qualified to at least // one particular module or has been qualifiedly exported // to all unnamed modules. @@ -125,6 +121,7 @@ public: return _is_exported_unqualified; } void set_unqual_exported() { + assert(Module_lock->owned_by_self(), "should have the Module_lock"); _is_exported_unqualified = true; _is_exported_allUnnamed = false; _qualified_exports = NULL; diff --git a/hotspot/test/runtime/modules/CompilerUtils.java b/hotspot/test/runtime/modules/CompilerUtils.java new file mode 100644 index 00000000000..488ec413e8d --- /dev/null +++ b/hotspot/test/runtime/modules/CompilerUtils.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016, 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. + */ + +import javax.tools.JavaCompiler; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * This class consists exclusively of static utility methods for invoking the + * java compiler. + * + * This class will eventually move to jdk.testlibrary. + */ + +public final class CompilerUtils { + private CompilerUtils() { } + + /** + * Compile all the java sources in {@code /**} to + * {@code /**}. The destination directory will be created if + * it doesn't exist. + * + * All warnings/errors emitted by the compiler are output to System.out/err. + * + * @return true if the compilation is successful + * + * @throws IOException if there is an I/O error scanning the source tree or + * creating the destination directory + */ + public static boolean compile(Path source, Path destination, String ... options) + throws IOException + { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null); + + List sources + = Files.find(source, Integer.MAX_VALUE, + (file, attrs) -> (file.toString().endsWith(".java"))) + .collect(Collectors.toList()); + + Files.createDirectories(destination); + jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, + Arrays.asList(destination)); + + List opts = Arrays.asList(options); + JavaCompiler.CompilationTask task + = compiler.getTask(null, jfm, null, opts, null, + jfm.getJavaFileObjectsFromPaths(sources)); + + return task.call(); + } +} diff --git a/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java b/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java new file mode 100644 index 00000000000..49c75b1d211 --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016, 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 8156871 + * @summary package in the boot layer is repeatedly exported to unique module created in layers on top of the boot layer + * @modules java.base/jdk.internal.misc + * @library /testlibrary /test/lib + * @compile ../CompilerUtils.java + * @build ExportModuleStressTest + * @run main/othervm ExportModuleStressTest + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import jdk.test.lib.*; + +public class ExportModuleStressTest { + + private static final String TEST_SRC = System.getProperty("test.src"); + private static final String TEST_CLASSES = System.getProperty("test.classes"); + + private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods"); + + /** + * Compiles all module definitions used by the test + */ + public static void main(String[] args) throws Exception { + + boolean compiled; + // Compile module jdk.test declaration + compiled = CompilerUtils.compile( + SRC_DIR.resolve("jdk.test"), + MODS_DIR.resolve("jdk.test")); + if (!compiled) { + throw new RuntimeException("Test failed to compile module jdk.test"); + } + + // Compile module jdk.translet declaration + compiled = CompilerUtils.compile( + SRC_DIR.resolve("jdk.translet"), + MODS_DIR.resolve("jdk.translet"), + "-XaddExports:jdk.test/test=jdk.translet", + "-mp", MODS_DIR.toString()); + if (!compiled) { + throw new RuntimeException("Test failed to compile module jdk.translet"); + } + + // Sanity check that the test, jdk.test/test/Main.java + // runs without error. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-mp", MODS_DIR.toString(), + "-m", "jdk.test/test.Main"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("failed: 0") + .shouldHaveExitValue(0); + } +} diff --git a/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/module-info.java b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/module-info.java new file mode 100644 index 00000000000..a946224311c --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/module-info.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016, 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. + */ + +module jdk.test { +} diff --git a/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/Main.java b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/Main.java new file mode 100644 index 00000000000..16e8dbc79e1 --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.test/test/Main.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016, 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. + */ + +package test; + +import java.lang.module.Configuration; +import java.lang.module.ModuleFinder; +import java.lang.reflect.Layer; +import java.lang.reflect.Method; +import java.lang.reflect.Module; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class Main { + + private static final Path MODS_DIR = Paths.get(System.getProperty("jdk.module.path")); + static final String MODULE_NAME = "jdk.translet"; + + public static void main(String[] args) throws Exception { + + ModuleFinder finder = ModuleFinder.of(MODS_DIR); + Layer layerBoot = Layer.boot(); + + Configuration cf = layerBoot + .configuration() + .resolveRequires(ModuleFinder.of(), finder, Set.of(MODULE_NAME)); + + Module testModule = Main.class.getModule(); + ClassLoader scl = ClassLoader.getSystemClassLoader(); + + // Create an unique module/class loader in a layer above the boot layer. + // Export this module to the jdk.test/test package. + Callable task = new Callable() { + @Override + public Void call() throws Exception { + Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl); + Module transletModule = layer.findModule(MODULE_NAME).get(); + testModule.addExports("test", transletModule); + Class c = layer.findLoader(MODULE_NAME).loadClass("translet.Main"); + Method method = c.getDeclaredMethod("go"); + method.invoke(null); + return null; + } + }; + + List> results = new ArrayList<>(); + + // Repeatedly create the layer above stressing the exportation of + // package jdk.test/test to several different modules. + ExecutorService pool = Executors.newFixedThreadPool(Math.min(100, Runtime.getRuntime().availableProcessors()*10)); + try { + for (int i = 0; i < 10000; i++) { + results.add(pool.submit(task)); + } + } finally { + pool.shutdown(); + } + + int passed = 0; + int failed = 0; + + // The failed state should be 0, the created modules in layers above the + // boot layer should be allowed access to the contents of the jdk.test/test + // package since that package was exported to the transletModule above. + for (Future result : results) { + try { + result.get(); + passed++; + } catch (Throwable x) { + x.printStackTrace(); + failed++; + } + } + + System.out.println("passed: " + passed); + System.out.println("failed: " + failed); + } + + public static void callback() { } +} diff --git a/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/module-info.java b/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/module-info.java new file mode 100644 index 00000000000..94f6af4ba23 --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2016, 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. + */ + +module jdk.translet { + requires jdk.test; + exports translet; +} diff --git a/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/translet/Main.java b/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/translet/Main.java new file mode 100644 index 00000000000..30dbaea2577 --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleStress/src/jdk.translet/translet/Main.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, 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. + */ + +package translet; + +public class Main { + public static void go() { + test.Main.callback(); + } +} From f04cf89a79b450aa7bd5510fbd2bf345b2c55bba Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 17 Jun 2016 13:07:27 +0300 Subject: [PATCH 080/191] 8157831: JVMCI tests should not be executed on linux-arm32 Reviewed-by: dpochepk, dholmes --- hotspot/test/TEST.ROOT | 10 +++++----- hotspot/test/compiler/cpuflags/TestSSE4Disabled.java | 2 +- .../test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java | 2 +- .../test/compiler/jvmci/SecurityRestrictionsTest.java | 2 +- .../jvmci/compilerToVM/AllocateCompileIdTest.java | 2 +- .../jvmci/compilerToVM/CanInlineMethodTest.java | 2 +- .../jvmci/compilerToVM/CollectCountersTest.java | 2 +- .../compiler/jvmci/compilerToVM/DebugOutputTest.java | 2 +- .../jvmci/compilerToVM/DisassembleCodeBlobTest.java | 2 +- .../jvmci/compilerToVM/DoNotInlineOrCompileTest.java | 2 +- .../jvmci/compilerToVM/ExecuteInstalledCodeTest.java | 2 +- .../compilerToVM/FindUniqueConcreteMethodTest.java | 2 +- .../compiler/jvmci/compilerToVM/GetBytecodeTest.java | 2 +- .../jvmci/compilerToVM/GetClassInitializerTest.java | 2 +- .../jvmci/compilerToVM/GetConstantPoolTest.java | 2 +- .../jvmci/compilerToVM/GetExceptionTableTest.java | 2 +- .../jvmci/compilerToVM/GetImplementorTest.java | 2 +- .../jvmci/compilerToVM/GetLineNumberTableTest.java | 2 +- .../jvmci/compilerToVM/GetLocalVariableTableTest.java | 2 +- .../jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java | 2 +- .../jvmci/compilerToVM/GetNextStackFrameTest.java | 2 +- .../compilerToVM/GetResolvedJavaMethodAtSlotTest.java | 2 +- .../jvmci/compilerToVM/GetResolvedJavaMethodTest.java | 2 +- .../jvmci/compilerToVM/GetResolvedJavaTypeTest.java | 2 +- .../jvmci/compilerToVM/GetStackTraceElementTest.java | 2 +- .../compiler/jvmci/compilerToVM/GetSymbolTest.java | 2 +- .../compilerToVM/GetVtableIndexForInterfaceTest.java | 2 +- .../jvmci/compilerToVM/HasCompiledCodeForOSRTest.java | 2 +- .../jvmci/compilerToVM/HasFinalizableSubclassTest.java | 2 +- .../compilerToVM/InitializeConfigurationTest.java | 2 +- .../compilerToVM/InvalidateInstalledCodeTest.java | 2 +- .../test/compiler/jvmci/compilerToVM/IsMatureTest.java | 2 +- .../jvmci/compilerToVM/JVM_RegisterJVMCINatives.java | 2 +- .../jvmci/compilerToVM/LookupKlassInPoolTest.java | 2 +- .../compilerToVM/LookupKlassRefIndexInPoolTest.java | 2 +- .../jvmci/compilerToVM/LookupMethodInPoolTest.java | 2 +- .../LookupNameAndTypeRefIndexInPoolTest.java | 2 +- .../jvmci/compilerToVM/LookupNameInPoolTest.java | 2 +- .../jvmci/compilerToVM/LookupSignatureInPoolTest.java | 2 +- .../compiler/jvmci/compilerToVM/LookupTypeTest.java | 2 +- .../compilerToVM/MaterializeVirtualObjectTest.java | 2 +- .../MethodIsIgnoredBySecurityStackWalkTest.java | 2 +- .../compiler/jvmci/compilerToVM/ReprofileTest.java | 2 +- .../jvmci/compilerToVM/ResolveConstantInPoolTest.java | 2 +- .../jvmci/compilerToVM/ResolveFieldInPoolTest.java | 2 +- .../compiler/jvmci/compilerToVM/ResolveMethodTest.java | 2 +- .../ResolvePossiblyCachedConstantInPoolTest.java | 2 +- .../jvmci/compilerToVM/ResolveTypeInPoolTest.java | 2 +- .../compilerToVM/ShouldDebugNonSafepointsTest.java | 2 +- .../jvmci/compilerToVM/ShouldInlineMethodTest.java | 2 +- .../jvmci/errors/TestInvalidCompilationResult.java | 2 +- .../compiler/jvmci/errors/TestInvalidDebugInfo.java | 2 +- .../test/compiler/jvmci/errors/TestInvalidOopMap.java | 2 +- .../events/JvmciNotifyBootstrapFinishedEventTest.java | 2 +- .../jvmci/events/JvmciNotifyInstallEventTest.java | 2 +- .../compiler/jvmci/events/JvmciShutdownEventTest.java | 2 +- .../src/jdk/vm/ci/code/test/DataPatchTest.java | 2 +- .../jdk/vm/ci/code/test/InterpreterFrameSizeTest.java | 2 +- .../vm/ci/code/test/SimpleCodeInstallationTest.java | 2 +- .../src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java | 2 +- .../vm/ci/code/test/VirtualObjectDebugInfoTest.java | 2 +- .../test/HotSpotConstantReflectionProviderTest.java | 2 +- .../vm/ci/hotspot/test/MemoryAccessProviderTest.java | 2 +- .../hotspot/test/MethodHandleAccessProviderTest.java | 2 +- .../src/jdk/vm/ci/runtime/test/ConstantTest.java | 2 +- .../src/jdk/vm/ci/runtime/test/RedefineClassTest.java | 2 +- .../ResolvedJavaTypeResolveConcreteMethodTest.java | 2 +- .../test/ResolvedJavaTypeResolveMethodTest.java | 2 +- .../runtime/test/TestConstantReflectionProvider.java | 2 +- .../src/jdk/vm/ci/runtime/test/TestJavaField.java | 2 +- .../src/jdk/vm/ci/runtime/test/TestJavaMethod.java | 2 +- .../src/jdk/vm/ci/runtime/test/TestJavaType.java | 2 +- .../jdk/vm/ci/runtime/test/TestMetaAccessProvider.java | 2 +- .../jdk/vm/ci/runtime/test/TestResolvedJavaField.java | 2 +- .../jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java | 2 +- .../jdk/vm/ci/runtime/test/TestResolvedJavaType.java | 2 +- hotspot/test/compiler/jvmci/meta/StableFieldTest.java | 2 +- .../runtime/ThreadSignalMask/ThreadSignalMask.java | 2 +- 78 files changed, 82 insertions(+), 82 deletions(-) diff --git a/hotspot/test/TEST.ROOT b/hotspot/test/TEST.ROOT index e52c1b1a3ff..07d50e2e5d4 100644 --- a/hotspot/test/TEST.ROOT +++ b/hotspot/test/TEST.ROOT @@ -1,4 +1,4 @@ -# +# # Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # @@ -19,7 +19,7 @@ # 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. -# +# # @@ -31,10 +31,10 @@ keys=cte_test jcmd nmt regression gc stress groups=TEST.groups [closed/TEST.groups] -# Source files for classes that will be used at the beginning of each test suite run, -# to determine additional characteristics of the system for use with the @requires tag. +# Source files for classes that will be used at the beginning of each test suite run, +# to determine additional characteristics of the system for use with the @requires tag. requires.extraPropDefns = ../../test/jtreg-ext/requires/VMProps.java -requires.properties=sun.arch.data.model +requires.properties=sun.arch.data.model vm.simpleArch # Tests using jtreg 4.2 b02 features requiredVersion=4.2 b02 diff --git a/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java b/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java index 4bd655f6cac..2700b9170d7 100644 --- a/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java +++ b/hotspot/test/compiler/cpuflags/TestSSE4Disabled.java @@ -25,7 +25,7 @@ /* * @test TestSSE4Disabled * @bug 8158214 - * @requires (os.simpleArch == "x64") + * @requires (vm.simpleArch == "x64") * @summary Test correct execution without SSE 4. * @run main/othervm -Xcomp -XX:UseSSE=3 TestSSE4Disabled */ diff --git a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java index 13849452847..57eed059a8d 100644 --- a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java +++ b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary / * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java index 48c406a4adc..22263a7f837 100644 --- a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java +++ b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java index 148402ee786..daeaaed3360 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java index 4500a83ac56..7a313d4a411 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java b/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java index dc905f3a2ae..8bd98dc05cb 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java index ffe0a899cba..477c9128c4e 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java index d8eedaad0c2..aeb384da0fe 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java index db741621e2a..a3ab66ac36a 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java index 399ff0cca73..5ea1bbd8923 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java @@ -21,7 +21,7 @@ import java.util.Map; /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @ignore 8139383 diff --git a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java index cc5ff3d9e2d..7b237098709 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java index 7bfd132a5e9..a72d0c408a6 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java index 3f2c80f1642..2eec0dacf1f 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java index c9826c857e3..00be36102ad 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java index 536972d755a..2d7d5115ac2 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java index 894791f1006..e907eb82d9d 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java index c1bfbba85ff..c121881154b 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @library ../common/patches diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java index d6f6725f723..4fb64f71398 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java index 93653fd57a0..44574b0455c 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java index afca9ec85fb..7809e94c656 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java index d23aad95fb6..7fc31dea426 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java index 6e0fea30328..8353fc5c536 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java index a648caaac67..98b3385c068 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java @@ -25,7 +25,7 @@ * @test * @bug 8136421 * @ignore 8158860 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java index 970e8cbfb58..da0feed2ae7 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java index 7e10c95e0b8..69a45d10185 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java index 66a0bd94f7d..163f6bdd095 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java index 9cb947eb7e1..84acf8ccd7b 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java index d972a22dc36..2f4e9214fac 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java index 9087b52baf1..2be4348c4f3 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java index 369be8612d1..881e339a495 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java index fe2f0259844..0b1296aac5f 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java index 56a43432040..61405cb9f46 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary / * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java index 88629b101a3..54fa2e653d2 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @summary Testing compiler.jvmci.CompilerToVM.lookupKlassInPool method * @library /testlibrary /test/lib / * @library ../common/patches diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java index 87020af5181..260f55387bb 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java index 3b64af7ffea..302b2093123 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java index 4f1cac0fb47..62093cb7d2a 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java index 65f6ec0efdf..7ea7b85c5cd 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java index 391a9dc12f6..98fa85d476b 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java index 712d5d8b2cf..22fa694e8cf 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index de107e0d220..9ffd2818e93 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java index d78672acfaf..cf244d19cc9 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java index 371af37813d..fded2340074 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java index cd16f512e52..fb0db08ecbf 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java index 8151340f9f8..f0298cdf96e 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java index 98b56f8cc3c..4ac3c87323a 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java index 6a1cfb7623e..ddec6f92a16 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8138708 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java index 92f7a19b5e0..37ab43922de 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java @@ -25,7 +25,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @summary Testing compiler.jvmci.CompilerToVM.resolveTypeInPool method * @library /testlibrary /test/lib / * @library ../common/patches diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java index a6dd4cfe8a3..1ec2722aa3d 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java index bef796ab825..ebaf42987a6 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java @@ -25,7 +25,7 @@ /** * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java b/hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java index 75d70e7baa7..bc2eae33f00 100644 --- a/hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java +++ b/hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site diff --git a/hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java b/hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java index 603b360a480..7beb74f263e 100644 --- a/hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java +++ b/hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site diff --git a/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java b/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java index 7fe01e55470..1c4b8840140 100644 --- a/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java +++ b/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java index 20177c3de6c..54d95182792 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8156034 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java index e045775c7ee..b6c47bfb342 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java index c5c5a19ddde..744ddc61bd5 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary / * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java index b2070884fc3..5a4680de2fe 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java index 098871da3b1..b4b3f44ffe8 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java index 0b8ca5c19f7..6db85e842e2 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java index 13c9d3a9012..057c7acfcda 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java index 6c2f5d7ae31..4a4b297e764 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java index 7cd0502bd5a..1cc6215e729 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java @@ -23,7 +23,7 @@ /* * @test jdk.vm.ci.hotspot.test.HotSpotConstantReflectionProviderTest - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java index ed07e8af3a1..466e4e32156 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8152341 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.common diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java index cf928d20356..dedb1cffcd2 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8152343 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java index 63230f38955..7857845edf3 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java index 604d671513b..0cc7a30667c 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java index b253a38f30b..213b7c2fc15 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.ResolvedJavaTypeResolveConcreteMethodTest diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java index 0d8121b3ee7..0d65a36ca33 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.ResolvedJavaTypeResolveMethodTest diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java index 824a1532c62..ab6325eda0a 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java index 4537b386de5..8359fb0676d 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java index faa96b898a6..b143206e6ad 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java index 23959e2059f..ffcd3b43e8a 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java index 8f16a40abb6..16ca94e2d3e 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java index 3fb08386077..2c3a677a90d 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java index d96560ce11f..0a58b4b39fe 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java index 4b06b4b9b29..b30686dfe71 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ * @modules java.base/jdk.internal.reflect * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/meta/StableFieldTest.java b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java index 5c2bd0d9e2b..c2087a57af8 100644 --- a/hotspot/test/compiler/jvmci/meta/StableFieldTest.java +++ b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8151664 - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation diff --git a/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java b/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java index 1670b02656f..55cee37ae31 100644 --- a/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java +++ b/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java @@ -35,7 +35,7 @@ import jdk.test.lib.Asserts; * @key cte_test * @bug 4345157 * @summary JDK 1.3.0 alters thread signal mask - * @requires (os.simpleArch == "sparcv9") + * @requires (vm.simpleArch == "sparcv9") * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile Prog.java From 36ac8c8a004fc3050500ed2a1c8ce232ae50b8c6 Mon Sep 17 00:00:00 2001 From: Rachel Protacio Date: Fri, 17 Jun 2016 10:46:55 -0400 Subject: [PATCH 081/191] 8153394: Add Unified Logging to make it easy to trace time taken in initPhase2 Added modules+startuptime logging for initPhase2 via TraceTime class Reviewed-by: rehn, hseigel, mockner --- hotspot/src/share/vm/runtime/thread.cpp | 2 ++ .../test/runtime/logging/StartupTimeTest.java | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 91d2ed4aa0c..a3f0561c93a 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -3405,6 +3405,8 @@ static void call_initPhase1(TRAPS) { // // After phase 2, The VM will begin search classes from -Xbootclasspath/a. static void call_initPhase2(TRAPS) { + TraceTime timer("Phase2 initialization", TRACETIME_LOG(Info, modules, startuptime)); + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); instanceKlassHandle klass (THREAD, k); diff --git a/hotspot/test/runtime/logging/StartupTimeTest.java b/hotspot/test/runtime/logging/StartupTimeTest.java index 3e65b1d9510..1c5a77e8730 100644 --- a/hotspot/test/runtime/logging/StartupTimeTest.java +++ b/hotspot/test/runtime/logging/StartupTimeTest.java @@ -50,6 +50,18 @@ public class StartupTimeTest { output.shouldHaveExitValue(0); } + static void analyzeModulesOutputOn(ProcessBuilder pb) throws Exception { + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldMatch("(Phase2 initialization, [0-9]+.[0-9]+ secs)"); + output.shouldHaveExitValue(0); + } + + static void analyzeModulesOutputOff(ProcessBuilder pb) throws Exception { + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("[modules,startuptime]"); + output.shouldHaveExitValue(0); + } + public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime", InnerClass.class.getName()); @@ -58,6 +70,14 @@ public class StartupTimeTest { pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime=off", InnerClass.class.getName()); analyzeOutputOff(pb); + + pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+modules", + InnerClass.class.getName()); + analyzeModulesOutputOn(pb); + + pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+modules=off", + InnerClass.class.getName()); + analyzeModulesOutputOff(pb); } public static class InnerClass { From 4dd736d71a0f0427a6c9d32fc5e5f29936e7f78f Mon Sep 17 00:00:00 2001 From: Michail Chernov Date: Fri, 17 Jun 2016 18:45:09 +0300 Subject: [PATCH 082/191] 8158412: [TESTBUG] TestIHOPErgo and TestStressG1Humongous should not be executed when JFR is enabled Reviewed-by: dfazunen, tschatzl --- hotspot/test/TEST.ROOT | 2 +- hotspot/test/gc/g1/ihop/TestIHOPErgo.java | 4 ++-- hotspot/test/gc/g1/ihop/TestIHOPStatic.java | 4 ++-- hotspot/test/gc/g1/plab/TestPLABPromotion.java | 4 ++-- hotspot/test/gc/g1/plab/TestPLABResize.java | 4 ++-- hotspot/test/gc/stress/TestStressG1Humongous.java | 3 ++- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hotspot/test/TEST.ROOT b/hotspot/test/TEST.ROOT index 07d50e2e5d4..00a177ae6b4 100644 --- a/hotspot/test/TEST.ROOT +++ b/hotspot/test/TEST.ROOT @@ -34,7 +34,7 @@ groups=TEST.groups [closed/TEST.groups] # Source files for classes that will be used at the beginning of each test suite run, # to determine additional characteristics of the system for use with the @requires tag. requires.extraPropDefns = ../../test/jtreg-ext/requires/VMProps.java -requires.properties=sun.arch.data.model vm.simpleArch +requires.properties=sun.arch.data.model vm.simpleArch vm.flightRecorder # Tests using jtreg 4.2 b02 features requiredVersion=4.2 b02 diff --git a/hotspot/test/gc/g1/ihop/TestIHOPErgo.java b/hotspot/test/gc/g1/ihop/TestIHOPErgo.java index f77d4584fa9..0332844da07 100644 --- a/hotspot/test/gc/g1/ihop/TestIHOPErgo.java +++ b/hotspot/test/gc/g1/ihop/TestIHOPErgo.java @@ -25,8 +25,8 @@ * @test TestIHOPErgo * @bug 8148397 * @summary Test checks that behavior of Adaptive and Static IHOP at concurrent cycle initiation - * @requires vm.gc=="G1" | vm.gc=="null" - * @requires vm.opt.FlightRecorder != true + * @requires vm.gc == "G1" | vm.gc == "null" + * @requires !vm.flightRecorder * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @requires vm.opt.MaxGCPauseMillis == "null" * @library /testlibrary /test/lib / diff --git a/hotspot/test/gc/g1/ihop/TestIHOPStatic.java b/hotspot/test/gc/g1/ihop/TestIHOPStatic.java index efbe6d6ab69..7fc78cf80fc 100644 --- a/hotspot/test/gc/g1/ihop/TestIHOPStatic.java +++ b/hotspot/test/gc/g1/ihop/TestIHOPStatic.java @@ -25,8 +25,8 @@ * @test TestIHOPStatic * @bug 8148397 * @summary Test checks concurrent cycle initiation which depends on IHOP value. - * @requires vm.gc=="G1" | vm.gc=="null" - * @requires vm.opt.FlightRecorder != true + * @requires vm.gc == "G1" | vm.gc == "null" + * @requires !vm.flightRecorder * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @library /testlibrary / * @modules java.base/jdk.internal.misc diff --git a/hotspot/test/gc/g1/plab/TestPLABPromotion.java b/hotspot/test/gc/g1/plab/TestPLABPromotion.java index cefff072c32..0f4a84c5104 100644 --- a/hotspot/test/gc/g1/plab/TestPLABPromotion.java +++ b/hotspot/test/gc/g1/plab/TestPLABPromotion.java @@ -25,8 +25,8 @@ * @test TestPLABPromotion * @bug 8141278 8141141 * @summary Test PLAB promotion - * @requires vm.gc=="G1" | vm.gc=="null" - * @requires vm.opt.FlightRecorder != true + * @requires vm.gc == "G1" | vm.gc == "null" + * @requires !vm.flightRecorder * @library /testlibrary /test/lib / * @modules java.base/jdk.internal.misc * @modules java.management diff --git a/hotspot/test/gc/g1/plab/TestPLABResize.java b/hotspot/test/gc/g1/plab/TestPLABResize.java index 039ef53e8ed..b065abb57e5 100644 --- a/hotspot/test/gc/g1/plab/TestPLABResize.java +++ b/hotspot/test/gc/g1/plab/TestPLABResize.java @@ -25,8 +25,8 @@ * @test TestPLABResize * @bug 8141278 8141141 * @summary Test for PLAB resizing - * @requires vm.gc=="G1" | vm.gc=="null" - * @requires vm.opt.FlightRecorder != true + * @requires vm.gc == "G1" | vm.gc == "null" + * @requires !vm.flightRecorder * @library /testlibrary /test/lib / * @modules java.base/jdk.internal.misc * @modules java.management diff --git a/hotspot/test/gc/stress/TestStressG1Humongous.java b/hotspot/test/gc/stress/TestStressG1Humongous.java index 91a5f06a421..de9e1be4555 100644 --- a/hotspot/test/gc/stress/TestStressG1Humongous.java +++ b/hotspot/test/gc/stress/TestStressG1Humongous.java @@ -26,7 +26,8 @@ * @key gc * @key stress * @summary Stress G1 by humongous allocations in situation near OOM - * @requires vm.gc=="G1" | vm.gc=="null" + * @requires vm.gc == "G1" | vm.gc == "null" + * @requires !vm.flightRecorder * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=4m * -Dtimeout=120 -Dthreads=3 -Dhumongoussize=1.1 -Dregionsize=4 TestStressG1Humongous * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=16m From d3e514269417832feaa96c0b39a59be59e3c7b22 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Sun, 19 Jun 2016 16:46:49 -0700 Subject: [PATCH 083/191] 8155955: packager needs to determine the root modules to create JRE image Reviewed-by: alanb --- .../jdk/tools/jlink/internal/JlinkTask.java | 39 +++++++------------ .../packager/AppRuntimeImageBuilder.java | 33 +++++++--------- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java index e8b43855d12..2f5088877d2 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java @@ -39,15 +39,7 @@ import java.nio.ByteOrder; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Date; -import java.util.Formatter; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import jdk.internal.module.ConfigurableModuleFinder; @@ -96,11 +88,9 @@ public class JlinkTask { }, "--help"), new Option(true, (task, opt, arg) -> { String[] dirs = arg.split(File.pathSeparator); - task.options.modulePath = new Path[dirs.length]; - int i = 0; - for (String dir : dirs) { - task.options.modulePath[i++] = Paths.get(dir); - } + Arrays.stream(dirs) + .map(Paths::get) + .forEach(task.options.modulePath::add); }, "--modulepath", "--mp"), new Option(true, (task, opt, arg) -> { for (String mn : arg.split(",")) { @@ -176,7 +166,7 @@ public class JlinkTask { String saveoptsfile; boolean version; boolean fullVersion; - Path[] modulePath; + List modulePath = new ArrayList<>(); Set limitMods = new HashSet<>(); Set addMods = new HashSet<>(); Path output; @@ -203,7 +193,7 @@ public class JlinkTask { return EXIT_OK; } if (taskHelper.getExistingImage() == null) { - if (options.modulePath == null || options.modulePath.length == 0) { + if (options.modulePath == null || options.modulePath.isEmpty()) { throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true); } createImage(); @@ -245,7 +235,7 @@ public class JlinkTask { * Jlink API entry point. */ public static void createImage(JlinkConfiguration config, - PluginsConfiguration plugins) + PluginsConfiguration plugins) throws Exception { Objects.requireNonNull(config); Objects.requireNonNull(config.getOutput()); @@ -254,10 +244,9 @@ public class JlinkTask { if (config.getModulepaths().isEmpty()) { throw new Exception("Empty module paths"); } - Path[] arr = new Path[config.getModulepaths().size()]; - arr = config.getModulepaths().toArray(arr); + ModuleFinder finder - = newModuleFinder(arr, config.getLimitmods(), config.getModules()); + = newModuleFinder(config.getModulepaths(), config.getLimitmods(), config.getModules()); // First create the image provider ImageProvider imageProvider @@ -332,10 +321,12 @@ public class JlinkTask { return addMods; } - private static ModuleFinder newModuleFinder(Path[] paths, - Set limitMods, - Set addMods) { - ModuleFinder finder = ModuleFinder.of(paths); + public static ModuleFinder newModuleFinder(List paths, + Set limitMods, + Set addMods) + { + + ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0])); // jmods are located at link-time if (finder instanceof ConfigurableModuleFinder) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java index 874b338c93f..7272a6ad5d1 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java @@ -27,36 +27,19 @@ package jdk.tools.jlink.internal.packager; import jdk.tools.jlink.Jlink; -import jdk.tools.jlink.builder.ImageBuilder; +import jdk.tools.jlink.builder.DefaultImageBuilder; +import jdk.tools.jlink.internal.JlinkTask; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.builder.*; -import jdk.tools.jlink.plugin.ModulePool; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringReader; +import java.lang.module.ModuleFinder; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Properties; -import java.util.ResourceBundle; import java.util.Set; -import java.util.StringTokenizer; -import java.util.TreeSet; -import java.util.stream.Collectors; /** * AppRuntimeImageBuilder is a private API used only by the Java Packager to generate @@ -143,4 +126,14 @@ public final class AppRuntimeImageBuilder { Jlink jlink = new Jlink(); jlink.build(jlinkConfig, pluginConfig); } + + /** + * Returns a ModuleFinder that limits observability to the given root + * modules, their transitive dependences, plus a set of other modules. + */ + public static ModuleFinder moduleFinder(List modulepaths, + Set roots, + Set otherModules) { + return JlinkTask.newModuleFinder(modulepaths, roots, otherModules); + } } From aba0a631d8eacafd69f1bf41906e3ba4c640b627 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 20 Jun 2016 13:21:09 -0700 Subject: [PATCH 084/191] 8159537: create build file to generate diags reports for all locales Reviewed-by: mcimadamore --- langtools/make/diags-examples.xml | 124 ++++++++++++++++++ .../test/tools/javac/diags/HTMLWriter.java | 12 +- .../test/tools/javac/diags/RunExamples.java | 5 +- 3 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 langtools/make/diags-examples.xml diff --git a/langtools/make/diags-examples.xml b/langtools/make/diags-examples.xml new file mode 100644 index 00000000000..425c124acf9 --- /dev/null +++ b/langtools/make/diags-examples.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/langtools/test/tools/javac/diags/HTMLWriter.java b/langtools/test/tools/javac/diags/HTMLWriter.java index e6f4c1d6a43..4aaff85b5e9 100644 --- a/langtools/test/tools/javac/diags/HTMLWriter.java +++ b/langtools/test/tools/javac/diags/HTMLWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -40,7 +40,7 @@ public class HTMLWriter * @throws IOException if there is a problem writing to the underlying stream */ public HTMLWriter(Writer out) throws IOException { - this(out, ""); + this(out, ""); } /** @@ -328,7 +328,7 @@ public class HTMLWriter */ public void writeLink(File file, String body) throws IOException { startTag(A); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String path = file.getPath().replace(File.separatorChar, '/'); if (file.isAbsolute() && !path.startsWith("/")) sb.append('/'); @@ -472,13 +472,15 @@ public class HTMLWriter public static final String BORDER = "border"; /** The HTML "br" tag. */ public static final String BR = "br"; + /** The HTML "charset" attribute. */ + public static final String CHARSET = "charset"; /** The HTML "class" attribute. */ public static final String CLASS = "class"; /** The HTML "classid" attribute. */ public static final String CLASSID = "classid"; /** The HTML "code" tag. */ public static final String CODE = "code"; - /** The HTML "color" attribte. */ + /** The HTML "color" attribute. */ public static final String COLOR = "color"; /** The HTML "col" attribute value. */ public static final String COL = "col"; @@ -522,6 +524,8 @@ public class HTMLWriter public static final String LI = "li"; /** The HTML "link" tag. */ public static final String LINK = "link"; + /** The HTML "meta" attribute. */ + public static final String META = "meta"; /** The HTML "name" attribute. */ public static final String NAME = "name"; /** The HTML "object" tag. */ diff --git a/langtools/test/tools/javac/diags/RunExamples.java b/langtools/test/tools/javac/diags/RunExamples.java index 75c45c46082..d0c7516d0fe 100644 --- a/langtools/test/tools/javac/diags/RunExamples.java +++ b/langtools/test/tools/javac/diags/RunExamples.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -354,7 +354,10 @@ public class RunExamples { html.write(title); html.endTag(HTMLWriter.TITLE); } + html.startTag(HTMLWriter.META); + html.writeAttr(HTMLWriter.CHARSET, "UTF-8"); html.startTag(HTMLWriter.STYLE); + html.write(null); // revert to body text html.newLine(); html.writeLine("div.file { background-color:#e0ffe0; margin-left:30px; margin-right:30px;\n" + " padding: 3px; border: thin solid silver; }"); From 432ff69a8b0c98a2dcd824e41965ef0579c06797 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Mon, 20 Jun 2016 14:08:05 -0700 Subject: [PATCH 085/191] 8136738: InputStream documentation for IOException in skip() is unclear or incorrect Clarify javadoc of skip(). Reviewed-by: rriggs, prappo --- .../share/classes/java/io/BufferedInputStream.java | 10 +++++----- .../share/classes/java/io/FilterInputStream.java | 5 ++--- .../java.base/share/classes/java/io/InputStream.java | 7 +++---- .../share/classes/java/io/PushbackInputStream.java | 10 +++++----- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/BufferedInputStream.java b/jdk/src/java.base/share/classes/java/io/BufferedInputStream.java index acf325867e4..42f0697b338 100644 --- a/jdk/src/java.base/share/classes/java/io/BufferedInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/BufferedInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2016, 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 @@ -359,10 +359,10 @@ class BufferedInputStream extends FilterInputStream { * See the general contract of the skip * method of InputStream. * - * @exception IOException if the stream does not support seek, - * or if this input stream has been closed by - * invoking its {@link #close()} method, or an - * I/O error occurs. + * @throws IOException if this input stream has been closed by + * invoking its {@link #close()} method, + * {@code in.skip(n)} throws an IOException, + * or an I/O error occurs. */ public synchronized long skip(long n) throws IOException { getBufIfOpen(); // Check for closed stream diff --git a/jdk/src/java.base/share/classes/java/io/FilterInputStream.java b/jdk/src/java.base/share/classes/java/io/FilterInputStream.java index 2046fc7a2c3..3304a1f2eb8 100644 --- a/jdk/src/java.base/share/classes/java/io/FilterInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/FilterInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2016, 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 @@ -144,8 +144,7 @@ class FilterInputStream extends InputStream { * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. - * @exception IOException if the stream does not support seek, - * or if some other I/O error occurs. + * @throws IOException if {@code in.skip(n)} throws an IOException. */ public long skip(long n) throws IOException { return in.skip(n); diff --git a/jdk/src/java.base/share/classes/java/io/InputStream.java b/jdk/src/java.base/share/classes/java/io/InputStream.java index c1e4a8e1d60..0f4b6f5baee 100644 --- a/jdk/src/java.base/share/classes/java/io/InputStream.java +++ b/jdk/src/java.base/share/classes/java/io/InputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2016, 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 @@ -325,7 +325,7 @@ public abstract class InputStream implements Closeable { * returns 0, and no bytes are skipped. Subclasses may handle the negative * value differently. * - *

    The skip method of this class creates a + *

    The skip method implementation of this class creates a * byte array and then repeatedly reads into it until n bytes * have been read or the end of the stream has been reached. Subclasses are * encouraged to provide a more efficient implementation of this method. @@ -333,8 +333,7 @@ public abstract class InputStream implements Closeable { * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. - * @exception IOException if the stream does not support seek, - * or if some other I/O error occurs. + * @throws IOException if an I/O error occurs. */ public long skip(long n) throws IOException { diff --git a/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java b/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java index fc5439e625b..d9905c8b429 100644 --- a/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2016, 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 @@ -291,10 +291,10 @@ class PushbackInputStream extends FilterInputStream { * * @param n {@inheritDoc} * @return {@inheritDoc} - * @exception IOException if the stream does not support seek, - * or the stream has been closed by - * invoking its {@link #close()} method, - * or an I/O error occurs. + * @throws IOException if the stream has been closed by + * invoking its {@link #close()} method, + * {@code in.skip(n)} throws an IOException, + * or an I/O error occurs. * @see java.io.FilterInputStream#in * @see java.io.InputStream#skip(long n) * @since 1.2 From 9354f95c6a74fc45c7e3a1265d075966e2f7f867 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Tue, 21 Jun 2016 00:40:51 +0100 Subject: [PATCH 086/191] 8146975: NullPointerException in IIOPInputStream.inputClassFields Reviewed-by: chegar, rriggs, coffeys --- .../sun/corba/se/impl/io/IIOPInputStream.java | 113 ++++++++++++------ 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java index c9d6320f65a..a23eec3c4c1 100644 --- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java @@ -2230,7 +2230,7 @@ public class IIOPInputStream * REVISIT -- This code doesn't do what the comment says to when * getField() is null! */ - private void inputClassFields(Object o, Class cl, + private void inputClassFields(Object o, Class cl, ObjectStreamField[] fields, com.sun.org.omg.SendingContext.CodeBase sender) throws InvalidClassException, StreamCorruptedException, @@ -2239,6 +2239,8 @@ public class IIOPInputStream int primFields = fields.length - currentClassDesc.objFields; + // this will leave primitives in the inputstream + // should really consume and discard where necessary if (o != null) { for (int i = 0; i < primFields; ++i) { inputPrimitiveField(o, cl, fields[i]); @@ -2264,21 +2266,32 @@ public class IIOPInputStream } try { - Class fieldCl = fields[i].getClazz(); + Class fieldCl = fields[i].getClazz(); if ((objectValue != null) && (!fieldCl.isAssignableFrom( objectValue.getClass()))) { throw new IllegalArgumentException("Field mismatch"); } - Field classField = null; + Field declaredClassField = null; + final String inputStreamFieldName = fields[i].getName(); try { - classField = cl.getDeclaredField(fields[i].getName()); - } catch (NoSuchFieldException nsfEx) { - throw new IllegalArgumentException(nsfEx); + declaredClassField = getDeclaredField( cl, inputStreamFieldName); + } catch (PrivilegedActionException paEx) { + throw new IllegalArgumentException( + (NoSuchFieldException) paEx.getException()); } catch (SecurityException secEx) { - throw new IllegalArgumentException(secEx.getCause()); + throw new IllegalArgumentException(secEx); + } catch (NullPointerException npEx) { + continue; + } catch (NoSuchFieldException e) { + continue; } - Class declaredFieldClass = classField.getType(); + + if (declaredClassField == null) { + continue; + } + + Class declaredFieldClass = declaredClassField.getType(); // check input field type is a declared field type // input field is a subclass of the declared field @@ -2291,15 +2304,24 @@ public class IIOPInputStream } bridge.putObject( o, fields[i].getFieldID(), objectValue ) ; // reflective code: fields[i].getField().set( o, objectValue ) ; - } catch (IllegalArgumentException e) { - ClassCastException exc = new ClassCastException("Assigning instance of class " + - objectValue.getClass().getName() + - " to field " + - currentClassDesc.getName() + - '#' + - fields[i].getField().getName()); - exc.initCause( e ) ; - throw exc ; + } catch (IllegalArgumentException iaEx) { + String objectValueClassName = "null"; + String currentClassDescClassName = "null"; + String fieldName = "null"; + if (objectValue != null) { + objectValueClassName = objectValue.getClass().getName(); + } + if (currentClassDesc != null) { + currentClassDescClassName = currentClassDesc.getName(); + } + if (fields[i] != null && fields[i].getField() != null) { + fieldName = fields[i].getField().getName(); + } + ClassCastException ccEx = new ClassCastException( + "Assigning instance of class " + objectValueClassName + + " to field " + currentClassDescClassName + '#' + fieldName); + ccEx.initCause( iaEx ) ; + throw ccEx ; } } // end : for loop } @@ -2592,12 +2614,11 @@ public class IIOPInputStream throw cce ; } } - } - private static void setObjectField(Object o, Class c, String fieldName, Object v) { + private static void setObjectField(Object o, Class c, String fieldName, Object v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; Class fieldCl = fld.getType(); if(v != null && !fieldCl.isInstance(v)) { throw new Exception(); @@ -2617,10 +2638,10 @@ public class IIOPInputStream } } - private static void setBooleanField(Object o, Class c, String fieldName, boolean v) + private static void setBooleanField(Object o, Class c, String fieldName, boolean v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Boolean.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putBoolean( o, key, v ) ; @@ -2640,10 +2661,10 @@ public class IIOPInputStream } } - private static void setByteField(Object o, Class c, String fieldName, byte v) + private static void setByteField(Object o, Class c, String fieldName, byte v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Byte.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putByte( o, key, v ) ; @@ -2663,10 +2684,10 @@ public class IIOPInputStream } } - private static void setCharField(Object o, Class c, String fieldName, char v) + private static void setCharField(Object o, Class c, String fieldName, char v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Character.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putChar( o, key, v ) ; @@ -2686,10 +2707,10 @@ public class IIOPInputStream } } - private static void setShortField(Object o, Class c, String fieldName, short v) + private static void setShortField(Object o, Class c, String fieldName, short v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Short.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putShort( o, key, v ) ; @@ -2709,10 +2730,10 @@ public class IIOPInputStream } } - private static void setIntField(Object o, Class c, String fieldName, int v) + private static void setIntField(Object o, Class c, String fieldName, int v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Integer.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putInt( o, key, v ) ; @@ -2732,10 +2753,10 @@ public class IIOPInputStream } } - private static void setLongField(Object o, Class c, String fieldName, long v) + private static void setLongField(Object o, Class c, String fieldName, long v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Long.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putLong( o, key, v ) ; @@ -2755,10 +2776,10 @@ public class IIOPInputStream } } - private static void setFloatField(Object o, Class c, String fieldName, float v) + private static void setFloatField(Object o, Class c, String fieldName, float v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Float.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putFloat( o, key, v ) ; @@ -2778,10 +2799,10 @@ public class IIOPInputStream } } - private static void setDoubleField(Object o, Class c, String fieldName, double v) + private static void setDoubleField(Object o, Class c, String fieldName, double v) { try { - Field fld = c.getDeclaredField( fieldName ) ; + Field fld = getDeclaredField( c, fieldName ) ; if ((fld != null) && (fld.getType() == Double.TYPE)) { long key = bridge.objectFieldOffset( fld ) ; bridge.putDouble( o, key, v ) ; @@ -2801,6 +2822,22 @@ public class IIOPInputStream } } + + private static Field getDeclaredField(final Class c, + final String fieldName) + throws PrivilegedActionException, NoSuchFieldException, SecurityException { + if (System.getSecurityManager() == null) { + return c.getDeclaredField(fieldName); + } else { + return AccessController + .doPrivileged(new PrivilegedExceptionAction() { + public Field run() throws NoSuchFieldException { + return c.getDeclaredField(fieldName); + } + }); + } + } + /** * This class maintains a map of stream position to * an Object currently being deserialized. It is used @@ -2811,12 +2848,12 @@ public class IIOPInputStream */ static class ActiveRecursionManager { - private Map offsetToObjectMap; + private Map offsetToObjectMap; public ActiveRecursionManager() { // A hash map is unsynchronized and allows // null values - offsetToObjectMap = new HashMap(); + offsetToObjectMap = new HashMap<>(); } // Called right after allocating a new object. From bc0e20636ea1eb7ec0b66ecb149ee4716a7e85f4 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Tue, 21 Jun 2016 00:45:52 +0100 Subject: [PATCH 087/191] 8146975: NullPointerException in IIOPInputStream.inputClassFields Reviewed-by: chegar, rriggs, coffeys --- .../8146975/HelloClient.java | 120 +++++++++++++ .../8146975/HelloImpl.java | 41 +++++ .../8146975/HelloInterface.java | 28 ++++ .../8146975/HelloServer.java | 58 +++++++ .../8146975/RmiIiopReturnValueTest.java | 157 ++++++++++++++++++ .../PortableRemoteObject/8146975/Test.java | 29 ++++ .../PortableRemoteObject/8146975/Test3.java | 36 ++++ .../PortableRemoteObject/8146975/Test4.java | 41 +++++ .../8146975/_HelloImpl_Tie.java | 103 ++++++++++++ .../8146975/_HelloInterface_Stub.java | 93 +++++++++++ .../8146975/jtreg.test.policy | 45 +++++ .../ConcurrentHashMapTest.java | 17 +- .../PortableRemoteObject/jtreg.test.policy | 43 +++++ 13 files changed, 801 insertions(+), 10 deletions(-) create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloClient.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloImpl.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloInterface.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloServer.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/Test.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/Test3.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/Test4.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloImpl_Tie.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloInterface_Stub.java create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy create mode 100644 jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloClient.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloClient.java new file mode 100644 index 00000000000..00a133ec972 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloClient.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.util.ArrayList; + +import javax.naming.InitialContext; +import javax.naming.Context; +import javax.naming.NameNotFoundException; + +import javax.rmi.PortableRemoteObject; + + + +public class HelloClient implements Runnable { + static final int MAX_RETRY = 10; + static final int ONE_SECOND = 1000; + private static boolean responseReceived; + + public static void main(String args[]) throws Exception { + executeRmiClientCall(); + } + + @Override + public void run() { + try { + executeRmiClientCall(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + + public static boolean isResponseReceived () { + return responseReceived; + } + + public static void executeRmiClientCall() throws Exception { + Context ic; + Object objref; + HelloInterface helloSvc; + String response; + Object testResponse; + int retryCount = 0; + + ArrayList listParam = new ArrayList(); + listParam.add(null); + System.out.println("HelloClient.main: enter ..."); + while (retryCount < MAX_RETRY) { + try { + ic = new InitialContext(); + System.out.println("HelloClient.main: HelloService lookup ..."); + // STEP 1: Get the Object reference from the Name Service + // using JNDI call. + objref = ic.lookup("HelloService"); + System.out.println("HelloClient: Obtained a ref. to Hello server."); + + // STEP 2: Narrow the object reference to the concrete type and + // invoke the method. + helloSvc = (HelloInterface) PortableRemoteObject.narrow(objref, + HelloInterface.class); + + Test3 test3 = new Test3(listParam); + Test3 test3Response = helloSvc.sayHelloWithTest3(test3); + System.out.println("Server says: Test3 response == " + test3Response); + + Test3 test3WithNullList = new Test3(null); + test3Response = helloSvc.sayHelloWithTest3(test3WithNullList); + System.out.println("Server says: Test3 response == " + + test3Response); + + Test4 test4 = new Test4(listParam); + Test3 test4Response = helloSvc.sayHelloWithTest3(test4); + System.out.println("Server says: Test4 response == " + test4Response); + + responseReceived = true; + break; + } catch (NameNotFoundException nnfEx) { + System.err.println("NameNotFoundException Caught .... try again"); + retryCount++; + try { + Thread.sleep(ONE_SECOND); + } catch (InterruptedException e) { + e.printStackTrace(); + } + continue; + } catch (Throwable t) { + System.err.println("Exception " + t + "Caught"); + t.printStackTrace(); + throw new RuntimeException(t); + } + } + System.err.println("HelloClient terminating "); + try { + Thread.sleep(ONE_SECOND); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloImpl.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloImpl.java new file mode 100644 index 00000000000..a54d575783c --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloImpl.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.rmi.RemoteException; +import javax.rmi.PortableRemoteObject; + +public class HelloImpl extends PortableRemoteObject implements HelloInterface { + + public HelloImpl() throws java.rmi.RemoteException { + super(); // invoke rmi linking and remote object initialization + } + + + @Override + public Test3 sayHelloWithTest3(Test3 test) throws RemoteException { + System.out.println("sayHelloToTest3: ENTER " ); + + return test; + } + +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloInterface.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloInterface.java new file mode 100644 index 00000000000..81d53fa7f20 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloInterface.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.rmi.Remote; + +public interface HelloInterface extends Remote { + public Test3 sayHelloWithTest3( Test3 test ) throws java.rmi.RemoteException; +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloServer.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloServer.java new file mode 100644 index 00000000000..bb83a801ec5 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloServer.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, 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. + */ + +import javax.naming.InitialContext; +import javax.naming.Context; + +public class HelloServer { + + static final int MAX_RETRY = 10; + static final int ONE_SECOND = 1000; + + public static void main(String[] args) { + int retryCount = 0; + while (retryCount < MAX_RETRY) { + try { + // Step 1: Instantiate the Hello servant + HelloImpl helloRef = new HelloImpl(); + + // Step 2: Publish the reference in the Naming Service + // using JNDI API + Context initialNamingContext = new InitialContext(); + initialNamingContext.rebind("HelloService", helloRef); + + System.out.println("Hello Server: Ready..."); + break; + } catch (Exception e) { + System.out.println("Server initialization problem: " + e); + e.printStackTrace(); + retryCount++; + try { + Thread.sleep(ONE_SECOND); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + } + } +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java new file mode 100644 index 00000000000..147fcd14e72 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2016, 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 8146975 + * @summary test RMI-IIOP with value object return + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @compile -addmods java.corba Test.java Test3.java Test4.java + * HelloInterface.java HelloServer.java + * HelloClient.java HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java + * RmiIiopReturnValueTest.java + * @run main/othervm -addmods java.corba + * -Djava.naming.provider.url=iiop://localhost:5050 + * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory + * RmiIiopReturnValueTest -port 5049 + * @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy + * -addmods java.corba -Djava.naming.provider.url=iiop://localhost:5050 + * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory + * RmiIiopReturnValueTest -port 5049 + */ + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import jdk.testlibrary.JDKToolFinder; +import jdk.testlibrary.JDKToolLauncher; + +public class RmiIiopReturnValueTest { + + static final String ORBD = JDKToolFinder.getTestJDKTool("orbd"); + static final String JAVA = JDKToolFinder.getTestJDKTool("java"); + static final JDKToolLauncher orbdLauncher = JDKToolLauncher.createUsingTestJDK("orbd"); + static final String CLASSPATH = System.getProperty("java.class.path"); + static final int FIVE_SECONDS = 5000; + + private static Throwable clientException; + private static boolean exceptionInClient; + private static Process orbdProcess; + private static Process rmiServerProcess; + + public static void main(String[] args) throws Exception { + startTestComponents(); + stopTestComponents(); + System.err.println("Test completed OK "); + } + + static void startTestComponents () throws Exception { + startOrbd(); + Thread.sleep(FIVE_SECONDS); + startRmiIiopServer(); + Thread.sleep(FIVE_SECONDS); + executeRmiIiopClient(); + } + + private static void stopTestComponents() throws Exception { + stopRmiIiopServer(); + stopOrbd(); + if (exceptionInClient) { + throw new RuntimeException(clientException); + } else if (!isResponseReceived()) { + throw new RuntimeException("Expected Response not received"); + } + } + + static void startOrbd() throws Exception { + System.out.println("\nStarting orbd with NS port 5050 and activation port 5049 "); + + //orbd -ORBInitialHost localhost -ORBInitialPort 5050 -port 5049 + orbdLauncher.addToolArg("-ORBInitialHost").addToolArg("localhost") + .addToolArg("-ORBInitialPort").addToolArg("5050") + .addToolArg("-port").addToolArg("5049"); + + System.out.println("RmiIiopReturnValueTest: Executing: " + Arrays.asList(orbdLauncher.getCommand())); + ProcessBuilder pb = new ProcessBuilder(orbdLauncher.getCommand()); + pb.redirectError(ProcessBuilder.Redirect.INHERIT); + orbdProcess = pb.start(); + } + + + static void startRmiIiopServer() throws Exception { + System.out.println("\nStarting RmiIiopServer"); + // java -addmods java.corba -cp . + // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory + // -Djava.naming.provider.url=iiop://localhost:5050 HelloServer -port 5049 + List commands = new ArrayList<>(); + commands.add(RmiIiopReturnValueTest.JAVA); + commands.add("-addmods"); + commands.add("java.corba"); + commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory"); + commands.add("-Djava.naming.provider.url=iiop://localhost:5050"); + commands.add("-cp"); + commands.add(RmiIiopReturnValueTest.CLASSPATH); + commands.add("HelloServer"); + commands.add("-port"); + commands.add("5049"); + + System.out.println("RmiIiopReturnValueTest: Executing: " + commands); + ProcessBuilder pb = new ProcessBuilder(commands); + pb.redirectError(ProcessBuilder.Redirect.INHERIT); + rmiServerProcess = pb.start(); + } + + static boolean isResponseReceived() { + return HelloClient.isResponseReceived(); + } + + static void stopRmiIiopServer() throws Exception { + if (rmiServerProcess != null) { + System.out.println("RmiIiopReturnValueTest.stopRmiIiopServer: destroy rmiServerProcess"); + rmiServerProcess.destroyForcibly(); + rmiServerProcess.waitFor(); + System.out.println("serverProcess exitCode:" + + rmiServerProcess.exitValue()); + } + } + + static void stopOrbd() throws Exception { + System.out.println("RmiIiopReturnValueTest.stopOrbd: destroy orbdProcess "); + orbdProcess.destroyForcibly(); + orbdProcess.waitFor(); + System.out.println("orbd exitCode:" + + orbdProcess.exitValue()); + } + + static void executeRmiIiopClient() throws Exception { + System.out.println("RmiIiopReturnValueTest.executeRmiIiopClient: HelloClient.executeRmiClientCall"); + try { + HelloClient.executeRmiClientCall(); + } catch (Throwable t) { + clientException = t; + exceptionInClient = true; + } + } +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test.java new file mode 100644 index 00000000000..510331f42ad --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.Serializable; + + +public class Test implements Serializable { + +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test3.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test3.java new file mode 100644 index 00000000000..d96cc1222bd --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test3.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.Serializable; +import java.util.List; + + +public class Test3 implements Serializable { + + private List list; + + public Test3(List list) { + this.list = list; + } + +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test4.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test4.java new file mode 100644 index 00000000000..47d5ff202ee --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/Test4.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.util.List; + + +public class Test4 extends Test3 { + + private int aNumber = 1; + + public Test4(List list) { + super(list); + } + + /** + * + */ + private static final long serialVersionUID = 1L; + + +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloImpl_Tie.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloImpl_Tie.java new file mode 100644 index 00000000000..57b856b2a87 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloImpl_Tie.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2016, 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. + */ + +// Tie class generated by rmic, do not edit. +// Contents subject to change without notice. + +import java.io.Serializable; +import java.rmi.Remote; +import java.rmi.RemoteException; +import javax.rmi.CORBA.Tie; +import javax.rmi.CORBA.Util; +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.ResponseHandler; +import org.omg.CORBA.portable.UnknownException; +import org.omg.CORBA_2_3.portable.ObjectImpl; + + +public class _HelloImpl_Tie extends ObjectImpl implements Tie { + + volatile private HelloImpl target = null; + + private static final String[] _type_ids = { + "RMI:HelloInterface:0000000000000000" + }; + + public void setTarget(Remote target) { + this.target = (HelloImpl) target; + } + + public Remote getTarget() { + return target; + } + + public org.omg.CORBA.Object thisObject() { + return this; + } + + public void deactivate() { + _orb().disconnect(this); + _set_delegate(null); + target = null; + } + + public ORB orb() { + return _orb(); + } + + public void orb(ORB orb) { + orb.connect(this); + } + + public String[] _ids() { + return (String[]) _type_ids.clone(); + } + + public OutputStream _invoke(String method, InputStream _in, ResponseHandler reply) throws SystemException { + try { + HelloImpl target = this.target; + if (target == null) { + throw new java.io.IOException(); + } + org.omg.CORBA_2_3.portable.InputStream in = + (org.omg.CORBA_2_3.portable.InputStream) _in; + if (method.equals("sayHelloWithTest3")) { + Test3 arg0 = (Test3) in.read_value(Test3.class); + Test3 result = target.sayHelloWithTest3(arg0); + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) reply.createReply(); + out.write_value(result,Test3.class); + return out; + } + throw new BAD_OPERATION(); + } catch (SystemException ex) { + throw ex; + } catch (Throwable ex) { + throw new UnknownException(ex); + } + } +} diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloInterface_Stub.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloInterface_Stub.java new file mode 100644 index 00000000000..dc05873f797 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/_HelloInterface_Stub.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016, 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. + */ + +// Stub class generated by rmic, do not edit. +// Contents subject to change without notice. + +import java.io.Serializable; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.UnexpectedException; +import javax.rmi.CORBA.Stub; +import javax.rmi.CORBA.Util; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.portable.ApplicationException; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.RemarshalException; +import org.omg.CORBA.portable.ResponseHandler; +import org.omg.CORBA.portable.ServantObject; + + +public class _HelloInterface_Stub extends Stub implements HelloInterface { + + private static final String[] _type_ids = { + "RMI:HelloInterface:0000000000000000" + }; + + public String[] _ids() { + return (String[]) _type_ids.clone(); + } + + public Test3 sayHelloWithTest3(Test3 arg0) throws java.rmi.RemoteException { + if (!Util.isLocal(this)) { + try { + org.omg.CORBA_2_3.portable.InputStream in = null; + try { + org.omg.CORBA_2_3.portable.OutputStream out = + (org.omg.CORBA_2_3.portable.OutputStream) + _request("sayHelloWithTest3", true); + out.write_value(arg0,Test3.class); + in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); + return (Test3) in.read_value(Test3.class); + } catch (ApplicationException ex) { + in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream(); + String $_id = in.read_string(); + throw new UnexpectedException($_id); + } catch (RemarshalException ex) { + return sayHelloWithTest3(arg0); + } finally { + _releaseReply(in); + } + } catch (SystemException ex) { + throw Util.mapSystemException(ex); + } + } else { + ServantObject so = _servant_preinvoke("sayHelloWithTest3",HelloInterface.class); + if (so == null) { + return sayHelloWithTest3(arg0); + } + try { + Test3 arg0Copy = (Test3) Util.copyObject(arg0,_orb()); + Test3 result = ((HelloInterface)so.servant).sayHelloWithTest3(arg0Copy); + return (Test3)Util.copyObject(result,_orb()); + } catch (Throwable ex) { + Throwable exCopy = (Throwable)Util.copyObject(ex,_orb()); + throw Util.wrapException(exCopy); + } finally { + _servant_postinvoke(so); + } + } + } + } diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy b/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy new file mode 100644 index 00000000000..52d9247b846 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016, 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. + */ + +grant codeBase "jrt:/java.corba" { + permission java.security.AllPermission; +}; + + + +grant { + permission java.io.FilePermission "./-", "read,write,execute"; + permission java.io.FilePermission "*", "read"; + permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve"; + permission java.util.PropertyPermission "*", "read, write"; + permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; + permission java.io.SerializablePermission "enableSubclassImplementation"; + permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.corba"; + permission java.lang.RuntimePermission "defineClassInPackage.sun.corba"; + permission java.lang.RuntimePermission "reflectionFactoryAccess"; + permission sun.corba.BridgePermission "getBridge"; + permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect"; + permission java.util.PropertyPermission "*", "read, write"; + permission java.io.FilePermission "<>", "read,write,execute"; +}; diff --git a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java index 52079aa359b..30b20c37150 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java +++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java @@ -31,17 +31,16 @@ * HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java ConcurrentHashMapTest.java * @run main/othervm -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050 * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest + * @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy + * -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050 + * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest * @key intermittent */ -import java.io.DataInputStream; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.CountDownLatch; import jdk.testlibrary.JDKToolFinder; import jdk.testlibrary.JDKToolLauncher; @@ -83,7 +82,7 @@ public class ConcurrentHashMapTest { } static void startOrbd() throws Exception { - System.out.println("\nStarting orbd on port 1050 "); + System.out.println("\nStarting orbd with NS port 1050 "); //orbd -ORBInitialHost localhost -ORBInitialPort 1050 orbdLauncher.addToolArg("-ORBInitialHost").addToolArg("localhost") @@ -98,7 +97,7 @@ public class ConcurrentHashMapTest { static void startRmiIiopServer() throws Exception { System.out.println("\nStarting RmiServer"); - // java -cp . + // java -cp . -addmods java.corba // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory // -Djava.naming.provider.url=iiop://localhost:1050 HelloServer List commands = new ArrayList<>(); @@ -122,17 +121,15 @@ public class ConcurrentHashMapTest { } static void stopRmiIiopServer() throws Exception { - rmiServerProcess.destroy(); + rmiServerProcess.destroyForcibly(); rmiServerProcess.waitFor(); - //rmiServerProcess.waitFor(30, TimeUnit.SECONDS); System.out.println("serverProcess exitCode:" + rmiServerProcess.exitValue()); } static void stopOrbd() throws Exception { - orbdProcess.destroy(); + orbdProcess.destroyForcibly(); orbdProcess.waitFor(); - //orbdProcess.waitFor(30, TimeUnit.SECONDS); System.out.println("orbd exitCode:" + orbdProcess.exitValue()); } diff --git a/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy b/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy new file mode 100644 index 00000000000..73477e5d250 --- /dev/null +++ b/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, 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. + */ + +grant codeBase "jrt:/java.corba" { + permission java.security.AllPermission; +}; + +grant { + permission java.io.FilePermission "./-", "read,write,execute"; + permission java.io.FilePermission "*", "read"; + permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve"; + permission java.util.PropertyPermission "*", "read, write"; + permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; + permission java.io.SerializablePermission "enableSubclassImplementation"; + permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.corba"; + permission java.lang.RuntimePermission "defineClassInPackage.sun.corba"; + permission java.lang.RuntimePermission "reflectionFactoryAccess"; + permission sun.corba.BridgePermission "getBridge"; + permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect"; + permission java.util.PropertyPermission "*", "read, write"; + permission java.io.FilePermission "<>", "read,write,execute"; +}; From a1025d0535372bf2511b76380fc7ed2f3988a9e2 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Mon, 20 Jun 2016 17:06:27 -0700 Subject: [PATCH 088/191] 8049314: javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java fails intermittently with "Unexpected EOF" message Reviewed-by: xuelei --- .../net/ssl/templates/SSLSocketSSLEngineTemplate.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java b/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java index fd5ec86e4ef..091ed4d1e5e 100644 --- a/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java +++ b/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java @@ -178,8 +178,11 @@ public class SSLSocketSSLEngineTemplate { char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); - ts.load(new FileInputStream(trustFilename), passphrase); + try (FileInputStream keyFile = new FileInputStream(keyFilename); + FileInputStream trustFile = new FileInputStream(trustFilename)) { + ks.load(keyFile, passphrase); + ts.load(trustFile, passphrase); + } KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); @@ -310,6 +313,7 @@ public class SSLSocketSSLEngineTemplate { if (retry && serverIn.remaining() < clientMsg.length) { log("Need to read more from client"); + serverIn.compact(); retry = false; continue; } else { From efac3d44f29907c969da529b0c6d735a37f1461f Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Mon, 20 Jun 2016 18:30:57 -0700 Subject: [PATCH 089/191] 8159879: Some typo and minor test bugs in ava/lang/module/ModuleReferenceTest.java and ConfigurationTest.java Reviewed-by: alanb --- jdk/test/java/lang/module/ConfigurationTest.java | 12 ++++++------ jdk/test/java/lang/module/ModuleReferenceTest.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/lang/module/ConfigurationTest.java b/jdk/test/java/lang/module/ConfigurationTest.java index 4d885cd7e59..a73987545e5 100644 --- a/jdk/test/java/lang/module/ConfigurationTest.java +++ b/jdk/test/java/lang/module/ConfigurationTest.java @@ -157,7 +157,7 @@ public class ConfigurationTest { * * The test consists of three configurations: * - Configuration cf1: m1, m2 requires public m1 - * - Configuration cf2: m3 requires m1 + * - Configuration cf2: m3 requires m2 */ public void testRequiresPublic2() { @@ -219,7 +219,7 @@ public class ConfigurationTest { * * The test consists of three configurations: * - Configuration cf1: m1 - * - Configuration cf2: m2 requires public m3, m3 requires m2 + * - Configuration cf2: m2 requires public m1, m3 requires m2 */ public void testRequiresPublic3() { @@ -283,7 +283,7 @@ public class ConfigurationTest { * The test consists of three configurations: * - Configuration cf1: m1 * - Configuration cf2: m2 requires public m1 - * - Configuraiton cf3: m3 requires m3 + * - Configuraiton cf3: m3 requires m2 */ public void testRequiresPublic4() { @@ -657,8 +657,8 @@ public class ConfigurationTest { * Basic test of binding services with configurations. * * Configuration cf1: p@1.0 provides p.S + * Test configuration cf2: m1 uses p.S, p@2.0 provides p.S * Test configuration cf2: m1 uses p.S - * Test configuration cf2: m1 uses p.S, p@2.0 uses p.S */ public void testServiceBindingWithConfigurations3() { @@ -896,7 +896,7 @@ public class ConfigurationTest { Configuration cf2 = resolveRequires(cf1, finder, "m1"); assertTrue(cf2.modules().size() == 1); - assertTrue(cf1.findModule("m1").isPresent()); + assertTrue(cf2.findModule("m1").isPresent()); } @@ -1305,7 +1305,7 @@ public class ConfigurationTest { /** - * Test "provides p.S" where p is not local + * Test "provides p.S with q.T" where q.T is not local */ @Test(expectedExceptions = { ResolutionException.class }) public void testProviderPackageNotLocal() { diff --git a/jdk/test/java/lang/module/ModuleReferenceTest.java b/jdk/test/java/lang/module/ModuleReferenceTest.java index 25b927716b1..fca7cc77c8a 100644 --- a/jdk/test/java/lang/module/ModuleReferenceTest.java +++ b/jdk/test/java/lang/module/ModuleReferenceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -110,7 +110,7 @@ public class ModuleReferenceTest { ModuleReference mref3 = new ModuleReference(descriptor1, null, supplier); assertTrue(mref1.equals(mref1)); - assertTrue(mref1.equals(mref1)); + assertTrue(mref1.equals(mref2)); assertTrue(mref2.equals(mref1)); assertTrue(mref1.hashCode() == mref2.hashCode()); From 8c65ff9c8c74200c72e38fb903cf1d6a0847b841 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 21 Jun 2016 11:09:13 +0800 Subject: [PATCH 090/191] 8157318: ThreadedSeedGenerator uses System.currentTimeMillis and stops generating when time is set back Reviewed-by: xuelei, wetmore --- .../share/classes/sun/security/provider/SeedGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java index dd55044d820..e72ae9f406c 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java @@ -354,8 +354,8 @@ abstract class SeedGenerator { // We wait 250milli quanta, so the minimum wait time // cannot be under 250milli. int latch = 0; - long l = System.currentTimeMillis() + 250; - while (System.currentTimeMillis() < l) { + long startTime = System.nanoTime(); + while (System.nanoTime() - startTime < 250000000) { synchronized(this){}; latch++; } From 47ade5bbb935dedc40453c8fb29f71e5734f20f5 Mon Sep 17 00:00:00 2001 From: Vyom Tewari Date: Tue, 21 Jun 2016 14:00:59 +0100 Subject: [PATCH 091/191] 8144008: Setting NO_PROXY on HTTP URL connections does not stop proxying Reviewed-by: chegar, rriggs --- .../share/classes/sun/net/NetworkClient.java | 8 ++- .../net/HttpURLConnection/NoProxyTest.java | 64 +++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/net/HttpURLConnection/NoProxyTest.java diff --git a/jdk/src/java.base/share/classes/sun/net/NetworkClient.java b/jdk/src/java.base/share/classes/sun/net/NetworkClient.java index f5cd53c295e..8b991b0b45d 100644 --- a/jdk/src/java.base/share/classes/sun/net/NetworkClient.java +++ b/jdk/src/java.base/share/classes/sun/net/NetworkClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2016, 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 @@ -165,8 +165,10 @@ public class NetworkClient { // server & port will be the proxy address and port s = new Socket(Proxy.NO_PROXY); } - } else + } else { s = createSocket(); + } + // Instance specific timeouts do have priority, that means // connectTimeout & readTimeout (-1 means not set) // Then global default timeouts @@ -194,7 +196,7 @@ public class NetworkClient { * to create the socket. */ protected Socket createSocket() throws IOException { - return new java.net.Socket(); + return new java.net.Socket(Proxy.NO_PROXY); // direct connection } protected InetAddress getLocalAddress() throws IOException { diff --git a/jdk/test/java/net/HttpURLConnection/NoProxyTest.java b/jdk/test/java/net/HttpURLConnection/NoProxyTest.java new file mode 100644 index 00000000000..d51d7500f0f --- /dev/null +++ b/jdk/test/java/net/HttpURLConnection/NoProxyTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, 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 8144008 + * @summary Setting NO_PROXY on HTTP URL connections does not stop proxying + * @run main/othervm NoProxyTest + */ + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; + +public class NoProxyTest { + + static class NoProxyTestSelector extends ProxySelector { + @Override + public List select(URI uri) { + throw new RuntimeException("Should not reach here as proxy==Proxy.NO_PROXY"); + } + @Override + public void connectFailed(URI u, SocketAddress s, IOException e) { } + } + + public static void main(String args[]) throws MalformedURLException { + ProxySelector.setDefault(new NoProxyTestSelector()); + + URL url = URI.create("http://127.0.0.1/").toURL(); + URLConnection connection; + try { + connection = url.openConnection(Proxy.NO_PROXY); + connection.connect(); + } catch (IOException ignore) { + //ignore + } + } +} From e011bbd371f2064ed955a346947021104c8fac89 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 21 Jun 2016 19:05:34 +0530 Subject: [PATCH 092/191] 8159593: Plugin Set getType() should return a Category Reviewed-by: jlaskey --- .../internal/ImagePluginConfiguration.java | 2 +- .../jdk/tools/jlink/internal/Utils.java | 37 ++----------------- .../plugins/DefaultCompressPlugin.java | 8 +--- .../internal/plugins/ExcludeFilesPlugin.java | 8 +--- .../jlink/internal/plugins/ExcludePlugin.java | 8 +--- .../internal/plugins/ExcludeVMPlugin.java | 8 +--- .../internal/plugins/FileCopierPlugin.java | 9 ----- .../plugins/GenerateJLIClassesPlugin.java | 5 --- .../plugins/IncludeLocalesPlugin.java | 7 +--- .../internal/plugins/OptimizationPlugin.java | 8 ---- .../plugins/OrderResourcesPlugin.java | 8 +--- .../internal/plugins/ReleaseInfoPlugin.java | 4 +- .../internal/plugins/StringSharingPlugin.java | 6 +-- .../internal/plugins/StripDebugPlugin.java | 9 ----- .../plugins/StripNativeCommandsPlugin.java | 8 +--- .../plugins/SystemModuleDescriptorPlugin.java | 5 --- .../jlink/internal/plugins/ZipPlugin.java | 8 +--- .../jdk/tools/jlink/plugin/Plugin.java | 27 ++++++++++---- jdk/test/tools/jlink/DefaultProviderTest.java | 8 ---- jdk/test/tools/jlink/IntegrationTest.java | 13 +------ jdk/test/tools/jlink/JLinkOptimTest.java | 9 ----- .../tools/jlink/JLinkPostProcessingTest.java | 8 +--- .../customplugin/plugin/CustomPlugin.java | 8 +--- .../customplugin/plugin/HelloPlugin.java | 9 ----- .../tools/jlink/plugins/LastSorterTest.java | 9 ----- .../tools/jlink/plugins/PluginOrderTest.java | 4 +- .../jlink/plugins/PluginsNegativeTest.java | 9 ----- .../tools/jlink/plugins/PrevisitorTest.java | 9 ----- 28 files changed, 51 insertions(+), 210 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java index 08ff3cb7e64..422029e07d4 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java @@ -101,7 +101,7 @@ public final class ImagePluginConfiguration { List orderedPlugins = PluginOrderingGraph.sort(entry.getValue()); Category category = entry.getKey(); for (Plugin p : orderedPlugins) { - if (Utils.isPostProcessor(category)) { + if (category.isPostProcessor()) { @SuppressWarnings("unchecked") PostProcessorPlugin pp = (PostProcessorPlugin) p; postProcessingPlugins.add(pp); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java index ae161b7f84d..f48665e4a57 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java @@ -35,7 +35,6 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Objects; -import java.util.Set; import java.util.stream.Collectors; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.Plugin.Category; @@ -57,46 +56,16 @@ public class Utils { .collect(Collectors.toList()); } - public static boolean isPostProcessor(Category category) { - return category.equals(Category.VERIFIER) - || category.equals(Category.PROCESSOR) - || category.equals(Category.PACKAGER); - } - - public static boolean isPreProcessor(Category category) { - return category.equals(Category.COMPRESSOR) - || category.equals(Category.FILTER) - || category.equals(Category.MODULEINFO_TRANSFORMER) - || category.equals(Category.SORTER) - || category.equals(Category.TRANSFORMER) - || category.equals(Category.METAINFO_ADDER); - } - public static boolean isPostProcessor(Plugin provider) { - Set types = provider.getType(); - Objects.requireNonNull(types); - for (Category pt : types) { - return isPostProcessor(pt); - } - return false; + return provider.getType().isPostProcessor(); } public static boolean isPreProcessor(Plugin provider) { - Set types = provider.getType(); - Objects.requireNonNull(types); - for (Category pt : types) { - return isPreProcessor(pt); - } - return false; + return !isPostProcessor(provider); } public static Category getCategory(Plugin provider) { - Set types = provider.getType(); - Objects.requireNonNull(types); - for (Category t : types) { - return t; - } - return null; + return provider.getType(); } public static List getPreProcessors(List plugins) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java index c3cde266d2b..d78ae453dda 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java @@ -25,9 +25,7 @@ package jdk.tools.jlink.internal.plugins; import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.plugin.ModulePool; @@ -77,10 +75,8 @@ public final class DefaultCompressPlugin implements TransformerPlugin, ResourceP } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.COMPRESSOR); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.COMPRESSOR; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java index 0ccabebb512..eeb454af0c4 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java @@ -26,9 +26,7 @@ package jdk.tools.jlink.internal.plugins; import java.io.UncheckedIOException; import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.plugin.ModulePool; @@ -60,10 +58,8 @@ public final class ExcludeFilesPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.FILTER); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.FILTER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java index 4f26bf464a0..b3a84ffa853 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java @@ -25,9 +25,7 @@ package jdk.tools.jlink.internal.plugins; import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.plugin.ModuleEntry; @@ -73,10 +71,8 @@ public final class ExcludePlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.FILTER); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.FILTER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java index 3ddfabef5ea..390dd9a3fb1 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java @@ -32,10 +32,8 @@ import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeSet; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -159,10 +157,8 @@ public final class ExcludeVMPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.FILTER); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.FILTER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java index d1839d3eb4f..9be4b023b48 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java @@ -36,11 +36,9 @@ import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; import jdk.tools.jlink.internal.ModuleEntryImpl; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModuleEntry; @@ -187,13 +185,6 @@ public class FileCopierPlugin implements TransformerPlugin { } } - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public void configure(Map config) { List arguments = Utils.parseList(config.get(NAME)); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index 2e075799076..397641febbf 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -60,11 +60,6 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { public GenerateJLIClassesPlugin() { } - @Override - public Set getType() { - return Collections.singleton(Category.TRANSFORMER); - } - @Override public String getName() { return NAME; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index b5e712003ae..94b3aa464bc 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -27,7 +27,6 @@ package jdk.tools.jlink.internal.plugins; import java.io.ByteArrayInputStream; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.IllformedLocaleException; import java.util.Locale; import java.util.List; @@ -134,10 +133,8 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.FILTER); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.FILTER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java index 9632cdf9b95..d5e9c25be09 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java @@ -31,7 +31,6 @@ import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -284,11 +283,4 @@ public final class OptimizationPlugin extends AsmPlugin { } } } - - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java index 47bb13d3c71..3041f4ac1d2 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java @@ -32,7 +32,6 @@ import java.nio.file.PathMatcher; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -143,11 +142,8 @@ public final class OrderResourcesPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.SORTER); - - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.SORTER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java index 8e676f614b9..1fbf0fbff36 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java @@ -49,8 +49,8 @@ public final class ReleaseInfoPlugin implements TransformerPlugin { private final Map release = new HashMap<>(); @Override - public Set getType() { - return Collections.singleton(Category.METAINFO_ADDER); + public Category getType() { + return Category.METAINFO_ADDER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java index 828cf10c0c1..cec1de1a4a1 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java @@ -343,10 +343,8 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.COMPRESSOR); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.COMPRESSOR; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java index 42ba8d16aa3..74b16e174e8 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java @@ -27,8 +27,6 @@ package jdk.tools.jlink.internal.plugins; import java.io.ByteArrayInputStream; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; import java.util.function.Predicate; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; @@ -57,13 +55,6 @@ public final class StripDebugPlugin implements TransformerPlugin { return NAME; } - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public String getDescription() { return PluginsResourceBundle.getDescription(NAME); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java index 496a4e538d7..44e3ec52bc8 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java @@ -25,8 +25,6 @@ package jdk.tools.jlink.internal.plugins; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; @@ -45,10 +43,8 @@ public final class StripNativeCommandsPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.FILTER); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.FILTER; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java index 70a613a8a86..226d759804a 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java @@ -82,11 +82,6 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { this.enabled = true; } - @Override - public Set getType() { - return Collections.singleton(Category.TRANSFORMER); - } - @Override public String getName() { return NAME; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java index 69645d0ff05..b44f2e81e64 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java @@ -29,9 +29,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import java.util.zip.Deflater; import jdk.tools.jlink.internal.ModulePoolImpl; @@ -66,10 +64,8 @@ public final class ZipPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.COMPRESSOR); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.COMPRESSOR; } @Override diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java index 30633b546d3..f748fa0f286 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java @@ -57,19 +57,29 @@ public interface Plugin { SORTER("SORTER"), COMPRESSOR("COMPRESSOR"), METAINFO_ADDER("METAINFO_ADDER"), - VERIFIER("VERIFIER"), - PROCESSOR("PROCESSOR"), - PACKAGER("PACKAGER"); + VERIFIER("VERIFIER", true), + PROCESSOR("PROCESSOR", true), + PACKAGER("PACKAGER", true); private final String name; + private final boolean postProcessor; + + Category(String name, boolean postProcessor) { + this.name = name; + this.postProcessor = postProcessor; + } Category(String name) { - this.name = name; + this(name, false); } public String getName() { return name; } + + public boolean isPostProcessor() { + return postProcessor; + } } /** @@ -90,11 +100,12 @@ public interface Plugin { } /** - * The Plugin set of types. - * @return The set of types. + * The type of this plugin. + * + * @return The type of this plugin */ - public default Set getType() { - return Collections.emptySet(); + public default Category getType() { + return Category.TRANSFORMER; } /** diff --git a/jdk/test/tools/jlink/DefaultProviderTest.java b/jdk/test/tools/jlink/DefaultProviderTest.java index c10e9d37060..9f4229a3451 100644 --- a/jdk/test/tools/jlink/DefaultProviderTest.java +++ b/jdk/test/tools/jlink/DefaultProviderTest.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -64,13 +63,6 @@ public class DefaultProviderTest { private static class Custom implements TransformerPlugin { private boolean enabled = true; - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public Set getState() { return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL) diff --git a/jdk/test/tools/jlink/IntegrationTest.java b/jdk/test/tools/jlink/IntegrationTest.java index e5637b421a8..e321b08ffa4 100644 --- a/jdk/test/tools/jlink/IntegrationTest.java +++ b/jdk/test/tools/jlink/IntegrationTest.java @@ -90,10 +90,8 @@ public class IntegrationTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.PROCESSOR); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.PROCESSOR; } @Override @@ -138,13 +136,6 @@ public class IntegrationTest { }, out); } - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public String getDescription() { return null; diff --git a/jdk/test/tools/jlink/JLinkOptimTest.java b/jdk/test/tools/jlink/JLinkOptimTest.java index f41e418fc3b..d4612fbe845 100644 --- a/jdk/test/tools/jlink/JLinkOptimTest.java +++ b/jdk/test/tools/jlink/JLinkOptimTest.java @@ -9,11 +9,9 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Stream; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.Opcodes; @@ -132,13 +130,6 @@ public class JLinkOptimTest { public String getName() { return NAME; } - - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } } private static void testForName() throws Exception { diff --git a/jdk/test/tools/jlink/JLinkPostProcessingTest.java b/jdk/test/tools/jlink/JLinkPostProcessingTest.java index abc2b58142e..c6da5dd97cc 100644 --- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java +++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java @@ -26,10 +26,8 @@ import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import jdk.tools.jlink.internal.PluginRepository; import jdk.tools.jlink.plugin.ExecutableImage; @@ -75,10 +73,8 @@ public class JLinkPostProcessingTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.PROCESSOR); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.PROCESSOR; } @Override diff --git a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java index 781039a517a..1b8b16b515b 100644 --- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java +++ b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java @@ -23,9 +23,7 @@ package plugin; import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.function.Function; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; @@ -58,9 +56,7 @@ public class CustomPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.PROCESSOR); - return Collections.unmodifiableSet(set); + public Category getType() { + return Category.PROCESSOR; } } diff --git a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java index aa150350d7f..e37dee780d9 100644 --- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java +++ b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java @@ -26,9 +26,7 @@ import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; @@ -62,13 +60,6 @@ public final class HelloPlugin implements TransformerPlugin { } } - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public String getDescription() { return NAME + "-description"; diff --git a/jdk/test/tools/jlink/plugins/LastSorterTest.java b/jdk/test/tools/jlink/plugins/LastSorterTest.java index 0dc27b44ec8..a15284dafa9 100644 --- a/jdk/test/tools/jlink/plugins/LastSorterTest.java +++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java @@ -33,10 +33,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import jdk.tools.jlink.internal.ImagePluginConfiguration; import jdk.tools.jlink.internal.PluginRepository; @@ -199,13 +197,6 @@ public class LastSorterTest { return name; } - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public void configure(Map config) { String arguments = config.get(name); diff --git a/jdk/test/tools/jlink/plugins/PluginOrderTest.java b/jdk/test/tools/jlink/plugins/PluginOrderTest.java index 4c9f2c2241d..18178145e64 100644 --- a/jdk/test/tools/jlink/plugins/PluginOrderTest.java +++ b/jdk/test/tools/jlink/plugins/PluginOrderTest.java @@ -260,8 +260,8 @@ public class PluginOrderTest { } @Override - public Set getType() { - return Collections.singleton(category); + public Category getType() { + return category; } @Override diff --git a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java index 5b8ed2d6c83..3b533556582 100644 --- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java +++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java @@ -32,10 +32,8 @@ import java.lang.reflect.Layer; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import jdk.tools.jlink.internal.ImagePluginConfiguration; import jdk.tools.jlink.internal.PluginRepository; @@ -137,13 +135,6 @@ public class PluginsNegativeTest { return name; } - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } - @Override public String getDescription() { return null; diff --git a/jdk/test/tools/jlink/plugins/PrevisitorTest.java b/jdk/test/tools/jlink/plugins/PrevisitorTest.java index 1f721d66d5f..019470c375b 100644 --- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java +++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java @@ -34,11 +34,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.stream.Collectors; import jdk.tools.jlink.internal.ImagePluginConfiguration; @@ -160,12 +158,5 @@ public class PrevisitorTest { } }); } - - @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(Category.TRANSFORMER); - return Collections.unmodifiableSet(set); - } } } From 0d9142bf891491c110b9bf4b2ae6f5b8463ce9b5 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 21 Jun 2016 15:31:08 +0100 Subject: [PATCH 093/191] 8159834: Add some support for jtreg test headers in IntelliJ langtools project Add live templates to help creation of jtreg tests Reviewed-by: jlahoda --- langtools/make/build.xml | 5 +++- .../intellij/utils/jtreg-live-templates.xml | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 langtools/make/intellij/utils/jtreg-live-templates.xml diff --git a/langtools/make/build.xml b/langtools/make/build.xml index b894201c341..d4946abbc4c 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -235,7 +235,10 @@ - + + + + diff --git a/langtools/make/intellij/utils/jtreg-live-templates.xml b/langtools/make/intellij/utils/jtreg-live-templates.xml new file mode 100644 index 00000000000..6412c0dfdc8 --- /dev/null +++ b/langtools/make/intellij/utils/jtreg-live-templates.xml @@ -0,0 +1,25 @@ + + + + From c49eb0c2b664825bd6552c163421ff845250eff8 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Tue, 21 Jun 2016 17:48:29 +0300 Subject: [PATCH 094/191] 8158802: com.sun.jndi.ldap.SimpleClientId produces wrong hash code Reviewed-by: rriggs, coffeys --- .../com/sun/jndi/ldap/DigestClientId.java | 9 +-- .../com/sun/jndi/ldap/SimpleClientId.java | 12 +-- .../sun/jndi/ldap/SimpleClientIdHashCode.java | 73 +++++++++++++++++++ 3 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 jdk/test/com/sun/jndi/ldap/SimpleClientIdHashCode.java diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/DigestClientId.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/DigestClientId.java index e7078098cbd..9e55a935e5a 100644 --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/DigestClientId.java +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/DigestClientId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -60,7 +60,6 @@ class DigestClientId extends SimpleClientId { final private String[] propvals; final private int myHash; - private int pHash = 0; DigestClientId(int version, String hostname, int port, String protocol, Control[] bindCtls, OutputStream trace, @@ -78,12 +77,9 @@ class DigestClientId extends SimpleClientId { propvals = new String[SASL_PROPS.length]; for (int i = 0; i < SASL_PROPS.length; i++) { propvals[i] = (String) env.get(SASL_PROPS[i]); - if (propvals[i] != null) { - pHash = pHash * 31 + propvals[i].hashCode(); - } } } - myHash = super.hashCode() + pHash; + myHash = super.hashCode() ^ Arrays.hashCode(propvals); } public boolean equals(Object obj) { @@ -92,7 +88,6 @@ class DigestClientId extends SimpleClientId { } DigestClientId other = (DigestClientId)obj; return myHash == other.myHash - && pHash == other.pHash && super.equals(obj) && Arrays.equals(propvals, other.propvals); } diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/SimpleClientId.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/SimpleClientId.java index 6fa5471281f..2915110407e 100644 --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/SimpleClientId.java +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/SimpleClientId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -49,21 +49,23 @@ class SimpleClientId extends ClientId { socketFactory); this.username = username; + int pwdHashCode = 0; if (passwd == null) { this.passwd = null; - } else if (passwd instanceof String) { - this.passwd = passwd; } else if (passwd instanceof byte[]) { this.passwd = ((byte[])passwd).clone(); + pwdHashCode = Arrays.hashCode((byte[])passwd); } else if (passwd instanceof char[]) { this.passwd = ((char[])passwd).clone(); + pwdHashCode = Arrays.hashCode((char[])passwd); } else { this.passwd = passwd; + pwdHashCode = passwd.hashCode(); } myHash = super.hashCode() - + (username != null ? username.hashCode() : 0) - + (passwd != null ? passwd.hashCode() : 0); + ^ (username != null ? username.hashCode() : 0) + ^ pwdHashCode; } public boolean equals(Object obj) { diff --git a/jdk/test/com/sun/jndi/ldap/SimpleClientIdHashCode.java b/jdk/test/com/sun/jndi/ldap/SimpleClientIdHashCode.java new file mode 100644 index 00000000000..956e2c4aea8 --- /dev/null +++ b/jdk/test/com/sun/jndi/ldap/SimpleClientIdHashCode.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016, 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 8158802 + * @summary com.sun.jndi.ldap.SimpleClientId produces wrong hash code + * @modules java.naming/com.sun.jndi.ldap + */ + +import java.io.OutputStream; +import java.lang.reflect.Constructor; +import javax.naming.ldap.Control; + + +public class SimpleClientIdHashCode { + public static void main(String[] args) throws Throwable { + Class simpleClientIdClass + = Class.forName("com.sun.jndi.ldap.SimpleClientId"); + Constructor init = simpleClientIdClass.getDeclaredConstructor( + int.class, String.class, int.class, String.class, + Control[].class, OutputStream.class, String.class, + String.class, Object.class); + init.setAccessible(true); + + Object p1 = new byte[]{66,77}; + Object p2 = new char[]{'w','d'}; + Object p3 = "word"; + + test(init, new byte[]{65}, new byte[]{65}); + test(init, new char[]{'p'}, new char[]{'p'}); + test(init, "pass", "pass"); + test(init, p1, p1); + test(init, p2, p2); + test(init, p3, p3); + test(init, null, null); + } + + private static void test(Constructor init, Object pass1, Object pass2) + throws Throwable { + + Object o1 = init.newInstance(1, "host", 3, "", null, System.out, + null, null, pass1); + Object o2 = init.newInstance(1, "host", 3, "", null, System.out, + null, null, pass2); + + if (!o1.equals(o2)) + throw new RuntimeException("Objects not equal"); + + if (o1.hashCode() != o2.hashCode()) + throw new RuntimeException("Inconsistent hash codes"); + } +} From bb15c9c8bf2fd539204d1d9664d021c058c1d23a Mon Sep 17 00:00:00 2001 From: Vyom Tewari Date: Tue, 21 Jun 2016 16:42:33 +0100 Subject: [PATCH 095/191] 8154234: Remove netdoc URL protocol Handler Reviewed-by: chegar --- .../sun/net/www/protocol/netdoc/Handler.java | 97 ------------------- 1 file changed, 97 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/net/www/protocol/netdoc/Handler.java diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/netdoc/Handler.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/netdoc/Handler.java deleted file mode 100644 index 5e441e8550b..00000000000 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/netdoc/Handler.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1996, 1998, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -/*- - * netdoc urls point either into the local filesystem or externally - * through an http url, with network documents being preferred. Useful for - * FAQs & other documents which are likely to be changing over time at the - * central site, and where the user will want the most recent edition. - * - * @author Steven B. Byrne - */ - -package sun.net.www.protocol.netdoc; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; -import java.net.URLStreamHandler; -import java.io.InputStream; -import java.io.IOException; -import sun.security.action.GetPropertyAction; - -public class Handler extends URLStreamHandler { - static URL base; - - /* - * Attempt to find a load the given url using the default (network) - * documentation location. If that fails, use the local copy - */ - public synchronized URLConnection openConnection(URL u) - throws IOException - { - URLConnection uc = null; - URL ru; - - boolean localonly = Boolean.parseBoolean( - GetPropertyAction.privilegedGetProperty("newdoc.localonly")); - - String docurl = GetPropertyAction.privilegedGetProperty("doc.url"); - - String file = u.getFile(); - if (!localonly) { - try { - if (base == null) { - base = new URL(docurl); - } - ru = new URL(base, file); - } catch (MalformedURLException e) { - ru = null; - } - if (ru != null) { - uc = ru.openConnection(); - } - } - - if (uc == null) { - try { - ru = new URL("file", "~", file); - - uc = ru.openConnection(); - InputStream is = uc.getInputStream(); // Check for success. - } catch (MalformedURLException e) { - uc = null; - } catch (IOException e) { - uc = null; - } - } - - if (uc == null) { - throw new IOException("Can't find file for URL: " - +u.toExternalForm()); - } - return uc; - } -} From 6ae11043e90a3e5b70cfab4a32cd89f4b4ab1fcb Mon Sep 17 00:00:00 2001 From: Vyom Tewari Date: Tue, 21 Jun 2016 16:52:16 +0100 Subject: [PATCH 096/191] 8114860: Behavior of java.net.URLPermission.getActions() contradicts spec Reviewed-by: chegar, prappo --- .../share/classes/java/net/URLPermission.java | 14 ++--- .../net/URLPermission/URLPermissionTest.java | 57 ++++++++++++++++++- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/URLPermission.java b/jdk/src/java.base/share/classes/java/net/URLPermission.java index e188c81d73b..ed76cd2333b 100644 --- a/jdk/src/java.base/share/classes/java/net/URLPermission.java +++ b/jdk/src/java.base/share/classes/java/net/URLPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -455,15 +455,11 @@ public final class URLPermission extends Permission { } private String actions() { - StringBuilder b = new StringBuilder(); - for (String s : methods) { - b.append(s); + String b = String.join(",", methods); + if (!requestHeaders.isEmpty()) { + b += ":" + String.join(",", requestHeaders); } - b.append(":"); - for (String s : requestHeaders) { - b.append(s); - } - return b.toString(); + return b; } /** diff --git a/jdk/test/java/net/URLPermission/URLPermissionTest.java b/jdk/test/java/net/URLPermission/URLPermissionTest.java index 2ffcf735f5b..0b870fb8acc 100644 --- a/jdk/test/java/net/URLPermission/URLPermissionTest.java +++ b/jdk/test/java/net/URLPermission/URLPermissionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -26,7 +26,7 @@ import java.io.*; /** * @test - * @bug 8010464 8027570 8027687 8029354 + * @bug 8010464 8027570 8027687 8029354 8114860 */ public class URLPermissionTest { @@ -129,6 +129,28 @@ public class URLPermissionTest { } } + static ActionsStringTest actionstest(String arg, String expectedActions) { + return new ActionsStringTest(arg, expectedActions); + } + + static class ActionsStringTest extends Test { + + String expectedActions; + String arg; + + public ActionsStringTest(String arg, String expectedActions) { + this.arg = arg; + this.expectedActions = expectedActions; + } + + @Override + boolean execute() { + String url = "http://www.foo.com/"; + URLPermission urlp = new URLPermission(url, arg); + return (expectedActions.equals(urlp.getActions())); + } + } + static ActionImpliesTest actest(String arg1, String arg2, boolean expected) { return new ActionImpliesTest(arg1, arg2, expected); } @@ -308,6 +330,20 @@ public class URLPermissionTest { actest("*:*", "GET:x-bar,x-foo", true) }; + static Test[] actionsStringTest = { + actionstest("", ""), + actionstest(":X-Bar", ":X-Bar"), + actionstest("GET", "GET"), + actionstest("get", "GET"), + actionstest("GET,POST", "GET,POST"), + actionstest("GET,post", "GET,POST"), + actionstest("get,post", "GET,POST"), + actionstest("get,post,DELETE", "DELETE,GET,POST"), + actionstest("GET,POST:", "GET,POST"), + actionstest("GET:X-Foo,X-bar", "GET:X-Bar,X-Foo"), + actionstest("GET,POST,DELETE:X-Bar,X-Foo,X-Bar,Y-Foo", "DELETE,GET,POST:X-Bar,X-Bar,X-Foo,Y-Foo") + }; + static Test[] equalityTests = { eqtest("http://www.foo.com", "http://www.FOO.CoM", true), eqtest("http://[fe80:0:0::]:1-2", "HTTP://[FE80::]:1-2", true), @@ -449,6 +485,23 @@ public class URLPermissionTest { System.out.println ("action test " + i + " OK"); } + for (int i = 0; i < actionsStringTest.length; i++) { + ActionsStringTest test = (ActionsStringTest) actionsStringTest[i]; + Exception caught = null; + boolean result = false; + try { + result = test.execute(); + } catch (Exception e) { + caught = e; + } + if (!result) { + failed = true; + System.out.println("test failed: " + test.arg + ": " + + test.expectedActions + " Exception: " + caught); + } + System.out.println("Actions String test " + i + " OK"); + } + serializationTest("http://www.foo.com/-", "GET,DELETE:*"); serializationTest("https://www.foo.com/-", "POST:X-Foo"); serializationTest("https:*", "*:*"); From e0c6d91241f17366080783c1bc059a21f72bd43b Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Tue, 21 Jun 2016 18:51:18 +0100 Subject: [PATCH 097/191] 8156742: Miscellaneous WebSocket API improvements Reviewed-by: chegar, rriggs --- .../share/classes/java/net/http/WS.java | 14 +- .../classes/java/net/http/WSBuilder.java | 17 +- .../java/net/http/WSFrameConsumer.java | 2 +- .../java/net/http/WSMessageSender.java | 6 - .../java/net/http/WSOpeningHandshake.java | 11 +- .../java/net/http/WSOutgoingMessage.java | 21 --- .../classes/java/net/http/WSReceiver.java | 3 +- .../classes/java/net/http/WSTransmitter.java | 7 - .../classes/java/net/http/WebSocket.java | 160 +++--------------- .../net/httpclient/BasicWebSocketAPITest.java | 31 +--- 10 files changed, 50 insertions(+), 222 deletions(-) diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WS.java b/jdk/src/java.httpclient/share/classes/java/net/http/WS.java index 7d51f646638..ac327a47609 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WS.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WS.java @@ -34,7 +34,6 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.function.Supplier; -import java.util.stream.Stream; import static java.lang.System.Logger.Level.ERROR; import static java.lang.System.Logger.Level.WARNING; @@ -103,15 +102,6 @@ final class WS implements WebSocket { } } - @Override - public CompletableFuture sendText(Stream message) { - requireNonNull(message, "message"); - synchronized (stateLock) { - checkState(); - return transmitter.sendText(message); - } - } - @Override public CompletableFuture sendBinary(ByteBuffer message, boolean isLast) { requireNonNull(message, "message"); @@ -179,11 +169,11 @@ final class WS implements WebSocket { } @Override - public long request(long n) { + public void request(long n) { if (n < 0L) { throw new IllegalArgumentException("The number must not be negative: " + n); } - return receiver.request(n); + receiver.request(n); } @Override diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSBuilder.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSBuilder.java index 90d2d79162a..42a166e4616 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSBuilder.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSBuilder.java @@ -25,6 +25,7 @@ package java.net.http; import java.net.URI; +import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -59,8 +60,7 @@ final class WSBuilder implements WebSocket.Builder { private final LinkedHashMap> headers = new LinkedHashMap<>(); private final WebSocket.Listener listener; private Collection subprotocols = Collections.emptyList(); - private long timeout; - private TimeUnit timeUnit; + private Duration timeout; WSBuilder(URI uri, HttpClient client, WebSocket.Listener listener) { checkURI(requireNonNull(uri, "uri")); @@ -93,13 +93,8 @@ final class WSBuilder implements WebSocket.Builder { } @Override - public WebSocket.Builder connectTimeout(long timeout, TimeUnit unit) { - if (timeout < 0) { - throw new IllegalArgumentException("Negative timeout: " + timeout); - } - requireNonNull(unit, "unit"); - this.timeout = timeout; - this.timeUnit = unit; + public WebSocket.Builder connectTimeout(Duration timeout) { + this.timeout = requireNonNull(timeout, "timeout"); return this; } @@ -139,9 +134,7 @@ final class WSBuilder implements WebSocket.Builder { return new ArrayList<>(subprotocols); } - long getTimeout() { return timeout; } - - TimeUnit getTimeUnit() { return timeUnit; } + Duration getConnectTimeout() { return timeout; } private static Collection checkSubprotocols(String mostPreferred, String... lesserPreferred) { diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSFrameConsumer.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSFrameConsumer.java index 9d0521e9700..eebfce66e0a 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSFrameConsumer.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSFrameConsumer.java @@ -206,7 +206,7 @@ final class WSFrameConsumer implements WSFrame.Consumer { boolean binaryNonEmpty = data.hasRemaining(); WSShared textData; try { - textData = decoder.decode(data, part.isLast()); + textData = decoder.decode(data, part == MessagePart.WHOLE || part == MessagePart.LAST); } catch (CharacterCodingException e) { throw new WSProtocolException ("5.6.", "Invalid UTF-8 sequence in frame " + opcode, NOT_CONSISTENT, e); diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSMessageSender.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSMessageSender.java index 95a9b902d36..46f8060d0d8 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSMessageSender.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSMessageSender.java @@ -30,7 +30,6 @@ import java.net.http.WSOutgoingMessage.Binary; import java.net.http.WSOutgoingMessage.Close; import java.net.http.WSOutgoingMessage.Ping; import java.net.http.WSOutgoingMessage.Pong; -import java.net.http.WSOutgoingMessage.StreamedText; import java.net.http.WSOutgoingMessage.Text; import java.net.http.WSOutgoingMessage.Visitor; import java.nio.ByteBuffer; @@ -122,11 +121,6 @@ final class WSMessageSender { previousIsLast = message.isLast; } - @Override - public void visit(StreamedText streamedText) { - throw new IllegalArgumentException("Not yet implemented"); - } - @Override public void visit(Binary message) { buffers[1] = message.bytes; diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java index d3cc7da3520..9d0a9c42cc2 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java @@ -32,11 +32,14 @@ import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Base64; import java.util.Collection; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -77,8 +80,12 @@ final class WSOpeningHandshake { WSOpeningHandshake(WSBuilder b) { URI httpURI = createHttpUri(b.getUri()); HttpRequest.Builder requestBuilder = b.getClient().request(httpURI); - if (b.getTimeUnit() != null) { - requestBuilder.timeout(b.getTimeUnit(), b.getTimeout()); + Duration connectTimeout = b.getConnectTimeout(); + if (connectTimeout != null) { + requestBuilder.timeout( + TimeUnit.of(ChronoUnit.MILLIS), + connectTimeout.get(ChronoUnit.MILLIS) + ); } Collection s = b.getSubprotocols(); if (!s.isEmpty()) { diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSOutgoingMessage.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSOutgoingMessage.java index bc3eabd62a4..34e91f81716 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSOutgoingMessage.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSOutgoingMessage.java @@ -25,13 +25,11 @@ package java.net.http; import java.nio.ByteBuffer; -import java.util.stream.Stream; abstract class WSOutgoingMessage { interface Visitor { void visit(Text message); - void visit(StreamedText message); void visit(Binary message); void visit(Ping message); void visit(Pong message); @@ -64,25 +62,6 @@ abstract class WSOutgoingMessage { } } - static final class StreamedText extends WSOutgoingMessage { - - public final Stream characters; - - StreamedText(Stream characters) { - this.characters = characters; - } - - @Override - void accept(Visitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return WSUtils.toStringSimple(this) + "[characters=" + characters + "]"; - } - } - static final class Binary extends WSOutgoingMessage { public final boolean isLast; diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSReceiver.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSReceiver.java index 7ce089b4a4a..9b4da82ca0f 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSReceiver.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSReceiver.java @@ -101,11 +101,10 @@ final class WSReceiver { } } - long request(long n) { + void request(long n) { long newDemand = demand.accumulateAndGet(n, (p, i) -> p + i < 0 ? Long.MAX_VALUE : p + i); handler.signal(); assert newDemand >= 0 : newDemand; - return newDemand; } private boolean getData() throws IOException { diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSTransmitter.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSTransmitter.java index a9a8287478e..62219d07009 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSTransmitter.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSTransmitter.java @@ -28,7 +28,6 @@ import java.net.http.WSOutgoingMessage.Binary; import java.net.http.WSOutgoingMessage.Close; import java.net.http.WSOutgoingMessage.Ping; import java.net.http.WSOutgoingMessage.Pong; -import java.net.http.WSOutgoingMessage.StreamedText; import java.net.http.WSOutgoingMessage.Text; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -40,7 +39,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.function.Consumer; -import java.util.stream.Stream; import static java.lang.String.format; import static java.net.http.Pair.pair; @@ -83,11 +81,6 @@ final class WSTransmitter { return acceptMessage(new Text(isLast, message)); } - CompletableFuture sendText(Stream message) { - checkAndUpdateText(true); - return acceptMessage(new StreamedText(message)); - } - CompletableFuture sendBinary(ByteBuffer message, boolean isLast) { checkAndUpdateBinary(isLast); return acceptMessage(new Binary(isLast, message)); diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WebSocket.java b/jdk/src/java.httpclient/share/classes/java/net/http/WebSocket.java index dfc7f71dc3b..6d1452567ed 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WebSocket.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WebSocket.java @@ -28,13 +28,11 @@ import java.io.IOException; import java.net.ProtocolException; import java.net.URI; import java.nio.ByteBuffer; +import java.time.Duration; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -import java.util.concurrent.TimeUnit; -import java.util.stream.Stream; /** * A WebSocket client conforming to RFC 6455. @@ -47,8 +45,9 @@ import java.util.stream.Stream; * receive messages. When the {@code WebSocket} is no longer * needed it must be closed: a Close message must both be {@linkplain * #sendClose() sent} and {@linkplain Listener#onClose(WebSocket, Optional, - * String) received}. Or to close abruptly, {@link #abort()} is called. Once - * closed it remains closed, cannot be reopened. + * String) received}. Otherwise, invoke {@link #abort() abort} to close abruptly. + * + *

    Once closed the {@code WebSocket} remains closed and cannot be reopened. * *

    Messages of type {@code X} are sent through the {@code WebSocket.sendX} * methods and received through {@link WebSocket.Listener}{@code .onX} methods @@ -71,10 +70,6 @@ import java.util.stream.Stream; * arranged from the {@code buffer}'s {@link ByteBuffer#position() position} to * the {@code buffer}'s {@link ByteBuffer#limit() limit}. * - *

    All message exchange is run by the threads belonging to the {@linkplain - * HttpClient#executorService() executor service} of {@code WebSocket}'s {@link - * HttpClient}. - * *

    Unless otherwise noted, passing a {@code null} argument to a constructor * or method of this type will cause a {@link NullPointerException * NullPointerException} to be thrown. @@ -217,22 +212,17 @@ public interface WebSocket { * Sets a timeout for the opening handshake. * *

    If the opening handshake is not finished within the specified - * timeout then {@link #buildAsync()} completes exceptionally with a - * {@code HttpTimeoutException}. + * amount of time then {@link #buildAsync()} completes exceptionally + * with a {@code HttpTimeoutException}. * - *

    If the timeout is not specified then it's deemed infinite. + *

    If this method is not invoked then the timeout is deemed infinite. * * @param timeout - * the maximum time to wait - * @param unit - * the time unit of the timeout argument + * the timeout * * @return this builder - * - * @throws IllegalArgumentException - * if the {@code timeout} is negative */ - Builder connectTimeout(long timeout, TimeUnit unit); + Builder connectTimeout(Duration timeout); /** * Builds a {@code WebSocket}. @@ -506,7 +496,7 @@ public interface WebSocket { *

    Once a Close message is received, the server will not send any * more messages. * - *

    A Close message may consist of a close code and a reason for + *

    A Close message may consist of a status code and a reason for * closing. The reason will have a UTF-8 representation not longer than * {@code 123} bytes. The reason may be useful for debugging or passing * information relevant to the connection but is not necessarily human @@ -545,12 +535,8 @@ public interface WebSocket { * the time {@code onError} is invoked, no more messages can be sent on * this {@code WebSocket}. * - * @apiNote Errors associated with send operations ({@link - * WebSocket#sendText(CharSequence, boolean) sendText}, {@link - * #sendBinary(ByteBuffer, boolean) sendBinary}, {@link - * #sendPing(ByteBuffer) sendPing}, {@link #sendPong(ByteBuffer) - * sendPong} and {@link #sendClose(CloseCode, CharSequence) sendClose}) - * are reported to the {@code CompletionStage} operations return. + * @apiNote Errors associated with {@code sendX} methods are reported to + * the {@code CompletableFuture} these methods return. * * @implSpec The default implementation does nothing. * @@ -563,8 +549,8 @@ public interface WebSocket { } /** - * A marker used by {@link WebSocket.Listener} for partial message - * receiving. + * A marker used by {@link WebSocket.Listener} in cases where a partial + * message may be received. * * @since 9 */ @@ -586,19 +572,9 @@ public interface WebSocket { LAST, /** - * A whole message. The message consists of a single part. + * A whole message consisting of a single part. */ - WHOLE; - - /** - * Tells whether a part of a message received with this marker is the - * last part. - * - * @return {@code true} if LAST or WHOLE, {@code false} otherwise - */ - public boolean isLast() { - return this == LAST || this == WHOLE; - } + WHOLE } /** @@ -630,7 +606,7 @@ public interface WebSocket { * @param message * the message * @param isLast - * {@code true} if this is the final part of the message, + * {@code true} if this is the last part of the message, * {@code false} otherwise * * @return a CompletableFuture with this WebSocket @@ -678,43 +654,6 @@ public interface WebSocket { return sendText(message, true); } - /** - * Sends a whole Text message with characters from {@code - * CharacterSequence}s provided by the given {@code Stream}. - * - *

    This is a convenience method. For the general case use {@link - * #sendText(CharSequence, boolean)}. - * - *

    Returns a {@code CompletableFuture} which completes - * normally when the message has been sent or completes exceptionally if an - * error occurs. - * - *

    Streamed character sequences should not be modified until the - * returned {@code CompletableFuture} completes (either normally or - * exceptionally). - * - *

    The returned {@code CompletableFuture} can complete exceptionally - * with: - *

      - *
    • {@link IOException} - * if an I/O error occurs during this operation - *
    • {@link IllegalStateException} - * if the {@code WebSocket} closes while this operation is in progress; - * or if a Close message has been sent already; - * or if there is an outstanding send operation; - * or if a previous Binary message was not sent with {@code isLast == true} - *
    - * - * @param message - * the message - * - * @return a CompletableFuture with this WebSocket - * - * @throws IllegalArgumentException - * if {@code message} is a malformed (or an incomplete) UTF-16 sequence - */ - CompletableFuture sendText(Stream message); - /** * Sends a Binary message with bytes from the given {@code ByteBuffer}. * @@ -737,50 +676,13 @@ public interface WebSocket { * @param message * the message * @param isLast - * {@code true} if this is the final part of the message, + * {@code true} if this is the last part of the message, * {@code false} otherwise * * @return a CompletableFuture with this WebSocket */ CompletableFuture sendBinary(ByteBuffer message, boolean isLast); - /** - * Sends a Binary message with bytes from the given {@code byte[]}. - * - *

    Returns a {@code CompletableFuture} which completes - * normally when the message has been sent or completes exceptionally if an - * error occurs. - * - *

    The returned {@code CompletableFuture} can complete exceptionally - * with: - *

      - *
    • {@link IOException} - * if an I/O error occurs during this operation - *
    • {@link IllegalStateException} - * if the {@code WebSocket} closes while this operation is in progress; - * or if a Close message has been sent already; - * or if there is an outstanding send operation; - * or if a previous Text message was not sent with {@code isLast == true} - *
    - * - * @implSpec This is equivalent to: - *
    {@code
    -     *     sendBinary(ByteBuffer.wrap(message), isLast)
    -     * }
    - * - * @param message - * the message - * @param isLast - * {@code true} if this is the final part of the message, - * {@code false} otherwise - * - * @return a CompletableFuture with this WebSocket - */ - default CompletableFuture sendBinary(byte[] message, boolean isLast) { - Objects.requireNonNull(message, "message"); - return sendBinary(ByteBuffer.wrap(message), isLast); - } - /** * Sends a Ping message. * @@ -858,10 +760,11 @@ public interface WebSocket { * normally when the message has been sent or completes exceptionally if an * error occurs. * - *

    A Close message may consist of a close code and a reason for closing. - * The reason must have a valid UTF-8 representation not longer than {@code - * 123} bytes. The reason may be useful for debugging or passing information - * relevant to the connection but is not necessarily human readable. + *

    A Close message may consist of a status code and a reason for + * closing. The reason must have a UTF-8 representation not longer than + * {@code 123} bytes. The reason may be useful for debugging or passing + * information relevant to the connection but is not necessarily human + * readable. * *

    The returned {@code CompletableFuture} can complete exceptionally * with: @@ -910,24 +813,21 @@ public interface WebSocket { CompletableFuture sendClose(); /** - * Requests {@code n} more messages to be received by the {@link Listener + * Allows {@code n} more messages to be received by the {@link Listener * Listener}. * - *

    The actual number might be fewer if either of the endpoints decide to - * close the connection before that or an error occurs. + *

    The actual number of received messages might be fewer if a Close + * message is received, the connection closes or an error occurs. * *

    A {@code WebSocket} that has just been created, hasn't requested * anything yet. Usually the initial request for messages is done in {@link * Listener#onOpen(java.net.http.WebSocket) Listener.onOpen}. * - * If all requested messages have been received, and the server sends more, - * then these messages are queued. - * * @implNote This implementation does not distinguish between partial and * whole messages, because it's not known beforehand how a message will be * received. * - *

    If a server sends more messages than requested, the implementation + *

    If a server sends more messages than requested, this implementation * queues up these messages on the TCP connection and may eventually force * the sender to stop sending through TCP flow control. * @@ -936,12 +836,8 @@ public interface WebSocket { * * @throws IllegalArgumentException * if {@code n < 0} - * - * @return resulting unfulfilled demand with this request taken into account */ - // TODO return void as it's breaking encapsulation (leaking info when exactly something deemed delivered) - // or demand behaves after LONG.MAX_VALUE - long request(long n); + void request(long n); /** * Returns a {@linkplain Builder#subprotocols(String, String...) subprotocol} diff --git a/jdk/test/java/net/httpclient/BasicWebSocketAPITest.java b/jdk/test/java/net/httpclient/BasicWebSocketAPITest.java index 0ee412450ed..89a37384428 100644 --- a/jdk/test/java/net/httpclient/BasicWebSocketAPITest.java +++ b/jdk/test/java/net/httpclient/BasicWebSocketAPITest.java @@ -32,10 +32,9 @@ import java.net.http.WebSocket.CloseCode; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.channels.SocketChannel; +import java.time.Duration; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import java.util.stream.Stream; /* * @test @@ -83,13 +82,7 @@ public class BasicWebSocketAPITest { (ws) -> TestKit.assertThrows(NullPointerException.class, "message", - () -> ws.sendBinary((byte[]) null, true)) - ); - checkAndClose( - (ws) -> - TestKit.assertThrows(NullPointerException.class, - "message", - () -> ws.sendBinary((ByteBuffer) null, true)) + () -> ws.sendBinary(null, true)) ); checkAndClose( (ws) -> @@ -125,13 +118,7 @@ public class BasicWebSocketAPITest { (ws) -> TestKit.assertThrows(NullPointerException.class, "message", - () -> ws.sendText((CharSequence) null)) - ); - checkAndClose( - (ws) -> - TestKit.assertThrows(NullPointerException.class, - "message", - () -> ws.sendText((Stream) null)) + () -> ws.sendText(null)) ); checkAndClose( (ws) -> @@ -214,17 +201,7 @@ public class BasicWebSocketAPITest { // FIXME: check timeout works // (i.e. it directly influences the time WebSocket waits for connection + opening handshake) TestKit.assertNotThrows( - () -> WebSocket.newBuilder(ws, defaultListener()).connectTimeout(1, TimeUnit.SECONDS) - ); - WebSocket.Builder builder = WebSocket.newBuilder(ws, defaultListener()); - TestKit.assertThrows(IllegalArgumentException.class, - "(?i).*\\bnegative\\b.*", - () -> builder.connectTimeout(-1, TimeUnit.SECONDS) - ); - WebSocket.Builder builder1 = WebSocket.newBuilder(ws, defaultListener()); - TestKit.assertThrows(NullPointerException.class, - "unit", - () -> builder1.connectTimeout(1, null) + () -> WebSocket.newBuilder(ws, defaultListener()).connectTimeout(Duration.ofSeconds(1)) ); // FIXME: check these headers are actually received by the server TestKit.assertNotThrows( From 6f94a3f4bfa77e50864e1e9bc58c64b32a9253f9 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 21 Jun 2016 21:06:54 +0200 Subject: [PATCH 098/191] 8136453: Parameter name indices array size not updated correctly Correctly resizing ClassReader.parameterNameIndices array. Reviewed-by: mcimadamore --- .../com/sun/tools/javac/jvm/ClassReader.java | 3 +- .../LocalVariableTable/T8136453/T.jcod | 112 ++++++++++++++++++ .../LocalVariableTable/T8136453/T8136453.java | 64 ++++++++++ 3 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T.jcod create mode 100644 langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T8136453.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 12c46059519..e242188e9d1 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -1039,7 +1039,8 @@ public class ClassReader { if (start_pc == 0) { // ensure array large enough if (register >= parameterNameIndices.length) { - int newSize = Math.max(register, parameterNameIndices.length + 8); + int newSize = + Math.max(register + 1, parameterNameIndices.length + 8); parameterNameIndices = Arrays.copyOf(parameterNameIndices, newSize); } diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T.jcod b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T.jcod new file mode 100644 index 00000000000..01fb37be8c2 --- /dev/null +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T.jcod @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2016, 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. + */ +class T { + 0xCAFEBABE; + 0; // minor version + 52; // version + [] { // Constant Pool + ; // first element is empty + Method #3 #15; // #1 + class #16; // #2 + class #17; // #3 + Utf8 ""; // #4 + Utf8 "()V"; // #5 + Utf8 "Code"; // #6 + Utf8 "LocalVariableTable"; // #7 + Utf8 "this"; // #8 + Utf8 "LT;"; // #9 + Utf8 "test"; // #10 + Utf8 "(I)I"; // #11 + Utf8 "p"; // #12 + Utf8 "I"; // #13 + Utf8 "l1"; // #14 + NameAndType #4 #5; // #15 + Utf8 "T"; // #16 + Utf8 "java/lang/Object"; // #17 + } // Constant Pool + + 0x0021; // access + #2;// this_cpx + #3;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0001; // access + #4; // name_cpx + #5; // sig_cpx + [] { // Attributes + Attr(#6) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#7) { // LocalVariableTable + [] { // LocalVariableTable + 0 5 8 9 0; + } + } // end LocalVariableTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0001; // access + #10; // name_cpx + #11; // sig_cpx + [] { // Attributes + Attr(#6) { // Code + 1; // max_stack + 3; // max_locals + Bytes[]{ + 0x033D1CAC; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#7) { // LocalVariableTable + [] { // LocalVariableTable + 0 4 8 9 0; + 0 4 12 13 1; + 0 4 14 13 20; + } + } // end LocalVariableTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + } // Attributes +} // end class T diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T8136453.java b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T8136453.java new file mode 100644 index 00000000000..baf472a3824 --- /dev/null +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/T8136453/T8136453.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, 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 8136453 + * @summary Checking that javac's ClassReader expands its parameterNameIndices array properly. + * @modules jdk.compiler + * @build T T8136453 + * @run main T8136453 + */ + +import java.util.Arrays; +import java.util.List; + +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.util.ElementFilter; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; + +public class T8136453 { + public static void main(String... args) { + new T8136453().run(); + } + + void run() { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + List opts = Arrays.asList("-XDsave-parameter-names"); + JavacTask task = (JavacTask) compiler.getTask(null, null, null, opts, null, null); + TypeElement t = task.getElements().getTypeElement("T"); + ExecutableElement testMethod = ElementFilter.methodsIn(t.getEnclosedElements()).get(0); + VariableElement param = testMethod.getParameters().get(0); + Name paramName = param.getSimpleName(); + + if (!paramName.contentEquals("p")) { + throw new AssertionError("Wrong parameter name: " + paramName); + } + } +} From e18eaa2e9bac046ff76d4d67e1da35a46d859bd5 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Tue, 21 Jun 2016 15:15:05 -0700 Subject: [PATCH 099/191] 8159548: Formatter returns unexpected strings if locale is null Reviewed-by: sherman --- .../share/classes/java/util/Formatter.java | 9 ++-- .../java/util/Formatter/FormatLocale.java | 49 ++++++++++++++++++- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Formatter.java b/jdk/src/java.base/share/classes/java/util/Formatter.java index d0f8a96d833..1871896bca9 100644 --- a/jdk/src/java.base/share/classes/java/util/Formatter.java +++ b/jdk/src/java.base/share/classes/java/util/Formatter.java @@ -3895,8 +3895,7 @@ public final class Formatter implements Closeable, Flushable { TimeZone tz = t.getTimeZone(); sb.append(tz.getDisplayName((t.get(Calendar.DST_OFFSET) != 0), TimeZone.SHORT, - Objects.requireNonNullElse(l, - Locale.getDefault(Locale.Category.FORMAT)))); + Objects.requireNonNullElse(l, Locale.US))); break; } @@ -3904,8 +3903,7 @@ public final class Formatter implements Closeable, Flushable { case DateTime.NAME_OF_DAY_ABBREV: // 'a' case DateTime.NAME_OF_DAY: { // 'A' int i = t.get(Calendar.DAY_OF_WEEK); - Locale lt = Objects.requireNonNullElse(l, - Locale.getDefault(Locale.Category.FORMAT)); + Locale lt = Objects.requireNonNullElse(l, Locale.US); DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt); if (c == DateTime.NAME_OF_DAY) sb.append(dfs.getWeekdays()[i]); @@ -3917,8 +3915,7 @@ public final class Formatter implements Closeable, Flushable { case DateTime.NAME_OF_MONTH_ABBREV_X: // 'h' -- same b case DateTime.NAME_OF_MONTH: { // 'B' int i = t.get(Calendar.MONTH); - Locale lt = Objects.requireNonNullElse(l, - Locale.getDefault(Locale.Category.FORMAT)); + Locale lt = Objects.requireNonNullElse(l, Locale.US); DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt); if (c == DateTime.NAME_OF_MONTH) sb.append(dfs.getMonths()[i]); diff --git a/jdk/test/java/util/Formatter/FormatLocale.java b/jdk/test/java/util/Formatter/FormatLocale.java index 2f61730a2ab..55aae027c6c 100644 --- a/jdk/test/java/util/Formatter/FormatLocale.java +++ b/jdk/test/java/util/Formatter/FormatLocale.java @@ -23,17 +23,22 @@ /** * @test - * @bug 8146156 + * @bug 8146156 8159548 * @summary test whether uppercasing follows Locale.Category.FORMAT locale. * @run main/othervm FormatLocale */ import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.time.ZoneId; import java.time.Month; +import java.util.Calendar; import java.util.Formatter; +import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; import java.util.Locale.Category; +import java.util.TimeZone; import java.util.stream.IntStream; public class FormatLocale { @@ -61,7 +66,7 @@ public class FormatLocale { "N\u0130SAN", "1,00000E+08"); - public static void main(String [] args) { + static void formatLocaleTest() { StringBuilder sb = new StringBuilder(); IntStream.range(0, src.size()).forEach(i -> { @@ -79,4 +84,44 @@ public class FormatLocale { } }); } + + static void nullLocaleTest() { + String fmt = "%1$ta %1$tA %1$th %1$tB %1tZ"; + String expected = "Fri Friday Jan January PST"; + StringBuilder sb = new StringBuilder(); + Locale orig = Locale.getDefault(); + + try { + Locale.setDefault(Locale.JAPAN); + Formatter f = new Formatter(sb, (Locale)null); + ZoneId zid = ZoneId.of("America/Los_Angeles"); + Calendar c = new GregorianCalendar(TimeZone.getTimeZone(zid), Locale.US); + c.set(2016, 0, 1, 0, 0, 0); + f.format(fmt, c); + if (!sb.toString().equals(expected)) { + throw new RuntimeException( + "Localized text returned with null locale.\n" + + " expected: " + expected + "\n" + + " returned: " + sb.toString()); + } + + sb.setLength(0); + ZonedDateTime zdt = ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, zid); + f.format(fmt, zdt); + + if (!sb.toString().equals(expected)) { + throw new RuntimeException( + "Localized text returned with null locale.\n" + + " expected: " + expected + "\n" + + " returned: " + sb.toString()); + } + } finally { + Locale.setDefault(orig); + } + } + + public static void main(String [] args) { + formatLocaleTest(); + nullLocaleTest(); + } } From 193d350e5561bfe35b38ae273f4d7951600d3e6d Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Tue, 21 Jun 2016 20:20:14 -0700 Subject: [PATCH 100/191] 8157530: Remove intermittent key from javax/net/ssl/DTLS/WeakCipherSuite.java Reviewed-by: xuelei --- jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java b/jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java index 14423c17849..71e043a92aa 100644 --- a/jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java +++ b/jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java @@ -27,7 +27,6 @@ /* * @test * @bug 8043758 - * @key intermittent * @summary Datagram Transport Layer Security (DTLS) * @modules java.base/sun.security.util * @build DTLSOverDatagram From c213f457ce52528d174aca3daac68c5a1b524e45 Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Wed, 22 Jun 2016 16:12:39 +0900 Subject: [PATCH 101/191] 8159766: "Switching encoding from UTF-8 to ISO-8859-1" log message should be trace/debug message Reviewed-by: alanb, mchung, naoto --- .../sun/util/PropertyResourceBundleCharset.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/util/PropertyResourceBundleCharset.java b/jdk/src/java.base/share/classes/sun/util/PropertyResourceBundleCharset.java index df7bc3fc3d2..f8bdf4d1f57 100644 --- a/jdk/src/java.base/share/classes/sun/util/PropertyResourceBundleCharset.java +++ b/jdk/src/java.base/share/classes/sun/util/PropertyResourceBundleCharset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -34,7 +34,6 @@ import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; import java.util.Objects; -import sun.util.logging.PlatformLogger; /** * A Charset implementation for reading PropertyResourceBundle, in order @@ -94,12 +93,11 @@ public class PropertyResourceBundleCharset extends Charset { return cr; } + // Invalid or unmappable UTF-8 sequence detected. + // Switching to the ISO 8859-1 decorder. + assert cr.isMalformed() || cr.isUnmappable(); in.reset(); out.reset(); - - PlatformLogger.getLogger(getClass().getCanonicalName()).info( - "Invalid or unmappable UTF-8 sequence detected. " + - "Switching encoding from UTF-8 to ISO-8859-1"); cdISO_8859_1 = StandardCharsets.ISO_8859_1.newDecoder(); return cdISO_8859_1.decode(in, out, false); } From b75020a9b0153843ac64741e411ece53e04457d0 Mon Sep 17 00:00:00 2001 From: Vyom Tewari Date: Wed, 22 Jun 2016 09:01:34 +0100 Subject: [PATCH 102/191] 8071660: URLPermission not handling empty method lists correctly Reviewed-by: chegar, dfuchs, prappo, rriggs --- .../share/classes/java/net/URLPermission.java | 12 +++++-- .../net/URLPermission/URLPermissionTest.java | 32 ++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/URLPermission.java b/jdk/src/java.base/share/classes/java/net/URLPermission.java index ed76cd2333b..8b2e8a8b536 100644 --- a/jdk/src/java.base/share/classes/java/net/URLPermission.java +++ b/jdk/src/java.base/share/classes/java/net/URLPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -265,8 +265,14 @@ public final class URLPermission extends Permission { URLPermission that = (URLPermission)p; - if (!this.methods.get(0).equals("*") && - Collections.indexOfSubList(this.methods, that.methods) == -1) { + if (this.methods.isEmpty() && !that.methods.isEmpty()) { + return false; + } + + if (!this.methods.isEmpty() && + !this.methods.get(0).equals("*") && + Collections.indexOfSubList(this.methods, + that.methods) == -1) { return false; } diff --git a/jdk/test/java/net/URLPermission/URLPermissionTest.java b/jdk/test/java/net/URLPermission/URLPermissionTest.java index 0b870fb8acc..69b280d1f85 100644 --- a/jdk/test/java/net/URLPermission/URLPermissionTest.java +++ b/jdk/test/java/net/URLPermission/URLPermissionTest.java @@ -26,7 +26,7 @@ import java.io.*; /** * @test - * @bug 8010464 8027570 8027687 8029354 8114860 + * @bug 8010464 8027570 8027687 8029354 8114860 8071660 */ public class URLPermissionTest { @@ -110,6 +110,8 @@ public class URLPermissionTest { static class ActionImpliesTest extends Test { String arg1, arg2; + String url1 = "http://www.foo.com/-"; + String url2 = "http://www.foo.com/a/b"; ActionImpliesTest(String arg1, String arg2, boolean expected) { this.arg1 = arg1; @@ -117,10 +119,17 @@ public class URLPermissionTest { this.expected = expected; } + ActionImpliesTest(String ur11, String url2, String arg1, String arg2, + boolean expected) { + this.url1 = ur11; + this.url2 = url2; + this.arg1 = arg1; + this.arg2 = arg2; + this.expected = expected; + } + @Override boolean execute() { - String url1 = "http://www.foo.com/-"; - String url2 = "http://www.foo.com/a/b"; URLPermission p1 = new URLPermission(url1, arg1); URLPermission p2 = new URLPermission(url2, arg2); boolean result = p1.implies(p2); @@ -155,6 +164,11 @@ public class URLPermissionTest { return new ActionImpliesTest(arg1, arg2, expected); } + static ActionImpliesTest actest(String url1, String url2, String arg1, + String arg2, boolean expected) { + return new ActionImpliesTest(url1, url2, arg1, arg2, expected); + } + static class HashCodeTest extends Test { String arg1, arg2; int hash; @@ -314,6 +328,9 @@ public class URLPermissionTest { imtest("https:*", "http:*", false) }; + static final String FOO_URL = "http://www.foo.com/"; + static final String BAR_URL = "http://www.bar.com/"; + static Test[] actionImplies = { actest("GET", "GET", true), actest("GET", "POST", false), @@ -327,7 +344,14 @@ public class URLPermissionTest { actest("GET:X-Foo,X-Bar", "GET:x-bar,x-foo", true), actest("GET:X-Bar,X-Foo,X-Bar,Y-Foo", "GET:x-bar,x-foo", true), actest("GET:*", "GET:x-bar,x-foo", true), - actest("*:*", "GET:x-bar,x-foo", true) + actest("*:*", "GET:x-bar,x-foo", true), + actest("", "GET:x-bar,x-foo", false), + actest("GET:x-bar,x-foo", "", true), + actest("", "", true), + actest("GET,DELETE", "GET,DELETE:x-foo", false), + actest(FOO_URL, BAR_URL, "", "GET:x-bar,x-foo", false), + actest(FOO_URL, BAR_URL, "GET:x-bar,x-foo", "", false), + actest(FOO_URL, BAR_URL, "", "", false) }; static Test[] actionsStringTest = { From 34f5b60b4abcc85654faa5c4521b613a5691fb30 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 22 Jun 2016 09:21:06 +0100 Subject: [PATCH 103/191] 8157166: Update spec to account for platforms that do not support multicast Reviewed-by: alanb --- .../share/classes/java/net/MulticastSocket.java | 10 ++++++---- .../java/nio/channels/MulticastChannel.java | 17 ++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/MulticastSocket.java b/jdk/src/java.base/share/classes/java/net/MulticastSocket.java index 9c9e4b8f53a..7d8d2090c91 100644 --- a/jdk/src/java.base/share/classes/java/net/MulticastSocket.java +++ b/jdk/src/java.base/share/classes/java/net/MulticastSocket.java @@ -300,8 +300,9 @@ class MulticastSocket extends DatagramSocket { * * @param mcastaddr is the multicast address to join * - * @exception IOException if there is an error joining - * or when the address is not a multicast address. + * @exception IOException if there is an error joining, or when the address + * is not a multicast address, or the platform does not support + * multicasting * @exception SecurityException if a security manager exists and its * {@code checkMulticast} method doesn't allow the join. * @@ -384,8 +385,9 @@ class MulticastSocket extends DatagramSocket { * {@link MulticastSocket#setInterface(InetAddress)} or * {@link MulticastSocket#setNetworkInterface(NetworkInterface)} * - * @exception IOException if there is an error joining - * or when the address is not a multicast address. + * @exception IOException if there is an error joining, or when the address + * is not a multicast address, or the platform does not support + * multicasting * @exception SecurityException if a security manager exists and its * {@code checkMulticast} method doesn't allow the join. * @throws IllegalArgumentException if mcastaddr is null or is a diff --git a/jdk/src/java.base/share/classes/java/nio/channels/MulticastChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/MulticastChannel.java index d1d13ebef11..f42cb8b8887 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/MulticastChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/MulticastChannel.java @@ -40,10 +40,11 @@ import java.net.StandardSocketOptions; // javadoc * address. * *

    In the case of a channel to an {@link StandardProtocolFamily#INET IPv4} socket, - * the underlying operating system supports - * RFC 2236: Internet Group Management Protocol, Version 2 (IGMPv2). - * It may optionally support source filtering as specified by RFC 3376: Internet Group + * the underlying operating system optionally supports + * RFC 2236: Internet Group + * Management Protocol, Version 2 (IGMPv2). When IGMPv2 is supported then + * the operating system may additionally support source filtering as specified by + * RFC 3376: Internet Group * Management Protocol, Version 3 (IGMPv3). * For channels to an {@link StandardProtocolFamily#INET6 IPv6} socket, the equivalent * standards are RFC 2710: @@ -167,7 +168,8 @@ public interface MulticastChannel * If the channel already has source-specific membership of the * group on the interface * @throws UnsupportedOperationException - * If the channel's socket is not an Internet Protocol socket + * If the channel's socket is not an Internet Protocol socket, or + * the platform does not support multicasting * @throws ClosedChannelException * If this channel is closed * @throws IOException @@ -214,8 +216,9 @@ public interface MulticastChannel * If the channel is currently a member of the group on the given * interface to receive all datagrams * @throws UnsupportedOperationException - * If the channel's socket is not an Internet Protocol socket or - * source filtering is not supported + * If the channel's socket is not an Internet Protocol socket, or + * source filtering is not supported, or the platform does not + * support multicasting * @throws ClosedChannelException * If this channel is closed * @throws IOException From d172b7b70b49e2b022c26ae7fe8e340ac23cf6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 22 Jun 2016 16:30:41 +0200 Subject: [PATCH 104/191] 8159977: typeof operator does not see lexical bindings declared in other scripts Reviewed-by: sundar --- .../jdk/nashorn/internal/objects/Global.java | 6 +-- .../internal/runtime/ScriptObject.java | 25 +++++------ .../internal/runtime/ScriptRuntime.java | 12 +++++- .../nashorn/internal/runtime/WithObject.java | 8 ++-- .../runtime/test/LexicalBindingTest.java | 41 +++++++++++++++---- 5 files changed, 64 insertions(+), 28 deletions(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java index 4a489b826f6..5a9b71cf1a6 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java @@ -2474,14 +2474,14 @@ public final class Global extends Scope { } @Override - protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) { - if (lexicalScope != null && start != this && start.isScope()) { + protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { + if (lexicalScope != null && isScope) { final FindProperty find = lexicalScope.findProperty(key, false); if (find != null) { return find; } } - return super.findProperty(key, deep, start); + return super.findProperty(key, deep, isScope, start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java index b5d1265b2ea..e5fa1874e6e 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java @@ -775,7 +775,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * @return FindPropertyData or null if not found. */ public final FindProperty findProperty(final Object key, final boolean deep) { - return findProperty(key, deep, this); + return findProperty(key, deep, false, this); } /** @@ -791,12 +791,12 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * @see jdk.nashorn.internal.objects.NativeArray * * @param key Property key. - * @param deep Whether the search should look up proto chain. + * @param deep true if the search should look up proto chain + * @param isScope true if this is a scope access * @param start the object on which the lookup was originally initiated - * * @return FindPropertyData or null if not found. */ - protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) { + protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { final PropertyMap selfMap = getMap(); final Property property = selfMap.findProperty(key); @@ -807,7 +807,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { if (deep) { final ScriptObject myProto = getProto(); - final FindProperty find = myProto == null ? null : myProto.findProperty(key, true, start); + final FindProperty find = myProto == null ? null : myProto.findProperty(key, true, isScope, start); // checkSharedProtoMap must be invoked after myProto.checkSharedProtoMap to propagate // shared proto invalidation up the prototype chain. It also must be invoked when prototype is null. checkSharedProtoMap(); @@ -1977,7 +1977,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { return findMegaMorphicGetMethod(desc, name, operation == StandardOperation.GET_METHOD); } - final FindProperty find = findProperty(name, true); + final FindProperty find = findProperty(name, true, NashornCallSiteDescriptor.isScope(desc), this); MethodHandle mh; if (find == null) { @@ -2035,7 +2035,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { } private static GuardedInvocation findMegaMorphicGetMethod(final CallSiteDescriptor desc, final String name, final boolean isMethod) { - Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic getter: " + desc + " " + name + " " +isMethod); + Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic getter: ", desc, " ", name + " ", isMethod); final MethodHandle invoker = MH.insertArguments(MEGAMORPHIC_GET, 1, name, isMethod, NashornCallSiteDescriptor.isScope(desc)); final MethodHandle guard = getScriptObjectGuard(desc.getMethodType(), true); return new GuardedInvocation(invoker, guard); @@ -2043,7 +2043,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { @SuppressWarnings("unused") private Object megamorphicGet(final String key, final boolean isMethod, final boolean isScope) { - final FindProperty find = findProperty(key, true); + final FindProperty find = findProperty(key, true, isScope, this); if (find != null) { return find.getObjectValue(); } @@ -2181,7 +2181,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * * toString = function() { print("global toString"); } // don't affect Object.prototype.toString */ - FindProperty find = findProperty(name, true, this); + FindProperty find = findProperty(name, true, NashornCallSiteDescriptor.isScope(desc), this); // If it's not a scope search, then we don't want any inherited properties except those with user defined accessors. if (find != null && find.isInherited() && !find.getProperty().isAccessorProperty()) { @@ -2258,6 +2258,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { } private GuardedInvocation findMegaMorphicSetMethod(final CallSiteDescriptor desc, final String name) { + Context.getContextTrusted().getLogger(ObjectClassGenerator.class).warning("Megamorphic setter: ", desc, " ", name); final MethodType type = desc.getMethodType().insertParameterTypes(1, Object.class); //never bother with ClassCastExceptionGuard for megamorphic callsites final GuardedInvocation inv = findSetIndexMethod(getClass(), desc, false, type); @@ -2734,7 +2735,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { if (isValidArrayIndex(index)) { for (ScriptObject object = this; ; ) { if (object.getMap().containsArrayKeys()) { - final FindProperty find = object.findProperty(key, false, this); + final FindProperty find = object.findProperty(key, false); if (find != null) { return getIntValue(find, programPoint); @@ -2805,7 +2806,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { if (isValidArrayIndex(index)) { for (ScriptObject object = this; ; ) { if (object.getMap().containsArrayKeys()) { - final FindProperty find = object.findProperty(key, false, this); + final FindProperty find = object.findProperty(key, false); if (find != null) { return getDoubleValue(find, programPoint); } @@ -2875,7 +2876,7 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { if (isValidArrayIndex(index)) { for (ScriptObject object = this; ; ) { if (object.getMap().containsArrayKeys()) { - final FindProperty find = object.findProperty(key, false, this); + final FindProperty find = object.findProperty(key, false); if (find != null) { return find.getObjectValue(); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java index 9ac75ecd217..4f08d4cd471 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java @@ -704,7 +704,17 @@ public final class ScriptRuntime { if (property != null) { if (obj instanceof ScriptObject) { - obj = ((ScriptObject)obj).get(property); + // this is a scope identifier + assert property instanceof String; + final ScriptObject sobj = (ScriptObject) obj; + + final FindProperty find = sobj.findProperty(property, true, true, sobj); + if (find != null) { + obj = find.getObjectValue(); + } else { + obj = sobj.invokeNoSuchProperty(property, false, UnwarrantedOptimismException.INVALID_PROGRAM_POINT); + } + if(Global.isLocationPropertyPlaceholder(obj)) { if(CompilerConstants.__LINE__.name().equals(property)) { obj = 0; diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java index 179437c832e..6dfb18e2330 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java @@ -193,20 +193,20 @@ public final class WithObject extends Scope { * * @param key Property key. * @param deep Whether the search should look up proto chain. + * @param isScope true if is this a scope access * @param start the object on which the lookup was originally initiated - * * @return FindPropertyData or null if not found. */ @Override - protected FindProperty findProperty(final Object key, final boolean deep, final ScriptObject start) { + protected FindProperty findProperty(final Object key, final boolean deep, boolean isScope, final ScriptObject start) { // We call findProperty on 'expression' with 'expression' itself as start parameter. // This way in ScriptObject.setObject we can tell the property is from a 'with' expression // (as opposed from another non-scope object in the proto chain such as Object.prototype). - final FindProperty exprProperty = expression.findProperty(key, true, expression); + final FindProperty exprProperty = expression.findProperty(key, true, false, expression); if (exprProperty != null) { return exprProperty; } - return super.findProperty(key, deep, start); + return super.findProperty(key, deep, isScope, start); } @Override diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java index 713a33caad9..9e91195fdf8 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java @@ -46,8 +46,8 @@ import static org.testng.Assert.assertEquals; public class LexicalBindingTest { final static String LANGUAGE_ES6 = "--language=es6"; - final static int NUMBER_OF_CONTEXTS = 20; - final static int MEGAMORPHIC_LOOP_COUNT = 20; + final static int NUMBER_OF_CONTEXTS = 40; + final static int MEGAMORPHIC_LOOP_COUNT = 40; /** * Test access to global var-declared variables for shared script classes with multiple globals. @@ -57,19 +57,21 @@ public class LexicalBindingTest { final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); final ScriptEngine e = factory.getScriptEngine(); final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS]; - final String sharedScript = "foo"; + final String sharedScript1 = "foo"; + final String sharedScript2 = "bar = foo; bar"; for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) { final ScriptContext context = contexts[i] = new SimpleScriptContext(); final Bindings b = e.createBindings(); context.setBindings(b, ScriptContext.ENGINE_SCOPE); - assertEquals(e.eval("var foo = '" + i + "';", context), null); + assertEquals(e.eval("var foo = '" + i + "'; var bar;", context), null); } for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) { final ScriptContext context = contexts[i]; - assertEquals(e.eval(sharedScript, context), String.valueOf(i)); + assertEquals(e.eval(sharedScript1, context), String.valueOf(i)); + assertEquals(e.eval(sharedScript2, context), String.valueOf(i)); } } @@ -81,19 +83,21 @@ public class LexicalBindingTest { final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6); final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS]; - final String sharedScript = "foo"; + final String sharedScript1 = "foo"; + final String sharedScript2 = "bar = foo; bar"; for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) { final ScriptContext context = contexts[i] = new SimpleScriptContext(); final Bindings b = e.createBindings(); context.setBindings(b, ScriptContext.ENGINE_SCOPE); - assertEquals(e.eval("let foo = '" + i + "';", context), null); + assertEquals(e.eval("let foo = '" + i + "'; let bar; ", context), null); } for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) { final ScriptContext context = contexts[i]; - assertEquals(e.eval(sharedScript, context), String.valueOf(i)); + assertEquals(e.eval(sharedScript1, context), String.valueOf(i)); + assertEquals(e.eval(sharedScript2, context), String.valueOf(i)); } } @@ -182,6 +186,27 @@ public class LexicalBindingTest { assertEquals(e.eval(sharedScript, newCtxt), "newer context"); } + /** + * Make sure lexically defined variables are accessible in other scripts. + */ + @Test + public void lexicalScopeTest() throws ScriptException { + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); + final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6); + + e.eval("let x; const y = 'world';"); + + assertEquals(e.eval("x = 'hello'"), "hello"); + assertEquals(e.eval("typeof x"), "string"); + assertEquals(e.eval("typeof y"), "string"); + assertEquals(e.eval("x"), "hello"); + assertEquals(e.eval("y"), "world"); + assertEquals(e.eval("typeof this.x"), "undefined"); + assertEquals(e.eval("typeof this.y"), "undefined"); + assertEquals(e.eval("this.x"), null); + assertEquals(e.eval("this.y"), null); + } + private static class ScriptRunner implements Runnable { final ScriptEngine engine; From 5c227bfdaec1aa90bdc2c7093ea57b24ccbac8ac Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 22 Jun 2016 08:51:32 -0700 Subject: [PATCH 105/191] 8159781: jlink --include-locales fails with java.util.regex.PatternSyntaxException Reviewed-by: mchung, okutsu --- .../plugins/IncludeLocalesPlugin.java | 57 +++++++++++-------- jdk/test/ProblemList.txt | 2 - 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index 94b3aa464bc..1a77e26273e 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -25,6 +25,7 @@ package jdk.tools.jlink.internal.plugins; import java.io.ByteArrayInputStream; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.IllformedLocaleException; @@ -81,15 +82,15 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr "sun.util.resources.ext", "sun.util.resources.provider"); private static final String METAINFONAME = "LocaleDataMetaInfo"; - private static final String META_FILES = - "*module-info.class," + - "*LocaleDataProvider.class," + - "*" + METAINFONAME + ".class,"; - private static final String INCLUDE_LOCALE_FILES = - "*sun/text/resources/ext/[^\\/]+_%%.class," + - "*sun/util/resources/ext/[^\\/]+_%%.class," + - "*sun/text/resources/cldr/ext/[^\\/]+_%%.class," + - "*sun/util/resources/cldr/ext/[^\\/]+_%%.class,"; + private static final List META_FILES = List.of( + ".+module-info.class", + ".+LocaleDataProvider.class", + ".+" + METAINFONAME + ".class"); + private static final List INCLUDE_LOCALE_FILES = List.of( + ".+sun/text/resources/ext/[^_]+_", + ".+sun/util/resources/ext/[^_]+_", + ".+sun/text/resources/cldr/ext/[^_]+_", + ".+sun/util/resources/cldr/ext/[^_]+_"); private Predicate predicate; private String userParam; private List priorityList; @@ -203,15 +204,17 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr String.format(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"), userParam)); } - String value = META_FILES + filtered.stream() - .map(s -> includeLocaleFilePatterns(s)) - .collect(Collectors.joining(",")); + List value = Stream.concat( + META_FILES.stream(), + filtered.stream().flatMap(s -> includeLocaleFilePatterns(s).stream())) + .map(s -> "regex:" + s) + .collect(Collectors.toList()); predicate = ResourceFilter.includeFilter(value); } - private String includeLocaleFilePatterns(String tag) { + private List includeLocaleFilePatterns(String tag) { + List files = new ArrayList<>(); String pTag = tag.replaceAll("-", "_"); - String files = ""; int lastDelimiter = tag.length(); String isoSpecial = pTag.matches("^(he|yi|id).*") ? pTag.replaceFirst("he", "iw") @@ -221,11 +224,11 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr // Add tag patterns including parents while (true) { pTag = pTag.substring(0, lastDelimiter); - files += INCLUDE_LOCALE_FILES.replaceAll("%%", pTag); + files.addAll(includeLocaleFiles(pTag)); if (!isoSpecial.isEmpty()) { isoSpecial = isoSpecial.substring(0, lastDelimiter); - files += INCLUDE_LOCALE_FILES.replaceAll("%%", isoSpecial); + files.addAll(includeLocaleFiles(isoSpecial)); } lastDelimiter = pTag.lastIndexOf('_'); @@ -237,31 +240,37 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr final String lang = pTag; // Add possible special locales of the COMPAT provider - files += Set.of(jaJPJPTag, noNONYTag, thTHTHTag).stream() + Set.of(jaJPJPTag, noNONYTag, thTHTHTag).stream() .filter(stag -> lang.equals(stag.substring(0,2))) - .map(t -> INCLUDE_LOCALE_FILES.replaceAll("%%", t.replaceAll("-", "_"))) - .collect(Collectors.joining(",")); + .map(t -> includeLocaleFiles(t.replaceAll("-", "_"))) + .forEach(files::addAll); // Add possible UN.M49 files (unconditional for now) for each language - files += INCLUDE_LOCALE_FILES.replaceAll("%%", lang + "_[0-9]{3}"); + files.addAll(includeLocaleFiles(lang + "_[0-9]{3}")); if (!isoSpecial.isEmpty()) { - files += INCLUDE_LOCALE_FILES.replaceAll("%%", isoSpecial + "_[0-9]{3}"); + files.addAll(includeLocaleFiles(isoSpecial + "_[0-9]{3}")); } // Add Thai BreakIterator related data files if (lang.equals("th")) { - files += "*sun/text/resources/thai_dict," + - "*sun/text/resources/[^\\/]+BreakIteratorData_th,"; + files.add(".+sun/text/resources/thai_dict"); + files.add(".+sun/text/resources/[^_]+BreakIteratorData_th"); } // Add Taiwan resource bundles for Hong Kong if (tag.startsWith("zh-HK")) { - files += INCLUDE_LOCALE_FILES.replaceAll("%%", "zh_TW"); + files.addAll(includeLocaleFiles("zh_TW")); } return files; } + private List includeLocaleFiles(String localeStr) { + return INCLUDE_LOCALE_FILES.stream() + .map(s -> s + localeStr + ".class") + .collect(Collectors.toList()); + } + private boolean stripUnsupportedLocales(byte[] bytes, ClassReader cr) { char[] buf = new char[cr.getMaxStringLength()]; boolean[] modified = new boolean[1]; diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 3cd2758ea72..2a028973c61 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -387,8 +387,6 @@ com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java 8141370 linux-i5 # core_tools -tools/jlink/plugins/IncludeLocalesPluginTest.java 8159781 generic-all - tools/jlink/JLinkOptimTest.java 8159264 generic-all ############################################################################ From 5856fc08008f33b0f186f09534ee9a8a758b55b1 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Wed, 22 Jun 2016 09:33:16 -0700 Subject: [PATCH 106/191] 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message Reviewed-by: xuelei --- .../javax/net/ssl/TLS/CipherTestUtils.java | 103 +++++------ jdk/test/javax/net/ssl/TLS/JSSEClient.java | 59 +++---- jdk/test/javax/net/ssl/TLS/JSSEServer.java | 20 ++- jdk/test/javax/net/ssl/TLS/TestJSSE.java | 160 ++++++------------ .../TLS/TestJSSEClientDefaultProtocol.java | 54 ++++++ .../net/ssl/TLS/TestJSSEClientProtocol.java | 52 ++++++ .../ssl/TLS/TestJSSENoCommonProtocols.java | 37 ++++ .../net/ssl/TLS/TestJSSEServerProtocol.java | 52 ++++++ 8 files changed, 322 insertions(+), 215 deletions(-) create mode 100644 jdk/test/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java create mode 100644 jdk/test/javax/net/ssl/TLS/TestJSSEClientProtocol.java create mode 100644 jdk/test/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java create mode 100644 jdk/test/javax/net/ssl/TLS/TestJSSEServerProtocol.java diff --git a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java index 04020bc6f03..4ad7465e87e 100644 --- a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java +++ b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -73,6 +73,7 @@ public class CipherTestUtils { private static final List TESTS = new ArrayList<>(3); private static final List EXCEPTIONS = Collections.synchronizedList(new ArrayList<>(1)); + private static final String CLIENT_PUBLIC_KEY = "-----BEGIN CERTIFICATE-----\n" + "MIICtTCCAh4CCQDkYJ46DMcGRjANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMC\n" @@ -191,7 +192,7 @@ public class CipherTestUtils { private final X509TrustManager clientTrustManager; private final X509TrustManager serverTrustManager; - static abstract class Server implements Runnable { + static abstract class Server implements Runnable, AutoCloseable { final CipherTestUtils cipherTest; @@ -240,12 +241,11 @@ public class CipherTestUtils { public static class TestParameters { - String cipherSuite; - String protocol; - String clientAuth; + final String cipherSuite; + final String protocol; + final String clientAuth; - TestParameters(String cipherSuite, String protocol, - String clientAuth) { + TestParameters(String cipherSuite, String protocol, String clientAuth) { this.cipherSuite = cipherSuite; this.protocol = protocol; this.clientAuth = clientAuth; @@ -267,10 +267,7 @@ public class CipherTestUtils { private static volatile CipherTestUtils instance = null; - public static CipherTestUtils getInstance() throws IOException, - FileNotFoundException, KeyStoreException, - NoSuchAlgorithmException, CertificateException, - UnrecoverableKeyException, InvalidKeySpecException { + public static CipherTestUtils getInstance() throws Exception { if (instance == null) { synchronized (CipherTestUtils.class) { if (instance == null) { @@ -281,21 +278,10 @@ public class CipherTestUtils { return instance; } - public static void setTestedArguments(String testedProtocol, - String testedCipherSuite) { - - TestParameters testedParams; - - String cipherSuite = testedCipherSuite.trim(); - if (cipherSuite.startsWith("SSL_")) { - testedParams = - new TestParameters(cipherSuite, testedProtocol, null); - TESTS.add(testedParams); - - } else { - System.out.println("Your input Cipher suites is not correct, " - + "please try another one ."); - } + public static void setTestedArguments(String protocol, String ciphersuite) { + ciphersuite = ciphersuite.trim(); + TestParameters params = new TestParameters(ciphersuite, protocol, null); + TESTS.add(params); } public X509ExtendedKeyManager getClientKeyManager() { @@ -318,10 +304,7 @@ public class CipherTestUtils { EXCEPTIONS.add(e); } - private CipherTestUtils() - throws IOException, FileNotFoundException, KeyStoreException, - NoSuchAlgorithmException, CertificateException, - UnrecoverableKeyException, InvalidKeySpecException { + private CipherTestUtils() throws Exception { factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); KeyStore serverKeyStore = createServerKeyStore(SERVER_PUBLIC_KEY, SERVER_PRIVATE_KEY); @@ -329,12 +312,11 @@ public class CipherTestUtils { CA_PRIVATE_KEY); if (serverKeyStore != null) { - KeyManagerFactory keyFactory1 - = KeyManagerFactory.getInstance( + KeyManagerFactory keyFactory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm()); - keyFactory1.init(serverKeyStore, PASSWORD); - serverKeyManager = (X509ExtendedKeyManager) keyFactory1. - getKeyManagers()[0]; + keyFactory.init(serverKeyStore, PASSWORD); + serverKeyManager = (X509ExtendedKeyManager) + keyFactory.getKeyManagers()[0]; } else { serverKeyManager = null; } @@ -346,12 +328,11 @@ public class CipherTestUtils { clientKeyStore = createServerKeyStore(CLIENT_PUBLIC_KEY,CLIENT_PRIVATE_KEY); if (clientKeyStore != null) { - KeyManagerFactory keyFactory - = KeyManagerFactory.getInstance( + KeyManagerFactory keyFactory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm()); keyFactory.init(clientKeyStore, PASSWORD); - clientKeyManager = (X509ExtendedKeyManager) keyFactory. - getKeyManagers()[0]; + clientKeyManager = (X509ExtendedKeyManager) + keyFactory.getKeyManagers()[0]; } else { clientKeyManager = null; } @@ -395,8 +376,8 @@ public class CipherTestUtils { this.cipherTest = cipherTest; } - Client(CipherTestUtils cipherTest, - String testedCipherSuite) throws Exception { + Client(CipherTestUtils cipherTest, String testedCipherSuite) + throws Exception { this.cipherTest = cipherTest; } @@ -417,7 +398,7 @@ public class CipherTestUtils { CipherTestUtils.addFailure(e); System.out.println("** Failed " + params + "**, got exception:"); - e.printStackTrace(System.err); + e.printStackTrace(System.out); } }); } @@ -448,11 +429,7 @@ public class CipherTestUtils { } public static void printStringArray(String[] stringArray) { - System.out.print(stringArray.length + " : "); - for (String stringArray1 : stringArray) { - System.out.print(stringArray1); - System.out.print(","); - } + System.out.println(Arrays.toString(stringArray)); System.out.println(); } @@ -496,15 +473,15 @@ public class CipherTestUtils { System.out.println("-----------------------"); } - private static KeyStore createServerKeyStore(String publicKeyStr, + private static KeyStore createServerKeyStore(String publicKey, String keySpecStr) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, InvalidKeySpecException { KeyStore ks = KeyStore.getInstance("JKS"); ks.load(null, null); - if (publicKeyStr == null || keySpecStr == null) { - throw new IllegalArgumentException("publicKeyStr or " + if (publicKey == null || keySpecStr == null) { + throw new IllegalArgumentException("publicKey or " + "keySpecStr cannot be null"); } String strippedPrivateKey = keySpecStr.substring( @@ -518,8 +495,7 @@ public class CipherTestUtils { = (RSAPrivateKey) kf.generatePrivate(priKeySpec); // generate certificate chain - try (InputStream is = - new ByteArrayInputStream(publicKeyStr.getBytes())) { + try (InputStream is = new ByteArrayInputStream(publicKey.getBytes())) { // generate certificate from cert string CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate keyCert = cf.generateCertificate(is); @@ -530,10 +506,9 @@ public class CipherTestUtils { return ks; } - public static int mainServer(PeerFactory peerFactory, + public static Server mainServer(PeerFactory peerFactory, String expectedException) throws Exception { - long time = System.currentTimeMillis(); setTestedArguments(peerFactory.getTestedProtocol(), peerFactory.getTestedCipher()); @@ -542,14 +517,11 @@ public class CipherTestUtils { secureRandom.nextInt(); CipherTestUtils cipherTest = CipherTestUtils.getInstance(); - Server server = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT); - Thread serverThread = new Thread(server, "Server"); + Server srv = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT); + Thread serverThread = new Thread(srv, "Server"); serverThread.start(); - time = System.currentTimeMillis() - time; - System.out.println("Elapsed time " + time); - - return server.getPort(); + return srv; } public static void mainClient(PeerFactory peerFactory, int port, @@ -566,7 +538,6 @@ public class CipherTestUtils { CipherTestUtils cipherTest = CipherTestUtils.getInstance(); peerFactory.newClient(cipherTest, port).run(); cipherTest.checkResult(expectedException); - JSSEServer.closeServer = true; time = System.currentTimeMillis() - time; System.out.println("Elapsed time " + time); @@ -582,9 +553,11 @@ public class CipherTestUtils { abstract String getTestedCipher(); - abstract Client newClient(CipherTestUtils cipherTest, int testPort) throws Exception; + abstract Client newClient(CipherTestUtils cipherTest, int testPort) + throws Exception; - abstract Server newServer(CipherTestUtils cipherTest, int testPort) throws Exception; + abstract Server newServer(CipherTestUtils cipherTest, int testPort) + throws Exception; boolean isSupported(String cipherSuite) { return true; @@ -618,7 +591,7 @@ class AlwaysTrustManager implements X509TrustManager { try { trustManager.checkClientTrusted(chain, authType); } catch (CertificateException excep) { - System.out.println("ERROR in client trust manager"); + System.out.println("ERROR in client trust manager: " + excep); } } @@ -628,7 +601,7 @@ class AlwaysTrustManager implements X509TrustManager { try { trustManager.checkServerTrusted(chain, authType); } catch (CertificateException excep) { - System.out.println("ERROR in server Trust manger"); + System.out.println("ERROR in server trust manager: " + excep); } } diff --git a/jdk/test/javax/net/ssl/TLS/JSSEClient.java b/jdk/test/javax/net/ssl/TLS/JSSEClient.java index b08ae917249..c9467ba2c53 100644 --- a/jdk/test/javax/net/ssl/TLS/JSSEClient.java +++ b/jdk/test/javax/net/ssl/TLS/JSSEClient.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. +/* + * Copyright (c) 2010, 2016, 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 @@ -35,39 +35,37 @@ class JSSEClient extends CipherTestUtils.Client { private static final String DEFAULT = "DEFAULT"; private static final String TLS = "TLS"; - private final SSLContext sslContext; + private final SSLContext context; private final MyX509KeyManager keyManager; - private final int serverPort; - private final String serverHost; - private final String testedProtocol; + private final int port; + private final String host; + private final String protocol; - JSSEClient(CipherTestUtils cipherTest, String serverHost, int serverPort, - String testedProtocols, String testedCipherSuite) throws Exception { - super(cipherTest, testedCipherSuite); - this.serverHost = serverHost; - this.serverPort = serverPort; - this.testedProtocol = testedProtocols; - this.keyManager = - new MyX509KeyManager(cipherTest.getClientKeyManager()); - sslContext = SSLContext.getInstance(TLS); + JSSEClient(CipherTestUtils cipherTest, String host, int port, + String protocols, String ciphersuite) throws Exception { + super(cipherTest, ciphersuite); + this.host = host; + this.port = port; + this.protocol = protocols; + this.keyManager = new MyX509KeyManager( + cipherTest.getClientKeyManager()); + context = SSLContext.getInstance(TLS); } @Override void runTest(CipherTestUtils.TestParameters params) throws Exception { - SSLSocket socket = null; - try { - System.out.println("Connecting to server..."); - keyManager.setAuthType(params.clientAuth); - sslContext.init(new KeyManager[]{keyManager}, - new TrustManager[]{cipherTest.getClientTrustManager()}, - CipherTestUtils.secureRandom); - SSLSocketFactory factory = (SSLSocketFactory) sslContext. - getSocketFactory(); - socket = (SSLSocket) factory.createSocket(serverHost, - serverPort); + keyManager.setAuthType(params.clientAuth); + context.init( + new KeyManager[]{ keyManager }, + new TrustManager[]{ cipherTest.getClientTrustManager() }, + CipherTestUtils.secureRandom); + SSLSocketFactory factory = (SSLSocketFactory)context.getSocketFactory(); + + System.out.println("Connecting to server..."); + try (SSLSocket socket = (SSLSocket) factory.createSocket(host, port)) { socket.setSoTimeout(CipherTestUtils.TIMEOUT); socket.setEnabledCipherSuites(params.cipherSuite.split(",")); - if (params.protocol != null && !params.protocol.trim().equals("") + if (params.protocol != null && !params.protocol.trim().isEmpty() && !params.protocol.trim().equals(DEFAULT)) { socket.setEnabledProtocols(params.protocol.split(",")); } @@ -105,16 +103,11 @@ class JSSEClient extends CipherTestUtils.Client { if ("EC".equals(keyAlg)) { keyAlg = "ECDSA"; } - if (params.clientAuth == null ? keyAlg != null - : !params.clientAuth.equals(keyAlg)) { + if (!params.clientAuth.equals(keyAlg)) { throw new RuntimeException("Certificate type mismatch: " + keyAlg + " != " + params.clientAuth); } } - } finally { - if (socket != null) { - socket.close(); - } } } } diff --git a/jdk/test/javax/net/ssl/TLS/JSSEServer.java b/jdk/test/javax/net/ssl/TLS/JSSEServer.java index 1ece6f0f8b8..d8f77922c4b 100644 --- a/jdk/test/javax/net/ssl/TLS/JSSEServer.java +++ b/jdk/test/javax/net/ssl/TLS/JSSEServer.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,13 +33,11 @@ import javax.net.ssl.TrustManager; public class JSSEServer extends CipherTestUtils.Server { private final SSLServerSocket serverSocket; - private final int serverPort; - static volatile boolean closeServer = false; + private static volatile boolean closeServer = false; JSSEServer(CipherTestUtils cipherTest, int serverPort, String protocol, String cipherSuite) throws Exception { super(cipherTest); - this.serverPort = serverPort; SSLContext serverContext = SSLContext.getInstance("TLS"); serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()}, new TrustManager[]{cipherTest.getServerTrustManager()}, @@ -56,7 +54,7 @@ public class JSSEServer extends CipherTestUtils.Server { @Override public void run() { - System.out.println("JSSE Server listening on port " + serverPort); + System.out.println("JSSE Server listening on port " + getPort()); while (!closeServer) { try (final SSLSocket socket = (SSLSocket) serverSocket.accept()) { socket.setSoTimeout(CipherTestUtils.TIMEOUT); @@ -68,12 +66,12 @@ public class JSSEServer extends CipherTestUtils.Server { } catch (IOException e) { CipherTestUtils.addFailure(e); System.out.println("Got IOException:"); - e.printStackTrace(System.err); + e.printStackTrace(System.out); } } catch (Exception e) { CipherTestUtils.addFailure(e); System.out.println("Exception:"); - e.printStackTrace(System.err); + e.printStackTrace(System.out); } } } @@ -81,4 +79,12 @@ public class JSSEServer extends CipherTestUtils.Server { int getPort() { return serverSocket.getLocalPort(); } + + @Override + public void close() throws IOException { + closeServer = true; + if (serverSocket != null && !serverSocket.isClosed()) { + serverSocket.close(); + } + } } diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSE.java b/jdk/test/javax/net/ssl/TLS/TestJSSE.java index d477e4facdf..7e89e11bb01 100644 --- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java +++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -20,59 +20,9 @@ * questions. */ -import static java.lang.System.out; import java.security.Provider; import java.security.Security; -/** - * @test - * @bug 8049429 - * @modules java.management - * jdk.crypto.ec/sun.security.ec - * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java - * @summary Test that all cipher suites work in all versions and all client - * authentication types. The way this is setup the server is stateless and - * all checking is done on the client side. - * @run main/othervm -DSERVER_PROTOCOL=SSLv3 - * -DCLIENT_PROTOCOL=SSLv3 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=TLSv1 - * -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=TLSv1.1 - * -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=TLSv1.2 - * -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1 - * -DCLIENT_PROTOCOL=TLSv1 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1 - * -DCLIENT_PROTOCOL=TLSv1.1 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv3 - * -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 - * TestJSSE javax.net.ssl.SSLHandshakeException - * @run main/othervm -DSERVER_PROTOCOL=TLSv1 - * -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 - * TestJSSE javax.net.ssl.SSLHandshakeException - * @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 - * -DCLIENT_PROTOCOL=TLSv1.2 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1 - * -DCLIENT_PROTOCOL=DEFAULT -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2 - * -DCLIENT_PROTOCOL=DEFAULT -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2 - * -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE - * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1 - * -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1.2 - * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 - * TestJSSE javax.net.ssl.SSLHandshakeException - * - */ - public class TestJSSE { private static final String LOCAL_IP = "127.0.0.1"; @@ -82,72 +32,64 @@ public class TestJSSE { // and keys used in this test are not disabled. Security.setProperty("jdk.tls.disabledAlgorithms", ""); - String serverProtocol = System.getProperty("SERVER_PROTOCOL"); - String clientProtocol = System.getProperty("CLIENT_PROTOCOL"); + // enable debug output + System.setProperty("javax.net.debug", "ssl,record"); + + String srvProtocol = System.getProperty("SERVER_PROTOCOL"); + String clnProtocol = System.getProperty("CLIENT_PROTOCOL"); String cipher = System.getProperty("CIPHER"); - if (serverProtocol == null - || clientProtocol == null - || cipher == null) { - throw new IllegalArgumentException("SERVER_PROTOCOL " - + "or CLIENT_PROTOCOL or CIPHER is missing"); + if (srvProtocol == null || clnProtocol == null || cipher == null) { + throw new IllegalArgumentException("Incorrect parameters"); } - out.println("ServerProtocol =" + serverProtocol); - out.println("ClientProtocol =" + clientProtocol); - out.println("Cipher =" + cipher); - int port = server(serverProtocol, cipher, args); - client(port, clientProtocol, cipher, args); - } + System.out.println("ServerProtocol = " + srvProtocol); + System.out.println("ClientProtocol = " + clnProtocol); + System.out.println("Cipher = " + cipher); - public static void client(int testPort, - String testProtocols, String testCipher, - String... exception) throws Exception { - String expectedException = exception.length >= 1 - ? exception[0] : null; - out.println("========================================="); - out.println(" Testing - https://" + LOCAL_IP + ":" + testPort); - out.println(" Testing - Protocol : " + testProtocols); - out.println(" Testing - Cipher : " + testCipher); - try { - CipherTestUtils.mainClient(new JSSEFactory(LOCAL_IP, testProtocols, - testCipher, "Client JSSE"), - testPort, expectedException); - } catch (Exception e) { - throw new RuntimeException(e); + try (CipherTestUtils.Server srv = server(srvProtocol, cipher, args)) { + client(srv.getPort(), clnProtocol, cipher, args); } } - public static int server(String testProtocol, String testCipher, - String... exception) throws Exception { + public static void client(int port, String protocols, String cipher, + String... exceptions) throws Exception { - String expectedException = exception.length >= 1 - ? exception[0] : null; - out.println(" This is Server"); - out.println(" Testing Protocol: " + testProtocol); - out.println(" Testing Cipher: " + testCipher); + String expectedExcp = exceptions.length >= 1 ? exceptions[0] : null; - try { - int port = CipherTestUtils.mainServer(new JSSEFactory( - null, testProtocol, testCipher, "Server JSSE"), - expectedException); + System.out.println("This is client"); + System.out.println("Testing protocol: " + protocols); + System.out.println("Testing cipher : " + cipher); - out.println(" Testing Port: " + port); - return port; - } catch (Exception e) { - throw new RuntimeException(e); - } + CipherTestUtils.mainClient( + new JSSEFactory(LOCAL_IP, protocols, cipher, "Client JSSE"), + port, expectedExcp); + } + + public static CipherTestUtils.Server server(String protocol, + String cipher, String... exceptions) throws Exception { + + String expectedExcp = exceptions.length >= 1 ? exceptions[0] : null; + + System.out.println("This is server"); + System.out.println("Testing protocol: " + protocol); + System.out.println("Testing cipher : " + cipher); + + return CipherTestUtils.mainServer( + new JSSEFactory(null, protocol, cipher, "Server JSSE"), + expectedExcp); } private static class JSSEFactory extends CipherTestUtils.PeerFactory { - final String testedCipherSuite, testedProtocol, testHost; - final String name; + private final String cipher; + private final String protocol; + private final String host; + private final String name; - JSSEFactory(String testHost, String testedProtocol, - String testedCipherSuite, String name) { - this.testedCipherSuite = testedCipherSuite; - this.testedProtocol = testedProtocol; - this.testHost = testHost; + JSSEFactory(String host, String protocol, String cipher, String name) { + this.cipher = cipher; + this.protocol = protocol; + this.host = host; this.name = name; } @@ -158,26 +100,24 @@ public class TestJSSE { @Override String getTestedCipher() { - return testedCipherSuite; + return cipher; } @Override String getTestedProtocol() { - return testedProtocol; + return protocol; } @Override - CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int testPort) + CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int port) throws Exception { - return new JSSEClient(cipherTest, testHost, testPort, - testedProtocol, testedCipherSuite); + return new JSSEClient(cipherTest, host, port, protocol, cipher); } @Override - CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int testPort) + CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int port) throws Exception { - return new JSSEServer(cipherTest, testPort, - testedProtocol, testedCipherSuite); + return new JSSEServer(cipherTest, port, protocol, cipher); } } } diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java b/jdk/test/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java new file mode 100644 index 00000000000..710bc681a8f --- /dev/null +++ b/jdk/test/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, 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 8049429 + * @modules java.management + * jdk.crypto.ec/sun.security.ec + * @summary Test that all cipher suites work in all versions and all client + * authentication types. The way this is setup the server is stateless + * and all checking is done on the client side. + * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1 + * -DCLIENT_PROTOCOL=DEFAULT + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2 + * -DCLIENT_PROTOCOL=DEFAULT + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2 + * -DCLIENT_PROTOCOL=DEFAULT + * -Djdk.tls.client.protocols=TLSv1 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1 + * -DCLIENT_PROTOCOL=DEFAULT + * -Djdk.tls.client.protocols=TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE javax.net.ssl.SSLHandshakeException + */ diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSEClientProtocol.java b/jdk/test/javax/net/ssl/TLS/TestJSSEClientProtocol.java new file mode 100644 index 00000000000..bae6ea6c822 --- /dev/null +++ b/jdk/test/javax/net/ssl/TLS/TestJSSEClientProtocol.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, 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 8049429 + * @modules java.management + * jdk.crypto.ec/sun.security.ec + * @summary Test that all cipher suites work in all versions and all client + * authentication types. The way this is setup the server is stateless + * and all checking is done on the client side. + * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv3 + * -DCLIENT_PROTOCOL=SSLv3 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv3,TLSv1 + * -DCLIENT_PROTOCOL=TLSv1 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1 + * -DCLIENT_PROTOCOL=TLSv1.1 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 + * -DCLIENT_PROTOCOL=TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + */ diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java b/jdk/test/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java new file mode 100644 index 00000000000..bfe59562fcf --- /dev/null +++ b/jdk/test/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016, 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 8049429 + * @modules java.management + * jdk.crypto.ec/sun.security.ec + * @summary Test that all cipher suites work in all versions and all client + * authentication types. The way this is setup the server is stateless + * and all checking is done on the client side. + * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java + * @run main/othervm + * -DSERVER_PROTOCOL=TLSv1 + * -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE javax.net.ssl.SSLHandshakeException + */ diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSEServerProtocol.java b/jdk/test/javax/net/ssl/TLS/TestJSSEServerProtocol.java new file mode 100644 index 00000000000..a745a747d8f --- /dev/null +++ b/jdk/test/javax/net/ssl/TLS/TestJSSEServerProtocol.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, 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 8049429 + * @modules java.management + * jdk.crypto.ec/sun.security.ec + * @summary Test that all cipher suites work in all versions and all client + * authentication types. The way this is setup the server is stateless + * and all checking is done on the client side. + * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java + * @run main/othervm + * -DSERVER_PROTOCOL=SSLv3 + * -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE javax.net.ssl.SSLHandshakeException + * @run main/othervm + * -DSERVER_PROTOCOL=TLSv1 + * -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=TLSv1.1 + * -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + * @run main/othervm + * -DSERVER_PROTOCOL=TLSv1.2 + * -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2 + * -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 + * TestJSSE + */ From e922fb0afba26216109aa81f42420b6ddd5c1602 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 22 Jun 2016 11:31:07 -0700 Subject: [PATCH 107/191] 8159545: closed/java/io/Console/TestConsole.java failed with exit code 1 Reviewed-by: rriggs --- .../share/classes/java/util/Scanner.java | 18 ++++++--------- jdk/test/java/util/Scanner/ScanTest.java | 22 ++----------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Scanner.java b/jdk/src/java.base/share/classes/java/util/Scanner.java index 32427e12801..a6b3d8cb56f 100644 --- a/jdk/src/java.base/share/classes/java/util/Scanner.java +++ b/jdk/src/java.base/share/classes/java/util/Scanner.java @@ -925,7 +925,6 @@ public final class Scanner implements Iterator, Closeable { needInput = true; return null; } - // Must look for next delims. Simply attempting to match the // pattern at this point may find a match but it might not be // the first longest match because of missing input, or it might @@ -941,16 +940,13 @@ public final class Scanner implements Iterator, Closeable { foundNextDelim = matcher.find(); } if (foundNextDelim) { - // In two rare cases that more input might cause the match to be - // lost or change. - // (1) if requireEnd() is true, more input might cause the match - // to be lost, we must wait for more input. - // (2) while hitting the end is okay IF the match does not - // go away AND the beginning of the next delims does not change - // (we don't care if they potentially extend further). But it's - // possible that more input could cause the beginning of the - // delims change, so have to wait for more input as well. - if ((matcher.requireEnd() || matcher.hitEnd()) && !sourceClosed) { + // In the rare case that more input could cause the match + // to be lost and there is more input coming we must wait + // for more input. Note that hitting the end is okay as long + // as the match cannot go away. It is the beginning of the + // next delims we want to be sure about, we don't care if + // they potentially extend further. + if (matcher.requireEnd() && !sourceClosed) { needInput = true; return null; } diff --git a/jdk/test/java/util/Scanner/ScanTest.java b/jdk/test/java/util/Scanner/ScanTest.java index cc8bca9deaa..13397751ad8 100644 --- a/jdk/test/java/util/Scanner/ScanTest.java +++ b/jdk/test/java/util/Scanner/ScanTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 4313885 4926319 4927634 5032610 5032622 5049968 5059533 6223711 6277261 6269946 6288823 - * 8072722 8072582 8139414 + * 8072722 8139414 * @summary Basic tests of java.util.Scanner methods * @key randomness * @modules jdk.localedata @@ -512,27 +512,9 @@ public class ScanTest { } public static void boundaryDelimTest() throws Exception { - // 8072582 - StringBuilder sb = new StringBuilder(); - append(sb, 'a', 228); sb.append(","); - append(sb, 'b', 293); sb.append("#,#"); - append(sb, 'c', 308); sb.append(","); - append(sb, 'd', 188); sb.append("#,#"); - append(sb, 'e', 2); - try (Scanner scanner = new Scanner(sb.toString())) { - scanner.useDelimiter("(#,#)|(,)"); - while(scanner.hasNext()){ - String next = scanner.next(); - if(next.contains("#")){ - System.out.printf("[%s]%n", next); - failCount++; - } - } - } - // 8139414 int i = 1019; - sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.append("--;"); for (int j = 0; j < 1019; ++j) { sb.append(j%10); From f2b622bfb3130a93443b617b55466f5189dfa404 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Wed, 22 Jun 2016 15:58:08 -0700 Subject: [PATCH 108/191] 8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED Reviewed-by: valeriep --- .../sun/security/pkcs11/wrapper/PKCS11.java | 9 +++-- .../share/native/libj2pkcs11/p11_general.c | 7 +++- .../share/native/libj2pkcs11/p11_keymgmt.c | 37 ++++++++++++++++--- .../share/native/libj2pkcs11/p11_util.c | 14 ++++++- .../share/native/libj2pkcs11/pkcs11wrapper.h | 7 +++- jdk/test/ProblemList.txt | 2 - .../pkcs11/rsa/TestKeyPairGenerator.java | 5 ++- 7 files changed, 65 insertions(+), 16 deletions(-) diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/PKCS11.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/PKCS11.java index c5799b44ab0..0b3c7a089d6 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/PKCS11.java +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/PKCS11.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -54,6 +54,8 @@ import java.util.*; import java.security.AccessController; import java.security.PrivilegedAction; +import sun.security.util.Debug; + import static sun.security.pkcs11.wrapper.PKCS11Constants.*; /** @@ -85,7 +87,8 @@ public class PKCS11 { return null; } }); - initializeLibrary(); + boolean enableDebug = Debug.getInstance("sunpkcs11") != null; + initializeLibrary(enableDebug); } public static void loadNative() { @@ -109,7 +112,7 @@ public class PKCS11 { * @preconditions * @postconditions */ - private static native void initializeLibrary(); + private static native void initializeLibrary(boolean debug); // XXX /** diff --git a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_general.c b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_general.c index 852a1478a72..ea7fd1704eb 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_general.c +++ b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_general.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -73,6 +73,8 @@ jclass jLongClass; JavaVM* jvm = NULL; +jboolean debug = 0; + JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) { jvm = vm; return JNI_VERSION_1_4; @@ -92,7 +94,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) { */ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_initializeLibrary -(JNIEnv *env, jclass thisClass) +(JNIEnv *env, jclass thisClass, jboolean enableDebug) { #ifndef NO_CALLBACKS if (notifyListLock == NULL) { @@ -101,6 +103,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_initializeLibrary #endif prefetchFields(env, thisClass); + debug = enableDebug; } jclass fetchClass(JNIEnv *env, const char *name) { diff --git a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_keymgmt.c b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_keymgmt.c index 0e088995652..dd5410c3163 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_keymgmt.c +++ b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_keymgmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -152,6 +152,8 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate CK_OBJECT_HANDLE_PTR ckpKeyHandles; /* pointer to array with Public and Private Key */ jlongArray jKeyHandles = NULL; CK_RV rv; + int attempts; + const int MAX_ATTEMPTS = 3; CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); if (ckpFunctions == NULL) { return NULL; } @@ -190,10 +192,35 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate return NULL; } - rv = (*ckpFunctions->C_GenerateKeyPair)(ckSessionHandle, &ckMechanism, - ckpPublicKeyAttributes, ckPublicKeyAttributesLength, - ckpPrivateKeyAttributes, ckPrivateKeyAttributesLength, - ckpPublicKeyHandle, ckpPrivateKeyHandle); + /* + * Workaround for NSS bug 1012786: + * + * Key generation may fail with CKR_FUNCTION_FAILED error + * if there is insufficient entropy to generate a random key. + * + * PKCS11 spec says the following about CKR_FUNCTION_FAILED error + * (see section 11.1.1): + * + * ... In any event, although the function call failed, the situation + * is not necessarily totally hopeless, as it is likely to be + * when CKR_GENERAL_ERROR is returned. Depending on what the root cause of + * the error actually was, it is possible that an attempt + * to make the exact same function call again would succeed. + * + * Call C_GenerateKeyPair() several times if CKR_FUNCTION_FAILED occurs. + */ + for (attempts = 0; attempts < MAX_ATTEMPTS; attempts++) { + rv = (*ckpFunctions->C_GenerateKeyPair)(ckSessionHandle, &ckMechanism, + ckpPublicKeyAttributes, ckPublicKeyAttributesLength, + ckpPrivateKeyAttributes, ckPrivateKeyAttributesLength, + ckpPublicKeyHandle, ckpPrivateKeyHandle); + if (rv == CKR_FUNCTION_FAILED) { + printDebug("C_1GenerateKeyPair(): C_GenerateKeyPair() failed \ + with CKR_FUNCTION_FAILED error, try again\n"); + } else { + break; + } + } if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) { jKeyHandles = ckULongArrayToJLongArray(env, ckpKeyHandles, 2); diff --git a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c index 172161abc52..f102baa64bf 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c +++ b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -1143,3 +1143,15 @@ void p11free(void *p, char *file, int line) { #endif +// prints a message to stdout if debug output is enabled +void printDebug(const char *format, ...) { + if (debug == JNI_TRUE) { + va_list args; + fprintf(stdout, "sunpkcs11: "); + va_start(args, format); + vfprintf(stdout, format, args); + va_end(args); + fflush(stdout); + } +} + diff --git a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/pkcs11wrapper.h b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/pkcs11wrapper.h index 3188774cab7..2ea1e87f886 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/pkcs11wrapper.h +++ b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/pkcs11wrapper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -159,6 +159,7 @@ #include "pkcs-11v2-20a3.h" #include #include +#include #define MAX_STACK_BUFFER_LEN (4 * 1024) #define MAX_HEAP_BUFFER_LEN (64 * 1024) @@ -217,6 +218,10 @@ #define TRACE_UNINTEND #endif +/* debug output */ +extern jboolean debug; +void printDebug(const char *format, ...); + #define CK_ASSERT_OK 0L #define CLASS_INFO "sun/security/pkcs11/wrapper/CK_INFO" diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2a028973c61..f4b8d9b056e 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -272,8 +272,6 @@ sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434 sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8074580 generic-all - sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all sun/security/tools/keytool/autotest.sh 8130302 generic-all diff --git a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java index 687a7a87bc1..8be07505c31 100644 --- a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java +++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java @@ -29,8 +29,9 @@ * @library .. * @library /lib/testlibrary * @build jdk.testlibrary.* - * @run main/othervm TestKeyPairGenerator - * @run main/othervm TestKeyPairGenerator sm TestKeyPairGenerator.policy + * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator + * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator + * sm TestKeyPairGenerator.policy * @key intermittent randomness */ From 5791bf6bd63bd6887cfdeae8c6267d2683184f60 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 22 Jun 2016 17:20:53 -0700 Subject: [PATCH 109/191] 8154399: Need replacement for jdk.javadoc/com.sun.tools.doclets.standard.Standard 8159096: Expose (new) Standard doclet class Reviewed-by: alanb, erikj, ksrini --- .../sun/tools/doclets/standard/Standard.java | 5 ++++ .../StandardDoclet.java} | 9 ++++-- .../jdk/javadoc/doclets/package-info.java | 30 +++++++++++++++++++ .../jdk/javadoc/internal/tool/Start.java | 2 +- .../share/classes/module-info.java | 3 ++ .../jdk/javadoc/tool/EnsureNewOldDoclet.java | 4 +-- 6 files changed, 47 insertions(+), 6 deletions(-) rename langtools/src/jdk.javadoc/share/classes/jdk/javadoc/{internal/doclets/standard/Standard.java => doclets/StandardDoclet.java} (90%) create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/package-info.java diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java index 67d9afd82fb..127becdc2ad 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/standard/Standard.java @@ -28,6 +28,11 @@ package com.sun.tools.doclets.standard; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.*; +/** + * This doclet generates HTML-formatted documentation for the specified packages and types. + * @deprecated The doclet has been superseded by its replacement, + * {@code jdk.javadoc.doclets.StandardDoclet}. + */ @Deprecated public class Standard { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/standard/Standard.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java similarity index 90% rename from langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/standard/Standard.java rename to langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java index b4d2e355163..fdbac496091 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/standard/Standard.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.javadoc.internal.doclets.standard; +package jdk.javadoc.doclets; import java.util.Locale; import java.util.Set; @@ -35,11 +35,14 @@ import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.Reporter; import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet; -public class Standard implements Doclet { +/** + * This doclet generates HTML-formatted documentation for the specified modules, packages and types. + */ +public class StandardDoclet implements Doclet { private final HtmlDoclet htmlDoclet; - public Standard() { + public StandardDoclet() { htmlDoclet = new HtmlDoclet(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/package-info.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/package-info.java new file mode 100644 index 00000000000..057c7713823 --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/package-info.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/** + * This package contains standard, supported doclets. + */ +package jdk.javadoc.doclets; + diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index e4a03e990cc..ca96d6cb87b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -86,7 +86,7 @@ public class Start extends ToolOption.Helper { com.sun.tools.doclets.standard.Standard.class; private static final Class StdDoclet = - jdk.javadoc.internal.doclets.standard.Standard.class; + jdk.javadoc.doclets.StandardDoclet.class; /** Context for this invocation. */ private final Context context; diff --git a/langtools/src/jdk.javadoc/share/classes/module-info.java b/langtools/src/jdk.javadoc/share/classes/module-info.java index c548ec9246d..d96c5319c9b 100644 --- a/langtools/src/jdk.javadoc/share/classes/module-info.java +++ b/langtools/src/jdk.javadoc/share/classes/module-info.java @@ -30,9 +30,12 @@ module jdk.javadoc { exports com.sun.javadoc; exports com.sun.tools.doclets; + exports com.sun.tools.doclets.standard; exports com.sun.tools.javadoc; + exports jdk.javadoc.doclet; exports jdk.javadoc.doclet.taglet; + exports jdk.javadoc.doclets; provides javax.tools.DocumentationTool with jdk.javadoc.internal.api.JavadocTool; diff --git a/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java b/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java index 6e56617507f..fe3b2f938ca 100644 --- a/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java +++ b/langtools/test/jdk/javadoc/tool/EnsureNewOldDoclet.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8035473 8154482 + * @bug 8035473 8154482 8154399 8159096 * @summary make sure the javadoc tool responds correctly to Xold, * old doclets and taglets. * @library /tools/lib @@ -87,7 +87,7 @@ public class EnsureNewOldDoclet extends TestRunner { CLASS_NAME + "\\$OldTaglet.*"); final static String OLD_STDDOCLET = "com.sun.tools.doclets.standard.Standard"; - final static String NEW_STDDOCLET = "jdk.javadoc.internal.doclets.standard.Standard"; + final static String NEW_STDDOCLET = "jdk.javadoc.doclets.StandardDoclet"; public EnsureNewOldDoclet() throws Exception { From 0f137a3deb4a8878fccf5dbef71d5f925cb4b208 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 23 Jun 2016 12:39:33 +0530 Subject: [PATCH 110/191] 8160141: removed deprecated method calls in nashorn code Reviewed-by: mhaupt, hannesw --- .../internal/tools/nasgen/ClassGenerator.java | 13 +- .../tools/nasgen/ConstructorGenerator.java | 3 +- .../tools/nasgen/MethodGenerator.java | 3 +- nashorn/samples/checknames.js | 142 ++++++++++++++++++ .../jdk/nashorn/internal/AssertsEnabled.java | 1 - .../internal/codegen/MethodEmitter.java | 11 +- .../jdk/nashorn/internal/objects/Global.java | 22 ++- .../linker/JavaAdapterBytecodeGenerator.java | 9 +- 8 files changed, 171 insertions(+), 33 deletions(-) create mode 100644 nashorn/samples/checknames.js diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java index 9f3380c0f1c..98a11d984e5 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java @@ -280,12 +280,11 @@ public class ClassGenerator { addField(cv, name, OBJECT_DESC); } - @SuppressWarnings("deprecation") static void newFunction(final MethodGenerator mi, final String objName, final String className, final MemberInfo memInfo, final List specs) { final boolean arityFound = (memInfo.getArity() != MemberInfo.DEFAULT_ARITY); loadFunctionName(mi, memInfo.getName()); - mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, memInfo.getJavaName(), memInfo.getJavaDesc())); + mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, memInfo.getJavaName(), memInfo.getJavaDesc(), false)); assert specs != null; if (!specs.isEmpty()) { @@ -306,7 +305,6 @@ public class ClassGenerator { mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATIONKEY, SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC); } - @SuppressWarnings("deprecation") static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) { final String propertyName = memInfo.getName(); // stack: Collection @@ -319,13 +317,13 @@ public class ClassGenerator { mi.push(memInfo.getAttributes()); // setup getter method handle String javaName = GETTER_PREFIX + memInfo.getJavaName(); - mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, getterDesc(memInfo))); + mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, getterDesc(memInfo), false)); // setup setter method handle if (memInfo.isFinal()) { mi.pushNull(); } else { javaName = SETTER_PREFIX + memInfo.getJavaName(); - mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo))); + mi.visitLdcInsn(new Handle(H_INVOKEVIRTUAL, className, javaName, setterDesc(memInfo), false)); } // property = AccessorProperty.create(key, flags, getter, setter); mi.invokeStatic(ACCESSORPROPERTY_TYPE, ACCESSORPROPERTY_CREATE, ACCESSORPROPERTY_CREATE_DESC); @@ -336,7 +334,6 @@ public class ClassGenerator { // stack: Collection } - @SuppressWarnings("deprecation") static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) { final String propertyName = getter.getName(); // stack: Collection @@ -349,13 +346,13 @@ public class ClassGenerator { mi.push(getter.getAttributes()); // setup getter method handle mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, - getter.getJavaName(), getter.getJavaDesc())); + getter.getJavaName(), getter.getJavaDesc(), false)); // setup setter method handle if (setter == null) { mi.pushNull(); } else { mi.visitLdcInsn(new Handle(H_INVOKESTATIC, className, - setter.getJavaName(), setter.getJavaDesc())); + setter.getJavaName(), setter.getJavaDesc(), false)); } // property = AccessorProperty.create(key, flags, getter, setter); mi.invokeStatic(ACCESSORPROPERTY_TYPE, ACCESSORPROPERTY_CREATE, ACCESSORPROPERTY_CREATE_DESC); diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java index 2d9cf74165e..1fa76ce9829 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java @@ -178,7 +178,6 @@ public class ConstructorGenerator extends ClassGenerator { } } - @SuppressWarnings("deprecation") private void callSuper(final MethodGenerator mi) { String superClass, superDesc; mi.loadThis(); @@ -192,7 +191,7 @@ public class ConstructorGenerator extends ClassGenerator { superClass = SCRIPTFUNCTION_TYPE; superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3; mi.loadLiteral(constructor.getName()); - mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc())); + mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc(), false)); loadMap(mi); mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty } diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java index aecd9c5aadc..bb361cc693a 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java @@ -390,7 +390,6 @@ public class MethodGenerator extends MethodVisitor { return EMPTY_LINK_LOGIC_TYPE.equals(type); } - @SuppressWarnings("deprecation") void memberInfoArray(final String className, final List mis) { if (mis.isEmpty()) { pushNull(); @@ -405,7 +404,7 @@ public class MethodGenerator extends MethodVisitor { push(pos++); visitTypeInsn(NEW, SPECIALIZATION_TYPE); dup(); - visitLdcInsn(new Handle(H_INVOKESTATIC, className, mi.getJavaName(), mi.getJavaDesc())); + visitLdcInsn(new Handle(H_INVOKESTATIC, className, mi.getJavaName(), mi.getJavaDesc(), false)); final Type linkLogicClass = mi.getLinkLogicClass(); final boolean linkLogic = !linkLogicIsEmpty(linkLogicClass); final String ctor = linkLogic ? SPECIALIZATION_INIT3 : SPECIALIZATION_INIT2; diff --git a/nashorn/samples/checknames.js b/nashorn/samples/checknames.js new file mode 100644 index 00000000000..80d4d578db7 --- /dev/null +++ b/nashorn/samples/checknames.js @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Simple Java identifier name pattern checker. You can check +// class, method and variable names in java sources to confirm +// to specified patterns. Default check functions just check for +// 'too short' names. You can customize checkXYZName functions to +// have arbitrary name pattern checks. + +// Usage: jjs checknames.js -- + +if (arguments.length == 0) { + print("Usage: jjs checknames.js -- "); + exit(1); +} + +// Java types used +var File = Java.type("java.io.File"); +var Files = Java.type("java.nio.file.Files"); +var StringArray = Java.type("java.lang.String[]"); +var ToolProvider = Java.type("javax.tools.ToolProvider"); +var Tree = Java.type("com.sun.source.tree.Tree"); +var Trees = Java.type("com.sun.source.util.Trees"); +var TreeScanner = Java.type("com.sun.source.util.TreeScanner"); + +// replace these checkXYZ functions with checks you want! +function checkClassName(name) { + return name.length < 3; +} + +function checkMethodName(name) { + return name.length < 3; +} + +function checkVarName(name) { + return name.length < 3; +} + +function checkNames() { + // get the system compiler tool + var compiler = ToolProvider.systemJavaCompiler; + // get standard file manager + var fileMgr = compiler.getStandardFileManager(null, null, null); + // Using Java.to convert script array (arguments) to a Java String[] + var compUnits = fileMgr.getJavaFileObjects(Java.to(arguments, StringArray)); + // create a new compilation task + var task = compiler.getTask(null, fileMgr, null, null, null, compUnits); + var sourcePositions = Trees.instance(task).sourcePositions; + // subclass SimpleTreeVisitor + var NameChecker = Java.extend(TreeScanner); + + var visitor = new NameChecker() { + report: function(node) { + var pos = sourcePositions.getStartPosition(this.compUnit, node); + var line = this.lineMap.getLineNumber(pos); + var col = this.lineMap.getColumnNumber(pos); + print("Too short name: " + node.name + " @ " + this.fileName + ":" + line + ":" + col); + }, + + // override to capture information on current compilation unit + visitCompilationUnit: function(compUnit, p) { + this.compUnit = compUnit; + this.lineMap = compUnit.lineMap; + this.fileName = compUnit.sourceFile.name; + + return Java.super(visitor).visitCompilationUnit(compUnit, p); + }, + + // override to check class name + visitClass: function(node, p) { + if (checkClassName(node.simpleName.toString())) { + this.report(node); + } + + return Java.super(visitor).visitClass(node, p); + }, + + // override to check method name + visitMethod: function(node, p) { + if (checkMethodName(node.name.toString())) { + this.report(node); + } + + return Java.super(visitor).visitMethod(node, p); + }, + + // override to check variable name + visitVariable: function(node, p) { + if (checkVarName(node.name.toString())) { + this.report(node); + } + + return Java.super(visitor).visitVariable(node, p); + } + } + + for each (var cu in task.parse()) { + cu.accept(visitor, null); + } +} + +// for each ".java" file in directory (recursively). +function main(dir) { + var totalCount = 0; + Files.walk(dir.toPath()). + forEach(function(p) { + var name = p.toFile().absolutePath; + if (name.endsWith(".java")) { + checkNames(p); + } + }); +} + +main(new File(arguments[0])); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java index 73d9dfdcb2e..e4752658146 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/AssertsEnabled.java @@ -28,7 +28,6 @@ package jdk.nashorn.internal; /** * Class that exposes the current state of asserts. */ -@SuppressWarnings("all") public final class AssertsEnabled { private static boolean assertsEnabled = false; static { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java index 6d92c68d957..cd3be1e92d3 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java @@ -32,6 +32,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.GETFIELD; import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC; import static jdk.internal.org.objectweb.asm.Opcodes.GOTO; import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC; +import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKEINTERFACE; import static jdk.internal.org.objectweb.asm.Opcodes.IFEQ; import static jdk.internal.org.objectweb.asm.Opcodes.IFGE; import static jdk.internal.org.objectweb.asm.Opcodes.IFGT; @@ -170,12 +171,10 @@ public class MethodEmitter { } /** Bootstrap for normal indy:s */ - @SuppressWarnings("deprecation") - private static final Handle LINKERBOOTSTRAP = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor()); + private static final Handle LINKERBOOTSTRAP = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor(), false); /** Bootstrap for array populators */ - @SuppressWarnings("deprecation") - private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor()); + private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor(), false); /** * Constructor - internal use from ClassEmitter only @@ -1007,10 +1006,10 @@ public class MethodEmitter { * * @return the method emitter */ - @SuppressWarnings("deprecation") MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet flags) { + final int flag = Flag.getValue(flags); debug("load handle "); - pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName))); + pushType(Type.OBJECT.ldc(method, new Handle(flag, className, methodName, descName, flag == H_INVOKEINTERFACE))); return this; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java index 5a9b71cf1a6..0b8aff80c23 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java @@ -2854,8 +2854,7 @@ public final class Global extends Scope { sb.append("$Constructor"); final Class funcClass = Class.forName(sb.toString()); - @SuppressWarnings("deprecation") - final T res = clazz.cast(funcClass.newInstance()); + final T res = clazz.cast(funcClass.getDeclaredConstructor().newInstance()); if (res instanceof ScriptFunction) { // All global constructor prototypes are not-writable, @@ -2871,8 +2870,12 @@ public final class Global extends Scope { res.setIsBuiltin(); return res; - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } } } @@ -2882,14 +2885,17 @@ public final class Global extends Scope { final String className = PACKAGE_PREFIX + name + "$Prototype"; final Class funcClass = Class.forName(className); - @SuppressWarnings("deprecation") - final ScriptObject res = (ScriptObject) funcClass.newInstance(); + final ScriptObject res = (ScriptObject) funcClass.getDeclaredConstructor().newInstance(); res.setIsBuiltin(); res.setInitialProto(prototype); return res; - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java index 7e2a15f02d6..acd8db54044 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java @@ -191,18 +191,16 @@ final class JavaAdapterBytecodeGenerator { private static final Call RUN = interfaceCallNoLookup(Runnable.class, "run", void.class); // ASM handle to the bootstrap method - @SuppressWarnings("deprecation") private static final Handle BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC, Type.getInternalName(JavaAdapterServices.class), "bootstrap", MethodType.methodType(CallSite.class, Lookup.class, String.class, - MethodType.class, int.class).toMethodDescriptorString()); + MethodType.class, int.class).toMethodDescriptorString(), false); // ASM handle to the bootstrap method for array populator - @SuppressWarnings("deprecation") private static final Handle CREATE_ARRAY_BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC, Type.getInternalName(JavaAdapterServices.class), "createArrayBootstrap", MethodType.methodType(CallSite.class, Lookup.class, String.class, - MethodType.class).toMethodDescriptorString()); + MethodType.class).toMethodDescriptorString(), false); // Field type names used in the generated bytecode private static final String SCRIPT_OBJECT_TYPE_DESCRIPTOR = SCRIPT_OBJECT_TYPE.getDescriptor(); @@ -1061,13 +1059,12 @@ final class JavaAdapterBytecodeGenerator { endMethod(mv); } - @SuppressWarnings("deprecation") private void generateFinalizerOverride() { final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize", VOID_METHOD_DESCRIPTOR, null, null)); // Overridden finalizer will take a MethodHandle to the finalizer delegating method, ... mv.aconst(new Handle(Opcodes.H_INVOKESTATIC, generatedClassName, FINALIZER_DELEGATE_NAME, - FINALIZER_DELEGATE_METHOD_DESCRIPTOR)); + FINALIZER_DELEGATE_METHOD_DESCRIPTOR, false)); mv.visitVarInsn(ALOAD, 0); // ...and invoke it through JavaAdapterServices.invokeNoPermissions INVOKE_NO_PERMISSIONS.invoke(mv); From 8b5cbab0f51ed65e2fef815d3750fed0d6a97d78 Mon Sep 17 00:00:00 2001 From: Sergey Kuksenko Date: Thu, 23 Jun 2016 10:25:04 +0100 Subject: [PATCH 111/191] 8158980: Memory leak in HTTP2Connection.streams Reviewed-by: chegar --- .../java.httpclient/share/classes/java/net/http/Stream.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java b/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java index 201aea650e3..2c1ad4178e7 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java @@ -617,6 +617,7 @@ class Stream extends ExchangeImpl { void sendBodyImpl() throws IOException, InterruptedException { if (requestContentLen == 0) { // no body + requestSent(); return; } DataFrame df; @@ -667,7 +668,7 @@ class Stream extends ExchangeImpl { responseFlowController); // TODO: filter headers if (body == null) { receiveData(); - return processor.onResponseComplete(); + body = processor.onResponseComplete(); } else receiveDataAsync(processor); responseReceived(); From a2b86b0b4376bdbe9dd119cea68bba61d50a669a Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:13 +0000 Subject: [PATCH 112/191] Added tag jdk-9+124 for changeset 55d10fdcb59e --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 90ec476151a..216d97144ce 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -366,3 +366,4 @@ daf533920b1266603b5cbdab31908d2a931c5361 jdk-9+119 9a5fc5a27560ac272c1341f8f3838338fba49059 jdk-9+121 a39131aafc51a6fd8836e6ebe1b04458702ce7d6 jdk-9+122 e33a34cc551907617d8129c4faaf1a5a7e61d21c jdk-9+123 +45121d5afb9d5bfadab75378572ad96832e0809e jdk-9+124 From c8233a3d2b16972df59e2383e070f9705c07721c Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:13 +0000 Subject: [PATCH 113/191] Added tag jdk-9+124 for changeset 6f7d687193a4 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index b7912892405..f81930c6c03 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -526,3 +526,4 @@ b64432bae5271735fd53300b2005b713e98ef411 jdk-9+114 7e293105dbb0789a468655f81320c891f491f371 jdk-9+121 af6b4ad908e732d23021f12e8322b204433d5cf6 jdk-9+122 75f81e1fecfb444f34f357295fe06af60e2762d9 jdk-9+123 +479631362b4930be985245ea063d87d821a472eb jdk-9+124 From 687c434b654b24799a82e547c70820a61ca618de Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:14 +0000 Subject: [PATCH 114/191] Added tag jdk-9+124 for changeset b3344e373fbe --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 2979f0820ba..70e4b392eb7 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -369,3 +369,4 @@ ecd0d6a71c7ccf93584ba4dacdd4fa8455efd741 jdk-9+120 fb771fa3a986ccfcb00d743b1956b98c380d1dd8 jdk-9+121 342705d785ffd9e999991a3d4baae2eca58ea7c3 jdk-9+122 c42decd28bbfa817347112ed6053b5fbd30517a2 jdk-9+123 +1600da1665cd2cc127014e8c002b328ec33a9147 jdk-9+124 From d830ecdfcd0734b4e3b5be7f5fe8ea073893cdfe Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:14 +0000 Subject: [PATCH 115/191] Added tag jdk-9+124 for changeset ed6e6065418a --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 5425d453ca2..54b236a0941 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -366,3 +366,4 @@ ecbe72546137cd29cb73d4dcc81cc099e847d543 jdk-9+120 a265b8116058c56179c321c38618570b780329be jdk-9+121 f8899b1884e2c4a000dbcc5b1a80954245fe462e jdk-9+122 3c19ab8742c196ac267b3d87e1d19ec3472c708d jdk-9+123 +e04a15153cc293f05fcd60bc98236f50e16af46a jdk-9+124 From 12c90f242c83ed4c9691e1c72bbcf1c710ad975c Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:15 +0000 Subject: [PATCH 116/191] Added tag jdk-9+124 for changeset 45cbf2937973 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index b477a29f382..60cab9fc7e1 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -366,3 +366,4 @@ b9a518bf72516954e57ac2f6e3ef21e13008f1cd jdk-9+120 ee29aaab5889555ea56e4c0ed690aabb7613529d jdk-9+121 981ae344923f09c46d8d1d5a3ed9fa71deafe0c6 jdk-9+122 c40c8739bcdc88892ff58ebee3fd8a3f287be94d jdk-9+123 +7ff61c55b5c6c124592f09b18953222009a204a6 jdk-9+124 From 5f1652cd4dc8fa8ec488e75c57a151a577744679 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:16 +0000 Subject: [PATCH 117/191] Added tag jdk-9+124 for changeset 956490b8da9c --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 280f72ae1a7..e3da27f7ee7 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -366,3 +366,4 @@ cba09a2e6ae969b029783eb59bb01017b78f8eef jdk-9+114 095bd53bdd1ef211a473553a95ee625fcfbc3f59 jdk-9+121 203a9e1b82b6cc7918f96a92e5a7eb28eafcdd18 jdk-9+122 d0c742ddfb01ebe427720798c4c8335023ae20f8 jdk-9+123 +26aa3caa778eab1c931910149c414783ee83bce7 jdk-9+124 From eac581e8b79eb1e149aef0fd879458deaf8a6d85 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 23 Jun 2016 20:35:16 +0000 Subject: [PATCH 118/191] Added tag jdk-9+124 for changeset c549268fe94c --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 3c9d686ec66..56db3f67644 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -357,3 +357,4 @@ ba21793a0e4816283cc0ecdab5142a4959363529 jdk-9+114 5992041b0794fa5f25518673d63e8f35bcc89360 jdk-9+121 b1de131a3fed6845c78bdda358ee127532f16a3f jdk-9+122 9ed859b4faaf9ff7cd35f9e7f51c7e630303067a jdk-9+123 +5d68f5155dded7efec7d5aca5d631caa7ee1042b jdk-9+124 From 17dc09ea237adfd05020dc721f1d8ea21eadb2ed Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Thu, 23 Jun 2016 14:14:06 -0700 Subject: [PATCH 119/191] 7131356: (props) "No Java runtime present, requesting install" when creating VM from JNI [macosx] Replace JRS calls with Core Foundation calls Reviewed-by: naoto --- .../macosx/native/libjava/java_props_macosx.c | 131 ++++++++++++------ .../unix/native/libjava/locale_str.h | 10 ++ 2 files changed, 98 insertions(+), 43 deletions(-) diff --git a/jdk/src/java.base/macosx/native/libjava/java_props_macosx.c b/jdk/src/java.base/macosx/native/libjava/java_props_macosx.c index 82f63169edd..cbbfde4c2a7 100644 --- a/jdk/src/java.base/macosx/native/libjava/java_props_macosx.c +++ b/jdk/src/java.base/macosx/native/libjava/java_props_macosx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -23,10 +23,10 @@ * questions. */ -#include #include #include #include +#include #include #include @@ -35,18 +35,6 @@ #include "java_props_macosx.h" -// need dlopen/dlsym trick to avoid pulling in JavaRuntimeSupport before libjava.dylib is loaded -static void *getJRSFramework() { - static void *jrsFwk = NULL; -#ifndef STATIC_BUILD -// JavaRuntimeSupport doesn't support static Java runtimes - if (jrsFwk == NULL) { - jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL); - } -#endif - return jrsFwk; -} - char *getPosixLocale(int cat) { char *lc = setlocale(cat, NULL); if ((lc == NULL) || (strcmp(lc, "C") == 0)) { @@ -61,18 +49,70 @@ char *getMacOSXLocale(int cat) { switch (cat) { case LC_MESSAGES: { - void *jrsFwk = getJRSFramework(); - if (jrsFwk == NULL) return NULL; + // get preferred language code + CFArrayRef languages = CFLocaleCopyPreferredLanguages(); + if (languages == NULL) { + return NULL; + } + if (CFArrayGetCount(languages) <= 0) { + CFRelease(languages); + return NULL; + } - char *(*JRSCopyPrimaryLanguage)() = dlsym(jrsFwk, "JRSCopyPrimaryLanguage"); - char *primaryLanguage = JRSCopyPrimaryLanguage ? JRSCopyPrimaryLanguage() : NULL; - if (primaryLanguage == NULL) return NULL; + CFStringRef primaryLanguage = (CFStringRef)CFArrayGetValueAtIndex(languages, 0); + if (primaryLanguage == NULL) { + CFRelease(languages); + return NULL; + } + char languageString[LOCALEIDLENGTH]; + if (CFStringGetCString(primaryLanguage, languageString, + LOCALEIDLENGTH, CFStringGetSystemEncoding()) == false) { + CFRelease(languages); + return NULL; + } + CFRelease(languages); - char *(*JRSCopyCanonicalLanguageForPrimaryLanguage)(char *) = dlsym(jrsFwk, "JRSCopyCanonicalLanguageForPrimaryLanguage"); - char *canonicalLanguage = JRSCopyCanonicalLanguageForPrimaryLanguage ? JRSCopyCanonicalLanguageForPrimaryLanguage(primaryLanguage) : NULL; - free (primaryLanguage); + // Language IDs use the language designators and (optional) region + // and script designators of BCP 47. So possible formats are: + // + // "en" (language designator only) + // "haw" (3-letter lanuage designator) + // "en-GB" (language with alpha-2 region designator) + // "es-419" (language with 3-digit UN M.49 area code) + // "zh-Hans" (language with ISO 15924 script designator) + // + // In the case of region designators (alpha-2 or UN M.49), we convert + // to our locale string format by changing '-' to '_'. That is, if + // the '-' is followed by fewer than 4 chars. + char* scriptOrRegion = strchr(languageString, '-'); + if (scriptOrRegion != NULL && strlen(scriptOrRegion) < 5) { + *scriptOrRegion = '_'; - return canonicalLanguage; + assert((strlen(scriptOrRegion) == 3 && + // '-' followed by a 2 character region designator + isalpha(scriptOrRegion[1]) && + isalpha(scriptOrRegion[2])) || + (strlen(scriptOrRegion) == 4 && + // '-' followed by a 3-digit UN M.49 area code + isdigit(scriptOrRegion[1]) && + isdigit(scriptOrRegion[2]) && + isdigit(scriptOrRegion[3]))); + } + const char* retVal = languageString; + + // Special case for Portuguese in Brazil: + // The language code needs the "_BR" region code (to distinguish it + // from Portuguese in Portugal), but this is missing when using the + // "Portuguese (Brazil)" language. + // If language is "pt" and the current locale is pt_BR, return pt_BR. + char localeString[LOCALEIDLENGTH]; + if (strcmp(retVal, "pt") == 0 && + CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()), + localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding()) && + strcmp(localeString, "pt_BR") == 0) { + retVal = localeString; + } + return strdup(retVal); } break; default: @@ -92,14 +132,6 @@ char *getMacOSXLocale(int cat) { char *setupMacOSXLocale(int cat) { char * ret = getMacOSXLocale(cat); - if (cat == LC_MESSAGES && ret != NULL) { - void *jrsFwk = getJRSFramework(); - if (jrsFwk != NULL) { - void (*JRSSetDefaultLocalization)(char *) = dlsym(jrsFwk, "JRSSetDefaultLocalization"); - if (JRSSetDefaultLocalization) JRSSetDefaultLocalization(ret); - } - } - if (ret == NULL) { return getPosixLocale(cat); } else { @@ -126,22 +158,35 @@ int isInAquaSession() { return 0; } +// 10.9 SDK does not include the NSOperatingSystemVersion struct. +// For now, create our own +typedef struct { + NSInteger majorVersion; + NSInteger minorVersion; + NSInteger patchVersion; +} OSVerStruct; + void setOSNameAndVersion(java_props_t *sprops) { - /* Don't rely on JRSCopyOSName because there's no guarantee the value will - * remain the same, or even if the JRS functions will continue to be part of - * Mac OS X. So hardcode os_name, and fill in os_version if we can. - */ + // Hardcode os_name, and fill in os_version sprops->os_name = strdup("Mac OS X"); - void *jrsFwk = getJRSFramework(); - if (jrsFwk != NULL) { - char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion"); - if (copyOSVersion != NULL) { - sprops->os_version = copyOSVersion(); - return; - } + char* osVersionCStr = NULL; + // Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, + // but it's not in the 10.9 SDK. So, call it via objc_msgSend_stret. + if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { + OSVerStruct (*procInfoFn)(id rec, SEL sel) = (OSVerStruct(*)(id, SEL))objc_msgSend_stret; + OSVerStruct osVer = procInfoFn([NSProcessInfo processInfo], + @selector(operatingSystemVersion)); + NSString *nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld", + (long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion]; + // Copy out the char* + osVersionCStr = strdup([nsVerStr UTF8String]); } - sprops->os_version = strdup("Unknown"); + + if (osVersionCStr == NULL) { + osVersionCStr = strdup("Unknown"); + } + sprops->os_version = osVersionCStr; } diff --git a/jdk/src/java.base/unix/native/libjava/locale_str.h b/jdk/src/java.base/unix/native/libjava/locale_str.h index 72a796c7a9f..684f796662a 100644 --- a/jdk/src/java.base/unix/native/libjava/locale_str.h +++ b/jdk/src/java.base/unix/native/libjava/locale_str.h @@ -134,6 +134,16 @@ "no_NY", "no_NO@nynorsk", "sr_SP", "sr_YU", "tchinese", "zh_TW", +#endif +#ifdef MACOSX + "sr-Latn", "sr_CS", // Mappings as done by old Apple JRS code + "tk", "tk-Cyrl", + "tt-Latn", "tt-Cyrl", + "uz", "uz_UZ", + "uz-Arab", "uz_UZ", + "uz-Latn", "uz_UZ", + "zh-Hans", "zh_CN", + "zh-Hant", "zh_TW", #endif "", "", }; From 7e1c0f82b6f718ec906e40c54271f1507d5e3e0e Mon Sep 17 00:00:00 2001 From: Tim Du Date: Thu, 23 Jun 2016 19:58:58 -0700 Subject: [PATCH 120/191] 8146393: sun/security/tools/jarsigner/ts.sh failed on OEL Linux 7 with ar_SA Locale Reviewed-by: weijun --- jdk/test/sun/security/tools/jarsigner/TimestampCheck.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java index ca27f3787c1..04d6c9ec526 100644 --- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java +++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -39,6 +39,7 @@ import java.security.cert.X509Certificate; import java.util.Calendar; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.Locale; import sun.security.pkcs.ContentInfo; import sun.security.pkcs.PKCS7; @@ -371,7 +372,7 @@ public class TimestampCheck { static void jarsigner(String cmd, int path, boolean expected) throws Exception { System.err.println("Test " + path); - Process p = Runtime.getRuntime().exec(String.format(cmd, path, path)); + Process p = Runtime.getRuntime().exec(String.format(Locale.ROOT,cmd, path, path)); BufferedReader reader = new BufferedReader( new InputStreamReader(p.getErrorStream())); while (true) { From c53f3cbcbed7a91254b413dead0813ac9bf2b8e1 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Fri, 24 Jun 2016 06:47:32 +0100 Subject: [PATCH 121/191] 8154017: Shutdown hooks are racing against shutdown sequence, if System.exit()-calling thread is interrupted Reviewed-by: alanb, dholmes, shade --- .../java/lang/ApplicationShutdownHooks.java | 10 ++- .../shutdown/ShutdownInterruptedMain.java | 63 +++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java diff --git a/jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java b/jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java index 648725cb331..fc255a905c4 100644 --- a/jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java +++ b/jdk/src/java.base/share/classes/java/lang/ApplicationShutdownHooks.java @@ -102,9 +102,13 @@ class ApplicationShutdownHooks { hook.start(); } for (Thread hook : threads) { - try { - hook.join(); - } catch (InterruptedException x) { } + while (true) { + try { + hook.join(); + break; + } catch (InterruptedException ignored) { + } + } } } } diff --git a/jdk/test/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java b/jdk/test/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java new file mode 100644 index 00000000000..51488ab4558 --- /dev/null +++ b/jdk/test/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, 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 8154017 + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @summary Shutdown hooks are racing against shutdown sequence, + if System.exit()-calling thread is interrupted + * @run main ShutdownInterruptedMain exec + */ + +import jdk.testlibrary.OutputAnalyzer; +import static jdk.testlibrary.ProcessTools.createJavaProcessBuilder; +import static jdk.testlibrary.ProcessTools.executeProcess; + +public class ShutdownInterruptedMain { + + public static void main(String[] args) throws Exception { + if (args.length > 0) { + ProcessBuilder pb = createJavaProcessBuilder(true, "ShutdownInterruptedMain"); + OutputAnalyzer output = executeProcess(pb); + output.shouldContain("Shutdown Hook"); + output.shouldHaveExitValue(0); + return; + } + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + // Wait for the race to unfold: + try { + Thread.sleep(5_000); + } catch (InterruptedException e) {} + System.out.println("Shutdown Hook"); + System.out.flush(); + } + }); + Thread.currentThread().interrupt(); + System.exit(0); + } +} From d90e966a97e038ce66ecf22e37b0799da50b7a72 Mon Sep 17 00:00:00 2001 From: Sergey Kuksenko Date: Fri, 24 Jun 2016 06:52:29 +0100 Subject: [PATCH 122/191] =?UTF-8?q?8158690:=20GET=20request=20via=20HTTP/2?= =?UTF-8?q?=20has=20a=20huge=20delays=20due=20to=20Nagle=E2=80=99s=20Algor?= =?UTF-8?q?ithm=20and=20Delayed=20ACK=20clash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: chegar --- .../share/classes/java/net/http/PlainHttpConnection.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java b/jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java index eeadb35f7a0..a690956670e 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java @@ -128,6 +128,7 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { this.chan = SocketChannel.open(); int bufsize = client.getReceiveBufferSize(); chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize); + chan.setOption(StandardSocketOptions.TCP_NODELAY, true); } catch (IOException e) { throw new InternalError(e); } From 939f1f7308eebc4497a5fde6282e6e82e41b80e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Fri, 24 Jun 2016 12:39:42 +0200 Subject: [PATCH 123/191] 8137240: Negative lookahead in RegEx breaks backreference Reviewed-by: mhaupt --- .../runtime/regexp/RegExpScanner.java | 18 ++++++-- nashorn/test/script/basic/JDK-8137240.js | 44 +++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8137240.js diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java index 88b023ac6f6..d194e2d9f67 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java @@ -80,8 +80,17 @@ final class RegExpScanner extends Scanner { this.negLookaheadLevel = negLookaheadLevel; } - boolean isContained(final int group, final int level) { - return group == this.negLookaheadGroup && level >= this.negLookaheadLevel; + /** + * Returns true if this Capture can be referenced from the position specified by the + * group and level parameters. This is the case if either the group is not within + * a negative lookahead, or the position of the referrer is in the same negative lookahead. + * + * @param group current negative lookahead group + * @param level current negative lokahead level + * @return true if this capture group can be referenced from the given position + */ + boolean canBeReferencedFrom(final int group, final int level) { + return this.negLookaheadLevel == 0 || (group == this.negLookaheadGroup && level >= this.negLookaheadLevel); } } @@ -671,8 +680,9 @@ final class RegExpScanner extends Scanner { } else if (decimalValue <= caps.size()) { // Captures inside a negative lookahead are undefined when referenced from the outside. - if (!caps.get(decimalValue - 1).isContained(negLookaheadGroup, negLookaheadLevel)) { - // Reference to capture in negative lookahead, omit from output buffer. + final Capture capture = caps.get(decimalValue - 1); + if (!capture.canBeReferencedFrom(negLookaheadGroup, negLookaheadLevel)) { + // Outside reference to capture in negative lookahead, omit from output buffer. sb.setLength(sb.length() - 1); } else { // Append backreference to output buffer. diff --git a/nashorn/test/script/basic/JDK-8137240.js b/nashorn/test/script/basic/JDK-8137240.js new file mode 100644 index 00000000000..645643edb75 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8137240.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8137240: Negative lookahead in RegEx breaks backreference + * + * @test + * @run + */ + + +Assert.assertEquals('aa'.replace(/(a)(?!b)\1/gm, 'c'), 'c'); + +var result = 'aa'.match(/(a)(?!b)\1/); +Assert.assertTrue(result.length === 2); +Assert.assertTrue(result[0] === 'aa'); +Assert.assertTrue(result[1] === 'a'); + +result = 'aa'.match(/(a)(?!(b))\2(a)/); +Assert.assertTrue(result.length === 4); +Assert.assertTrue(result[0] === 'aa'); +Assert.assertTrue(result[1] === 'a'); +Assert.assertTrue(result[2] === undefined); +Assert.assertTrue(result[3] === 'a'); From 4f3b48809e7fd98732f26e5f2c4925e81deaafb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Fri, 24 Jun 2016 14:46:45 +0200 Subject: [PATCH 124/191] 8073653: Secondary heredoc eating wrong lines Reviewed-by: mhaupt, jlaskey --- .../jdk/nashorn/internal/parser/Lexer.java | 12 +++- nashorn/test/script/basic/JDK-8073653.js | 59 +++++++++++++++++++ .../test/script/basic/JDK-8073653.js.EXPECTED | 12 ++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8073653.js create mode 100644 nashorn/test/script/basic/JDK-8073653.js.EXPECTED diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java index 3ac89091e0a..ab615d5c5b6 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java @@ -609,6 +609,9 @@ public class Lexer extends Scanner { if (stream.get(stream.last()) != token) { return false; } + + // Record current position in case multiple heredocs start on this line - see JDK-8073653 + final State state = saveState(); // Rewind to token start position reset(Token.descPosition(token)); @@ -616,7 +619,7 @@ public class Lexer extends Scanner { return scanRegEx(); } else if (ch0 == '<') { if (ch1 == '<') { - return scanHereString(lir); + return scanHereString(lir, state); } else if (Character.isJavaIdentifierStart(ch1)) { return scanXMLLiteral(); } @@ -1539,7 +1542,7 @@ public class Lexer extends Scanner { * * @return TRUE if is a here string. */ - private boolean scanHereString(final LineInfoReceiver lir) { + private boolean scanHereString(final LineInfoReceiver lir, final State oldState) { assert ch0 == '<' && ch1 == '<'; if (scripting) { // Record beginning of here string. @@ -1589,6 +1592,11 @@ public class Lexer extends Scanner { int lastLinePosition = position; restState.setLimit(position); + if (oldState.position > position) { + restoreState(oldState); + skipLine(false); + } + // Record beginning of string. final State stringState = saveState(); int stringEnd = position; diff --git a/nashorn/test/script/basic/JDK-8073653.js b/nashorn/test/script/basic/JDK-8073653.js new file mode 100644 index 00000000000..5e9398fd2c9 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8073653.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8073653: Secondary heredoc eating wrong lines. + * + * @test + * @run + * @option -scripting + */ + + +print(< Date: Fri, 24 Jun 2016 11:20:24 -0300 Subject: [PATCH 125/191] 8159172: Update usage of jlink/jimage/jmod to show option patterns Reviewed-by: mchung, alanb --- .../classes/jdk/tools/jimage/JImageTask.java | 26 ++++++++++--------- .../tools/jimage/resources/jimage.properties | 16 +++++++++--- .../jdk/tools/jlink/internal/TaskHelper.java | 2 ++ .../tools/jlink/resources/jlink.properties | 15 +++++++++-- .../tools/jlink/resources/plugins.properties | 20 +++++++------- .../classes/jdk/tools/jmod/JmodTask.java | 6 ++--- .../jdk/tools/jmod/resources/jmod.properties | 10 ++++--- 7 files changed, 63 insertions(+), 32 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java index 2004c1630fa..6516d68ab24 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java @@ -54,8 +54,8 @@ class JImageTask { }, "--dir"), new Option(true, (task, option, arg) -> { - task.options.filters = arg; - }, "--filter"), + task.options.include = arg; + }, "--include"), new Option(false, (task, option, arg) -> { task.options.fullVersion = true; @@ -81,12 +81,12 @@ class JImageTask { private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem(); private final OptionsValues options; - private final List> filterPredicates; + private final List> includePredicates; private PrintWriter log; JImageTask() { this.options = new OptionsValues(); - this.filterPredicates = new ArrayList<>(); + this.includePredicates = new ArrayList<>(); log = null; } @@ -98,7 +98,7 @@ class JImageTask { static class OptionsValues { Task task = Task.LIST; String directory = "."; - String filters = ""; + String include = ""; boolean fullVersion; boolean help; boolean verbose; @@ -200,6 +200,8 @@ class JImageTask { log.println(TASK_HELPER.getMessage("main.opt." + name)); } + + log.println(TASK_HELPER.getMessage("main.opt.footer")); } else { try { log.println(TASK_HELPER.getMessage("main.usage." + @@ -219,7 +221,7 @@ class JImageTask { } } - processFilter(options.filters); + processInclude(options.include); return run() ? EXIT_OK : EXIT_ERROR; } catch (BadArgs e) { @@ -239,15 +241,15 @@ class JImageTask { } } - private void processFilter(String filters) { - if (filters.isEmpty()) { + private void processInclude(String include) { + if (include.isEmpty()) { return; } - for (String filter : filters.split(",")) { + for (String filter : include.split(",")) { final PathMatcher matcher = Utils.getPathMatcher(JRT_FILE_SYSTEM, filter); Predicate predicate = (path) -> matcher.matches(JRT_FILE_SYSTEM.getPath(path)); - filterPredicates.add(predicate); + includePredicates.add(predicate); } } @@ -388,9 +390,9 @@ class JImageTask { String oldModule = ""; for (String name : entryNames) { - boolean match = filterPredicates.isEmpty(); + boolean match = includePredicates.isEmpty(); - for (Predicate predicate : filterPredicates) { + for (Predicate predicate : includePredicates) { if (predicate.test(name)) { match = true; break; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties index f0494be5763..8b5b2f3e858 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties @@ -62,9 +62,19 @@ warn.prefix=Warning: main.opt.dir=\ \ --dir Target directory for extract directive -main.opt.filter=\ -\ --filter Filter entries for list or extract\n\ -\ Ex. /java.base/*, */module-info.class +main.opt.include=\ +\ --include Pattern list for filtering list or extract entries. + +main.opt.footer=\ +\n\ +\For options requiring a , the value will be a comma\ +\ separated list of elements each using one the following forms:\n\ +\ \n\ +\ glob:\n\ +\ regex:\n\ +\ @ where filename is the name of a file containing patterns to be\ +\ used, one pattern per line\n\ + main.opt.fullversion=\ \ --fullversion Print full version information diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java index 5cc986f1bfd..eed739da19b 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java @@ -584,6 +584,8 @@ public final class TaskHelper { showPlugin(plugin, log, showsImageBuilder); } } + + log.println("\n" + bundleHelper.getMessage("main.extended.help.footer")); } private void showPlugin(Plugin plugin, PrintWriter log, boolean showsImageBuilder) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties index 975dc81e4ea..e7714e6e884 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -29,7 +29,7 @@ use --help for a list of possible options main.usage=\ Usage: {0} --modulepath --addmods --output \n\ -Possible options include: +\Possible options include: error.prefix=Error: warn.prefix=Warning: @@ -68,7 +68,18 @@ after checking the database for duplicates. \ Include your program and the following diagnostic in your report. Thank you. main.extended.help=\ -List of available plugins: +\List of available plugins: + +main.extended.help.footer=\ +\For options requiring a , the value will be a comma\ +\ separated list of elements each using one the following forms:\n\ +\ \n\ +\ glob:\n\ +\ regex:\n\ +\ @ where filename is the name of a file containing patterns to be\ +\ used, one pattern per line\n\ +\n\ + err.unknown.byte.order:unknown byte order {0} err.output.must.be.specified:--output must be specified diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 66fc5efcec8..afab935c836 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -37,15 +37,16 @@ class-optim.description=\ Class optimization. Warning: This plugin is experimental.\n\ An optional can be specified to log applied optimizations. -compress.argument=<0|1|2>[:filter=] +compress.argument=<0|1|2>[:filter=] compress.description=\ Compress all resources in the output image.\n\ Level 0: constant string sharing\n\ Level 1: ZIP\n\ Level 2: both.\n\ -An optional filter can be specified to list the pattern of files to be filtered.\n\ -Use ^ for negation. e.g.: *Exception.class,*Error.class,^/java.base/java/lang/* +An optional filter can be specified to list the pattern of\n\ +files to be included. + compact-cp.argument= @@ -59,15 +60,15 @@ copy-files.description=\ If files to copy are not absolute path, JDK home dir is used.\n\ e.g.: jrt-fs.jar,LICENSE,/home/me/myfile.txt=somewehere/conf.txt -exclude-files.argument= +exclude-files.argument= of files to exclude exclude-files.description=\ -Specify files to exclude. e.g.: *.diz, /java.base/native/client/* +Specify files to exclude. e.g.: **.java,glob:/java.base/native/client/** -exclude-resources.argument= +exclude-resources.argument= resources to exclude exclude-resources.description=\ -Specify resources to exclude. e.g.: *.jcov, */META-INF/* +Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** generate-jli-classes.argument= @@ -78,10 +79,11 @@ installed-modules.description=Fast loading of module descriptors (always enabled onoff.argument= -order-resources.argument= +order-resources.argument= of paths in priority order. If a @file\n\ +is specified, then each line should be an exact match for the path to be ordered order-resources.description=\ -Order resources. e.g.: */module-info.class,/java.base/java/lang/* +Order resources. e.g.: **/module-info.class,@classlist,/java.base/java/lang/** strip-debug.description=\ Strip debug information from the output image diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java index 121bd91304e..009cd0c122e 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java @@ -1085,7 +1085,7 @@ public class JmodTask { @Override public Class valueType() { return Pattern.class; } - @Override public String valuePattern() { return "pattern"; } + @Override public String valuePattern() { return "regex-pattern"; } } static class PathMatcherConverter implements ValueConverter { @@ -1100,7 +1100,7 @@ public class JmodTask { @Override public Class valueType() { return PathMatcher.class; } - @Override public String valuePattern() { return "pattern"; } + @Override public String valuePattern() { return "pattern-list"; } } /* Support for @ in jmod help */ @@ -1145,7 +1145,7 @@ public class JmodTask { String content = super.format(all); StringBuilder builder = new StringBuilder(); - builder.append("\n").append(" Main operation modes:\n "); + builder.append(getMessage("main.opt.mode")).append("\n "); builder.append(getMessage("main.opt.mode.create")).append("\n "); builder.append(getMessage("main.opt.mode.list")).append("\n "); builder.append(getMessage("main.opt.mode.describe")).append("\n "); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties index 12cb85cc919..a2595e25ca0 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties @@ -28,11 +28,13 @@ Usage: {0} (create|list|describe|hash) \n\ use --help for a list of possible options main.usage=\ -Usage: {0} (create|list|describe|hash) +Usage: {0} (create|list|describe|hash) \n\ error.prefix=Error: warn.prefix=Warning: +main.opt.mode=\ +\Main operation modes: main.opt.mode.create=\ \create - Creates a new jmod archive main.opt.mode.list=\ @@ -49,7 +51,9 @@ main.opt.libs=Location of native libraries main.opt.cmds=Location of native commands main.opt.config=Location of user-editable config files main.opt.dry-run=Dry run of hash mode -main.opt.exclude=Exclude files, given as a PATTERN +main.opt.exclude=Exclude files matching the supplied comma separated pattern\ +\ list, each element using one the following forms: ,\ +\ glob: or regex: main.opt.module-version= Module version main.opt.main-class=Main class main.opt.main-class.arg=class-name @@ -61,7 +65,7 @@ main.opt.os-version=Operating system version main.opt.os-version.arg=os-version main.opt.modulepath=Module path main.opt.hash-modules=Compute and record hashes to tie a packaged module\ -\ with modules matching the given pattern and depending upon it directly\ +\ with modules matching the given and depending upon it directly\ \ or indirectly. The hashes are recorded in the JMOD file being created, or\ \ a JMOD file or modular JAR on the module path specified the jmod hash command. From 72d2e8594fa666c9841922359cc62409faa118f7 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 24 Jun 2016 19:56:50 +0530 Subject: [PATCH 126/191] 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed Reviewed-by: jlaskey, psandoz --- ...ntryImpl.java => AbstractModuleEntry.java} | 86 ++---------- .../internal/ArchiveEntryModuleEntry.java | 82 +++++++++++ .../jlink/internal/ByteArrayModuleEntry.java | 78 +++++++++++ .../jlink/internal/ImageFileCreator.java | 52 ++----- .../jlink/internal/ImagePluginStack.java | 4 +- .../jlink/internal/ModuleEntryFactory.java | 67 +++++++++ .../tools/jlink/internal/ModulePoolImpl.java | 34 +++-- .../tools/jlink/internal/PathModuleEntry.java | 75 ++++++++++ .../internal/plugins/ExcludeVMPlugin.java | 5 +- .../internal/plugins/FileCopierPlugin.java | 30 +--- .../plugins/GenerateJLIClassesPlugin.java | 5 +- .../plugins/IncludeLocalesPlugin.java | 4 +- .../internal/plugins/StripDebugPlugin.java | 2 +- .../plugins/SystemModuleDescriptorPlugin.java | 17 +-- .../internal/plugins/asm/AsmPoolImpl.java | 3 +- .../jdk/tools/jlink/plugin/ModuleEntry.java | 132 ++++++++++++------ jdk/test/tools/jlink/ImageFilePoolTest.java | 25 ++-- jdk/test/tools/jlink/ResourcePoolTest.java | 34 ++--- .../jlink/plugins/ExcludeFilesPluginTest.java | 4 +- .../jlink/plugins/ExcludePluginTest.java | 6 +- .../jlink/plugins/ExcludeVMPluginTest.java | 8 +- .../plugins/StringSharingPluginTest.java | 3 + 22 files changed, 479 insertions(+), 277 deletions(-) rename jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/{ModuleEntryImpl.java => AbstractModuleEntry.java} (58%) create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java create mode 100644 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java similarity index 58% rename from jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java rename to jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java index 30c07a3b2d7..19a76ee36b6 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryImpl.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/AbstractModuleEntry.java @@ -25,9 +25,7 @@ package jdk.tools.jlink.internal; -import java.io.IOException; import java.io.InputStream; -import java.io.UncheckedIOException; import java.util.Objects; import jdk.tools.jlink.plugin.ModuleEntry; @@ -44,103 +42,39 @@ import jdk.tools.jlink.plugin.ModuleEntry; * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name} * */ -public class ModuleEntryImpl implements ModuleEntry { - - private final Type type; +abstract class AbstractModuleEntry implements ModuleEntry { private final String path; private final String module; - private final long length; - private final InputStream stream; - private byte[] buffer; + private final Type type; /** - * Create a new LinkModuleEntry. + * Create a new AbstractModuleEntry. * * @param module The module name. * @param path The data path identifier. * @param type The data type. - * @param stream The data content stream. - * @param length The stream length. */ - public ModuleEntryImpl(String module, String path, Type type, InputStream stream, long length) { - Objects.requireNonNull(module); - Objects.requireNonNull(path); - Objects.requireNonNull(type); - Objects.requireNonNull(stream); - this.path = path; - this.type = type; - this.module = module; - this.stream = stream; - this.length = length; + AbstractModuleEntry(String module, String path, Type type) { + this.module = Objects.requireNonNull(module); + this.path = Objects.requireNonNull(path); + this.type = Objects.requireNonNull(type); } - /** - * The LinkModuleEntry module name. - * - * @return The module name. - */ @Override public final String getModule() { return module; } - /** - * The LinkModuleEntry path. - * - * @return The module path. - */ @Override public final String getPath() { return path; } - /** - * The LinkModuleEntry's type. - * - * @return The data type. - */ @Override public final Type getType() { return type; } - /** - * The LinkModuleEntry content as an array of byte. - * - * @return An Array of bytes. - */ - @Override - public byte[] getBytes() { - if (buffer == null) { - try (InputStream is = stream) { - buffer = is.readAllBytes(); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - } - return buffer; - } - - /** - * The LinkModuleEntry content length. - * - * @return The length. - */ - @Override - public long getLength() { - return length; - } - - /** - * The LinkModuleEntry stream. - * - * @return The module data stream. - */ - @Override - public InputStream stream() { - return stream; - } - @Override public int hashCode() { int hash = 7; @@ -150,10 +84,10 @@ public class ModuleEntryImpl implements ModuleEntry { @Override public boolean equals(Object other) { - if (!(other instanceof ModuleEntryImpl)) { + if (!(other instanceof AbstractModuleEntry)) { return false; } - ModuleEntryImpl f = (ModuleEntryImpl) other; + AbstractModuleEntry f = (AbstractModuleEntry) other; return f.path.equals(path); } @@ -161,4 +95,4 @@ public class ModuleEntryImpl implements ModuleEntry { public String toString() { return getPath(); } -} \ No newline at end of file +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java new file mode 100644 index 00000000000..6656c935101 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ArchiveEntryModuleEntry.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.tools.jlink.internal; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +/** + * A ModuleEntry backed by a given Archive Entry. + */ +final class ArchiveEntryModuleEntry extends AbstractModuleEntry { + private final Archive.Entry entry; + + /** + * Create a new ArchiveModuleEntry. + * + * @param module The module name. + * @param path The data path identifier. + * @param entry The archive Entry. + */ + ArchiveEntryModuleEntry(String module, String path, Archive.Entry entry) { + super(module, path, getImageFileType(entry)); + this.entry = entry; + } + + @Override + public InputStream stream() { + try { + return entry.stream(); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + @Override + public long getLength() { + return entry.size(); + } + + private static ModuleEntry.Type getImageFileType(Archive.Entry entry) { + Objects.requireNonNull(entry); + switch(entry.type()) { + case CLASS_OR_RESOURCE: + return ModuleEntry.Type.CLASS_OR_RESOURCE; + case CONFIG: + return ModuleEntry.Type.CONFIG; + case NATIVE_CMD: + return ModuleEntry.Type.NATIVE_CMD; + case NATIVE_LIB: + return ModuleEntry.Type.NATIVE_LIB; + default: + return ModuleEntry.Type.OTHER; + } + } +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java new file mode 100644 index 00000000000..20a016817c4 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ByteArrayModuleEntry.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.tools.jlink.internal; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UncheckedIOException; +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +/** + * A ModuleEntry backed by a given byte[]. + */ +class ByteArrayModuleEntry extends AbstractModuleEntry { + private final byte[] buffer; + + /** + * Create a new ByteArrayModuleEntry. + * + * @param module The module name. + * @param path The data path identifier. + * @param type The data type. + * @param buf The byte buffer. + */ + ByteArrayModuleEntry(String module, String path, Type type, byte[] buffer) { + super(module, path, type); + this.buffer = Objects.requireNonNull(buffer); + } + + @Override + public byte[] getBytes() { + return buffer.clone(); + } + + @Override + public InputStream stream() { + return new ByteArrayInputStream(buffer); + } + + @Override + public void write(OutputStream out) { + try { + out.write(buffer); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + @Override + public long getLength() { + return buffer.length; + } +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java index f765be2919b..182ce68d538 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java @@ -233,8 +233,7 @@ public final class ImageFileCreator { // write module content for (ModuleEntry res : content) { - byte[] buf = res.getBytes(); - out.write(buf, 0, buf.length); + res.write(out); } tree.addContent(out); @@ -244,21 +243,6 @@ public final class ImageFileCreator { return resultResources; } - private static ModuleEntry.Type mapImageFileType(EntryType type) { - switch(type) { - case CONFIG: { - return ModuleEntry.Type.CONFIG; - } - case NATIVE_CMD: { - return ModuleEntry.Type.NATIVE_CMD; - } - case NATIVE_LIB: { - return ModuleEntry.Type.NATIVE_LIB; - } - } - return null; - } - private static ModulePoolImpl createPools(Set archives, Map> entriesForModule, ByteOrder byteOrder, @@ -278,34 +262,22 @@ public final class ImageFileCreator { for (Archive archive : archives) { String mn = archive.moduleName(); for (Entry entry : entriesForModule.get(mn)) { - + String path; if (entry.type() == EntryType.CLASS_OR_RESOURCE) { // Removal of "classes/" radical. - String path = entry.name(); - try (InputStream stream = entry.stream()) { - byte[] bytes = readAllBytes(stream); - if (path.endsWith("module-info.class")) { - path = "/" + path; - } else { - path = "/" + mn + "/" + path; - } - try { - resources.add(ModuleEntry.create(path, bytes)); - } catch (Exception ex) { - throw new IOException(ex); - } + path = entry.name(); + if (path.endsWith("module-info.class")) { + path = "/" + path; + } else { + path = "/" + mn + "/" + path; } } else { - try { - // Entry.path() contains the kind of file native, conf, bin, ... - // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg - resources.add(ModuleEntry.create(mn, - "/" + mn + "/" + entry.path(), mapImageFileType(entry.type()), - entry.stream(), entry.size())); - } catch (Exception ex) { - throw new IOException(ex); - } + // Entry.path() contains the kind of file native, conf, bin, ... + // Keep it to avoid naming conflict (eg: native/jvm.cfg and config/jvm.cfg + path = "/" + mn + "/" + entry.path(); } + + resources.add(new ArchiveEntryModuleEntry(mn, path, entry)); } } return resources; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java index 24b8aeb632d..5b78f5ba696 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java @@ -443,9 +443,7 @@ public final class ImagePluginStack { byte[] bytes = decompressor.decompressResource(getByteOrder(), (int offset) -> pool.getStringTable().getString(offset), res.getBytes()); - res = ModuleEntry.create(res.getPath(), - new ByteArrayInputStream(bytes), - bytes.length); + res = res.create(bytes); } catch (IOException ex) { throw new PluginException(ex); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java new file mode 100644 index 00000000000..61c22ffc457 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleEntryFactory.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package jdk.tools.jlink.internal; + +import java.io.InputStream; +import java.nio.file.Path; +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +public final class ModuleEntryFactory { + private ModuleEntryFactory() {} + + public static ModuleEntry create(String path, + ModuleEntry.Type type, byte[] content) { + return new ByteArrayModuleEntry(moduleFrom(path), path, type, content); + } + + public static ModuleEntry create(String path, + ModuleEntry.Type type, Path file) { + return new PathModuleEntry(moduleFrom(path), path, type, file); + } + + public static ModuleEntry create(ModuleEntry original, byte[] content) { + return new ByteArrayModuleEntry(original.getModule(), + original.getPath(), original.getType(), content); + } + + public static ModuleEntry create(ModuleEntry original, Path file) { + return new PathModuleEntry(original.getModule(), + original.getPath(), original.getType(), file); + } + + private static String moduleFrom(String path) { + Objects.requireNonNull(path); + if (path.isEmpty() || path.charAt(0) != '/') { + throw new IllegalArgumentException(path + " must start with /"); + } + String noRoot = path.substring(1); + int idx = noRoot.indexOf('/'); + if (idx == -1) { + throw new IllegalArgumentException("/ missing after module: " + path); + } + return noRoot.substring(0, idx); + } +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java index a572fa48637..dabdb5bb972 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java @@ -95,7 +95,7 @@ public class ModulePoolImpl implements ModulePool { @Override public void add(ModuleEntry data) { if (isReadOnly()) { - throw new PluginException("LinkConfiguration is readonly"); + throw new PluginException("ModulePool is readonly"); } Objects.requireNonNull(data); if (!data.getModule().equals(name)) { @@ -180,7 +180,7 @@ public class ModulePoolImpl implements ModulePool { @Override public void add(ModuleEntry data) { if (isReadOnly()) { - throw new PluginException("LinkConfiguration is readonly"); + throw new PluginException("ModulePool is readonly"); } Objects.requireNonNull(data); if (resources.get(data.getPath()) != null) { @@ -215,7 +215,7 @@ public class ModulePoolImpl implements ModulePool { } /** - * The stream of modules contained in this LinkConfiguration. + * The stream of modules contained in this ModulePool. * * @return The stream of modules. */ @@ -225,7 +225,7 @@ public class ModulePoolImpl implements ModulePool { } /** - * Return the number of LinkModule count in this LinkConfiguration. + * Return the number of LinkModule count in this ModulePool. * * @return the module count. */ @@ -235,7 +235,7 @@ public class ModulePoolImpl implements ModulePool { } /** - * Get all ModuleEntry contained in this LinkConfiguration instance. + * Get all ModuleEntry contained in this ModulePool instance. * * @return The stream of LinkModuleEntries. */ @@ -245,7 +245,7 @@ public class ModulePoolImpl implements ModulePool { } /** - * Return the number of ModuleEntry count in this LinkConfiguration. + * Return the number of ModuleEntry count in this ModulePool. * * @return the entry count. */ @@ -267,7 +267,7 @@ public class ModulePoolImpl implements ModulePool { } /** - * Check if the LinkConfiguration contains the given ModuleEntry. + * Check if the ModulePool contains the given ModuleEntry. * * @param data The module data to check existence for. * @return The module data or null if not found. @@ -279,7 +279,7 @@ public class ModulePoolImpl implements ModulePool { } /** - * Check if the LinkConfiguration contains some content at all. + * Check if the ModulePool contains some content at all. * * @return True, no content, false otherwise. */ @@ -289,16 +289,16 @@ public class ModulePoolImpl implements ModulePool { } /** - * Visit each ModuleEntry in this LinkConfiguration to transform it and - * copy the transformed ModuleEntry to the output LinkConfiguration. + * Visit each ModuleEntry in this ModulePool to transform it and + * copy the transformed ModuleEntry to the output ModulePool. * * @param transform The function called for each ModuleEntry found in - * the LinkConfiguration. The transform function should return a + * the ModulePool. The transform function should return a * ModuleEntry instance which will be added to the output or it should * return null if the passed ModuleEntry is to be ignored for the * output. * - * @param output The LinkConfiguration to be filled with Visitor returned + * @param output The ModulePool to be filled with Visitor returned * ModuleEntry. */ @Override @@ -351,14 +351,13 @@ public class ModulePoolImpl implements ModulePool { /** * A resource that has been compressed. */ - public static final class CompressedModuleData extends ModuleEntryImpl { + public static final class CompressedModuleData extends ByteArrayModuleEntry { final long uncompressed_size; private CompressedModuleData(String module, String path, - InputStream stream, long size, - long uncompressed_size) { - super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, stream, size); + byte[] content, long uncompressed_size) { + super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, content); this.uncompressed_size = uncompressed_size; } @@ -413,8 +412,7 @@ public class ModulePoolImpl implements ModulePool { CompressedModuleData compressedResource = new CompressedModuleData(original.getModule(), original.getPath(), - new ByteArrayInputStream(contentWithHeader), - contentWithHeader.length, uncompressed_size); + contentWithHeader, uncompressed_size); return compressedResource; } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java new file mode 100644 index 00000000000..28c56391193 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathModuleEntry.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classfile" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.tools.jlink.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; +import jdk.tools.jlink.plugin.ModuleEntry; + +/** + * A ModuleEntry backed by a given nio Path. + */ +public class PathModuleEntry extends AbstractModuleEntry { + private final Path file; + + /** + * Create a new PathModuleEntry. + * + * @param module The module name. + * @param file The data file identifier. + * @param type The data type. + * @param file The Path for the resource content. + */ + public PathModuleEntry(String module, String path, Type type, Path file) { + super(module, path, type); + this.file = Objects.requireNonNull(file); + if (!Files.isRegularFile(file)) { + throw new IllegalArgumentException(file + " not a file"); + } + } + + @Override + public final InputStream stream() { + try { + return Files.newInputStream(file); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + @Override + public final long getLength() { + try { + return Files.size(file); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java index 390dd9a3fb1..6b34a5da436 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java @@ -244,10 +244,7 @@ public final class ExcludeVMPlugin implements TransformerPlugin { byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8); - return ModuleEntry.create(orig.getModule(), - orig.getPath(), - orig.getType(), - new ByteArrayInputStream(content), content.length); + return orig.create(content); } private static String jvmlib() { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java index 9be4b023b48..8bbd02cdb79 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java @@ -39,7 +39,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; -import jdk.tools.jlink.internal.ModuleEntryImpl; +import jdk.tools.jlink.internal.PathModuleEntry; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.ModulePool; @@ -66,13 +66,13 @@ public class FileCopierPlugin implements TransformerPlugin { /** * Symbolic link to another path. */ - public static abstract class SymImageFile extends ModuleEntryImpl { + public static abstract class SymImageFile extends PathModuleEntry { private final String targetPath; public SymImageFile(String targetPath, String module, String path, - ModuleEntry.Type type, InputStream stream, long size) { - super(module, path, type, stream, size); + ModuleEntry.Type type, Path file) { + super(module, path, type, file); this.targetPath = targetPath; } @@ -85,23 +85,7 @@ public class FileCopierPlugin implements TransformerPlugin { public SymImageFileImpl(String targetPath, Path file, String module, String path, ModuleEntry.Type type) { - super(targetPath, module, path, type, newStream(file), length(file)); - } - } - - private static long length(Path file) { - try { - return Files.size(file); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - private static InputStream newStream(Path file) { - try { - return Files.newInputStream(file); - } catch (IOException ex) { - throw new UncheckedIOException(ex); + super(targetPath, module, path, type, file); } } @@ -175,9 +159,9 @@ public class FileCopierPlugin implements TransformerPlugin { Objects.requireNonNull(pool); Objects.requireNonNull(file); Objects.requireNonNull(path); - ModuleEntry impl = ModuleEntry.create(FAKE_MODULE, + ModuleEntry impl = ModuleEntry.create( "/" + FAKE_MODULE + "/other/" + path, - ModuleEntry.Type.OTHER, newStream(file), length(file)); + ModuleEntry.Type.OTHER, file); try { pool.add(impl); } catch (Exception ex) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index 397641febbf..0fe662a0bb9 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -171,10 +171,9 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { byte[] bytes = result.getValue(); // Add class to pool - ModuleEntry ndata = ModuleEntry.create(data.getModule(), + ModuleEntry ndata = ModuleEntry.create( "/java.base/" + className + ".class", - ModuleEntry.Type.CLASS_OR_RESOURCE, - new ByteArrayInputStream(bytes), bytes.length); + bytes); if (!out.contains(ndata)) { out.add(ndata); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index 1a77e26273e..6742d695cc6 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -123,9 +123,7 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr if (Arrays.stream(cr.getInterfaces()) .anyMatch(i -> i.contains(METAINFONAME)) && stripUnsupportedLocales(bytes, cr)) { - resource = ModuleEntry.create(MODULENAME, path, - resource.getType(), - new ByteArrayInputStream(bytes), bytes.length); + resource = resource.create(bytes); } } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java index 74b16e174e8..62d89651869 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java @@ -75,7 +75,7 @@ public final class StripDebugPlugin implements TransformerPlugin { ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); reader.accept(writer, ClassReader.SKIP_DEBUG); byte[] content = writer.toByteArray(); - res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length); + res = resource.create(content); } } } else if (predicate.test(res.getPath())) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java index 226d759804a..cc140664183 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java @@ -139,11 +139,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { ModuleInfoRewriter minfoWriter = new ModuleInfoRewriter(bain, mbuilder.conceals()); // replace with the overridden version - data = ModuleEntry.create(data.getModule(), - data.getPath(), - data.getType(), - minfoWriter.stream(), - minfoWriter.size()); + data = data.create(minfoWriter.getBytes()); } out.add(data); } catch (IOException e) { @@ -158,12 +154,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { return; if (builder.isOverriddenClass(data.getPath())) { byte[] bytes = cwriter.toByteArray(); - ModuleEntry ndata = - ModuleEntry.create(data.getModule(), - data.getPath(), - data.getType(), - new ByteArrayInputStream(bytes), - bytes.length); + ModuleEntry ndata = data.create(bytes); out.add(ndata); } else { out.add(data); @@ -183,8 +174,8 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { this.extender.write(this); } - InputStream stream() { - return new ByteArrayInputStream(buf); + byte[] getBytes() { + return buf; } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java index 20c17c85b7b..b82eca51895 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java @@ -93,8 +93,7 @@ final class AsmPoolImpl implements AsmModulePool { } byte[] content = writer.toByteArray(); - ModuleEntry res = ModuleEntry.create(path, - new ByteArrayInputStream(content), content.length); + ModuleEntry res = ModuleEntry.create(path, content); transformedClasses.put(className, res); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java index d8adebb8fc5..f23e1e437f7 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java @@ -26,16 +26,18 @@ package jdk.tools.jlink.plugin; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.Objects; -import jdk.tools.jlink.internal.ImageFileCreator; -import jdk.tools.jlink.internal.ModuleEntryImpl; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import jdk.tools.jlink.internal.ModuleEntryFactory; /** - * A LinkModuleEntry is the elementary unit of data inside an image. It is - * generally a file. e.g.: a java class file, a resource file, a shared library, - * ... + * A ModuleEntry is the elementary unit of data inside an image. It is + * generally a file. e.g.: a java class file, a resource file, a shared library. *
    - * A LinkModuleEntry is identified by a path of the form: + * A ModuleEntry is identified by a path of the form: *