diff -r 2c33418a6d57 -r 83b611b88ac8 jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java --- a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java Thu Apr 06 17:01:03 2017 +0000 +++ b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java Fri Apr 07 08:05:54 2017 +0000 @@ -23,11 +23,10 @@ * questions. */ - package sun.instrument; +import java.lang.instrument.UnmodifiableModuleException; import java.lang.reflect.Method; -import java.lang.reflect.Module; import java.lang.reflect.AccessibleObject; import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.ClassDefinition; @@ -132,6 +131,13 @@ return isModifiableClass0(mNativeAgent, theClass); } + public boolean isModifiableModule(Module module) { + if (module == null) { + throw new NullPointerException("'module' is null"); + } + return true; + } + public boolean isRetransformClassesSupported() { // ask lazily since there is some overhead @@ -243,6 +249,9 @@ if (!module.isNamed()) return; + if (!isModifiableModule(module)) + throw new UnmodifiableModuleException(module.getName()); + // copy and check reads extraReads = new HashSet<>(extraReads); if (extraReads.contains(null)) @@ -312,7 +321,7 @@ return Collections.emptyMap(); Map> result = new HashMap<>(); - Set packages = Set.of(module.getPackages()); + Set packages = module.getPackages(); for (Map.Entry> e : map.entrySet()) { String pkg = e.getKey(); if (pkg == null)