< prev index next >

src/jdk.jartool/share/classes/sun/tools/jar/Validator.java

Print this page
rev 16153 : 8164805: Fail to create a MR modular JAR with a versioned entry of a concealed package
Reviewed-by: chegar, mchung

*** 150,163 **** --- 150,167 ---- isValid = false; } return; } if (fp.isPublicClass()) { + if (!isConcealed(internalName)) { main.error(Main.formatMsg("error.validator.new.public.class", entryName)); isValid = false; return; } + main.warn(Main.formatMsg("warn.validator.concealed.public.class", entryName)); + debug("%s is a public class entry in a concealed package", entryName); + } debug("%s is a non-public class entry", entryName); fps.put(internalName, fp); currentTopLevelName = fp.topLevelName(); return; }
*** 167,177 **** } debug("match found"); // are the two classes/resources identical? if (fp.isIdentical(matchFp)) { ! main.error(Main.formatMsg("error.validator.identical.entry", entryName)); return; // it's okay, just takes up room } debug("sha1 not equal -- different bytes"); // ok, not identical, check for compatible class version and api --- 171,181 ---- } debug("match found"); // are the two classes/resources identical? if (fp.isIdentical(matchFp)) { ! main.warn(Main.formatMsg("warn.validator.identical.entry", entryName)); return; // it's okay, just takes up room } debug("sha1 not equal -- different bytes"); // ok, not identical, check for compatible class version and api
*** 202,212 **** currentTopLevelName = fp.topLevelName(); return; } debug("%s is a resource", entryName); ! main.error(Main.formatMsg("error.validator.resources.with.same.name", entryName)); fps.put(internalName, fp); return; } private boolean checkInternalName(String entryName, String basename, String internalName) { --- 206,216 ---- currentTopLevelName = fp.topLevelName(); return; } debug("%s is a resource", entryName); ! main.warn(Main.formatMsg("warn.validator.resources.with.same.name", entryName)); fps.put(internalName, fp); return; } private boolean checkInternalName(String entryName, String basename, String internalName) {
*** 233,242 **** --- 237,255 ---- private String className(String entryName) { return entryName.endsWith(".class") ? entryName.substring(0, entryName.length() - 6) : null; } + private boolean isConcealed(String internalName) { + if (main.concealedPackages.isEmpty()) { + return false; + } + int idx = internalName.lastIndexOf('/'); + String pkgName = idx != -1 ? internalName.substring(0, idx).replace('/', '.') : ""; + return main.concealedPackages.contains(pkgName); + } + private void debug(String fmt, Object... args) { if (DEBUG) System.err.format(fmt, args); } }
< prev index next >