diff --git a/.hgtags b/.hgtags index a7efe189cb34ad5b01d9280ff57f33732d353f41..77659b823f66c631b1e0e1b5f99083563049ae74 100644 --- a/.hgtags +++ b/.hgtags @@ -108,3 +108,4 @@ bdc069d3f9101f89ec3f81c2950ee2d68fa846d3 jdk7-b130 8ac52c85f9e91336dc00b52ef90b42eecf3230b3 jdk7-b131 6bbc7a4734952ae7604578f270e1566639fa8752 jdk7-b132 5e5f68a01d12a4432172f384d5201f3a05254493 jdk7-b133 +554adcfb615e63e62af530b1c10fcf7813a75b26 jdk7-b134 diff --git a/make/common/Demo.gmk b/make/common/Demo.gmk index 576f8103428f6e1cc2c8c81f8e027e0ce6b4fa8c..31c032497872b386fea5d3eabbd5e835e07f819f 100644 --- a/make/common/Demo.gmk +++ b/make/common/Demo.gmk @@ -118,8 +118,11 @@ DEMO_ALL_NATIVE_SOURCES += $(filter %.h,$(DEMO_ALL_FILES)) DEMO_ALL_NATIVE_SOURCES += $(filter %.hpp,$(DEMO_ALL_FILES)) # If we have java sources, then define the jar file we will create +ifndef DEMO_JAR_NAME + DEMO_JAR_NAME = $(DEMONAME).jar +endif ifneq ($(strip $(DEMO_JAVA_SOURCES)),) - DEMO_JAR = $(DEMO_DESTDIR)/$(DEMONAME).jar + DEMO_JAR = $(DEMO_DESTDIR)/$(DEMO_JAR_NAME) endif # If we have native sources, define the native library we will create @@ -252,6 +255,17 @@ $(DEMO_JAR): \ $(MKDIR) -p $(DEMO_JAR_IMAGE) $(JAVAC_CMD) -d $(DEMO_JAR_IMAGE) -sourcepath $(DEMO_BUILD_SRCDIR) \ @$(DEMO_JAVAC_INPUT) + ifeq ($(DEMO_INCL_SRC),true) + $(CP) $(DEMO_JAVA_SOURCES:%=$(DEMO_BUILD_SRCDIR)/%) $(DEMO_JAR_IMAGE) + endif + ifeq ($(DEMO_ONLY_SRC),true) + $(RM) -r $(DEMO_JAR_IMAGE) + $(MKDIR) -p $(DEMO_JAR_IMAGE) + $(CP) -r $(DEMO_BUILD_SRCDIR)/* $(DEMO_JAR_IMAGE) + ifneq ($(DEMO_TOPFILES),) + $(CP) $(DEMO_ROOT)/$(DEMO_TOPFILES) $(DEMO_JAR_IMAGE) + endif + endif $(BOOT_JAR_CMD) -cfm $@ $(DEMO_MANIFEST) \ -C $(DEMO_JAR_IMAGE) . \ $(BOOT_JAR_JFLAGS) @@ -324,9 +338,9 @@ bundles: $(DEMO_BUILD_SRCZIP) ifdef DEMO_IS_APPLET @$(ECHO) "Expanding jar file into demos area at $(DEMO_DESTDIR)" ( $(CD) $(DEMO_DESTDIR) && \ - $(BOOT_JAR_CMD) -xfv $(DEMONAME).jar \ + $(BOOT_JAR_CMD) -xfv $(DEMO_JAR_NAME) \ $(BOOT_JAR_JFLAGS) && \ - $(RM) -r META-INF $(DEMONAME).jar && \ + $(RM) -r META-INF $(DEMO_JAR_NAME) && \ $(java-vm-cleanup) ) @( $(CD) $(DEMO_DESTDIR) && $(java-vm-cleanup) ) @$(ECHO) "Expanding source into demos area at $(DEMO_DESTDIR)" diff --git a/make/common/shared/Compiler-msvc.gmk b/make/common/shared/Compiler-msvc.gmk index 1b6d38d5f7f2a88c5324e8af57ac6a42b9f99f6b..8be9f79f822b2e0a69f53bf2c60b61013f5e661a 100644 --- a/make/common/shared/Compiler-msvc.gmk +++ b/make/common/shared/Compiler-msvc.gmk @@ -153,6 +153,9 @@ ifeq ($(PLATFORM), windows) ifndef COMPILER_VERSION COMPILER_VERSION := $(error COMPILER_VERSION cannot be empty here) endif + ifneq ($(COMPILER_VERSION),VS2010) + COMPILER_VERSION := $(error COMPILER_VERSION must be VS2010) + endif # Shared library generation flag SHARED_LIBRARY_FLAG = -LD diff --git a/make/common/shared/Platform.gmk b/make/common/shared/Platform.gmk index d789f221b7f62710c40cc5dcd20d2f1a3f6e3c5d..3998a2a24fce7a207ca7bc6e8ce0f255fda7b2a5 100644 --- a/make/common/shared/Platform.gmk +++ b/make/common/shared/Platform.gmk @@ -148,7 +148,7 @@ ifeq ($(SYSTEM_UNAME), SunOS) # Suffix for file bundles used in previous release BUNDLE_FILE_SUFFIX=.tar # How much RAM does this machine have: - MB_OF_MEMORY=$(shell /etc/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3) + MB_OF_MEMORY=$(shell /usr/sbin/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3) endif # Platform settings specific to Linux diff --git a/make/mkdemo/jfc/SwingSet2/Makefile b/make/mkdemo/jfc/SwingSet2/Makefile index 3e1509b197c79bdf85b432f50527db69c8a33eca..2a4881c8937c8a9cb3b67894f02262a1102231de 100644 --- a/make/mkdemo/jfc/SwingSet2/Makefile +++ b/make/mkdemo/jfc/SwingSet2/Makefile @@ -37,6 +37,7 @@ DEMO_TOPFILES = ./README.txt DEMO_MAINCLASS = $(DEMONAME) DEMO_MANIFEST_ATTR = SplashScreen-Image: resources/images/splash.png DEMO_DESTDIR = $(DEMODIR)/jfc/$(DEMONAME) +DEMO_INCL_SRC = true # # Demo jar building rules. diff --git a/make/mkdemo/jpda/Makefile b/make/mkdemo/jpda/Makefile index 2007df39531a71635f1c30d7245320fe666d8b97..9844a739258d1297772477a53589ade2cf2d53f9 100644 --- a/make/mkdemo/jpda/Makefile +++ b/make/mkdemo/jpda/Makefile @@ -32,6 +32,8 @@ DEMO_ROOT = $(SHARE_SRC)/classes DEMO_PKGDIR = com/sun/tools/example DEMO_TOPFILES = ./com/sun/tools/example/README DEMO_DESTDIR = $(DEMODIR)/jpda +DEMO_JAR_NAME = examples.jar +DEMO_ONLY_SRC = true # # Demo jar building rules. diff --git a/make/tools/manifest.mf b/make/tools/manifest.mf index 3b3b37efe45cb578cd2bb9486c3ef4306206b547..5e631b7bb41daf86319c6be180197b5ed12cb98d 100644 --- a/make/tools/manifest.mf +++ b/make/tools/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Specification-Title: Java Platform API Specification -Specification-Version: 1.6 +Specification-Version: 1.7 Specification-Vendor: Oracle Implementation-Title: Java Runtime Environment Implementation-Version: @@RELEASE@@ diff --git a/src/share/bin/java.c b/src/share/bin/java.c index 2d339547761d1f510b354c188f162632fa942657..307a25335cadeef511f0d1272baae682068b2801 100644 --- a/src/share/bin/java.c +++ b/src/share/bin/java.c @@ -61,6 +61,9 @@ * interfaces. */ +/* we always print to stderr */ +#define USE_STDERR JNI_TRUE + static jboolean printVersion = JNI_FALSE; /* print and exit */ static jboolean showVersion = JNI_FALSE; /* print but continue */ static jboolean printUsage = JNI_FALSE; /* print and exit*/ @@ -1136,36 +1139,18 @@ InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn) return; \ } -static jstring platformEncoding = NULL; -static jstring getPlatformEncoding(JNIEnv *env) { - if (platformEncoding == NULL) { - jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding"); - if (propname) { - jclass cls; - jmethodID mid; - NULL_CHECK0 (cls = FindBootStrapClass(env, "java/lang/System")); - NULL_CHECK0 (mid = (*env)->GetStaticMethodID( - env, cls, - "getProperty", - "(Ljava/lang/String;)Ljava/lang/String;")); - platformEncoding = (*env)->CallStaticObjectMethod ( - env, cls, mid, propname); - } - } - return platformEncoding; -} +static jclass helperClass = NULL; -static jboolean isEncodingSupported(JNIEnv *env, jstring enc) { - jclass cls; - jmethodID mid; - NULL_CHECK0 (cls = FindBootStrapClass(env, "java/nio/charset/Charset")); - NULL_CHECK0 (mid = (*env)->GetStaticMethodID( - env, cls, - "isSupported", - "(Ljava/lang/String;)Z")); - return (*env)->CallStaticBooleanMethod(env, cls, mid, enc); +static jclass +GetLauncherHelperClass(JNIEnv *env) { + if (helperClass == NULL) { + NULL_CHECK0(helperClass = FindBootStrapClass(env, + "sun/launcher/LauncherHelper")); + } + return helperClass; } +static jmethodID makePlatformStringMID = NULL; /* * Returns a new Java string object for the specified platform string. */ @@ -1173,36 +1158,23 @@ static jstring NewPlatformString(JNIEnv *env, char *s) { int len = (int)JLI_StrLen(s); - jclass cls; - jmethodID mid; jbyteArray ary; - jstring enc; - + jclass cls = GetLauncherHelperClass(env); + NULL_CHECK0(cls); if (s == NULL) return 0; - enc = getPlatformEncoding(env); ary = (*env)->NewByteArray(env, len); if (ary != 0) { jstring str = 0; (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s); if (!(*env)->ExceptionOccurred(env)) { - NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String")); - if (isEncodingSupported(env, enc) == JNI_TRUE) { - NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "", - "([BLjava/lang/String;)V")); - str = (*env)->NewObject(env, cls, mid, ary, enc); - } else { - /*If the encoding specified in sun.jnu.encoding is not - endorsed by "Charset.isSupported" we have to fall back - to use String(byte[]) explicitly here without specifying - the encoding name, in which the StringCoding class will - pickup the iso-8859-1 as the fallback converter for us. - */ - NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "", - "([B)V")); - str = (*env)->NewObject(env, cls, mid, ary); + if (makePlatformStringMID == NULL) { + NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env, + cls, "makePlatformString", "(Z[B)Ljava/lang/String;")); } + str = (*env)->CallStaticObjectMethod(env, cls, + makePlatformStringMID, USE_STDERR, ary); (*env)->DeleteLocalRef(env, ary); return str; } @@ -1239,20 +1211,28 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc) static jclass LoadMainClass(JNIEnv *env, int mode, char *name) { - jclass cls; jmethodID mid; jstring str; jobject result; jlong start, end; - + jclass cls = GetLauncherHelperClass(env); + NULL_CHECK0(cls); if (JLI_IsTraceLauncher()) { start = CounterGet(); } - NULL_CHECK0(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); - NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "checkAndLoadMain", - "(ZILjava/lang/String;)Ljava/lang/Class;")); - str = (*env)->NewStringUTF(env, name); - result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, mode, str); + NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, + "checkAndLoadMain", + "(ZILjava/lang/String;)Ljava/lang/Class;")); + + switch (mode) { + case LM_CLASS: + str = NewPlatformString(env, name); + break; + default: + str = (*env)->NewStringUTF(env, name); + break; + } + result = (*env)->CallStaticObjectMethod(env, cls, mid, USE_STDERR, mode, str); if (JLI_IsTraceLauncher()) { end = CounterGet(); @@ -1478,15 +1458,15 @@ PrintJavaVersion(JNIEnv *env, jboolean extraLF) static void ShowSettings(JNIEnv *env, char *optString) { - jclass cls; jmethodID showSettingsID; jstring joptString; - NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); + jclass cls = GetLauncherHelperClass(env); + NULL_CHECK(cls); NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls, "showSettings", "(ZLjava/lang/String;JJJZ)V")); joptString = (*env)->NewStringUTF(env, optString); (*env)->CallStaticVoidMethod(env, cls, showSettingsID, - JNI_TRUE, + USE_STDERR, joptString, (jlong)initialHeapSize, (jlong)maxHeapSize, @@ -1500,18 +1480,15 @@ ShowSettings(JNIEnv *env, char *optString) static void PrintUsage(JNIEnv* env, jboolean doXUsage) { - jclass cls; jmethodID initHelp, vmSelect, vmSynonym, vmErgo, printHelp, printXUsageMessage; jstring jprogname, vm1, vm2; int i; - - NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); - - + jclass cls = GetLauncherHelperClass(env); + NULL_CHECK(cls); if (doXUsage) { NULL_CHECK(printXUsageMessage = (*env)->GetStaticMethodID(env, cls, "printXUsageMessage", "(Z)V")); - (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, JNI_TRUE); + (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, USE_STDERR); } else { NULL_CHECK(initHelp = (*env)->GetStaticMethodID(env, cls, "initHelpMessage", "(Ljava/lang/String;)V")); @@ -1570,7 +1547,7 @@ PrintUsage(JNIEnv* env, jboolean doXUsage) } /* Complete the usage message and print to stderr*/ - (*env)->CallStaticVoidMethod(env, cls, printHelp, JNI_TRUE); + (*env)->CallStaticVoidMethod(env, cls, printHelp, USE_STDERR); } return; } diff --git a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java index 473d51108c0bf875c06fb19dcc32671774508822..6984a2ba35076fd356aa3358d8a9e0601e2174b5 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java +++ b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java @@ -743,24 +743,24 @@ class BandStructure { private void dumpBand() throws IOException { assert(optDumpBands); - PrintStream ps = new PrintStream(getDumpStream(this, ".txt")); - String irr = (bandCoding == regularCoding) ? "" : " irregular"; - ps.print("# length="+length+ - " size="+outputSize()+ - irr+" coding="+bandCoding); - if (metaCoding != noMetaCoding) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < metaCoding.length; i++) { - if (i == 1) sb.append(" /"); - sb.append(" ").append(metaCoding[i] & 0xFF); + try (PrintStream ps = new PrintStream(getDumpStream(this, ".txt"))) { + String irr = (bandCoding == regularCoding) ? "" : " irregular"; + ps.print("# length="+length+ + " size="+outputSize()+ + irr+" coding="+bandCoding); + if (metaCoding != noMetaCoding) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < metaCoding.length; i++) { + if (i == 1) sb.append(" /"); + sb.append(" ").append(metaCoding[i] & 0xFF); + } + ps.print(" //header: "+sb); } - ps.print(" //header: "+sb); + printArrayTo(ps, values, 0, length); + } + try (OutputStream ds = getDumpStream(this, ".bnd")) { + bandCoding.writeArrayTo(ds, values, 0, length); } - printArrayTo(ps, values, 0, length); - ps.close(); - OutputStream ds = getDumpStream(this, ".bnd"); - bandCoding.writeArrayTo(ds, values, 0, length); - ds.close(); } /** Disburse one value. */ @@ -829,12 +829,12 @@ class BandStructure { private void dumpBand() throws IOException { assert(optDumpBands); - OutputStream ds = getDumpStream(this, ".bnd"); - if (bytesForDump != null) - bytesForDump.writeTo(ds); - else - bytes.writeTo(ds); - ds.close(); + try (OutputStream ds = getDumpStream(this, ".bnd")) { + if (bytesForDump != null) + bytesForDump.writeTo(ds); + else + bytes.writeTo(ds); + } } public void readDataFrom(InputStream in) throws IOException { diff --git a/src/share/classes/com/sun/java/util/jar/pack/Driver.java b/src/share/classes/com/sun/java/util/jar/pack/Driver.java index 36885a86ed2327eb639cfffbef7e0984a3bba0d0..2194a731f35f903e4354feed957374bae3efe6fd 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Driver.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Driver.java @@ -150,12 +150,12 @@ class Driver { // See if there is any other action to take. if ("--config-file=".equals(state)) { String propFile = av.remove(0); - InputStream propIn = new FileInputStream(propFile); Properties fileProps = new Properties(); - fileProps.load(new BufferedInputStream(propIn)); + try (InputStream propIn = new FileInputStream(propFile)) { + fileProps.load(propIn); + } if (engProps.get(verboseProp) != null) fileProps.list(System.out); - propIn.close(); for (Map.Entry me : fileProps.entrySet()) { engProps.put((String) me.getKey(), (String) me.getValue()); } @@ -348,10 +348,10 @@ class Driver { else fileOut = new FileOutputStream(outfile); fileOut = new BufferedOutputStream(fileOut); - JarOutputStream out = new JarOutputStream(fileOut); - junpack.unpack(in, out); - //in.close(); // p200 closes in but not out - out.close(); + try (JarOutputStream out = new JarOutputStream(fileOut)) { + junpack.unpack(in, out); + // p200 closes in but not out + } // At this point, we have a good jarfile (or newfile, if -r) } @@ -411,8 +411,7 @@ class Driver { long filelen = new File(jarfile).length(); if (filelen <= 0) return ""; long skiplen = Math.max(0, filelen - tail.length); - InputStream in = new FileInputStream(new File(jarfile)); - try { + try (InputStream in = new FileInputStream(new File(jarfile))) { in.skip(skiplen); in.read(tail); for (int i = tail.length-4; i >= 0; i--) { @@ -426,8 +425,6 @@ class Driver { } } return ""; - } finally { - in.close(); } } diff --git a/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java b/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java index baa70b6786309e9472e98c10c0f1054a8ec5ce2b..44792a6006508535f29027481e84c1cf2cf9eab4 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java +++ b/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java @@ -241,9 +241,9 @@ class NativeUnpack { void run(File inFile, JarOutputStream jstream) throws IOException { // %%% maybe memory-map the file, and pass it straight into unpacker ByteBuffer mappedFile = null; - FileInputStream fis = new FileInputStream(inFile); - run(fis, jstream, mappedFile); - fis.close(); + try (FileInputStream fis = new FileInputStream(inFile)) { + run(fis, jstream, mappedFile); + } // Note: caller is responsible to finish with jstream. } diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java index d676ee8e6fb27f27adb4e89124e67d373de56703..be9b485d78a2ca7d466f33f1926f3632b7b1d22f 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -540,9 +540,9 @@ class PackageReader extends BandStructure { Index index = initCPIndex(tag, cpMap); if (optDumpBands) { - PrintStream ps = new PrintStream(getDumpStream(index, ".idx")); - printArrayTo(ps, index.cpMap, 0, index.cpMap.length); - ps.close(); + try (PrintStream ps = new PrintStream(getDumpStream(index, ".idx"))) { + printArrayTo(ps, index.cpMap, 0, index.cpMap.length); + } } } @@ -828,26 +828,27 @@ class PackageReader extends BandStructure { attr_definition_headers.readFrom(in); attr_definition_name.readFrom(in); attr_definition_layout.readFrom(in); - PrintStream dump = !optDumpBands ? null - : new PrintStream(getDumpStream(attr_definition_headers, ".def")); - for (int i = 0; i < numAttrDefs; i++) { - int header = attr_definition_headers.getByte(); - Utf8Entry name = (Utf8Entry) attr_definition_name.getRef(); - Utf8Entry layout = (Utf8Entry) attr_definition_layout.getRef(); - int ctype = (header & ADH_CONTEXT_MASK); - int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB; - Attribute.Layout def = new Attribute.Layout(ctype, - name.stringValue(), - layout.stringValue()); - // Check layout string for Java 6 extensions. - String pvLayout = def.layoutForPackageMajver(getPackageMajver()); - if (!pvLayout.equals(def.layout())) { - throw new IOException("Bad attribute layout in version 150 archive: "+def.layout()); + try (PrintStream dump = !optDumpBands ? null + : new PrintStream(getDumpStream(attr_definition_headers, ".def"))) + { + for (int i = 0; i < numAttrDefs; i++) { + int header = attr_definition_headers.getByte(); + Utf8Entry name = (Utf8Entry) attr_definition_name.getRef(); + Utf8Entry layout = (Utf8Entry) attr_definition_layout.getRef(); + int ctype = (header & ADH_CONTEXT_MASK); + int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB; + Attribute.Layout def = new Attribute.Layout(ctype, + name.stringValue(), + layout.stringValue()); + // Check layout string for Java 6 extensions. + String pvLayout = def.layoutForPackageMajver(getPackageMajver()); + if (!pvLayout.equals(def.layout())) { + throw new IOException("Bad attribute layout in version 150 archive: "+def.layout()); + } + this.setAttributeLayoutIndex(def, index); + if (dump != null) dump.println(index+" "+def); } - this.setAttributeLayoutIndex(def, index); - if (dump != null) dump.println(index+" "+def); } - if (dump != null) dump.close(); attr_definition_headers.doneDisbursing(); attr_definition_name.doneDisbursing(); attr_definition_layout.doneDisbursing(); diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java index f531fb7d999fe62dcb0288da284f98dab25cb23d..e2bad8904a10f92c37c0fcb071b8ce19dd0fdcab 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java @@ -458,9 +458,9 @@ class PackageWriter extends BandStructure { Utils.log.info("Writing "+cpMap.length+" "+ConstantPool.tagName(tag)+" entries..."); if (optDumpBands) { - PrintStream ps = new PrintStream(getDumpStream(index, ".idx")); - printArrayTo(ps, cpMap, 0, cpMap.length); - ps.close(); + try (PrintStream ps = new PrintStream(getDumpStream(index, ".idx"))) { + printArrayTo(ps, cpMap, 0, cpMap.length); + } } switch (tag) { @@ -923,33 +923,34 @@ class PackageWriter extends BandStructure { } }); attrDefsWritten = new Attribute.Layout[numAttrDefs]; - PrintStream dump = !optDumpBands ? null - : new PrintStream(getDumpStream(attr_definition_headers, ".def")); - int[] indexForDebug = Arrays.copyOf(attrIndexLimit, ATTR_CONTEXT_LIMIT); - for (int i = 0; i < defs.length; i++) { - int header = ((Integer)defs[i][0]).intValue(); - Attribute.Layout def = (Attribute.Layout) defs[i][1]; - attrDefsWritten[i] = def; - assert((header & ADH_CONTEXT_MASK) == def.ctype()); - attr_definition_headers.putByte(header); - attr_definition_name.putRef(ConstantPool.getUtf8Entry(def.name())); - String layout = def.layoutForPackageMajver(getPackageMajver()); - attr_definition_layout.putRef(ConstantPool.getUtf8Entry(layout)); - // Check that we are transmitting that correct attribute index: - boolean debug = false; - assert(debug = true); - if (debug) { - int hdrIndex = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB; - if (hdrIndex < 0) hdrIndex = indexForDebug[def.ctype()]++; - int realIndex = (attrIndexTable.get(def)).intValue(); - assert(hdrIndex == realIndex); - } - if (dump != null) { - int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB; - dump.println(index+" "+def); + try (PrintStream dump = !optDumpBands ? null + : new PrintStream(getDumpStream(attr_definition_headers, ".def"))) + { + int[] indexForDebug = Arrays.copyOf(attrIndexLimit, ATTR_CONTEXT_LIMIT); + for (int i = 0; i < defs.length; i++) { + int header = ((Integer)defs[i][0]).intValue(); + Attribute.Layout def = (Attribute.Layout) defs[i][1]; + attrDefsWritten[i] = def; + assert((header & ADH_CONTEXT_MASK) == def.ctype()); + attr_definition_headers.putByte(header); + attr_definition_name.putRef(ConstantPool.getUtf8Entry(def.name())); + String layout = def.layoutForPackageMajver(getPackageMajver()); + attr_definition_layout.putRef(ConstantPool.getUtf8Entry(layout)); + // Check that we are transmitting that correct attribute index: + boolean debug = false; + assert(debug = true); + if (debug) { + int hdrIndex = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB; + if (hdrIndex < 0) hdrIndex = indexForDebug[def.ctype()]++; + int realIndex = (attrIndexTable.get(def)).intValue(); + assert(hdrIndex == realIndex); + } + if (dump != null) { + int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB; + dump.println(index+" "+def); + } } } - if (dump != null) dump.close(); } void writeAttrCounts() throws IOException { diff --git a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java index afed905b274c509572a31dcb612a9271c7bce20c..9656e55c9dea21d78dc69da588ce2d433c4e0d25 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java @@ -122,26 +122,23 @@ final class PropMap implements SortedMap { // Define certain attribute layouts by default. // Do this after the previous props are put in place, // to allow override if necessary. - InputStream propStr = null; - try { - String propFile = "intrinsic.properties"; - propStr = PackerImpl.class.getResourceAsStream(propFile); - props.load(new BufferedInputStream(propStr)); - for (Map.Entry e : props.entrySet()) { - String key = (String) e.getKey(); - String val = (String) e.getValue(); - if (key.startsWith("attribute.")) { - e.setValue(Attribute.normalizeLayoutString(val)); - } + String propFile = "intrinsic.properties"; + + try (InputStream propStr = PackerImpl.class.getResourceAsStream(propFile)) { + if (propStr == null) { + throw new RuntimeException(propFile + " cannot be loaded"); } + props.load(propStr); } catch (IOException ee) { throw new RuntimeException(ee); - } finally { - try { - if (propStr != null) { - propStr.close(); - } - } catch (IOException ignore) {} + } + + for (Map.Entry e : props.entrySet()) { + String key = (String) e.getKey(); + String val = (String) e.getValue(); + if (key.startsWith("attribute.")) { + e.setValue(Attribute.normalizeLayoutString(val)); + } } defaultProps = (new HashMap<>(props)); // shrink to fit diff --git a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java index 06bec826ff9def504e9d977bab48592d40ca92c9..377705ccb259366b99eea5871b1dd35ce2803dd9 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java +++ b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java @@ -161,8 +161,9 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker { } // Use the stream-based implementation. // %%% Reconsider if native unpacker learns to memory-map the file. - FileInputStream instr = new FileInputStream(in); - unpack(instr, out); + try (FileInputStream instr = new FileInputStream(in)) { + unpack(instr, out); + } if (props.getBoolean(Utils.UNPACK_REMOVE_PACKFILE)) { in.delete(); } diff --git a/src/share/classes/com/sun/java/util/jar/pack/Utils.java b/src/share/classes/com/sun/java/util/jar/pack/Utils.java index 4b5c4c87817a9698596c6490205897abec698174..7cf2cef00e53d5e9f62225ad6f61ed27481812f6 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Utils.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Utils.java @@ -268,18 +268,18 @@ class Utils { // 4947205 : Peformance is slow when using pack-effort=0 out = new BufferedOutputStream(out); out = new NonCloser(out); // protect from JarOutputStream.close() - JarOutputStream jout = new JarOutputStream(out); - copyJarFile(in, jout); - jout.close(); + try (JarOutputStream jout = new JarOutputStream(out)) { + copyJarFile(in, jout); + } } static void copyJarFile(JarFile in, OutputStream out) throws IOException { // 4947205 : Peformance is slow when using pack-effort=0 out = new BufferedOutputStream(out); out = new NonCloser(out); // protect from JarOutputStream.close() - JarOutputStream jout = new JarOutputStream(out); - copyJarFile(in, jout); - jout.close(); + try (JarOutputStream jout = new JarOutputStream(out)) { + copyJarFile(in, jout); + } } // Wrapper to prevent closing of client-supplied stream. static private diff --git a/src/share/classes/java/nio/file/Files.java b/src/share/classes/java/nio/file/Files.java index 3e19ca3e515dac1ad4ed8fcb7fe64ad53b628402..8b7af13544ce6f9914c873215e636f9aa901ea8c 100644 --- a/src/share/classes/java/nio/file/Files.java +++ b/src/share/classes/java/nio/file/Files.java @@ -1712,10 +1712,10 @@ public final class Files { * @return the {@code path} parameter * * @throws UnsupportedOperationException - * if the attribute view is not available or it does not support - * updating the attribute + * if the attribute view is not available * @throws IllegalArgumentException - * if the attribute value is of the correct type but has an + * if the attribute name is not specified, or is not recognized, or + * the attribute value is of the correct type but has an * inappropriate value * @throws ClassCastException * if the attribute value is not of the expected type or is a @@ -1776,9 +1776,12 @@ public final class Files { * @param options * options indicating how symbolic links are handled * - * @return the attribute value or {@code null} if the attribute view - * is not available or it does not support reading the attribute + * @return the attribute value * + * @throws UnsupportedOperationException + * if the attribute view is not available + * @throws IllegalArgumentException + * if the attribute name is not specified or is not recognized * @throws IOException * if an I/O error occurs * @throws SecurityException @@ -1794,8 +1797,9 @@ public final class Files { { // only one attribute should be read if (attribute.indexOf('*') >= 0 || attribute.indexOf(',') >= 0) - return null; + throw new IllegalArgumentException(attribute); Map map = readAttributes(path, attribute, options); + assert map.size() == 1; String name; int pos = attribute.indexOf(':'); if (pos == -1) { @@ -1868,9 +1872,14 @@ public final class Files { * @param options * options indicating how symbolic links are handled * - * @return a map of the attributes returned; may be empty. The map's keys - * are the attribute names, its values are the attribute values + * @return a map of the attributes returned; The map's keys are the + * attribute names, its values are the attribute values * + * @throws UnsupportedOperationException + * if the attribute view is not available + * @throws IllegalArgumentException + * if no attributes are specified or an unrecognized attributes is + * specified * @throws IOException * if an I/O error occurs * @throws SecurityException diff --git a/src/share/classes/java/nio/file/Path.java b/src/share/classes/java/nio/file/Path.java index 85436b01d9ae47eb3cc0c29d20de56c378b11f61..618f0226363a530da3e20d809e8c3527048b6544 100644 --- a/src/share/classes/java/nio/file/Path.java +++ b/src/share/classes/java/nio/file/Path.java @@ -228,6 +228,9 @@ public interface Path * not have a root component and the given path has a root component then * this path does not start with the given path. * + *

If the given path is associated with a different {@code FileSystem} + * to this path then {@code false} is returned. + * * @param other * the given path * @@ -270,6 +273,9 @@ public interface Path * does not have a root component and the given path has a root component * then this path does not end with the given path. * + *

If the given path is associated with a different {@code FileSystem} + * to this path then {@code false} is returned. + * * @param other * the given path * @@ -283,7 +289,10 @@ public interface Path * the given path string, in exactly the manner specified by the {@link * #endsWith(Path) endsWith(Path)} method. On UNIX for example, the path * "{@code foo/bar}" ends with "{@code foo/bar}" and "{@code bar}". It does - * not end with "{@code r}" or "{@code /bar}". + * not end with "{@code r}" or "{@code /bar}". Note that trailing separators + * are not taken into account, and so invoking this method on the {@code + * Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns + * {@code true}. * * @param other * the given path string @@ -724,12 +733,18 @@ public interface Path * provider, platform specific. This method does not access the file system * and neither file is required to exist. * + *

This method may not be used to compare paths that are associated + * with different file system providers. + * * @param other the path compared to this path. * * @return zero if the argument is {@link #equals equal} to this path, a * value less than zero if this path is lexicographically less than * the argument, or a value greater than zero if this path is * lexicographically greater than the argument + * + * @throws ClassCastException + * if the paths are associated with different providers */ @Override int compareTo(Path other); @@ -738,7 +753,7 @@ public interface Path * Tests this path for equality with the given object. * *

If the given object is not a Path, or is a Path associated with a - * different provider, then this method immediately returns {@code false}. + * different {@code FileSystem}, then this method returns {@code false}. * *

Whether or not two path are equal depends on the file system * implementation. In some cases the paths are compared without regard diff --git a/src/share/classes/java/nio/file/WatchKey.java b/src/share/classes/java/nio/file/WatchKey.java index 23897dba4543484875bd1d03d72e8f7a219c326d..83403e96a3bc468c439b9b22fe97d0617d8ebf06 100644 --- a/src/share/classes/java/nio/file/WatchKey.java +++ b/src/share/classes/java/nio/file/WatchKey.java @@ -146,5 +146,5 @@ public interface WatchKey { * * @return the object for which this watch key was created */ - //T watchable(); + Watchable watchable(); } diff --git a/src/share/classes/java/nio/file/attribute/FileTime.java b/src/share/classes/java/nio/file/attribute/FileTime.java index 6cac437cdcef92b42732c6ae8bbf3bfe026a50e0..4e77b0e0172bfb8fe0360a247fb66fa277edf03b 100644 --- a/src/share/classes/java/nio/file/attribute/FileTime.java +++ b/src/share/classes/java/nio/file/attribute/FileTime.java @@ -216,12 +216,14 @@ public final class FileTime * "2009-02-13T23:31:30Z"}, and {@code FileTime.fromMillis(1234567890123L).toString()} * yields {@code "2009-02-13T23:31:30.123Z"}. * - *

A {@code FileTime} is primarly intended to represent the value of a + *

A {@code FileTime} is primarily intended to represent the value of a * file's time stamp. Where used to represent extreme values, where * the year is less than "{@code 0001}" or greater than "{@code 9999}" then - * the year may be expanded to more than four digits and may be - * negative-signed. If more than four digits then leading zeros are not - * present. The year before "{@code 0001}" is "{@code -0001}". + * this method deviates from ISO 8601 in the same manner as the + * XML Schema + * language. That is, the year may be expanded to more than four digits + * and may be negative-signed. If more than four digits then leading zeros + * are not present. The year before "{@code 0001}" is "{@code -0001}". * * @return the string representation of this file time */ diff --git a/src/share/classes/java/nio/file/spi/FileSystemProvider.java b/src/share/classes/java/nio/file/spi/FileSystemProvider.java index ad285bd6ddb30dfb3414d626931a6413a9354e92..8d43fb937690137f33d37fa2f7c67d5c75c8303c 100644 --- a/src/share/classes/java/nio/file/spi/FileSystemProvider.java +++ b/src/share/classes/java/nio/file/spi/FileSystemProvider.java @@ -1037,6 +1037,11 @@ public abstract class FileSystemProvider { * @return a map of the attributes returned; may be empty. The map's keys * are the attribute names, its values are the attribute values * + * @throws UnsupportedOperationException + * if the attribute view is not available + * @throws IllegalArgumentException + * if no attributes are specified or an unrecognized attributes is + * specified * @throws IOException * If an I/O error occurs * @throws SecurityException @@ -1064,10 +1069,10 @@ public abstract class FileSystemProvider { * options indicating how symbolic links are handled * * @throws UnsupportedOperationException - * if the attribute view is not available or it does not support - * updating the attribute + * if the attribute view is not available * @throws IllegalArgumentException - * if the attribute value is of the correct type but has an + * if the attribute name is not specified, or is not recognized, or + * the attribute value is of the correct type but has an * inappropriate value * @throws ClassCastException * If the attribute value is not of the expected type or is a diff --git a/src/share/classes/sun/launcher/LauncherHelper.java b/src/share/classes/sun/launcher/LauncherHelper.java index ff71e8908b1bf3e253918cfb683d5ffea2d30f57..bd0b72e47abbcebe12b35e2ed65e6a048e92c45d 100644 --- a/src/share/classes/sun/launcher/LauncherHelper.java +++ b/src/share/classes/sun/launcher/LauncherHelper.java @@ -42,10 +42,12 @@ package sun.launcher; import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.math.BigDecimal; import java.math.RoundingMode; +import java.nio.charset.Charset; import java.util.ResourceBundle; import java.text.MessageFormat; import java.util.ArrayList; @@ -471,11 +473,11 @@ public enum LauncherHelper { } catch (ClassNotFoundException cnfe) { abort(ostream, cnfe, "java.launcher.cls.error1", cn); } - signatureDiagnostic(ostream, c); + getMainMethod(ostream, c); return c; } - static void signatureDiagnostic(PrintStream ostream, Class clazz) { + static Method getMainMethod(PrintStream ostream, Class clazz) { String classname = clazz.getName(); Method method = null; try { @@ -495,6 +497,31 @@ public enum LauncherHelper { if (method.getReturnType() != java.lang.Void.TYPE) { abort(ostream, null, "java.launcher.cls.error3", classname); } - return; + return method; + } + + private static final String encprop = "sun.jnu.encoding"; + private static String encoding = null; + private static boolean isCharsetSupported = false; + + /* + * converts a c or a byte array to a platform specific string, + * previously implemented as a native method in the launcher. + */ + static String makePlatformString(boolean printToStderr, byte[] inArray) { + final PrintStream ostream = (printToStderr) ? System.err : System.out; + if (encoding == null) { + encoding = System.getProperty(encprop); + isCharsetSupported = Charset.isSupported(encoding); + } + try { + String out = isCharsetSupported + ? new String(inArray, encoding) + : new String(inArray); + return out; + } catch (UnsupportedEncodingException uee) { + abort(ostream, uee, null); + } + return null; // keep the compiler happy } } diff --git a/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java b/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java index cd1e6c26b8d2d999e32d783d1c16a88f3c7fccc3..33eeb315f432db7a348b2ca9107b4df8baf49335 100644 --- a/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java +++ b/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java @@ -57,8 +57,8 @@ abstract class AbstractAclFileAttributeView setAcl((List)value); return; } - throw new UnsupportedOperationException("'" + name() + ":" + - attribute + "' not supported"); + throw new IllegalArgumentException("'" + name() + ":" + + attribute + "' not recognized"); } @Override @@ -81,6 +81,8 @@ abstract class AbstractAclFileAttributeView owner = true; continue; } + throw new IllegalArgumentException("'" + name() + ":" + + attribute + "' not recognized"); } Map result = new HashMap<>(2); if (acl) diff --git a/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java b/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java index 6383c08edf1a64de8ec63c09b54bf5b669e87a46..9fa04ee7f8e570e85f7fb1b86460e74f25549589 100644 --- a/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java +++ b/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java @@ -46,6 +46,18 @@ abstract class AbstractBasicFileAttributeView private static final String IS_SYMBOLIC_LINK_NAME = "isSymbolicLink"; private static final String IS_OTHER_NAME = "isOther"; + // the names of the basic attributes + static final Set basicAttributeNames = + Util.newSet(SIZE_NAME, + CREATION_TIME_NAME, + LAST_ACCESS_TIME_NAME, + LAST_MODIFIED_TIME_NAME, + FILE_KEY_NAME, + IS_DIRECTORY_NAME, + IS_REGULAR_FILE_NAME, + IS_SYMBOLIC_LINK_NAME, + IS_OTHER_NAME); + protected AbstractBasicFileAttributeView() { } @Override @@ -69,24 +81,26 @@ abstract class AbstractBasicFileAttributeView setTimes(null, null, (FileTime)value); return; } - throw new UnsupportedOperationException("'" + attribute + - "' is unknown or read-only attribute"); + throw new IllegalArgumentException("'" + name() + ":" + + attribute + "' not recognized"); } /** * Used to build a map of attribute name/values. */ static class AttributesBuilder { - private Set set = new HashSet<>(); + private Set names = new HashSet<>(); private Map map = new HashMap<>(); private boolean copyAll; - private AttributesBuilder(String[] attributes) { - for (String attribute: attributes) { - if (attribute.equals("*")) { + private AttributesBuilder(Set allowed, String[] requested) { + for (String name: requested) { + if (name.equals("*")) { copyAll = true; } else { - set.add(attribute); + if (!allowed.contains(name)) + throw new IllegalArgumentException("'" + name + "' not recognized"); + names.add(name); } } } @@ -94,21 +108,19 @@ abstract class AbstractBasicFileAttributeView /** * Creates builder to build up a map of the matching attributes */ - static AttributesBuilder create(String[] attributes) { - return new AttributesBuilder(attributes); + static AttributesBuilder create(Set allowed, String[] requested) { + return new AttributesBuilder(allowed, requested); } /** * Returns true if the attribute should be returned in the map */ - boolean match(String attribute) { - if (copyAll) - return true; - return set.contains(attribute); + boolean match(String name) { + return copyAll || names.contains(name); } - void add(String attribute, Object value) { - map.put(attribute, value); + void add(String name, Object value) { + map.put(name, value); } /** @@ -124,7 +136,7 @@ abstract class AbstractBasicFileAttributeView * Invoked by readAttributes or sub-classes to add all matching basic * attributes to the builder */ - final void addBasicAttributesToBuilder(BasicFileAttributes attrs, + final void addRequestedBasicAttributes(BasicFileAttributes attrs, AttributesBuilder builder) { if (builder.match(SIZE_NAME)) @@ -148,9 +160,12 @@ abstract class AbstractBasicFileAttributeView } @Override - public Map readAttributes(String[] attributes) throws IOException { - AttributesBuilder builder = AttributesBuilder.create(attributes); - addBasicAttributesToBuilder(readAttributes(), builder); + public Map readAttributes(String[] requested) + throws IOException + { + AttributesBuilder builder = + AttributesBuilder.create(basicAttributeNames, requested); + addRequestedBasicAttributes(readAttributes(), builder); return builder.unmodifiableMap(); } } diff --git a/src/share/classes/sun/nio/fs/AbstractFileSystemProvider.java b/src/share/classes/sun/nio/fs/AbstractFileSystemProvider.java index 95d1cb30931de80e6c470110b9b565d7a6a01edb..9e1dc6133ace9d080976640f3be55eabec0ea211 100644 --- a/src/share/classes/sun/nio/fs/AbstractFileSystemProvider.java +++ b/src/share/classes/sun/nio/fs/AbstractFileSystemProvider.java @@ -29,7 +29,6 @@ import java.nio.file.*; import java.nio.file.spi.FileSystemProvider; import java.io.IOException; import java.util.Map; -import java.util.Collections; /** * Base implementation class of FileSystemProvider @@ -72,6 +71,8 @@ abstract class AbstractFileSystemProvider extends FileSystemProvider { throws IOException { String[] s = split(attribute); + if (s[0].length() == 0) + throw new IllegalArgumentException(attribute); DynamicFileAttributeView view = getFileAttributeView(file, s[0], options); if (view == null) throw new UnsupportedOperationException("View '" + s[0] + "' not available"); @@ -83,9 +84,11 @@ abstract class AbstractFileSystemProvider extends FileSystemProvider { throws IOException { String[] s = split(attributes); + if (s[0].length() == 0) + throw new IllegalArgumentException(attributes); DynamicFileAttributeView view = getFileAttributeView(file, s[0], options); if (view == null) - return Collections.emptyMap(); + throw new UnsupportedOperationException("View '" + s[0] + "' not available"); return view.readAttributes(s[1].split(",")); } diff --git a/src/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java b/src/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java index cf36a09ff0a72c61c6db6225c0999a2f6866e087..8a4f975c4f4784ea174ef16537b135923407aaf3 100644 --- a/src/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java +++ b/src/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java @@ -59,22 +59,6 @@ abstract class AbstractUserDefinedFileAttributeView return "user"; } - private Object getAttribute(String attribute) throws IOException { - int size; - try { - size = size(attribute); - } catch (IOException e) { - // not found or some other I/O error - if (list().contains(attribute)) - throw e; - return null; - } - - byte[] buf = new byte[size]; - int n = read(attribute, ByteBuffer.wrap(buf)); - return (n == size) ? buf : Arrays.copyOf(buf, n); - } - @Override public final void setAttribute(String attribute, Object value) throws IOException @@ -94,12 +78,13 @@ abstract class AbstractUserDefinedFileAttributeView { // names of attributes to return List names = new ArrayList<>(); - for (String name: attributes) { if (name.equals("*")) { names = list(); break; } else { + if (name.length() == 0) + throw new IllegalArgumentException(); names.add(name); } } @@ -107,11 +92,12 @@ abstract class AbstractUserDefinedFileAttributeView // read each value and return in map Map result = new HashMap<>(); for (String name: names) { - Object value = getAttribute(name); - if (value != null) - result.put(name, value); + int size = size(name); + byte[] buf = new byte[size]; + int n = read(name, ByteBuffer.wrap(buf)); + byte[] value = (n == size) ? buf : Arrays.copyOf(buf, n); + result.put(name, value); } - return result; } } diff --git a/src/share/classes/sun/nio/fs/AbstractWatchKey.java b/src/share/classes/sun/nio/fs/AbstractWatchKey.java index 55234ba6528f690cca40eab80454f0c48df30a9b..f083f46313ac3d1107158d49d258243232e000c8 100644 --- a/src/share/classes/sun/nio/fs/AbstractWatchKey.java +++ b/src/share/classes/sun/nio/fs/AbstractWatchKey.java @@ -81,7 +81,8 @@ abstract class AbstractWatchKey implements WatchKey { /** * Return the original watchable (Path) */ - Path watchable() { + @Override + public Path watchable() { return dir; } diff --git a/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java b/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java index aae9bd318c114691b289b3067f6f1efa957ec1e0..5fcb21e264a6b74897ecd53b1d948376ff6843ec 100644 --- a/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java +++ b/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java @@ -63,10 +63,10 @@ final class FileOwnerAttributeViewImpl { if (attribute.equals(OWNER_NAME)) { setOwner((UserPrincipal)value); - return; + } else { + throw new IllegalArgumentException("'" + name() + ":" + + attribute + "' not recognized"); } - throw new UnsupportedOperationException("'" + name() + ":" + - attribute + "' not supported"); } @Override @@ -75,6 +75,9 @@ final class FileOwnerAttributeViewImpl for (String attribute: attributes) { if (attribute.equals("*") || attribute.equals(OWNER_NAME)) { result.put(OWNER_NAME, getOwner()); + } else { + throw new IllegalArgumentException("'" + name() + ":" + + attribute + "' not recognized"); } } return result; diff --git a/src/share/classes/sun/nio/fs/Util.java b/src/share/classes/sun/nio/fs/Util.java index 6a289058e4b4647fbe10675e237fe2af8500adaa..7628701116964fdd8980eb4ee9acfdfd53111bfb 100644 --- a/src/share/classes/sun/nio/fs/Util.java +++ b/src/share/classes/sun/nio/fs/Util.java @@ -25,6 +25,8 @@ package sun.nio.fs; +import java.util.*; + /** * Utility methods */ @@ -54,6 +56,28 @@ class Util { } result[n] = s.substring(last, s.length()); return result; + } + + /** + * Returns a Set containing the given elements. + */ + static Set newSet(E... elements) { + HashSet set = new HashSet<>(); + for (E e: elements) { + set.add(e); + } + return set; + } + /** + * Returns a Set containing all the elements of the given Set plus + * the given elements. + */ + static Set newSet(Set other, E... elements) { + HashSet set = new HashSet<>(other); + for (E e: elements) { + set.add(e); + } + return set; } } diff --git a/src/share/sample/nio/file/WatchDir.java b/src/share/sample/nio/file/WatchDir.java index 33c15dd0c042fb003d6e7447b11819d68028718a..796b728206bcdb22b4bfe4fe62a67a6e8911b412 100644 --- a/src/share/sample/nio/file/WatchDir.java +++ b/src/share/sample/nio/file/WatchDir.java @@ -33,8 +33,7 @@ import java.nio.file.*; import static java.nio.file.StandardWatchEventKind.*; import static java.nio.file.LinkOption.*; import java.nio.file.attribute.*; -import java.io.*; -import java.util.*; +import java.io.IOException; /** * Example to watch a directory (or tree) for changes to files. @@ -43,9 +42,9 @@ import java.util.*; public class WatchDir { private final WatchService watcher; - private final Map keys; private final boolean recursive; private boolean trace = false; + private int count; @SuppressWarnings("unchecked") static WatchEvent cast(WatchEvent event) { @@ -57,17 +56,9 @@ public class WatchDir { */ private void register(Path dir) throws IOException { WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY); - if (trace) { - Path prev = keys.get(key); - if (prev == null) { - System.out.format("register: %s\n", dir); - } else { - if (!dir.equals(prev)) { - System.out.format("update: %s -> %s\n", prev, dir); - } - } - } - keys.put(key, dir); + count++; + if (trace) + System.out.format("register: %s\n", dir); } /** @@ -92,7 +83,6 @@ public class WatchDir { */ WatchDir(Path dir, boolean recursive) throws IOException { this.watcher = FileSystems.getDefault().newWatchService(); - this.keys = new HashMap(); this.recursive = recursive; if (recursive) { @@ -121,12 +111,6 @@ public class WatchDir { return; } - Path dir = keys.get(key); - if (dir == null) { - System.err.println("WatchKey not recognized!!"); - continue; - } - for (WatchEvent event: key.pollEvents()) { WatchEvent.Kind kind = event.kind(); @@ -138,7 +122,7 @@ public class WatchDir { // Context for directory entry event is the file name of entry WatchEvent ev = cast(event); Path name = ev.context(); - Path child = dir.resolve(name); + Path child = ((Path)key.watchable()).resolve(name); // print out event System.out.format("%s: %s\n", event.kind().name(), child); @@ -156,15 +140,13 @@ public class WatchDir { } } - // reset key and remove from set if directory no longer accessible + // reset key boolean valid = key.reset(); if (!valid) { - keys.remove(key); - - // all directories are inaccessible - if (keys.isEmpty()) { + // directory no longer accessible + count--; + if (count == 0) break; - } } } } diff --git a/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java b/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java index 4499a08924c51d77479a9352a8811d292d714bcc..af0dc1036bdb5818222ffe9397701d6253aa03e4 100644 --- a/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java +++ b/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java @@ -27,6 +27,7 @@ package sun.nio.fs; import java.nio.file.attribute.*; import java.util.Map; +import java.util.Set; import java.io.IOException; import sun.misc.Unsafe; @@ -57,6 +58,10 @@ class LinuxDosFileAttributeView private static final int DOS_XATTR_SYSTEM = 0x04; private static final int DOS_XATTR_ARCHIVE = 0x20; + // the names of the DOS attributes (includes basic) + private static final Set dosAttributeNames = + Util.newSet(basicAttributeNames, READONLY_NAME, ARCHIVE_NAME, SYSTEM_NAME, HIDDEN_NAME); + LinuxDosFileAttributeView(UnixPath file, boolean followLinks) { super(file, followLinks); } @@ -93,9 +98,10 @@ class LinuxDosFileAttributeView public Map readAttributes(String[] attributes) throws IOException { - AttributesBuilder builder = AttributesBuilder.create(attributes); + AttributesBuilder builder = + AttributesBuilder.create(dosAttributeNames, attributes); DosFileAttributes attrs = readAttributes(); - addBasicAttributesToBuilder(attrs, builder); + addRequestedBasicAttributes(attrs, builder); if (builder.match(READONLY_NAME)) builder.add(READONLY_NAME, attrs.isReadOnly()); if (builder.match(ARCHIVE_NAME)) diff --git a/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java b/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java index b8b8c30f936e80a3114ce23aa0b69041cd33a8b2..18309cb445079109ca1521c867f4ec30dc1b6f1a 100644 --- a/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java +++ b/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java @@ -28,8 +28,6 @@ package sun.nio.fs; import java.nio.file.*; import java.io.IOException; import java.util.*; -import java.security.AccessController; -import sun.security.action.GetPropertyAction; import static sun.nio.fs.LinuxNativeDispatcher.*; /** @@ -37,42 +35,16 @@ import static sun.nio.fs.LinuxNativeDispatcher.*; */ class LinuxFileSystem extends UnixFileSystem { - private final boolean hasInotify; - LinuxFileSystem(UnixFileSystemProvider provider, String dir) { super(provider, dir); - - // assume X.Y[-Z] format - String osversion = AccessController - .doPrivileged(new GetPropertyAction("os.version")); - String[] vers = Util.split(osversion, '.'); - assert vers.length >= 2; - - int majorVersion = Integer.parseInt(vers[0]); - int minorVersion = Integer.parseInt(vers[1]); - int microVersion = 0; - if (vers.length > 2) { - String[] microVers = Util.split(vers[2], '-'); - microVersion = (microVers.length > 0) ? - Integer.parseInt(microVers[0]) : 0; - } - - // inotify available since 2.6.13 - this.hasInotify = ((majorVersion > 2) || - (majorVersion == 2 && minorVersion > 6) || - ((majorVersion == 2) && (minorVersion == 6) && (microVersion >= 13))); } @Override public WatchService newWatchService() throws IOException { - if (hasInotify) { - return new LinuxWatchService(this); - } else { - // use polling implementation on older kernels - return new PollingWatchService(); - } + // assume 2.6.13 or newer + return new LinuxWatchService(this); } diff --git a/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java b/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java index c21a17707a8e446fead460f4e12a7722d4a9f995..ad0a2a00d12597e6fc9466b9c5eaccb13b08d3dd 100644 --- a/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java +++ b/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java @@ -123,6 +123,10 @@ class UnixFileAttributeViews { private static final String OWNER_NAME = "owner"; private static final String GROUP_NAME = "group"; + // the names of the posix attributes (incudes basic) + static final Set posixAttributeNames = + Util.newSet(basicAttributeNames, PERMISSIONS_NAME, OWNER_NAME, GROUP_NAME); + Posix(UnixPath file, boolean followLinks) { super(file, followLinks); } @@ -172,9 +176,10 @@ class UnixFileAttributeViews { * Invoked by readAttributes or sub-classes to add all matching posix * attributes to the builder */ - final void addPosixAttributesToBuilder(PosixFileAttributes attrs, + final void addRequestedPosixAttributes(PosixFileAttributes attrs, AttributesBuilder builder) { + addRequestedBasicAttributes(attrs, builder); if (builder.match(PERMISSIONS_NAME)) builder.add(PERMISSIONS_NAME, attrs.permissions()); if (builder.match(OWNER_NAME)) @@ -184,13 +189,13 @@ class UnixFileAttributeViews { } @Override - public Map readAttributes(String[] attributes) + public Map readAttributes(String[] requested) throws IOException { - AttributesBuilder builder = AttributesBuilder.create(attributes); + AttributesBuilder builder = + AttributesBuilder.create(posixAttributeNames, requested); PosixFileAttributes attrs = readAttributes(); - addBasicAttributesToBuilder(attrs, builder); - addPosixAttributesToBuilder(attrs, builder); + addRequestedPosixAttributes(attrs, builder); return builder.unmodifiableMap(); } @@ -287,6 +292,12 @@ class UnixFileAttributeViews { private static final String GID_NAME = "gid"; private static final String CTIME_NAME = "ctime"; + // the names of the unix attributes (including posix) + static final Set unixAttributeNames = + Util.newSet(posixAttributeNames, + MODE_NAME, INO_NAME, DEV_NAME, RDEV_NAME, + NLINK_NAME, UID_NAME, GID_NAME, CTIME_NAME); + Unix(UnixPath file, boolean followLinks) { super(file, followLinks); } @@ -316,13 +327,13 @@ class UnixFileAttributeViews { } @Override - public Map readAttributes(String[] attributes) + public Map readAttributes(String[] requested) throws IOException { - AttributesBuilder builder = AttributesBuilder.create(attributes); + AttributesBuilder builder = + AttributesBuilder.create(unixAttributeNames, requested); UnixFileAttributes attrs = readAttributes(); - addBasicAttributesToBuilder(attrs, builder); - addPosixAttributesToBuilder(attrs, builder); + addRequestedPosixAttributes(attrs, builder); if (builder.match(MODE_NAME)) builder.add(MODE_NAME, attrs.mode()); if (builder.match(INO_NAME)) diff --git a/src/solaris/classes/sun/nio/fs/UnixPath.java b/src/solaris/classes/sun/nio/fs/UnixPath.java index 9ec49b8d37a7131d42a6e8e459f598cdd3d3dfcb..b392b56b7e92c2c3839baec5c7184548ab4e5255 100644 --- a/src/solaris/classes/sun/nio/fs/UnixPath.java +++ b/src/solaris/classes/sun/nio/fs/UnixPath.java @@ -606,7 +606,9 @@ class UnixPath @Override public boolean startsWith(Path other) { - UnixPath that = toUnixPath(other); + if (!(Objects.requireNonNull(other) instanceof UnixPath)) + return false; + UnixPath that = (UnixPath)other; // other path is longer if (that.path.length > path.length) @@ -655,7 +657,9 @@ class UnixPath @Override public boolean endsWith(Path other) { - UnixPath that = toUnixPath(other); + if (!(Objects.requireNonNull(other) instanceof UnixPath)) + return false; + UnixPath that = (UnixPath)other; int thisLen = path.length; int thatLen = that.path.length; diff --git a/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java b/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java index 8a81b87a0abdfa9c8b0236b4ae6021057944155e..67e5be670e09049b9b4caf2527423195b75eba66 100644 --- a/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java +++ b/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java @@ -157,6 +157,11 @@ class WindowsFileAttributeViews { private static final String HIDDEN_NAME = "hidden"; private static final String ATTRIBUTES_NAME = "attributes"; + // the names of the DOS attribtues (includes basic) + static final Set dosAttributeNames = + Util.newSet(basicAttributeNames, + READONLY_NAME, ARCHIVE_NAME, SYSTEM_NAME, HIDDEN_NAME, ATTRIBUTES_NAME); + Dos(WindowsPath file, boolean followLinks) { super(file, followLinks); } @@ -193,9 +198,10 @@ class WindowsFileAttributeViews { public Map readAttributes(String[] attributes) throws IOException { - AttributesBuilder builder = AttributesBuilder.create(attributes); + AttributesBuilder builder = + AttributesBuilder.create(dosAttributeNames, attributes); WindowsFileAttributes attrs = readAttributes(); - addBasicAttributesToBuilder(attrs, builder); + addRequestedBasicAttributes(attrs, builder); if (builder.match(READONLY_NAME)) builder.add(READONLY_NAME, attrs.isReadOnly()); if (builder.match(ARCHIVE_NAME)) diff --git a/src/windows/classes/sun/nio/fs/WindowsPath.java b/src/windows/classes/sun/nio/fs/WindowsPath.java index 26c2b26ce8e6c08200f587c520a0497137275115..eb35de8167e554d3dbc649bf1c84395fd2497ff3 100644 --- a/src/windows/classes/sun/nio/fs/WindowsPath.java +++ b/src/windows/classes/sun/nio/fs/WindowsPath.java @@ -646,7 +646,9 @@ class WindowsPath extends AbstractPath { @Override public boolean startsWith(Path obj) { - WindowsPath other = toWindowsPath(obj); + if (!(Objects.requireNonNull(obj) instanceof WindowsPath)) + return false; + WindowsPath other = (WindowsPath)obj; // if this path has a root component the given path's root must match if (!this.root.equalsIgnoreCase(other.root)) { @@ -675,7 +677,9 @@ class WindowsPath extends AbstractPath { @Override public boolean endsWith(Path obj) { - WindowsPath other = toWindowsPath(obj); + if (!(Objects.requireNonNull(obj) instanceof WindowsPath)) + return false; + WindowsPath other = (WindowsPath)obj; // other path is longer if (other.path.length() > this.path.length()) { diff --git a/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c b/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c index 07b136aba2d717b9bd1cb09185e4c6fbe2340188..6086ddf30f0b7befcb6e377b7e0b77ee7173137c 100644 --- a/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c +++ b/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, 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 @@ -173,24 +173,45 @@ JNIEXPORT jbyteArray JNICALL Java_sun_tools_attach_WindowsVirtualMachine_generat JNIEXPORT jlong JNICALL Java_sun_tools_attach_WindowsVirtualMachine_openProcess (JNIEnv *env, jclass cls, jint pid) { - HANDLE hProcess; + HANDLE hProcess = NULL; - /* - * Attempt to open process. If it fails then we try to enable the - * SE_DEBUG_NAME privilege and retry. - */ - hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); - if (hProcess == NULL && GetLastError() == ERROR_ACCESS_DENIED) { - hProcess = doPrivilegedOpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); + if (pid == (jint) GetCurrentProcessId()) { + /* process is attaching to itself; get a pseudo handle instead */ + hProcess = GetCurrentProcess(); + /* duplicate the pseudo handle so it can be used in more contexts */ + if (DuplicateHandle(hProcess, hProcess, hProcess, &hProcess, + PROCESS_ALL_ACCESS, FALSE, 0) == 0) { + /* + * Could not duplicate the handle which isn't a good sign, + * but we'll try again with OpenProcess() below. + */ + hProcess = NULL; + } } if (hProcess == NULL) { - if (GetLastError() == ERROR_INVALID_PARAMETER) { - JNU_ThrowIOException(env, "no such process"); - } else { - JNU_ThrowIOExceptionWithLastError(env, "OpenProcess failed"); + /* + * Attempt to open process. If it fails then we try to enable the + * SE_DEBUG_NAME privilege and retry. + */ + hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); + if (hProcess == NULL && GetLastError() == ERROR_ACCESS_DENIED) { + hProcess = doPrivilegedOpenProcess(PROCESS_ALL_ACCESS, FALSE, + (DWORD)pid); + } + + if (hProcess == NULL) { + if (GetLastError() == ERROR_INVALID_PARAMETER) { + JNU_ThrowIOException(env, "no such process"); + } else { + char err_mesg[255]; + /* include the last error in the default detail message */ + sprintf(err_mesg, "OpenProcess(pid=%d) failed; LastError=0x%x", + (int)pid, (int)GetLastError()); + JNU_ThrowIOExceptionWithLastError(env, err_mesg); + } + return (jlong)0; } - return (jlong)0; } /* diff --git a/test/java/nio/file/Files/FileAttributes.java b/test/java/nio/file/Files/FileAttributes.java index bd799dc6b1e71fcdc1d1c569c2441f530e7923b8..d8aea7fe3bae96b3dd3851ec03e05ab350b4d6c0 100644 --- a/test/java/nio/file/Files/FileAttributes.java +++ b/test/java/nio/file/Files/FileAttributes.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 6838333 + * @bug 4313887 6838333 7017446 * @summary Unit test for java.nio.file.Files * @library .. */ @@ -94,12 +94,6 @@ public class FileAttributes { assertTrue(map.size() == 2); checkEqual(attrs.size(), map.get("size")); checkEqual(attrs.lastModifiedTime(), map.get("lastModifiedTime")); - - map = Files.readAttributes(file, - "basic:lastModifiedTime,lastAccessTime,ShouldNotExist"); - assertTrue(map.size() == 2); - checkEqual(attrs.lastModifiedTime(), map.get("lastModifiedTime")); - checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime")); } // Exercise getAttribute/setAttribute/readAttributes on posix attributes @@ -132,7 +126,7 @@ public class FileAttributes { assertTrue(map.size() >= 12); checkEqual(attrs.permissions(), map.get("permissions")); // check one - map = Files.readAttributes(file, "posix:size,owner,ShouldNotExist"); + map = Files.readAttributes(file, "posix:size,owner"); assertTrue(map.size() == 2); checkEqual(attrs.size(), map.get("size")); checkEqual(attrs.owner(), map.get("owner")); @@ -155,7 +149,7 @@ public class FileAttributes { map = Files.readAttributes(file, "unix:*"); assertTrue(map.size() >= 20); - map = Files.readAttributes(file, "unix:size,uid,gid,ShouldNotExist"); + map = Files.readAttributes(file, "unix:size,uid,gid"); assertTrue(map.size() == 3); checkEqual(map.get("size"), Files.readAttributes(file, BasicFileAttributes.class).size()); @@ -206,14 +200,65 @@ public class FileAttributes { assertTrue(map.size() >= 13); checkEqual(attrs.isReadOnly(), map.get("readonly")); // check one - map = Files.readAttributes(file, "dos:size,hidden,ShouldNotExist"); + map = Files.readAttributes(file, "dos:size,hidden"); assertTrue(map.size() == 2); checkEqual(attrs.size(), map.get("size")); checkEqual(attrs.isHidden(), map.get("hidden")); } + static void checkBadSet(Path file, String attribute, Object value) + throws IOException + { + try { + Files.setAttribute(file, attribute, 0); + throw new RuntimeException("IllegalArgumentException expected"); + } catch (IllegalArgumentException ignore) { } + } + + static void checkBadGet(Path file, String attribute) throws IOException { + try { + Files.getAttribute(file, attribute); + throw new RuntimeException("IllegalArgumentException expected"); + } catch (IllegalArgumentException ignore) { } + } + + static void checkBadRead(Path file, String attribute) throws IOException { + try { + Files.readAttributes(file, attribute); + throw new RuntimeException("IllegalArgumentException expected"); + } catch (IllegalArgumentException ignore) { } + } + static void miscTests(Path file) throws IOException { - // NPE tests + // unsupported views + try { + Files.setAttribute(file, "foo:bar", 0); + throw new RuntimeException("UnsupportedOperationException expected"); + } catch (UnsupportedOperationException ignore) { } + try { + Files.getAttribute(file, "foo:bar"); + throw new RuntimeException("UnsupportedOperationException expected"); + } catch (UnsupportedOperationException ignore) { } + try { + Files.readAttributes(file, "foo:*"); + throw new RuntimeException("UnsupportedOperationException expected"); + } catch (UnsupportedOperationException ignore) { } + + // bad args + checkBadSet(file, "", 0); + checkBadSet(file, "basic:", 0); + checkBadSet(file, "basic:foobar", 0); + checkBadGet(file, ""); + checkBadGet(file, "basic:"); + checkBadGet(file, "basic:foobar"); + checkBadGet(file, "basic:size,lastModifiedTime"); + checkBadGet(file, "basic:*"); + checkBadRead(file, ""); + checkBadRead(file, "basic:"); + checkBadRead(file, "basic:foobar"); + checkBadRead(file, "basic:size,foobar"); + + // nulls try { Files.getAttribute(file, null); throw new RuntimeException("NullPointerException expected"); diff --git a/test/java/nio/file/WatchService/Basic.java b/test/java/nio/file/WatchService/Basic.java index 2869a519f376961c9d9a15a0dbe807f4d510d542..1b4c526dbd8c2a3da554a69e5f9b8e104610b765 100644 --- a/test/java/nio/file/WatchService/Basic.java +++ b/test/java/nio/file/WatchService/Basic.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 6838333 + * @bug 4313887 6838333 7017446 * @summary Unit test for java.nio.file.WatchService * @library .. * @run main/timeout=120 Basic @@ -44,6 +44,8 @@ public class Basic { static void checkKey(WatchKey key, Path dir) { if (!key.isValid()) throw new RuntimeException("Key is not valid"); + if (key.watchable() != dir) + throw new RuntimeException("Unexpected watchable"); } static void takeExpectedKey(WatchService watcher, WatchKey expected) { diff --git a/test/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java b/test/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java index a6af419223496809e1fd6aa24725779367232203..c8c07b4d8e4b951c3460ca4043c7d9f506956d51 100644 --- a/test/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java +++ b/test/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java @@ -141,9 +141,6 @@ public class Basic { map = Files.readAttributes(file, "user:*"); if (!Arrays.equals(valueAsBytes, (byte[])map.get(ATTR_NAME))) throw new RuntimeException("Unexpected attribute value"); - map = Files.readAttributes(file, "user:DoesNotExist"); - if (!map.isEmpty()) - throw new RuntimeException("Map expected to be empty"); } static void miscTests(final Path file) throws IOException {