From 961783d9540609ca22df320493996d747e95af9e Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Feb 2014 14:07:55 +0000 Subject: [PATCH 01/18] 8034776: Remove sun.misc.Service Reviewed-by: sundar, lancea, chegar --- .../javax/imageio/spi/ServiceRegistry.java | 9 - .../classes/javax/sound/midi/MidiSystem.java | 2 +- .../javax/sound/sampled/AudioSystem.java | 2 +- jdk/src/share/classes/sun/misc/Service.java | 434 ------------------ .../sun/misc/ServiceConfigurationError.java | 62 --- .../misc/JarIndex/metaInfFilenames/Basic.java | 63 +-- 6 files changed, 7 insertions(+), 565 deletions(-) delete mode 100644 jdk/src/share/classes/sun/misc/Service.java delete mode 100644 jdk/src/share/classes/sun/misc/ServiceConfigurationError.java diff --git a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java index 3f4338d7db9..a3fc54816a2 100644 --- a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java +++ b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java @@ -123,15 +123,6 @@ public class ServiceRegistry { } } - // The following two methods expose functionality from - // sun.misc.Service. If that class is made public, they may be - // removed. - // - // The sun.misc.ServiceConfigurationError class may also be - // exposed, in which case the references to 'an - // Error' below should be changed to 'a - // ServiceConfigurationError'. - /** * Searches for implementations of a particular service class * using the given class loader. diff --git a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java index d0eab92865e..c661e23304d 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java @@ -1475,7 +1475,7 @@ public class MidiSystem { /** * Obtains the set of services currently installed on the system - * using sun.misc.Service, the SPI mechanism in 1.3. + * using the SPI mechanism in 1.3. * @return a List of instances of providers for the requested service. * If no providers are available, a List of length 0 will be returned. */ diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java index 17c0f26d6fb..235ed234276 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java @@ -1622,7 +1622,7 @@ public class AudioSystem { /** * Obtains the set of services currently installed on the system - * using sun.misc.Service, the SPI mechanism in 1.3. + * using the SPI mechanism in 1.3. * @return a List of instances of providers for the requested service. * If no providers are available, a vector of length 0 will be returned. */ diff --git a/jdk/src/share/classes/sun/misc/Service.java b/jdk/src/share/classes/sun/misc/Service.java deleted file mode 100644 index e00077fec44..00000000000 --- a/jdk/src/share/classes/sun/misc/Service.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (c) 1999, 2012, 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 sun.misc; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.TreeSet; - - -/** - * A simple service-provider lookup mechanism. A service is a - * well-known set of interfaces and (usually abstract) classes. A service - * provider is a specific implementation of a service. The classes in a - * provider typically implement the interfaces and subclass the classes defined - * in the service itself. Service providers may be installed in an - * implementation of the Java platform in the form of extensions, that is, jar - * files placed into any of the usual extension directories. Providers may - * also be made available by adding them to the applet or application class - * path or by some other platform-specific means. - * - *

In this lookup mechanism a service is represented by an interface or an - * abstract class. (A concrete class may be used, but this is not - * recommended.) A provider of a given service contains one or more concrete - * classes that extend this service class with data and code specific to - * the provider. This provider class will typically not be the entire - * provider itself but rather a proxy that contains enough information to - * decide whether the provider is able to satisfy a particular request together - * with code that can create the actual provider on demand. The details of - * provider classes tend to be highly service-specific; no single class or - * interface could possibly unify them, so no such class has been defined. The - * only requirement enforced here is that provider classes must have a - * zero-argument constructor so that they may be instantiated during lookup. - * - *

A service provider identifies itself by placing a provider-configuration - * file in the resource directory META-INF/services. The file's name - * should consist of the fully-qualified name of the abstract service class. - * The file should contain a list of fully-qualified concrete provider-class - * names, one per line. Space and tab characters surrounding each name, as - * well as blank lines, are ignored. The comment character is '#' - * (0x23); on each line all characters following the first comment - * character are ignored. The file must be encoded in UTF-8. - * - *

If a particular concrete provider class is named in more than one - * configuration file, or is named in the same configuration file more than - * once, then the duplicates will be ignored. The configuration file naming a - * particular provider need not be in the same jar file or other distribution - * unit as the provider itself. The provider must be accessible from the same - * class loader that was initially queried to locate the configuration file; - * note that this is not necessarily the class loader that found the file. - * - *

Example: Suppose we have a service class named - * java.io.spi.CharCodec. It has two abstract methods: - * - *

- *   public abstract CharEncoder getEncoder(String encodingName);
- *   public abstract CharDecoder getDecoder(String encodingName);
- * 
- * - * Each method returns an appropriate object or null if it cannot - * translate the given encoding. Typical CharCodec providers will - * support more than one encoding. - * - *

If sun.io.StandardCodec is a provider of the CharCodec - * service then its jar file would contain the file - * META-INF/services/java.io.spi.CharCodec. This file would contain - * the single line: - * - *

- *   sun.io.StandardCodec    # Standard codecs for the platform
- * 
- * - * To locate an encoder for a given encoding name, the internal I/O code would - * do something like this: - * - *
- *   CharEncoder getEncoder(String encodingName) {
- *       Iterator ps = Service.providers(CharCodec.class);
- *       while (ps.hasNext()) {
- *           CharCodec cc = (CharCodec)ps.next();
- *           CharEncoder ce = cc.getEncoder(encodingName);
- *           if (ce != null)
- *               return ce;
- *       }
- *       return null;
- *   }
- * 
- * - * The provider-lookup mechanism always executes in the security context of the - * caller. Trusted system code should typically invoke the methods in this - * class from within a privileged security context. - * - * @author Mark Reinhold - * @since 1.3 - */ - -public final class Service { - - private static final String prefix = "META-INF/services/"; - - private Service() { } - - private static void fail(Class service, String msg, Throwable cause) - throws ServiceConfigurationError - { - ServiceConfigurationError sce - = new ServiceConfigurationError(service.getName() + ": " + msg); - sce.initCause(cause); - throw sce; - } - - private static void fail(Class service, String msg) - throws ServiceConfigurationError - { - throw new ServiceConfigurationError(service.getName() + ": " + msg); - } - - private static void fail(Class service, URL u, int line, String msg) - throws ServiceConfigurationError - { - fail(service, u + ":" + line + ": " + msg); - } - - /** - * Parse a single line from the given configuration file, adding the name - * on the line to both the names list and the returned set iff the name is - * not already a member of the returned set. - */ - private static int parseLine(Class service, URL u, BufferedReader r, int lc, - List names, Set returned) - throws IOException, ServiceConfigurationError - { - String ln = r.readLine(); - if (ln == null) { - return -1; - } - int ci = ln.indexOf('#'); - if (ci >= 0) ln = ln.substring(0, ci); - ln = ln.trim(); - int n = ln.length(); - if (n != 0) { - if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0)) - fail(service, u, lc, "Illegal configuration-file syntax"); - int cp = ln.codePointAt(0); - if (!Character.isJavaIdentifierStart(cp)) - fail(service, u, lc, "Illegal provider-class name: " + ln); - for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) { - cp = ln.codePointAt(i); - if (!Character.isJavaIdentifierPart(cp) && (cp != '.')) - fail(service, u, lc, "Illegal provider-class name: " + ln); - } - if (!returned.contains(ln)) { - names.add(ln); - returned.add(ln); - } - } - return lc + 1; - } - - /** - * Parse the content of the given URL as a provider-configuration file. - * - * @param service - * The service class for which providers are being sought; - * used to construct error detail strings - * - * @param url - * The URL naming the configuration file to be parsed - * - * @param returned - * A Set containing the names of provider classes that have already - * been returned. This set will be updated to contain the names - * that will be yielded from the returned Iterator. - * - * @return A (possibly empty) Iterator that will yield the - * provider-class names in the given configuration file that are - * not yet members of the returned set - * - * @throws ServiceConfigurationError - * If an I/O error occurs while reading from the given URL, or - * if a configuration-file format error is detected - */ - private static Iterator parse(Class service, URL u, Set returned) - throws ServiceConfigurationError - { - InputStream in = null; - BufferedReader r = null; - ArrayList names = new ArrayList<>(); - try { - in = u.openStream(); - r = new BufferedReader(new InputStreamReader(in, "utf-8")); - int lc = 1; - while ((lc = parseLine(service, u, r, lc, names, returned)) >= 0); - } catch (IOException x) { - fail(service, ": " + x); - } finally { - try { - if (r != null) r.close(); - if (in != null) in.close(); - } catch (IOException y) { - fail(service, ": " + y); - } - } - return names.iterator(); - } - - - /** - * Private inner class implementing fully-lazy provider lookup - */ - private static class LazyIterator implements Iterator { - - Class service; - ClassLoader loader; - Enumeration configs = null; - Iterator pending = null; - Set returned = new TreeSet<>(); - String nextName = null; - - private LazyIterator(Class service, ClassLoader loader) { - this.service = service; - this.loader = loader; - } - - public boolean hasNext() throws ServiceConfigurationError { - if (nextName != null) { - return true; - } - if (configs == null) { - try { - String fullName = prefix + service.getName(); - if (loader == null) - configs = ClassLoader.getSystemResources(fullName); - else - configs = loader.getResources(fullName); - } catch (IOException x) { - fail(service, ": " + x); - } - } - while ((pending == null) || !pending.hasNext()) { - if (!configs.hasMoreElements()) { - return false; - } - pending = parse(service, configs.nextElement(), returned); - } - nextName = pending.next(); - return true; - } - - public S next() throws ServiceConfigurationError { - if (!hasNext()) { - throw new NoSuchElementException(); - } - String cn = nextName; - nextName = null; - Class c = null; - try { - c = Class.forName(cn, false, loader); - } catch (ClassNotFoundException x) { - fail(service, - "Provider " + cn + " not found"); - } - if (!service.isAssignableFrom(c)) { - fail(service, - "Provider " + cn + " not a subtype"); - } - try { - return service.cast(c.newInstance()); - } catch (Throwable x) { - fail(service, - "Provider " + cn + " could not be instantiated: " + x, - x); - } - return null; /* This cannot happen */ - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - } - - - /** - * Locates and incrementally instantiates the available providers of a - * given service using the given class loader. - * - *

This method transforms the name of the given service class into a - * provider-configuration filename as described above and then uses the - * getResources method of the given class loader to find all - * available files with that name. These files are then read and parsed to - * produce a list of provider-class names. The iterator that is returned - * uses the given class loader to lookup and then instantiate each element - * of the list. - * - *

Because it is possible for extensions to be installed into a running - * Java virtual machine, this method may return different results each time - * it is invoked.

- * - * @param service - * The service's abstract service class - * - * @param loader - * The class loader to be used to load provider-configuration files - * and instantiate provider classes, or null if the system - * class loader (or, failing that the bootstrap class loader) is to - * be used - * - * @return An Iterator that yields provider objects for the given - * service, in some arbitrary order. The iterator will throw a - * ServiceConfigurationError if a provider-configuration - * file violates the specified format or if a provider class cannot - * be found and instantiated. - * - * @throws ServiceConfigurationError - * If a provider-configuration file violates the specified format - * or names a provider class that cannot be found and instantiated - * - * @see #providers(java.lang.Class) - * @see #installedProviders(java.lang.Class) - */ - public static Iterator providers(Class service, ClassLoader loader) - throws ServiceConfigurationError - { - return new LazyIterator(service, loader); - } - - - /** - * Locates and incrementally instantiates the available providers of a - * given service using the context class loader. This convenience method - * is equivalent to - * - *

-     *   ClassLoader cl = Thread.currentThread().getContextClassLoader();
-     *   return Service.providers(service, cl);
-     * 
- * - * @param service - * The service's abstract service class - * - * @return An Iterator that yields provider objects for the given - * service, in some arbitrary order. The iterator will throw a - * ServiceConfigurationError if a provider-configuration - * file violates the specified format or if a provider class cannot - * be found and instantiated. - * - * @throws ServiceConfigurationError - * If a provider-configuration file violates the specified format - * or names a provider class that cannot be found and instantiated - * - * @see #providers(java.lang.Class, java.lang.ClassLoader) - */ - public static Iterator providers(Class service) - throws ServiceConfigurationError - { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - return Service.providers(service, cl); - } - - - /** - * Locates and incrementally instantiates the available providers of a - * given service using the extension class loader. This convenience method - * simply locates the extension class loader, call it - * extClassLoader, and then does - * - *
-     *   return Service.providers(service, extClassLoader);
-     * 
- * - * If the extension class loader cannot be found then the system class - * loader is used; if there is no system class loader then the bootstrap - * class loader is used. - * - * @param service - * The service's abstract service class - * - * @return An Iterator that yields provider objects for the given - * service, in some arbitrary order. The iterator will throw a - * ServiceConfigurationError if a provider-configuration - * file violates the specified format or if a provider class cannot - * be found and instantiated. - * - * @throws ServiceConfigurationError - * If a provider-configuration file violates the specified format - * or names a provider class that cannot be found and instantiated - * - * @see #providers(java.lang.Class, java.lang.ClassLoader) - */ - public static Iterator installedProviders(Class service) - throws ServiceConfigurationError - { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - ClassLoader prev = null; - while (cl != null) { - prev = cl; - cl = cl.getParent(); - } - return Service.providers(service, prev); - } - -} diff --git a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java b/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java deleted file mode 100644 index 1060f2079b9..00000000000 --- a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 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 - * 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 sun.misc; - - -/** - * Error thrown when something goes wrong while looking up service providers. - * In particular, this error will be thrown in the following situations: - * - *
    - *
  • A concrete provider class cannot be found, - *
  • A concrete provider class cannot be instantiated, - *
  • The format of a provider-configuration file is illegal, or - *
  • An IOException occurs while reading a provider-configuration file. - *
- * - * @author Mark Reinhold - * @since 1.3 - */ - -public class ServiceConfigurationError extends Error { - - static final long serialVersionUID = 8769866263384244465L; - - /** - * Constructs a new instance with the specified detail string. - */ - public ServiceConfigurationError(String msg) { - super(msg); - } - - /** - * Constructs a new instance that wraps the specified throwable. - */ - public ServiceConfigurationError(Throwable x) { - super(x); - } - -} diff --git a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java index 83485d5f134..dffc5a0639d 100644 --- a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java +++ b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java @@ -24,7 +24,7 @@ /* * @test * @bug 6887710 - * @summary Verify the impact of sun.misc.JarIndex.metaInfFilenames on Service loaders + * @summary Verify the impact of sun.misc.JarIndex.metaInfFilenames on ServiceLoader * @run main/othervm Basic */ @@ -48,9 +48,8 @@ import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; /** - * Verifies the impact of sun.misc.JarIndex.metaInfFilenames on service loaders - * (sun.misc.Service & java.util.ServiceLoader), as well as finding resources - * through Class.getResouce. + * Verifies the impact of sun.misc.JarIndex.metaInfFilenames on ServiceLoader + * and on finding resources via Class.getResource. * * 1) Compile the test sources: * jarA: @@ -214,23 +213,13 @@ public class Basic { int failed = 0; - // Tests using sun.misc.Service - if (!sunMiscServiceTest(baseURL, messageService, true, false, true)) { - System.out.println("Test: sun.misc.Service looking for " + messageService + ", failed"); - failed++; - } - if (!sunMiscServiceTest(baseURL, unknownService, false, false, false)) { - System.out.println("Test: sun.misc.Service looking for " + unknownService + " failed"); - failed++; - } - // Tests using java.util.SerivceLoader if (!javaUtilServiceLoaderTest(baseURL, messageService, true, false, true)) { - System.out.println("Test: sun.misc.Service looking for " + messageService + ", failed"); + System.out.println("Test: ServiceLoader looking for " + messageService + ", failed"); failed++; } if (!javaUtilServiceLoaderTest(baseURL, unknownService, false, false, false)) { - System.out.println("Test: sun.misc.Service looking for " + unknownService + " failed"); + System.out.println("Test: ServiceLoader looking for " + unknownService + " failed"); failed++; } @@ -248,48 +237,6 @@ public class Basic { throw new RuntimeException("Failed: " + failed + " tests"); } - static boolean sunMiscServiceTest(URL baseURL, - String serviceClass, - boolean expectToFind, - boolean expectbDotJar, - boolean expectcDotJar) throws IOException { - debug("----------------------------------"); - debug("Running test with sun.misc.Service looking for " + serviceClass); - URLClassLoader loader = getLoader(baseURL); - httpServer.reset(); - - Class messageServiceClass = null; - try { - messageServiceClass = loader.loadClass(serviceClass); - } catch (ClassNotFoundException cnfe) { - System.err.println(cnfe); - throw new RuntimeException("Error in test: " + cnfe); - } - - Iterator iterator = sun.misc.Service.providers(messageServiceClass, loader); - if (expectToFind && !iterator.hasNext()) { - debug(messageServiceClass + " NOT found."); - return false; - } - - while (iterator.hasNext()) { - debug("found " + iterator.next() + " " + messageService); - } - - debug("HttpServer: " + httpServer); - - if (!expectbDotJar && httpServer.bDotJar > 0) { - debug("Unexpeced request sent to the httpserver for b.jar"); - return false; - } - if (!expectcDotJar && httpServer.cDotJar > 0) { - debug("Unexpeced request sent to the httpserver for c.jar"); - return false; - } - - return true; - } - static boolean javaUtilServiceLoaderTest(URL baseURL, String serviceClass, boolean expectToFind, From 87ed9d213a7bd3704e888bc788dedfb705e294d2 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Feb 2014 14:23:52 +0000 Subject: [PATCH 02/18] 8034780: Remove used imports Reviewed-by: sundar, chegar, lancea, dfuchs --- jdk/src/share/classes/java/lang/invoke/MethodHandle.java | 2 -- jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java | 2 -- jdk/src/share/classes/sun/applet/AppletViewerPanel.java | 1 - 3 files changed, 5 deletions(-) diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java index ce115df85ed..f142076f528 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java @@ -31,8 +31,6 @@ import sun.invoke.util.*; import sun.misc.Unsafe; import static java.lang.invoke.MethodHandleStatics.*; -import java.util.logging.Level; -import java.util.logging.Logger; /** * A method handle is a typed, directly executable reference to an underlying method, diff --git a/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java index c2d8e583a88..07f08dd6962 100644 --- a/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java @@ -27,8 +27,6 @@ package java.lang.invoke; import static java.lang.invoke.LambdaForm.*; import static java.lang.invoke.MethodHandleNatives.Constants.*; -import java.util.logging.Level; -import java.util.logging.Logger; /** * A method handle whose behavior is determined only by its LambdaForm. diff --git a/jdk/src/share/classes/sun/applet/AppletViewerPanel.java b/jdk/src/share/classes/sun/applet/AppletViewerPanel.java index 2b79c3fc8cc..93f064bb36d 100644 --- a/jdk/src/share/classes/sun/applet/AppletViewerPanel.java +++ b/jdk/src/share/classes/sun/applet/AppletViewerPanel.java @@ -31,7 +31,6 @@ import java.net.URL; import java.net.MalformedURLException; import java.awt.*; import java.applet.*; -import sun.tools.jar.*; /** From fa26d0e934154ce0545c05fad56f508c988d3572 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Feb 2014 17:51:31 +0000 Subject: [PATCH 03/18] 8034102: Check solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c for JNI pending exceptions Reviewed-by: chegar, henryjen --- .../sun/nio/fs/MacOSXNativeDispatcher.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c index f3602b8fdb7..5c752930c14 100644 --- a/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c @@ -39,12 +39,15 @@ Java_sun_nio_fs_MacOSXNativeDispatcher_normalizepath(JNIEnv* env, jclass this, jint form) { jcharArray result = NULL; - char chars_buf[(PATH_MAX + 1) * 2]; // utf16 + zero padding + char *chars; CFMutableStringRef csref = CFStringCreateMutable(NULL, 0); if (csref == NULL) { JNU_ThrowOutOfMemoryError(env, "native heap"); - } else { - char *chars = (char*)(*env)->GetPrimitiveArrayCritical(env, path, 0); + return NULL; + } + chars = (char*)(*env)->GetPrimitiveArrayCritical(env, path, 0); + if (chars != NULL) { + char chars_buf[(PATH_MAX + 1) * 2]; // utf16 + zero padding jsize len = (*env)->GetArrayLength(env, path); CFStringAppendCharacters(csref, (const UniChar*)chars, len); (*env)->ReleasePrimitiveArrayCritical(env, path, chars, 0); @@ -53,24 +56,26 @@ Java_sun_nio_fs_MacOSXNativeDispatcher_normalizepath(JNIEnv* env, jclass this, if (len < PATH_MAX) { if (CFStringGetCString(csref, chars_buf, sizeof(chars_buf), kCFStringEncodingUTF16)) { result = (*env)->NewCharArray(env, len); - (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)&chars_buf); + if (result != NULL) { + (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)&chars_buf); + } } } else { int ulen = (len + 1) * 2; chars = malloc(ulen); if (chars == NULL) { - CFRelease(csref); JNU_ThrowOutOfMemoryError(env, "native heap"); - return result; } else { if (CFStringGetCString(csref, chars, ulen, kCFStringEncodingUTF16)) { result = (*env)->NewCharArray(env, len); - (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)chars); + if (result != NULL) { + (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)chars); + } } free(chars); } } - CFRelease(csref); } + CFRelease(csref); return result; } From 328fa609d0fc8ea607ca1f848710a3d9304b8e65 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 12 Feb 2014 10:51:50 -0800 Subject: [PATCH 04/18] 8030010: cleanup native code warnings Co-authored-by: Francis Andre Reviewed-by: alanb, lancea --- jdk/src/share/bin/java.c | 5 ++--- jdk/src/share/bin/parse_manifest.c | 4 ++-- jdk/src/share/instrument/InvocationAdapter.c | 1 - jdk/src/share/native/java/lang/ClassLoader.c | 8 ++++---- jdk/src/share/native/java/lang/Throwable.c | 2 +- jdk/src/windows/native/common/jdk_util_md.c | 1 - jdk/src/windows/native/java/io/WinNTFileSystem_md.c | 1 - jdk/src/windows/native/java/lang/ProcessImpl_md.c | 2 +- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c index b72fa0e6d26..79912d52d0a 100644 --- a/jdk/src/share/bin/java.c +++ b/jdk/src/share/bin/java.c @@ -345,10 +345,10 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ } \ } while (JNI_FALSE) -#define CHECK_EXCEPTION_RETURN(CER_return_value) \ +#define CHECK_EXCEPTION_RETURN() \ do { \ if ((*env)->ExceptionOccurred(env)) { \ - return CER_return_value; \ + return; \ } \ } while (JNI_FALSE) @@ -1258,7 +1258,6 @@ static jclass GetApplicationClass(JNIEnv *env) { jmethodID mid; - jobject result; jclass cls = GetLauncherHelperClass(env); NULL_CHECK0(cls); NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, diff --git a/jdk/src/share/bin/parse_manifest.c b/jdk/src/share/bin/parse_manifest.c index 4926824e36b..c17249c0b30 100644 --- a/jdk/src/share/bin/parse_manifest.c +++ b/jdk/src/share/bin/parse_manifest.c @@ -233,7 +233,7 @@ compute_cen(int fd, Byte *bp) jlong base_offset; jlong offset; char buffer[MINREAD]; - p = buffer; + p = (Byte*) buffer; /* * Read the END Header, which is the starting point for ZIP files. * (Clearly designed to make writing a zip file easier than reading @@ -276,7 +276,7 @@ compute_cen(int fd, Byte *bp) if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong)0) { return (-1); } - p = buffer; + p = (Byte*) buffer; base_offset = base_offset - ZIP64_ENDSIZ(p) - ZIP64_ENDOFF(p) - ZIP64_ENDHDR; } else { base_offset = base_offset - ENDSIZ(p) - ENDOFF(p); diff --git a/jdk/src/share/instrument/InvocationAdapter.c b/jdk/src/share/instrument/InvocationAdapter.c index f1923d7cc3f..878adeced8c 100644 --- a/jdk/src/share/instrument/InvocationAdapter.c +++ b/jdk/src/share/instrument/InvocationAdapter.c @@ -153,7 +153,6 @@ Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) { char * options; jarAttribute* attributes; char * premainClass; - char * agentClass; char * bootClassPath; /* diff --git a/jdk/src/share/native/java/lang/ClassLoader.c b/jdk/src/share/native/java/lang/ClassLoader.c index 8e0b950406a..7701cce4bea 100644 --- a/jdk/src/share/native/java/lang/ClassLoader.c +++ b/jdk/src/share/native/java/lang/ClassLoader.c @@ -325,7 +325,7 @@ static void *findJniFunction(JNIEnv *env, void *handle, void *entryName = NULL; char *jniFunctionName; int i; - int len; + size_t len; // Check for JNI_On(Un)Load<_libname> function if (isLoad) { @@ -501,9 +501,9 @@ Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib { const char *cname; char *libName; - int prefixLen = (int) strlen(JNI_LIB_PREFIX); - int suffixLen = (int) strlen(JNI_LIB_SUFFIX); - int len; + size_t prefixLen = strlen(JNI_LIB_PREFIX); + size_t suffixLen = strlen(JNI_LIB_SUFFIX); + size_t len; jstring lib; void *ret; const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS; diff --git a/jdk/src/share/native/java/lang/Throwable.c b/jdk/src/share/native/java/lang/Throwable.c index aaf3c265865..768c7e114a4 100644 --- a/jdk/src/share/native/java/lang/Throwable.c +++ b/jdk/src/share/native/java/lang/Throwable.c @@ -44,7 +44,7 @@ * `this' so you can write 'throw e.fillInStackTrace();' */ JNIEXPORT jobject JNICALL -Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject throwable, int dummy) +Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject throwable, jint dummy) { JVM_FillInStackTrace(env, throwable); return throwable; diff --git a/jdk/src/windows/native/common/jdk_util_md.c b/jdk/src/windows/native/common/jdk_util_md.c index 65d20f55b3b..0eae2158f97 100644 --- a/jdk/src/windows/native/common/jdk_util_md.c +++ b/jdk/src/windows/native/common/jdk_util_md.c @@ -42,7 +42,6 @@ void* JDK_FindJvmEntry(const char* name) { JNIEXPORT HMODULE JDK_LoadSystemLibrary(const char* name) { HMODULE handle = NULL; char path[MAX_PATH]; - int ret; if (GetSystemDirectory(path, sizeof(path)) != 0) { strcat(path, "\\"); diff --git a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c index ec7d9d7294b..cfaeccdd030 100644 --- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c +++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c @@ -360,7 +360,6 @@ Java_java_io_WinNTFileSystem_getBooleanAttributes(JNIEnv *env, jobject this, jobject file) { jint rv = 0; - jint pathlen; WCHAR *pathbuf = fileToNTPath(env, file, ids.path); if (pathbuf == NULL) diff --git a/jdk/src/windows/native/java/lang/ProcessImpl_md.c b/jdk/src/windows/native/java/lang/ProcessImpl_md.c index da7d00b081a..04db1e341b4 100644 --- a/jdk/src/windows/native/java/lang/ProcessImpl_md.c +++ b/jdk/src/windows/native/java/lang/ProcessImpl_md.c @@ -79,7 +79,7 @@ win32Error(JNIEnv *env, const WCHAR *functionName) /*Good suggestion about 2-bytes-per-symbol in localized error reports*/ char utf8_javaMessage[MESSAGE_LENGTH*2]; const int errnum = (int)GetLastError(); - int n = os_error_message(errnum, utf16_OSErrorMsg, ARRAY_SIZE(utf16_OSErrorMsg)); + size_t n = os_error_message(errnum, utf16_OSErrorMsg, ARRAY_SIZE(utf16_OSErrorMsg)); n = (n > 0) ? swprintf(utf16_javaMessage, MESSAGE_LENGTH, L"%s error=%d, %s", functionName, errnum, utf16_OSErrorMsg) : swprintf(utf16_javaMessage, MESSAGE_LENGTH, L"%s failed, error=%d", functionName, errnum); From cd941767e312292147fbe1a4e02faa206a54c364 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 13 Feb 2014 00:01:07 +0100 Subject: [PATCH 05/18] 8034191: Move relevant parts of build system to new closed repo Reviewed-by: erikj, tbell --- jdk/make/BuildJdk.gmk | 6 +++--- jdk/make/CopyFiles.gmk | 5 +++-- jdk/make/CreateJars.gmk | 5 +++-- jdk/make/Images.gmk | 5 +++-- jdk/make/lib/Awt2dLibraries.gmk | 7 +++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/jdk/make/BuildJdk.gmk b/jdk/make/BuildJdk.gmk index eeb4a533220..ac6d919689f 100644 --- a/jdk/make/BuildJdk.gmk +++ b/jdk/make/BuildJdk.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 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 @@ -42,8 +42,8 @@ include Setup.gmk # Include Profile information include ProfileNames.gmk -# Include the corresponding custom file, if present. --include $(CUSTOM_MAKE_DIR)/BuildJdk.gmk +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, jdk, BuildJdk.gmk)) import: import-only import-only: diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk index 0ac509cc7be..9fba2dd04cc 100644 --- a/jdk/make/CopyFiles.gmk +++ b/jdk/make/CopyFiles.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -570,4 +570,5 @@ COPY_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties ########################################################################################## --include $(CUSTOM_MAKE_DIR)/CopyFiles.gmk +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, jdk, CopyFiles.gmk)) diff --git a/jdk/make/CreateJars.gmk b/jdk/make/CreateJars.gmk index 22f0b3b57f5..cda4777e9c6 100644 --- a/jdk/make/CreateJars.gmk +++ b/jdk/make/CreateJars.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -745,7 +745,8 @@ $(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar: $(NASHORN_DIST)/nashorn.jar ########################################################################################## --include $(CUSTOM_MAKE_DIR)/CreateJars.gmk +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, jdk, CreateJars.gmk)) ########################################################################################## diff --git a/jdk/make/Images.gmk b/jdk/make/Images.gmk index 4406a721b80..f5ca8a19f71 100644 --- a/jdk/make/Images.gmk +++ b/jdk/make/Images.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -783,4 +783,5 @@ endif # Profile .PHONY: default images jre-image jdk-image --include $(CUSTOM_MAKE_DIR)/Images.gmk +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, jdk, Images.gmk)) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index a1263ba5775..140fff2b832 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -23,6 +23,9 @@ # questions. # +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, jdk, lib/Awt2dLibraries.gmk)) + # Openwin is defined on Solaris. OPENWIN_LIB := $(OPENWIN_HOME)/lib @@ -550,10 +553,6 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) endif ifeq ($(OPENJDK_TARGET_OS), linux) - ifndef OPENJDK - include $(JDK_TOPDIR)/make/closed/xawt.gmk - endif - ifeq ($(DISABLE_XRENDER), true) LIBAWT_XAWT_CFLAGS += -DDISABLE_XRENDER_BY_DEFAULT=true endif From 4e71a94e914b9c6d9e5b49f7cef310bb0f1ada1b Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 13 Feb 2014 14:08:12 +0000 Subject: [PATCH 06/18] 8034856: gcc warnings compiling src/solaris/native/sun/security/pkcs11 8034857: gcc warnings compiling src/solaris/native/sun/management Reviewed-by: sla, mullan --- jdk/src/share/instrument/JarFacade.c | 1 + .../share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h | 5 +++++ jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c | 3 ++- jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c | 1 + jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.h | 5 +++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/instrument/JarFacade.c b/jdk/src/share/instrument/JarFacade.c index 07ae23c2220..6d7678f9a5d 100644 --- a/jdk/src/share/instrument/JarFacade.c +++ b/jdk/src/share/instrument/JarFacade.c @@ -33,6 +33,7 @@ #endif /* _WIN32 */ #include #include +#include #include "jni.h" #include "manifest_info.h" diff --git a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h index 01aeb6fcaea..3188774cab7 100644 --- a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h +++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h @@ -55,6 +55,9 @@ * @author Martin Schlaeffer */ +#ifndef _PKCS11WRAPPER_H +#define _PKCS11WRAPPER_H 1 + /* disable asserts in product mode */ #ifndef DEBUG #ifndef NDEBUG @@ -461,3 +464,5 @@ void p11free(void *p, char *file, int line); #define free(c) (p11free((c), THIS_FILE, __LINE__)) #endif + +#endif /* _PKCS11WRAPPER_H */ diff --git a/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c b/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c index 1d6c89ed754..96d3fa30174 100644 --- a/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c +++ b/jdk/src/solaris/native/sun/management/LinuxOperatingSystem.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "sun_management_OperatingSystemImpl.h" struct ticks { @@ -57,7 +58,7 @@ static struct perfbuf { ticks *cpus; } counters; -#define DEC_64 "%lld" +#define DEC_64 "%"SCNd64 static void next_line(FILE *f) { while (fgetc(f) != '\n'); diff --git a/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c b/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c index 8b3a62bfdc6..e07bea75149 100644 --- a/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c +++ b/jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c @@ -32,6 +32,7 @@ #include #include "j2secmod.h" +#include "wrapper/pkcs11wrapper.h" void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) { void *hModule = (void*)jlong_to_ptr(jHandle); diff --git a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.h b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.h index 9a112181a8a..49379f18dbf 100644 --- a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.h +++ b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.h @@ -56,6 +56,9 @@ /* defines for UNIX platforms *************************************************/ +#ifndef _P11_MD_H +#define _P11_MD_H 1 + #define CK_PTR * #define CK_DEFINE_FUNCTION(returnType, name) returnType name #define CK_DECLARE_FUNCTION(returnType, name) returnType name @@ -83,3 +86,5 @@ struct ModuleData { }; typedef struct ModuleData ModuleData; + +#endif /* _P11_MD_H */ From dca4d10631a7720bedf6303b8d81a208adc26e31 Mon Sep 17 00:00:00 2001 From: Michael Cui Date: Thu, 13 Feb 2014 15:59:04 +0000 Subject: [PATCH 07/18] 8028711: TEST_BUG: Shell tests should pass through VM options Reviewed-by: alanb --- jdk/test/com/sun/corba/5036554/TestCorbaBug.sh | 2 +- .../java/awt/FontClass/CreateFont/DeleteFont.sh | 2 +- jdk/test/java/awt/JAWT/JAWT.sh | 2 +- jdk/test/java/awt/PrintJob/Text/stringwidth.sh | 2 +- .../AutoShutdown/ShowExitTest/ShowExitTest.sh | 2 +- .../awt/Toolkit/BadDisplayTest/BadDisplayTest.sh | 4 ++-- .../WrappedToolkitTest/WrappedToolkitTest.sh | 13 +++++++------ jdk/test/java/net/URLPermission/nstest/lookup.sh | 5 ++++- .../SelectorProvider/inheritedChannel/run_tests.sh | 2 +- .../IIOMetadataFormat/runMetadataFormatTest.sh | 3 ++- .../runMetadataFormatThreadTest.sh | 3 ++- .../imageio/stream/StreamCloserLeak/run_test.sh | 5 +++-- jdk/test/javax/print/PrintSE/PrintSE.sh | 5 ++++- .../SharedMemoryPixmapsTest.sh | 2 +- jdk/test/sun/security/krb5/config/dns.sh | 2 +- jdk/test/sun/security/tools/keytool/autotest.sh | 2 +- jdk/test/sun/tools/jconsole/ResourceCheckTest.sh | 2 +- .../native2ascii/resources/ImmutableResourceTest.sh | 2 +- 18 files changed, 35 insertions(+), 25 deletions(-) diff --git a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh index 7e057e72c38..4f0ff231a99 100644 --- a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh +++ b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh @@ -83,7 +83,7 @@ chmod -fR 777 bug ${TESTJAVA}${FS}bin${FS}javac -d . bug${FS}*.java -${TESTJAVA}${FS}bin${FS}java -cp . bug/JavaBug > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp . bug/JavaBug > test.out 2>&1 grep "NullPointerException" test.out diff --git a/jdk/test/java/awt/FontClass/CreateFont/DeleteFont.sh b/jdk/test/java/awt/FontClass/CreateFont/DeleteFont.sh index 032559423a6..08b75c8eb9a 100644 --- a/jdk/test/java/awt/FontClass/CreateFont/DeleteFont.sh +++ b/jdk/test/java/awt/FontClass/CreateFont/DeleteFont.sh @@ -47,7 +47,7 @@ ${TESTJAVA}/bin/javac -d ${TESTCLASSES} DeleteFont.java cd ${TESTCLASSES} numfiles0=`ls ${TESTCLASSES} | wc -l` -${TESTJAVA}/bin/java -Djava.io.tmpdir=${TESTCLASSES} DeleteFont +${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.io.tmpdir=${TESTCLASSES} DeleteFont if [ $? -ne 0 ] then diff --git a/jdk/test/java/awt/JAWT/JAWT.sh b/jdk/test/java/awt/JAWT/JAWT.sh index 48182d437b7..42107990fab 100644 --- a/jdk/test/java/awt/JAWT/JAWT.sh +++ b/jdk/test/java/awt/JAWT/JAWT.sh @@ -165,7 +165,7 @@ export CC SYST ARCH LD_LIBRARY_PATH ${JAVAC} -d . ${TESTSRC}${FS}MyCanvas.java ${JAVAH} -jni -classpath . -d . MyCanvas ${MAKE} -f ${MAKEFILE} -${JAVA} -classpath . MyCanvas +${JAVA} ${TESTVMOPTS} -classpath . MyCanvas exit $? diff --git a/jdk/test/java/awt/PrintJob/Text/stringwidth.sh b/jdk/test/java/awt/PrintJob/Text/stringwidth.sh index 3d5ba3eff62..a0de596f60a 100644 --- a/jdk/test/java/awt/PrintJob/Text/stringwidth.sh +++ b/jdk/test/java/awt/PrintJob/Text/stringwidth.sh @@ -58,7 +58,7 @@ else JAVA_HOME=$TESTJAVA fi - $JAVA_HOME/bin/java -cp "${CP}" StringWidth + $JAVA_HOME/bin/java ${TESTVMOPTS} -cp "${CP}" StringWidth checkstatus exit 0 diff --git a/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh b/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh index f772c25245f..0b83b09e973 100644 --- a/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh +++ b/jdk/test/java/awt/Toolkit/AutoShutdown/ShowExitTest/ShowExitTest.sh @@ -175,7 +175,7 @@ chmod 777 ./* # pass, you should be able to cut and paste it into here and it will # run with the test harness. -${TESTJAVA}/bin/java ShowExitTest +${TESTJAVA}/bin/java ${TESTVMOPTS} ShowExitTest ############### END YOUR TEST CODE !!!!! ############ #Be sure the last command executed above this line returns 0 for success, diff --git a/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh index e58072890c1..76249577488 100644 --- a/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh +++ b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh @@ -28,10 +28,10 @@ export DISPLAY OS=`uname -s` case "$OS" in SunOS ) - ${TESTJAVA}/bin/java BadDisplayTest + ${TESTJAVA}/bin/java ${TESTVMOPTS} BadDisplayTest ;; Linux ) - ${TESTJAVA}/bin/java BadDisplayTest + ${TESTJAVA}/bin/java ${TESTVMOPTS} BadDisplayTest ;; * ) echo "Unsupported System: ${OS}" diff --git a/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh index 977f1b47361..36acfe81867 100644 --- a/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh +++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh @@ -146,13 +146,13 @@ chmod 777 ./* case "$OS" in Windows* | CYGWIN* ) - ${TESTJAVA}/bin/java -Djava.awt.headless=true \ + ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ TestWrapped sun.awt.windows.WToolkit status=$? if [ ! $status -eq "0" ]; then fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit"; fi - ${TESTJAVA}/bin/java -Djava.awt.headless=true \ + ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ -Dawt.toolkit=sun.awt.windows.WToolkit \ TestWrapped sun.awt.windows.WToolkit status=$? @@ -162,14 +162,15 @@ case "$OS" in ;; SunOS | Linux ) - ${TESTJAVA}/bin/java -Djava.awt.headless=true \ + ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ -Dawt.toolkit=sun.awt.X11.XToolkit \ TestWrapped sun.awt.X11.XToolkit status=$? if [ ! $status -eq "0" ]; then fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit"; fi - AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java -Djava.awt.headless=true \ + AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java ${TESTVMOPTS} \ + -Djava.awt.headless=true \ TestWrapped sun.awt.X11.XToolkit status=$? if [ ! $status -eq "0" ]; then @@ -178,13 +179,13 @@ case "$OS" in ;; Darwin) - ${TESTJAVA}/bin/java -Djava.awt.headless=true \ + ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ TestWrapped sun.lwawt.macosx.LWCToolkit status=$? if [ ! $status -eq "0" ]; then fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.lwawt.macosx.LWCToolkit"; fi - ${TESTJAVA}/bin/java -Djava.awt.headless=true \ + ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ -Dawt.toolkit=sun.lwawt.macosx.LWCToolkit \ TestWrapped sun.lwawt.macosx.LWCToolkit status=$? diff --git a/jdk/test/java/net/URLPermission/nstest/lookup.sh b/jdk/test/java/net/URLPermission/nstest/lookup.sh index 89cfd101d21..9aa3ccbf527 100644 --- a/jdk/test/java/net/URLPermission/nstest/lookup.sh +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh @@ -56,4 +56,7 @@ grant { }; POLICY -${TESTJAVA}/bin/java -Djava.security.policy=file:./policy -Dsun.net.spi.nameservice.provider.1=simple,sun -cp ${TESTCLASSES}${PS}${TESTSRC} LookupTest -runtest ${port} +${TESTJAVA}/bin/java ${TESTVMOPTS} \ + -Djava.security.policy=file:./policy \ + -Dsun.net.spi.nameservice.provider.1=simple,sun \ + -cp ${TESTCLASSES}${PS}${TESTSRC} LookupTest -runtest ${port} diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh index dca835c6525..37d56a84ed9 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh @@ -109,7 +109,7 @@ failures=0 go() { echo '' - sh -xc "$JAVA $DFLAG $1 $2 $3 $4 $5 $6 $7 $8" 2>&1 + sh -xc "$JAVA ${TESTVMOPTS} $DFLAG $1 $2 $3 $4 $5 $6 $7 $8" 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi } diff --git a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh index 800a898eb1a..c6d912869f6 100644 --- a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh +++ b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.sh @@ -211,7 +211,8 @@ mkdir ./test_classes # split application classes and test plugin classes mv ./UserPluginMetadataFormatTest*.class ./test_classes -$TESTJAVA/bin/java MetadataFormatTest test_classes UserPluginMetadataFormatTest +$TESTJAVA/bin/java ${TESTVMOPTS} \ + MetadataFormatTest test_classes UserPluginMetadataFormatTest ############### END YOUR TEST CODE !!!!! ############ status=$? diff --git a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh index eb60ba99282..9eb53fbf499 100644 --- a/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh +++ b/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh @@ -212,7 +212,8 @@ mkdir ./test_classes # split application classes and test plugin classes mv ./UserPluginMetadataFormatTest*.class ./test_classes -$TESTJAVA/bin/java MetadataFormatThreadTest test_classes UserPluginMetadataFormatTest +$TESTJAVA/bin/java ${TESTVMOPTS} \ + MetadataFormatThreadTest test_classes UserPluginMetadataFormatTest ############### END YOUR TEST CODE !!!!! ############ status=$? diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh index 1977ca80275..6f889251775 100644 --- a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh +++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh @@ -198,14 +198,15 @@ if [ $? -ne 0 ] ; then fi # Verify that all classoladers are destroyed -${TESTJAVA}/bin/java -cp Test.jar test.Main +${TESTJAVA}/bin/java ${TESTVMOPTS} -cp Test.jar test.Main if [ $? -ne 0 ] ; then fail "Test FAILED: some classloaders weren't destroyed." fi # Verify that ImageIO shutdown hook works correcly -${TESTJAVA}/bin/java -cp Test.jar -DforgetSomeStreams=true test.Main +${TESTJAVA}/bin/java ${TESTVMOPTS} \ + -cp Test.jar -DforgetSomeStreams=true test.Main if [ $? -ne 0 ] ; then fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed." fi diff --git a/jdk/test/javax/print/PrintSE/PrintSE.sh b/jdk/test/javax/print/PrintSE/PrintSE.sh index 9b555054f07..2acbd3f781f 100644 --- a/jdk/test/javax/print/PrintSE/PrintSE.sh +++ b/jdk/test/javax/print/PrintSE/PrintSE.sh @@ -46,6 +46,9 @@ EOF createJavaPolicyFile -${TESTJAVA}/bin/java -Djava.security.manager -Djava.security.policy=${TESTCLASSES}/print.policy -cp ${TESTCLASSES} PrintSE +${TESTJAVA}/bin/java ${TESTVMOPTS} \ + -Djava.security.manager \ + -Djava.security.policy=${TESTCLASSES}/print.policy \ + -cp ${TESTCLASSES} PrintSE exit $? diff --git a/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh b/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh index 9c1b4f81156..103b702b429 100644 --- a/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh +++ b/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh @@ -41,7 +41,7 @@ NO_J2D_DGA=true J2D_PIXMAPS=shared export NO_J2D_DGA J2D_PIXMAPS -${TESTJAVA}/bin/java SharedMemoryPixmapsTest +${TESTJAVA}/bin/java ${TESTVMOPTS} SharedMemoryPixmapsTest if [ $? -ne 0 ]; then echo "Test failed!" diff --git a/jdk/test/sun/security/krb5/config/dns.sh b/jdk/test/sun/security/krb5/config/dns.sh index 71b2addc2d5..7e5b9885989 100644 --- a/jdk/test/sun/security/krb5/config/dns.sh +++ b/jdk/test/sun/security/krb5/config/dns.sh @@ -40,5 +40,5 @@ fi $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ ${TESTSRC}/NamingManager.java ${TESTSRC}/DNS.java -$TESTJAVA/bin/java -Xbootclasspath/p:. DNS +$TESTJAVA/bin/java ${TESTVMOPTS} -Xbootclasspath/p:. DNS diff --git a/jdk/test/sun/security/tools/keytool/autotest.sh b/jdk/test/sun/security/tools/keytool/autotest.sh index 0d8e57ce680..90e0a66a268 100644 --- a/jdk/test/sun/security/tools/keytool/autotest.sh +++ b/jdk/test/sun/security/tools/keytool/autotest.sh @@ -106,7 +106,7 @@ cp ${NSS}${FS}db${FS}secmod.db . chmod u+w key3.db chmod u+w cert8.db -echo | ${TESTJAVA}${FS}bin${FS}java -Dnss \ +echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dnss \ -Dnss.lib=${LIBNAME} \ KeyToolTest status=$? diff --git a/jdk/test/sun/tools/jconsole/ResourceCheckTest.sh b/jdk/test/sun/tools/jconsole/ResourceCheckTest.sh index b82b3ac387c..796da94f1f4 100644 --- a/jdk/test/sun/tools/jconsole/ResourceCheckTest.sh +++ b/jdk/test/sun/tools/jconsole/ResourceCheckTest.sh @@ -102,7 +102,7 @@ ${TESTJAVA}/bin/javac -d "${TESTCLASSES}" ${CP} -g \ "${TESTSRC}"/"${TARGETCLASS}".java # #Run the test class, again with the classpath we need: -${TESTJAVA}/bin/java ${CP} ${TARGETCLASS} +${TESTJAVA}/bin/java ${TESTVMOPTS} ${CP} ${TARGETCLASS} status=$? echo "test status was: $status" if [ $status -eq "0" ]; diff --git a/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.sh b/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.sh index 29c72ed6254..bd22582beb1 100644 --- a/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.sh +++ b/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.sh @@ -104,7 +104,7 @@ ${TESTJAVA}/bin/javac -d "${TESTCLASSES}" ${CP} -g \ "${TESTSRC}"/"${TARGETCLASS}".java # #Run the test class, again with the classpath we need: -${TESTJAVA}/bin/java ${CP} ${TARGETCLASS} +${TESTJAVA}/bin/java ${TESTVMOPTS} ${CP} ${TARGETCLASS} status=$? echo "test status was: $status" if [ $status -eq "0" ]; From ff24be63a7f200b2b405e017bda82df85ce612a8 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 13 Feb 2014 17:14:24 +0100 Subject: [PATCH 08/18] 8034179: Clean up nio genConstants Reviewed-by: alanb, ihse --- jdk/make/CompileJavaClasses.gmk | 5 ---- jdk/make/gensrc/GensrcMisc.gmk | 28 ++++++++----------- .../ch/genSocketOptionRegistry.c | 0 .../genconstants}/fs/genSolarisConstants.c | 0 .../genconstants}/fs/genUnixConstants.c | 0 5 files changed, 12 insertions(+), 21 deletions(-) rename jdk/{src/share/native/sun/nio => make/src/native/genconstants}/ch/genSocketOptionRegistry.c (100%) rename jdk/{src/solaris/native/sun/nio => make/src/native/genconstants}/fs/genSolarisConstants.c (100%) rename jdk/{src/solaris/native/sun/nio => make/src/native/genconstants}/fs/genUnixConstants.c (100%) diff --git a/jdk/make/CompileJavaClasses.gmk b/jdk/make/CompileJavaClasses.gmk index f5e6184eadf..2c65d12cc8b 100644 --- a/jdk/make/CompileJavaClasses.gmk +++ b/jdk/make/CompileJavaClasses.gmk @@ -239,11 +239,6 @@ ifeq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx aix)) EXFILES += sun/nio/fs/PollingWatchService.java endif -# TODO: Fix when converting NIO -# Exclude *-linux-arm.java and *-linux-ppc.java from closed. -EXFILES += -linux-arm.java \ - -linux-ppc.java - ifeq ($(OPENJDK_TARGET_OS), windows) EXFILES += sun/nio/ch/AbstractPollSelectorImpl.java \ sun/nio/ch/PollSelectorProvider.java \ diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk index adb8e858577..32690efd5ee 100644 --- a/jdk/make/gensrc/GensrcMisc.gmk +++ b/jdk/make/gensrc/GensrcMisc.gmk @@ -83,9 +83,9 @@ endif GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java -GENSRC_SOR_SRC := $(JDK_TOPDIR)/src/share/native/sun/nio/ch +GENSRC_SOR_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/ch GENSRC_SOR_SRC_FILE := genSocketOptionRegistry.c -GENSRC_SOR_BIN := $(JDK_OUTPUTDIR)/gensrc/genSocketOptionRegistry +GENSRC_SOR_BIN := $(JDK_OUTPUTDIR)/btnative/genSocketOptionRegistry SOR_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOR_SRC)/$(GENSRC_SOR_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') @@ -100,11 +100,9 @@ $(eval $(call SetupNativeCompilation,BUILD_GENSRC_SOR_EXE, \ OUTPUT_DIR := $(GENSRC_SOR_BIN), \ PROGRAM := genSocketOptionRegistry)) -ifneq ($(wildcard $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java), ) - HAS_SOCKET_OPTION_REGISTRY := true -endif +SOR_PREGEN_FILE := $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java.template -ifneq ($(HAS_SOCKET_OPTION_REGISTRY), true) +ifeq ($(wildcard $(SOR_PREGEN_FILE)), ) $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java: $(BUILD_GENSRC_SOR_EXE) $(MKDIR) -p $(@D) $(RM) $@ $@.tmp @@ -112,7 +110,7 @@ ifneq ($(HAS_SOCKET_OPTION_REGISTRY), true) $(BUILD_GENSRC_SOR_EXE) >> $@.tmp $(MV) $@.tmp $@ else - $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java: $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java + $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java: $(SOR_PREGEN_FILE) $(call install-file) endif @@ -122,9 +120,9 @@ ifneq ($(OPENJDK_TARGET_OS), windows) GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java - GENSRC_UC_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs + GENSRC_UC_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/fs GENSRC_UC_SRC_FILE := genUnixConstants.c - GENSRC_UC_BIN := $(JDK_OUTPUTDIR)/gensrc/genUnixConstants + GENSRC_UC_BIN := $(JDK_OUTPUTDIR)/btnative/genUnixConstants UC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_UC_SRC)/$(GENSRC_UC_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') @@ -140,11 +138,9 @@ ifneq ($(OPENJDK_TARGET_OS), windows) OUTPUT_DIR := $(GENSRC_UC_BIN), \ PROGRAM := genUnixConstants)) - ifneq ($(wildcard $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java), ) - HAS_UNIX_CONSTANTS := true - endif + UC_PREGEN_FILE := $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java.template - ifneq ($(HAS_UNIX_CONSTANTS), true) + ifeq ($(wildcard $(UC_PREGEN_FILE)), ) $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java: $(BUILD_GENSRC_UC_EXE) $(MKDIR) -p $(@D) $(RM) $@ $@.tmp @@ -152,7 +148,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows) $(BUILD_GENSRC_UC_EXE) >> $@.tmp $(MV) $@.tmp $@ else - $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java: $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java + $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java: $(UC_PREGEN_FILE) $(call install-file) endif @@ -164,9 +160,9 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/SolarisConstants.java - GENSRC_SOL_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs + GENSRC_SOL_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/fs GENSRC_SOL_SRC_FILE := genSolarisConstants.c - GENSRC_SOL_BIN := $(JDK_OUTPUTDIR)/gensrc/genSolarisConstants + GENSRC_SOL_BIN := $(JDK_OUTPUTDIR)/btnative/genSolarisConstants SOL_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOL_SRC)/$(GENSRC_SOL_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') diff --git a/jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c b/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c similarity index 100% rename from jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c rename to jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c diff --git a/jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c b/jdk/make/src/native/genconstants/fs/genSolarisConstants.c similarity index 100% rename from jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c rename to jdk/make/src/native/genconstants/fs/genSolarisConstants.c diff --git a/jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c b/jdk/make/src/native/genconstants/fs/genUnixConstants.c similarity index 100% rename from jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c rename to jdk/make/src/native/genconstants/fs/genUnixConstants.c From 708c2d8f03d1104cf1987d5e30c74391ce670553 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 13 Feb 2014 17:40:43 +0100 Subject: [PATCH 09/18] 8034193: Move X11 wrapper generator files to make/src and make/data Reviewed-by: ihse, alanb, tbell --- jdk/make/CompileJavaClasses.gmk | 2 -- jdk/make/Tools.gmk | 10 ++-------- .../data/x11wrappergen}/functions.txt | 0 .../X11/generator => make/data/x11wrappergen}/sizes.32 | 0 .../X11/generator => make/data/x11wrappergen}/sizes.64 | 0 .../data/x11wrappergen}/sizes.64-solaris-i386 | 0 .../data/x11wrappergen}/xlibtypes.txt | 0 jdk/make/gensrc/GensrcX11Wrappers.gmk | 2 +- .../build/tools/x11wrappergen}/WrapperGenerator.java | 2 ++ 9 files changed, 5 insertions(+), 11 deletions(-) rename jdk/{src/solaris/classes/sun/awt/X11/generator => make/data/x11wrappergen}/functions.txt (100%) rename jdk/{src/solaris/classes/sun/awt/X11/generator => make/data/x11wrappergen}/sizes.32 (100%) rename jdk/{src/solaris/classes/sun/awt/X11/generator => make/data/x11wrappergen}/sizes.64 (100%) rename jdk/{src/solaris/classes/sun/awt/X11/generator => make/data/x11wrappergen}/sizes.64-solaris-i386 (100%) rename jdk/{src/solaris/classes/sun/awt/X11/generator => make/data/x11wrappergen}/xlibtypes.txt (100%) rename jdk/{src/solaris/classes/sun/awt/X11/generator => make/src/classes/build/tools/x11wrappergen}/WrapperGenerator.java (99%) diff --git a/jdk/make/CompileJavaClasses.gmk b/jdk/make/CompileJavaClasses.gmk index 2c65d12cc8b..e993d75a8dd 100644 --- a/jdk/make/CompileJavaClasses.gmk +++ b/jdk/make/CompileJavaClasses.gmk @@ -100,8 +100,6 @@ ifneq ($(OPENJDK_TARGET_OS), solaris) EXCLUDES += com/oracle/security endif -EXFILES += WrapperGenerator.java - ifneq ($(OPENJDK_TARGET_OS), windows) # Exclude Window security related files in src/share/classes EXFILES += NTLoginModule.java \ diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 661bf3e3b03..52a843bce8e 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -26,17 +26,11 @@ # Cache all finds needed for this file. Only used on windows. $(eval $(call FillCacheFind, $(JDK_TOPDIR)/make/src/classes)) -TOOLS_SRC := $(JDK_TOPDIR)/make/src/classes - -ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) - TOOLS_SRC += $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator -endif - # The exception handling of swing beaninfo which have the own tool directory ifeq (, $(BUILD_TOOLS)) $(eval $(call SetupJavaCompilation,BUILD_TOOLS, \ SETUP := GENERATE_OLDBYTECODE, \ - SRC := $(TOOLS_SRC), \ + SRC := $(JDK_TOPDIR)/make/src/classes, \ BIN := $(JDK_OUTPUTDIR)/btclasses)) endif @@ -111,7 +105,7 @@ TOOL_GENERATENIMBUS = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.generatenimbus.Generator TOOL_WRAPPERGENERATOR = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \ - WrapperGenerator + build.tools.x11wrappergen.WrapperGenerator TOOL_AWT_TOBIN = $(JAVA) -Djava.awt.headless=true -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.icondata.awt.ToBin diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/functions.txt b/jdk/make/data/x11wrappergen/functions.txt similarity index 100% rename from jdk/src/solaris/classes/sun/awt/X11/generator/functions.txt rename to jdk/make/data/x11wrappergen/functions.txt diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.32 b/jdk/make/data/x11wrappergen/sizes.32 similarity index 100% rename from jdk/src/solaris/classes/sun/awt/X11/generator/sizes.32 rename to jdk/make/data/x11wrappergen/sizes.32 diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64 b/jdk/make/data/x11wrappergen/sizes.64 similarity index 100% rename from jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64 rename to jdk/make/data/x11wrappergen/sizes.64 diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386 b/jdk/make/data/x11wrappergen/sizes.64-solaris-i386 similarity index 100% rename from jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386 rename to jdk/make/data/x11wrappergen/sizes.64-solaris-i386 diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt b/jdk/make/data/x11wrappergen/xlibtypes.txt similarity index 100% rename from jdk/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt rename to jdk/make/data/x11wrappergen/xlibtypes.txt diff --git a/jdk/make/gensrc/GensrcX11Wrappers.gmk b/jdk/make/gensrc/GensrcX11Wrappers.gmk index 0afe0664104..2aff2f48b0a 100644 --- a/jdk/make/gensrc/GensrcX11Wrappers.gmk +++ b/jdk/make/gensrc/GensrcX11Wrappers.gmk @@ -42,7 +42,7 @@ GENSRC_X11WRAPPERS_TMP := $(JDK_OUTPUTDIR)/gensrc_x11wrappers GENSRC_X11WRAPPERS_DST := $(JDK_OUTPUTDIR)/gensrc/sun/awt/X11 # The pre-calculated offset file are stored here: -GENSRC_SIZER_DIR := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator +GENSRC_SIZER_DIR := $(JDK_TOPDIR)/make/data/x11wrappergen # Normal case is to generate only according to target bits GENSRC_X11_VERSION := $(OPENJDK_TARGET_CPU_BITS) diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java b/jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java similarity index 99% rename from jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java rename to jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java index 9da0fd93442..e3a68c42afb 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java +++ b/jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java @@ -23,6 +23,8 @@ * questions. */ +package build.tools.x11wrappergen; + import java.util.*; import java.io.*; import java.nio.charset.*; From c4edb555927986c9259c75990da017a1a5dea586 Mon Sep 17 00:00:00 2001 From: Jason Uh Date: Thu, 13 Feb 2014 11:47:43 -0800 Subject: [PATCH 10/18] 8031025: SQE test CertPath/CertPathBuilderTest/* failed with java.lang.IndexOutOfBoundsException Reviewed-by: mullan --- .../sun/security/provider/certpath/RevocationChecker.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/security/provider/certpath/RevocationChecker.java b/jdk/src/share/classes/sun/security/provider/certpath/RevocationChecker.java index 19b41f6bc64..f38e7dc5005 100644 --- a/jdk/src/share/classes/sun/security/provider/certpath/RevocationChecker.java +++ b/jdk/src/share/classes/sun/security/provider/certpath/RevocationChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -1035,6 +1035,9 @@ class RevocationChecker extends PKIXRevocationChecker { boolean signFlag = true; List cpList = cpbr.getCertPath().getCertificates(); + if (cpList.isEmpty()) { + return; + } try { for (int i = cpList.size()-1; i >= 0; i-- ) { X509Certificate cert = (X509Certificate)cpList.get(i); From 935bd9f97918048cc01d6c603d9490d5ed44a738 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Thu, 13 Feb 2014 14:48:39 -0800 Subject: [PATCH 11/18] 8034000: lack of /othervm option can cause some RMI tests to fail Reviewed-by: darcy, alanb --- jdk/test/java/rmi/MarshalledObject/compare/NullReference.java | 4 +++- jdk/test/java/rmi/server/Unmarshal/PrimitiveClasses.java | 3 ++- jdk/test/javax/rmi/ssl/SocketFactoryTest.java | 2 ++ jdk/test/sun/rmi/log/ReliableLog/LogAlignmentTest.java | 2 +- jdk/test/sun/rmi/log/ReliableLog/SnapshotSize.java | 2 +- jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/rmi/MarshalledObject/compare/NullReference.java b/jdk/test/java/rmi/MarshalledObject/compare/NullReference.java index 5210e948b51..b8f25bbbb6d 100644 --- a/jdk/test/java/rmi/MarshalledObject/compare/NullReference.java +++ b/jdk/test/java/rmi/MarshalledObject/compare/NullReference.java @@ -24,7 +24,9 @@ /* * @test * @bug 4105900 - * @summary MarshalledObject with null throws NullPointerException + * @summary MarshalledObject with null throws NullPointerException. + * This test does not affect VM global state, so othervm + * is not required. * @author Ken Arnold * * @run main NullReference diff --git a/jdk/test/java/rmi/server/Unmarshal/PrimitiveClasses.java b/jdk/test/java/rmi/server/Unmarshal/PrimitiveClasses.java index b9dfb0c300e..18f13eabfaf 100644 --- a/jdk/test/java/rmi/server/Unmarshal/PrimitiveClasses.java +++ b/jdk/test/java/rmi/server/Unmarshal/PrimitiveClasses.java @@ -24,7 +24,8 @@ /* @test * @bug 4442373 * @summary Verify that RMI can successfully unmarshal Class objects for - * primitive types. + * primitive types. This test does not affect VM global state, + * so othervm is not required. * @run main PrimitiveClasses */ diff --git a/jdk/test/javax/rmi/ssl/SocketFactoryTest.java b/jdk/test/javax/rmi/ssl/SocketFactoryTest.java index 76bf51a1c77..b3b7e0de908 100644 --- a/jdk/test/javax/rmi/ssl/SocketFactoryTest.java +++ b/jdk/test/javax/rmi/ssl/SocketFactoryTest.java @@ -25,6 +25,8 @@ * @test * @bug 4932837 6582235 * @summary Test SslRMI[Client|Server]SocketFactory equals() and hashCode(). + * This test does not affect VM global state, so othervm is + * not required. * @author Daniel Fuchs * * @run main SocketFactoryTest diff --git a/jdk/test/sun/rmi/log/ReliableLog/LogAlignmentTest.java b/jdk/test/sun/rmi/log/ReliableLog/LogAlignmentTest.java index 012c0b8cab9..b5b2066202f 100644 --- a/jdk/test/sun/rmi/log/ReliableLog/LogAlignmentTest.java +++ b/jdk/test/sun/rmi/log/ReliableLog/LogAlignmentTest.java @@ -25,7 +25,7 @@ * @bug 4094889 * @summary rmid can have a corrupted log * - * @run main LogAlignmentTest + * @run main/othervm LogAlignmentTest */ /* Fault: ReliableLog used RandomAccessFile.skipBytes() to seek past the end diff --git a/jdk/test/sun/rmi/log/ReliableLog/SnapshotSize.java b/jdk/test/sun/rmi/log/ReliableLog/SnapshotSize.java index 592ef5eaba9..ae379d8da3e 100644 --- a/jdk/test/sun/rmi/log/ReliableLog/SnapshotSize.java +++ b/jdk/test/sun/rmi/log/ReliableLog/SnapshotSize.java @@ -26,7 +26,7 @@ * @summary Verify that ReliableLog.snapshotSize() returns correct snapshot * file size even if LogHandler doesn't flush. * - * @run main SnapshotSize + * @run main/othervm SnapshotSize */ import java.io.ByteArrayOutputStream; diff --git a/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java b/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java index f4c64b75d33..747ccc15694 100644 --- a/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java +++ b/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java @@ -28,7 +28,8 @@ /* @test * @bug 6610897 * @summary New constructor in sun.tools.java.ClassPath builds a path using - * File.separator instead of File.pathSeparator + * File.separator instead of File.pathSeparator. This test does + * not affect VM global state, so othervm is not required. * @run main RMICClassPathTest */ From 3b32d0da29d2e1156395eaa6cf4f6c8aa71f5421 Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Thu, 13 Feb 2014 18:05:36 -0500 Subject: [PATCH 12/18] 8034896: Correct Clob.free javadoc typo Reviewed-by: dfuchs --- jdk/src/share/classes/java/sql/Clob.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/java/sql/Clob.java b/jdk/src/share/classes/java/sql/Clob.java index 86bd1cc870c..2cfd4e47018 100644 --- a/jdk/src/share/classes/java/sql/Clob.java +++ b/jdk/src/share/classes/java/sql/Clob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -309,8 +309,8 @@ public interface Clob { void truncate(long len) throws SQLException; /** - * This method frees the Clob object and releases the resources the resources - * that it holds. The object is invalid once the free method + * This method releases the resources that the Clob object + * holds. The object is invalid once the free method * is called. *

* After free has been called, any attempt to invoke a From 39d3c424cb882d2de76af6145c0a29e8e82d916d Mon Sep 17 00:00:00 2001 From: Tristan Yan Date: Thu, 13 Feb 2014 11:15:56 +0800 Subject: [PATCH 13/18] 8030844: sun/rmi/rmic/classpath/RMICClassPathTest.java timeout in same binaries run Reviewed-by: smarks --- .../sun/rmi/rmic/classpath/RMICClassPathTest.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java b/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java index 747ccc15694..cecdfb7ec43 100644 --- a/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java +++ b/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -26,7 +26,7 @@ */ /* @test - * @bug 6610897 + * @bug 6610897 8030844 * @summary New constructor in sun.tools.java.ClassPath builds a path using * File.separator instead of File.pathSeparator. This test does * not affect VM global state, so othervm is not required. @@ -38,12 +38,13 @@ import java.io.File; import sun.rmi.rmic.BatchEnvironment; public class RMICClassPathTest { + private final static String SRC_PATH = System.getProperty("test.src", "."); public static void main(String[] args) throws Exception { - String sysPath = "/home/~user/jdk/jre/lib/rt.jar"; + String sysPath = SRC_PATH + "/jdk/jre/lib/rt.jar"; String extDir = ""; - String clPath = "/home/~user/user.jar" + File.pathSeparator + - "/home/~user/user2.jar" + File.pathSeparator + - "/home/~user/user3.jar"; + String clPath = SRC_PATH + "/user.jar" + File.pathSeparator + + SRC_PATH + "/user2.jar" + File.pathSeparator + + SRC_PATH + "/user3.jar"; String cpStr = BatchEnvironment.createClassPath(clPath, sysPath, extDir).toString(); From 063b3a7453709eca60aa14f8cfcb7e2754a5e15e Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Fri, 14 Feb 2014 11:23:58 +0100 Subject: [PATCH 14/18] 8034801: AIX: (ch) Fix synchronization issue in AixPollPort.java Reviewed-by: alanb --- .../aix/classes/sun/nio/ch/AixPollPort.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/jdk/src/aix/classes/sun/nio/ch/AixPollPort.java b/jdk/src/aix/classes/sun/nio/ch/AixPollPort.java index 2db99a77b3e..a7a954597e5 100644 --- a/jdk/src/aix/classes/sun/nio/ch/AixPollPort.java +++ b/jdk/src/aix/classes/sun/nio/ch/AixPollPort.java @@ -107,6 +107,7 @@ final class AixPollPort private final ArrayBlockingQueue queue; private final Event NEED_TO_POLL = new Event(null, 0); private final Event EXECUTE_TASK_OR_SHUTDOWN = new Event(null, 0); + private final Event CONTINUE_AFTER_CTL_EVENT = new Event(null, 0); // encapsulates a pollset control event for a file descriptor static class ControlEvent { @@ -342,7 +343,11 @@ final class AixPollPort // To emulate one shot semantic we need to remove // the file descriptor here. - pollsetCtl(pollset, PS_DELETE, fd, 0); + if (fd != sp[0] && fd != ctlSp[0]) { + synchronized (controlQueue) { + pollsetCtl(pollset, PS_DELETE, fd, 0); + } + } // wakeup if (fd == sp[0]) { @@ -351,10 +356,6 @@ final class AixPollPort drain1(sp[0]); } - // This is the only file descriptor without - // one shot semantic => register it again. - pollsetCtl(pollset, PS_ADD, sp[0], Net.POLLIN); - // queue special event if there are more events // to handle. if (n > 0) { @@ -368,12 +369,12 @@ final class AixPollPort if (fd == ctlSp[0]) { synchronized (controlQueue) { drain1(ctlSp[0]); - // This file descriptor does not have - // one shot semantic => register it again. - pollsetCtl(pollset, PS_ADD, ctlSp[0], Net.POLLIN); processControlQueue(); } - continue; + if (n > 0) { + continue; + } + return CONTINUE_AFTER_CTL_EVENT; } PollableChannel channel = fdToChannel.get(fd); @@ -431,6 +432,11 @@ final class AixPollPort continue; } + // contine after we processed a control event + if (ev == CONTINUE_AFTER_CTL_EVENT) { + continue; + } + // handle wakeup to execute task or shutdown if (ev == EXECUTE_TASK_OR_SHUTDOWN) { Runnable task = pollTask(); From ee719c94cd92a8e286a572f0e72bec5306217c3c Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Fri, 14 Feb 2014 15:21:26 +0000 Subject: [PATCH 15/18] 8034943: Eliminate Kerberos dependency on com.sun.security.auth to avoid circular dependency Reviewed-by: weijun --- .../auth/callback/TextCallbackHandler.java | 202 +------------- .../classes/sun/security/jgss/GSSUtil.java | 4 +- .../security/util/ConsoleCallbackHandler.java | 247 ++++++++++++++++++ 3 files changed, 258 insertions(+), 195 deletions(-) create mode 100644 jdk/src/share/classes/sun/security/util/ConsoleCallbackHandler.java diff --git a/jdk/src/share/classes/com/sun/security/auth/callback/TextCallbackHandler.java b/jdk/src/share/classes/com/sun/security/auth/callback/TextCallbackHandler.java index 6bebfb4f398..86dfb7fba14 100644 --- a/jdk/src/share/classes/com/sun/security/auth/callback/TextCallbackHandler.java +++ b/jdk/src/share/classes/com/sun/security/auth/callback/TextCallbackHandler.java @@ -28,21 +28,14 @@ package com.sun.security.auth.callback; /* JAAS imports */ import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.ConfirmationCallback; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.TextOutputCallback; +import javax.security.auth.callback.NameCallback; // javadoc +import javax.security.auth.callback.PasswordCallback; // javadoc import javax.security.auth.callback.UnsupportedCallbackException; /* Java imports */ -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PushbackInputStream; -import java.util.Arrays; -import sun.security.util.Password; +import sun.security.util.ConsoleCallbackHandler; /** *

@@ -55,6 +48,7 @@ import sun.security.util.Password; @jdk.Exported public class TextCallbackHandler implements CallbackHandler { + private final CallbackHandler consoleHandler; /** *

Creates a callback handler that prompts and reads from the @@ -63,7 +57,9 @@ public class TextCallbackHandler implements CallbackHandler { * CallbackHandler. */ - public TextCallbackHandler() { } + public TextCallbackHandler() { + this.consoleHandler = new ConsoleCallbackHandler(); + } /** * Handles the specified set of callbacks. @@ -76,187 +72,7 @@ public class TextCallbackHandler implements CallbackHandler { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { - ConfirmationCallback confirmation = null; - - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof TextOutputCallback) { - TextOutputCallback tc = (TextOutputCallback) callbacks[i]; - - String text; - switch (tc.getMessageType()) { - case TextOutputCallback.INFORMATION: - text = ""; - break; - case TextOutputCallback.WARNING: - text = "Warning: "; - break; - case TextOutputCallback.ERROR: - text = "Error: "; - break; - default: - throw new UnsupportedCallbackException( - callbacks[i], "Unrecognized message type"); - } - - String message = tc.getMessage(); - if (message != null) { - text += message; - } - if (text != null) { - System.err.println(text); - } - - } else if (callbacks[i] instanceof NameCallback) { - NameCallback nc = (NameCallback) callbacks[i]; - - if (nc.getDefaultName() == null) { - System.err.print(nc.getPrompt()); - } else { - System.err.print(nc.getPrompt() + - " [" + nc.getDefaultName() + "] "); - } - System.err.flush(); - - String result = readLine(); - if (result.equals("")) { - result = nc.getDefaultName(); - } - - nc.setName(result); - - } else if (callbacks[i] instanceof PasswordCallback) { - PasswordCallback pc = (PasswordCallback) callbacks[i]; - - System.err.print(pc.getPrompt()); - System.err.flush(); - - pc.setPassword(Password.readPassword(System.in, pc.isEchoOn())); - - } else if (callbacks[i] instanceof ConfirmationCallback) { - confirmation = (ConfirmationCallback) callbacks[i]; - - } else { - throw new UnsupportedCallbackException( - callbacks[i], "Unrecognized Callback"); - } - } - - /* Do the confirmation callback last. */ - if (confirmation != null) { - doConfirmation(confirmation); - } - } - - /* Reads a line of input */ - private String readLine() throws IOException { - String result = new BufferedReader - (new InputStreamReader(System.in)).readLine(); - if (result == null) { - throw new IOException("Cannot read from System.in"); - } - return result; - } - - private void doConfirmation(ConfirmationCallback confirmation) - throws IOException, UnsupportedCallbackException - { - String prefix; - int messageType = confirmation.getMessageType(); - switch (messageType) { - case ConfirmationCallback.WARNING: - prefix = "Warning: "; - break; - case ConfirmationCallback.ERROR: - prefix = "Error: "; - break; - case ConfirmationCallback.INFORMATION: - prefix = ""; - break; - default: - throw new UnsupportedCallbackException( - confirmation, "Unrecognized message type: " + messageType); - } - - class OptionInfo { - String name; - int value; - OptionInfo(String name, int value) { - this.name = name; - this.value = value; - } - } - - OptionInfo[] options; - int optionType = confirmation.getOptionType(); - switch (optionType) { - case ConfirmationCallback.YES_NO_OPTION: - options = new OptionInfo[] { - new OptionInfo("Yes", ConfirmationCallback.YES), - new OptionInfo("No", ConfirmationCallback.NO) - }; - break; - case ConfirmationCallback.YES_NO_CANCEL_OPTION: - options = new OptionInfo[] { - new OptionInfo("Yes", ConfirmationCallback.YES), - new OptionInfo("No", ConfirmationCallback.NO), - new OptionInfo("Cancel", ConfirmationCallback.CANCEL) - }; - break; - case ConfirmationCallback.OK_CANCEL_OPTION: - options = new OptionInfo[] { - new OptionInfo("OK", ConfirmationCallback.OK), - new OptionInfo("Cancel", ConfirmationCallback.CANCEL) - }; - break; - case ConfirmationCallback.UNSPECIFIED_OPTION: - String[] optionStrings = confirmation.getOptions(); - options = new OptionInfo[optionStrings.length]; - for (int i = 0; i < options.length; i++) { - options[i] = new OptionInfo(optionStrings[i], i); - } - break; - default: - throw new UnsupportedCallbackException( - confirmation, "Unrecognized option type: " + optionType); - } - - int defaultOption = confirmation.getDefaultOption(); - - String prompt = confirmation.getPrompt(); - if (prompt == null) { - prompt = ""; - } - prompt = prefix + prompt; - if (!prompt.equals("")) { - System.err.println(prompt); - } - - for (int i = 0; i < options.length; i++) { - if (optionType == ConfirmationCallback.UNSPECIFIED_OPTION) { - // defaultOption is an index into the options array - System.err.println( - i + ". " + options[i].name + - (i == defaultOption ? " [default]" : "")); - } else { - // defaultOption is an option value - System.err.println( - i + ". " + options[i].name + - (options[i].value == defaultOption ? " [default]" : "")); - } - } - System.err.print("Enter a number: "); - System.err.flush(); - int result; - try { - result = Integer.parseInt(readLine()); - if (result < 0 || result > (options.length - 1)) { - result = defaultOption; - } - result = options[result].value; - } catch (NumberFormatException e) { - result = defaultOption; - } - - confirmation.setSelectedIndex(result); + // delegate to console handler + consoleHandler.handle(callbacks); } } diff --git a/jdk/src/share/classes/sun/security/jgss/GSSUtil.java b/jdk/src/share/classes/sun/security/jgss/GSSUtil.java index f2d9f376d80..51dbdd62846 100644 --- a/jdk/src/share/classes/sun/security/jgss/GSSUtil.java +++ b/jdk/src/share/classes/sun/security/jgss/GSSUtil.java @@ -25,7 +25,6 @@ package sun.security.jgss; -import com.sun.security.auth.callback.TextCallbackHandler; import javax.security.auth.Subject; import javax.security.auth.kerberos.KerberosPrincipal; import javax.security.auth.kerberos.KerberosTicket; @@ -48,6 +47,7 @@ import javax.security.auth.callback.CallbackHandler; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import sun.security.action.GetBooleanAction; +import sun.security.util.ConsoleCallbackHandler; /** * The GSSUtilImplementation that knows how to work with the internals of @@ -243,7 +243,7 @@ public class GSSUtil { if ((defaultHandler != null) && (defaultHandler.length() != 0)) { cb = null; } else { - cb = new TextCallbackHandler(); + cb = new ConsoleCallbackHandler(); } } diff --git a/jdk/src/share/classes/sun/security/util/ConsoleCallbackHandler.java b/jdk/src/share/classes/sun/security/util/ConsoleCallbackHandler.java new file mode 100644 index 00000000000..e29e0b15127 --- /dev/null +++ b/jdk/src/share/classes/sun/security/util/ConsoleCallbackHandler.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 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. 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 sun.security.util; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.ConfirmationCallback; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.TextOutputCallback; +import javax.security.auth.callback.UnsupportedCallbackException; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * A {@code CallbackHandler} that prompts and reads from the command line + * for answers to authentication questions. + */ +public class ConsoleCallbackHandler implements CallbackHandler { + + /** + * Creates a callback handler that prompts and reads from the + * command line for answers to authentication questions. + */ + public ConsoleCallbackHandler() { } + + /** + * Handles the specified set of callbacks. + * + * @param callbacks the callbacks to handle + * @throws IOException if an input or output error occurs. + * @throws UnsupportedCallbackException if the callback is not an + * instance of NameCallback or PasswordCallback + */ + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException + { + ConfirmationCallback confirmation = null; + + for (int i = 0; i < callbacks.length; i++) { + if (callbacks[i] instanceof TextOutputCallback) { + TextOutputCallback tc = (TextOutputCallback) callbacks[i]; + + String text; + switch (tc.getMessageType()) { + case TextOutputCallback.INFORMATION: + text = ""; + break; + case TextOutputCallback.WARNING: + text = "Warning: "; + break; + case TextOutputCallback.ERROR: + text = "Error: "; + break; + default: + throw new UnsupportedCallbackException( + callbacks[i], "Unrecognized message type"); + } + + String message = tc.getMessage(); + if (message != null) { + text += message; + } + if (text != null) { + System.err.println(text); + } + + } else if (callbacks[i] instanceof NameCallback) { + NameCallback nc = (NameCallback) callbacks[i]; + + if (nc.getDefaultName() == null) { + System.err.print(nc.getPrompt()); + } else { + System.err.print(nc.getPrompt() + + " [" + nc.getDefaultName() + "] "); + } + System.err.flush(); + + String result = readLine(); + if (result.equals("")) { + result = nc.getDefaultName(); + } + + nc.setName(result); + + } else if (callbacks[i] instanceof PasswordCallback) { + PasswordCallback pc = (PasswordCallback) callbacks[i]; + + System.err.print(pc.getPrompt()); + System.err.flush(); + + pc.setPassword(Password.readPassword(System.in, pc.isEchoOn())); + + } else if (callbacks[i] instanceof ConfirmationCallback) { + confirmation = (ConfirmationCallback) callbacks[i]; + + } else { + throw new UnsupportedCallbackException( + callbacks[i], "Unrecognized Callback"); + } + } + + /* Do the confirmation callback last. */ + if (confirmation != null) { + doConfirmation(confirmation); + } + } + + /* Reads a line of input */ + private String readLine() throws IOException { + String result = new BufferedReader + (new InputStreamReader(System.in)).readLine(); + if (result == null) { + throw new IOException("Cannot read from System.in"); + } + return result; + } + + private void doConfirmation(ConfirmationCallback confirmation) + throws IOException, UnsupportedCallbackException + { + String prefix; + int messageType = confirmation.getMessageType(); + switch (messageType) { + case ConfirmationCallback.WARNING: + prefix = "Warning: "; + break; + case ConfirmationCallback.ERROR: + prefix = "Error: "; + break; + case ConfirmationCallback.INFORMATION: + prefix = ""; + break; + default: + throw new UnsupportedCallbackException( + confirmation, "Unrecognized message type: " + messageType); + } + + class OptionInfo { + String name; + int value; + OptionInfo(String name, int value) { + this.name = name; + this.value = value; + } + } + + OptionInfo[] options; + int optionType = confirmation.getOptionType(); + switch (optionType) { + case ConfirmationCallback.YES_NO_OPTION: + options = new OptionInfo[] { + new OptionInfo("Yes", ConfirmationCallback.YES), + new OptionInfo("No", ConfirmationCallback.NO) + }; + break; + case ConfirmationCallback.YES_NO_CANCEL_OPTION: + options = new OptionInfo[] { + new OptionInfo("Yes", ConfirmationCallback.YES), + new OptionInfo("No", ConfirmationCallback.NO), + new OptionInfo("Cancel", ConfirmationCallback.CANCEL) + }; + break; + case ConfirmationCallback.OK_CANCEL_OPTION: + options = new OptionInfo[] { + new OptionInfo("OK", ConfirmationCallback.OK), + new OptionInfo("Cancel", ConfirmationCallback.CANCEL) + }; + break; + case ConfirmationCallback.UNSPECIFIED_OPTION: + String[] optionStrings = confirmation.getOptions(); + options = new OptionInfo[optionStrings.length]; + for (int i = 0; i < options.length; i++) { + options[i] = new OptionInfo(optionStrings[i], i); + } + break; + default: + throw new UnsupportedCallbackException( + confirmation, "Unrecognized option type: " + optionType); + } + + int defaultOption = confirmation.getDefaultOption(); + + String prompt = confirmation.getPrompt(); + if (prompt == null) { + prompt = ""; + } + prompt = prefix + prompt; + if (!prompt.equals("")) { + System.err.println(prompt); + } + + for (int i = 0; i < options.length; i++) { + if (optionType == ConfirmationCallback.UNSPECIFIED_OPTION) { + // defaultOption is an index into the options array + System.err.println( + i + ". " + options[i].name + + (i == defaultOption ? " [default]" : "")); + } else { + // defaultOption is an option value + System.err.println( + i + ". " + options[i].name + + (options[i].value == defaultOption ? " [default]" : "")); + } + } + System.err.print("Enter a number: "); + System.err.flush(); + int result; + try { + result = Integer.parseInt(readLine()); + if (result < 0 || result > (options.length - 1)) { + result = defaultOption; + } + result = options[result].value; + } catch (NumberFormatException e) { + result = defaultOption; + } + + confirmation.setSelectedIndex(result); + } +} From 878d40f04e912e7a5447382d51614744a6892974 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Sat, 15 Feb 2014 10:17:35 +0400 Subject: [PATCH 16/18] 4682009: Typo in javadocs in javax/naming Reviewed-by: lancea, alanb --- .../javax/naming/AuthenticationException.java | 4 ++-- .../AuthenticationNotSupportedException.java | 2 +- .../javax/naming/CannotProceedException.java | 2 +- .../classes/javax/naming/CompositeName.java | 4 ++-- .../share/classes/javax/naming/CompoundName.java | 8 ++++---- .../classes/javax/naming/LinkException.java | 16 ++++++++-------- .../classes/javax/naming/LinkLoopException.java | 4 ++-- .../javax/naming/MalformedLinkException.java | 2 +- .../classes/javax/naming/NamingException.java | 6 +++--- jdk/src/share/classes/javax/naming/RefAddr.java | 2 +- .../share/classes/javax/naming/Reference.java | 4 ++-- .../classes/javax/naming/Referenceable.java | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/jdk/src/share/classes/javax/naming/AuthenticationException.java b/jdk/src/share/classes/javax/naming/AuthenticationException.java index c66f4eaab31..2c0d788bf5a 100644 --- a/jdk/src/share/classes/javax/naming/AuthenticationException.java +++ b/jdk/src/share/classes/javax/naming/AuthenticationException.java @@ -29,7 +29,7 @@ package javax.naming; * This exception is thrown when an authentication error occurs while * accessing the naming or directory service. * An authentication error can happen, for example, when the credentials - * supplied by the user program is invalid or otherwise fails to + * supplied by the user program are invalid or otherwise fail to * authenticate the user to the naming/directory service. *

* If the program wants to handle this exception in particular, it @@ -37,7 +37,7 @@ package javax.naming; * catch NamingException. After catching AuthenticationException, the * program could reattempt the authentication by updating * the resolved context's environment properties with the appropriate - * appropriate credentials. + * credentials. *

* Synchronization and serialization issues that apply to NamingException * apply directly here. diff --git a/jdk/src/share/classes/javax/naming/AuthenticationNotSupportedException.java b/jdk/src/share/classes/javax/naming/AuthenticationNotSupportedException.java index aae22489f44..2287a3c636a 100644 --- a/jdk/src/share/classes/javax/naming/AuthenticationNotSupportedException.java +++ b/jdk/src/share/classes/javax/naming/AuthenticationNotSupportedException.java @@ -67,7 +67,7 @@ public class AuthenticationNotSupportedException extends NamingSecurityException /** * Constructs a new instance of AuthenticationNotSupportedException - * all name resolution fields and explanation initialized to null. + * with all name resolution fields and explanation initialized to null. */ public AuthenticationNotSupportedException() { super(); diff --git a/jdk/src/share/classes/javax/naming/CannotProceedException.java b/jdk/src/share/classes/javax/naming/CannotProceedException.java index 9754bd768e6..da3f55b1087 100644 --- a/jdk/src/share/classes/javax/naming/CannotProceedException.java +++ b/jdk/src/share/classes/javax/naming/CannotProceedException.java @@ -64,7 +64,7 @@ public class CannotProceedException extends NamingException { /** * Contains the remaining unresolved part of the second * "name" argument to Context.rename(). - * This information necessary for + * This information is necessary for * continuing the Context.rename() operation. *

* This field is initialized to null. diff --git a/jdk/src/share/classes/javax/naming/CompositeName.java b/jdk/src/share/classes/javax/naming/CompositeName.java index 7c79d529959..93ef152c64b 100644 --- a/jdk/src/share/classes/javax/naming/CompositeName.java +++ b/jdk/src/share/classes/javax/naming/CompositeName.java @@ -205,7 +205,7 @@ public class CompositeName implements Name { private transient NameImpl impl; /** * Constructs a new composite name instance using the components - * specified by 'comps'. This protected method is intended to be + * specified by 'comps'. This protected method is intended * to be used by subclasses of CompositeName when they override * methods such as clone(), getPrefix(), getSuffix(). * @@ -436,7 +436,7 @@ public class CompositeName implements Name { /** * Determines whether a composite name is a suffix of this composite name. - * A composite name 'n' is a suffix if it it is equal to + * A composite name 'n' is a suffix if it is equal to * getSuffix(size()-n.size())--in other words, this * composite name ends with 'n'. * If n is null or not a composite name, false is returned. diff --git a/jdk/src/share/classes/javax/naming/CompoundName.java b/jdk/src/share/classes/javax/naming/CompoundName.java index 6d41cf861e4..059d951cd71 100644 --- a/jdk/src/share/classes/javax/naming/CompoundName.java +++ b/jdk/src/share/classes/javax/naming/CompoundName.java @@ -165,7 +165,7 @@ public class CompoundName implements Name { /** * Constructs a new compound name instance using the components - * specified in comps and syntax. This protected method is intended to be + * specified in comps and syntax. This protected method is intended * to be used by subclasses of CompoundName when they override * methods such as clone(), getPrefix(), getSuffix(). * @@ -365,7 +365,7 @@ public class CompoundName implements Name { * components in this compound name. * The result and this compound name share the same syntax. * Subsequent changes to - * this compound name does not affect the name that is returned and + * this compound name do not affect the name that is returned and * vice versa. * * @param posn The 0-based index of the component at which to stop. @@ -385,7 +385,7 @@ public class CompoundName implements Name { * components in this compound name. * The result and this compound name share the same syntax. * Subsequent changes to - * this compound name does not affect the name that is returned. + * this compound name do not affect the name that is returned. * * @param posn The 0-based index of the component at which to start. * Must be in the range [0,size()]. @@ -423,7 +423,7 @@ public class CompoundName implements Name { /** * Determines whether a compound name is a suffix of this compound name. - * A compound name 'n' is a suffix if it it is equal to + * A compound name 'n' is a suffix if it is equal to * getSuffix(size()-n.size())--in other words, this * compound name ends with 'n'. * If n is null or not a compound name, false is returned. diff --git a/jdk/src/share/classes/javax/naming/LinkException.java b/jdk/src/share/classes/javax/naming/LinkException.java index 30f3ea4478f..60ce3d16181 100644 --- a/jdk/src/share/classes/javax/naming/LinkException.java +++ b/jdk/src/share/classes/javax/naming/LinkException.java @@ -26,11 +26,11 @@ package javax.naming; /** - * This exception is used to describe problems encounter while resolving links. - * Addition information is added to the base NamingException for pinpointing + * This exception is used to describe problems encountered while resolving links. + * Additional information is added to the base NamingException for pinpointing * the problem with the link. *

- * Analogous to how NamingException captures name resolution information, + * Analogously to how NamingException captures name resolution information, * LinkException captures "link"-name resolution information pinpointing * the problem encountered while resolving a link. All these fields may * be null. @@ -111,7 +111,7 @@ public class LinkException extends NamingException { protected String linkExplanation; /** - * Constructs a new instance of LinkException with an explanation + * Constructs a new instance of LinkException with an explanation. * All the other fields are initialized to null. * @param explanation A possibly null string containing additional * detail about this exception. @@ -176,7 +176,7 @@ public class LinkException extends NamingException { } /** - * Retrieves the explanation associated with the problem encounter + * Retrieves the explanation associated with the problem encountered * when resolving a link. * * @return The possibly null detail string explaining more about the problem @@ -190,7 +190,7 @@ public class LinkException extends NamingException { } /** - * Sets the explanation associated with the problem encounter + * Sets the explanation associated with the problem encountered * when resolving a link. * * @param msg The possibly null detail string explaining more about the problem @@ -211,7 +211,7 @@ public class LinkException extends NamingException { * invoke this method using the resulting composite name. *

* A copy of name is made and stored. - * Subsequent changes to name does not + * Subsequent changes to name do not * affect the copy in this NamingException and vice versa. * * @@ -237,7 +237,7 @@ public class LinkException extends NamingException { * invoke this method using the resulting composite name. *

* A copy of name is made and stored. - * Subsequent changes to name does not + * Subsequent changes to name do not * affect the copy in this NamingException and vice versa. * * @param name The name to set remaining link name to. This can be null. diff --git a/jdk/src/share/classes/javax/naming/LinkLoopException.java b/jdk/src/share/classes/javax/naming/LinkLoopException.java index 58b6a65b42a..6865233cf81 100644 --- a/jdk/src/share/classes/javax/naming/LinkLoopException.java +++ b/jdk/src/share/classes/javax/naming/LinkLoopException.java @@ -27,7 +27,7 @@ package javax.naming; /** * This exception is thrown when - * a loop was detected will attempting to resolve a link, or an implementation + * a loop was detected while attempting to resolve a link, or an implementation * specific limit on link counts has been reached. *

* Synchronization and serialization issues that apply to LinkException @@ -42,7 +42,7 @@ package javax.naming; public class LinkLoopException extends LinkException { /** - * Constructs a new instance of LinkLoopException with an explanation + * Constructs a new instance of LinkLoopException with an explanation. * All the other fields are initialized to null. * @param explanation A possibly null string containing additional * detail about this exception. diff --git a/jdk/src/share/classes/javax/naming/MalformedLinkException.java b/jdk/src/share/classes/javax/naming/MalformedLinkException.java index f23ef9e40f2..1d7e511fd7c 100644 --- a/jdk/src/share/classes/javax/naming/MalformedLinkException.java +++ b/jdk/src/share/classes/javax/naming/MalformedLinkException.java @@ -42,7 +42,7 @@ package javax.naming; public class MalformedLinkException extends LinkException { /** - * Constructs a new instance of MalformedLinkException with an explanation + * Constructs a new instance of MalformedLinkException with an explanation. * All the other fields are initialized to null. * @param explanation A possibly null string containing additional * detail about this exception. diff --git a/jdk/src/share/classes/javax/naming/NamingException.java b/jdk/src/share/classes/javax/naming/NamingException.java index 030acc6a72f..e1252da5f00 100644 --- a/jdk/src/share/classes/javax/naming/NamingException.java +++ b/jdk/src/share/classes/javax/naming/NamingException.java @@ -201,7 +201,7 @@ public class NamingException extends Exception { * invoke this method using the resulting composite name. *

* A copy of name is made and stored. - * Subsequent changes to name does not + * Subsequent changes to name do not * affect the copy in this NamingException and vice versa. * * @param name The possibly null name to set resolved name to. @@ -225,7 +225,7 @@ public class NamingException extends Exception { * invoke this method using the resulting composite name. *

* A copy of name is made and stored. - * Subsequent changes to name does not + * Subsequent changes to name do not * affect the copy in this NamingException and vice versa. * @param name The possibly null name to set remaining name to. * If null, it sets the remaining name field to null. @@ -279,7 +279,7 @@ public class NamingException extends Exception { * a compound name, you should "stringify" the compound name * then invoke the overloaded form that accepts a String parameter. *

- * Subsequent changes to name does not + * Subsequent changes to name do not * affect the remaining name field in this NamingException and vice versa. * @param name The possibly null name containing ordered components to add. * If name is null, this method does not do anything. diff --git a/jdk/src/share/classes/javax/naming/RefAddr.java b/jdk/src/share/classes/javax/naming/RefAddr.java index 92ac4320f5d..3dc90f21adf 100644 --- a/jdk/src/share/classes/javax/naming/RefAddr.java +++ b/jdk/src/share/classes/javax/naming/RefAddr.java @@ -90,7 +90,7 @@ public abstract class RefAddr implements java.io.Serializable { /** * Determines whether obj is equal to this RefAddr. *

- * obj is equal to this RefAddr all of these conditions are true + * obj is equal to this RefAddr if all of these conditions are true *

    *
  • non-null *
  • instance of RefAddr diff --git a/jdk/src/share/classes/javax/naming/Reference.java b/jdk/src/share/classes/javax/naming/Reference.java index 51e0be7f88c..34593168cc8 100644 --- a/jdk/src/share/classes/javax/naming/Reference.java +++ b/jdk/src/share/classes/javax/naming/Reference.java @@ -218,8 +218,8 @@ public class Reference implements Cloneable, java.io.Serializable { * String.compareTo() is used to test the equality of the address types. * * @param addrType The non-null address type for which to find the address. - * @return The address in this reference with address type 'addrType; - * null if no such address exist. + * @return The address in this reference with address type 'addrType'; + * null if no such address exists. */ public RefAddr get(String addrType) { int len = addrs.size(); diff --git a/jdk/src/share/classes/javax/naming/Referenceable.java b/jdk/src/share/classes/javax/naming/Referenceable.java index ef45b06c1a7..1bb6d8176d4 100644 --- a/jdk/src/share/classes/javax/naming/Referenceable.java +++ b/jdk/src/share/classes/javax/naming/Referenceable.java @@ -33,7 +33,7 @@ package javax.naming; * objects which themselves are not directly bound to the naming system. * Such objects can implement the Referenceable interface as a way * for programs that use that object to determine what its Reference is. - * For example, when binding a object, if an object implements the + * For example, when binding an object, if an object implements the * Referenceable interface, getReference() can be invoked on the object to * get its Reference to use for binding. * From 431e7d6c3903a048c39f15691644b334ca250ddb Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Mon, 17 Feb 2014 09:43:12 +0100 Subject: [PATCH 17/18] 8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use Reviewed-by: dfuchs, sjiang --- .../jmxremote/startstop/JMXStartStopTest.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java index 65f4a3a33aa..fe3a7748377 100644 --- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.net.ConnectException; +import java.net.ServerSocket; import java.rmi.NoSuchObjectException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; @@ -255,26 +256,23 @@ public class JMXStartStopTest { private static List failures = new ArrayList<>(); public static void main(String args[]) throws Exception { - for (int i=0;i<3;i++) { - System.out.println("=== PASS " + i + " ==="); - for (Method m : JMXStartStopTest.class.getDeclaredMethods()) { - if (m.getName().startsWith("test_")) { - try { - m.invoke(null); - System.out.println("=== PASSED\n"); - } catch (Throwable e) { - failures.add(new Failure(e, m.getName() + " failed")); - } + for (Method m : JMXStartStopTest.class.getDeclaredMethods()) { + if (m.getName().startsWith("test_")) { + try { + m.invoke(null); + System.out.println("=== PASSED\n"); + } catch (Throwable e) { + failures.add(new Failure(e, m.getName() + " failed")); } } + } - if (!failures.isEmpty()) { - for(Failure f : failures) { - System.err.println(f.getMsg()); - f.getCause().printStackTrace(System.err); - } - throw new Error(); + if (!failures.isEmpty()) { + for(Failure f : failures) { + System.err.println(f.getMsg()); + f.getCause().printStackTrace(System.err); } + throw new Error(); } } @@ -371,6 +369,7 @@ public class JMXStartStopTest { )); pbArgs.addAll(Arrays.asList(args)); pbArgs.add("JMXStartStopDoSomething"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( pbArgs.toArray(new String[pbArgs.size()]) ); @@ -596,14 +595,16 @@ public class JMXStartStopTest { jcmd(CMD_STOP); jcmd(CMD_STOP); + ServerSocket ss = new ServerSocket(0); + jcmd( line -> { - if (line.contains("Port already in use: 22")) { + if (line.contains("Port already in use: " + ss.getLocalPort())) { checks[2] = true; } }, CMD_START, - "jmxremote.port=22", + "jmxremote.port=" + ss.getLocalPort(), "jmxremote.rmi.port=" + port2, "jmxremote.authenticate=false", "jmxremote.ssl=false"); @@ -616,7 +617,7 @@ public class JMXStartStopTest { "report an invalid agent state"); } if (!checks[2]) { - throw new Exception("Starting agent on port 22 should " + + throw new Exception("Starting agent on port " + ss.getLocalPort() + " should " + "report port in use"); } } finally { @@ -627,7 +628,7 @@ public class JMXStartStopTest { private static void test_07() throws Exception { // Run an app without JMX enabled, but with some properties set // in command line. - // make sure these properties overriden corectly + // make sure these properties overridden corectly System.out.println("**** Test seven ****"); @@ -654,7 +655,7 @@ public class JMXStartStopTest { // Run an app with JMX enabled and with some properties set // in command line. // stop JMX agent and then start it again with different property values - // make sure these properties overriden corectly + // make sure these properties overridden corectly System.out.println("**** Test eight ****"); @@ -690,7 +691,7 @@ public class JMXStartStopTest { // stop JMX agent and then start it again with different property values // specifing some property in management config file and some of them // in command line - // make sure these properties overriden corectly + // make sure these properties overridden corectly System.out.println("**** Test nine ****"); @@ -725,7 +726,7 @@ public class JMXStartStopTest { // in command line. // stop JMX agent and then start it again with different property values // stop JMX agent again and then start it without property value - // make sure these properties overriden corectly + // make sure these properties overridden corectly System.out.println("**** Test ten ****"); @@ -800,7 +801,7 @@ public class JMXStartStopTest { // Run an app with -javaagent make sure it works as expected - // system properties are ignored - System.out.println("**** Test fourteen ****"); + System.out.println("**** Test thirteen ****"); String agent = TEST_JDK + "/jre/lib/management-agent.jar"; if (!new File(agent).exists()) { From 2b1f66ac9555c281afc64b8cdc1a0dbd03c6f5df Mon Sep 17 00:00:00 2001 From: Amanda Jiang Date: Mon, 17 Feb 2014 11:27:18 +0000 Subject: [PATCH 18/18] 8031661: java/net/Authenticator/B4769350.java failed intermittently Reviewed-by: michaelm --- jdk/test/java/net/Authenticator/B4769350.java | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/jdk/test/java/net/Authenticator/B4769350.java b/jdk/test/java/net/Authenticator/B4769350.java index e6cdaa12b74..8e302d93b86 100644 --- a/jdk/test/java/net/Authenticator/B4769350.java +++ b/jdk/test/java/net/Authenticator/B4769350.java @@ -66,14 +66,15 @@ public class B4769350 { this.allowerror = allowerror; } + @Override public void run () { try { URI u = new URI ("http", authority, path, null, null); URL url = u.toURL(); URLConnection urlc = url.openConnection(); - InputStream is = urlc.getInputStream(); - read (is); - is.close(); + try (InputStream is = urlc.getInputStream()) { + read (is); + } } catch (URISyntaxException e) { System.out.println (e); error = true; @@ -91,8 +92,6 @@ public class B4769350 { class Server implements AutoCloseable { HttpServer server; Executor executor; - CyclicBarrier t1Cond1; - CyclicBarrier t1Cond2; public String getAddress() { return server.getAddress().getHostName(); @@ -126,8 +125,7 @@ public class B4769350 { new AuthenticationHandlerT3bc()); server.createContext("/test/realm4/t3c", new AuthenticationHandlerT3bc()); - t1Cond1 = new CyclicBarrier(2); - t1Cond2 = new CyclicBarrier(2); + t1Cond1 = new CyclicBarrier(3); server.start(); } @@ -135,6 +133,7 @@ public class B4769350 { return server.getAddress().getPort(); } + @Override public void close() { if (executor != null) ((ExecutorService)executor).shutdownNow(); @@ -163,7 +162,6 @@ public class B4769350 { break; case 1: t1Cond1.await(); - t1cond2latch.await(); AuthenticationHandler.okReply(exchange); break; default: @@ -192,8 +190,6 @@ public class B4769350 { break; case 1: t1Cond1.await(); - t1cond1latch.countDown(); - t1cond2latch.await(); AuthenticationHandler.okReply(exchange); break; default: @@ -216,13 +212,6 @@ public class B4769350 { case 0: AuthenticationHandler.errorReply(exchange, "Basic realm=\"realm1\""); - try { - t1Cond2.await(); - } catch (InterruptedException | - BrokenBarrierException e) - { - throw new RuntimeException(e); - } break; case 1: AuthenticationHandler.okReply(exchange); @@ -244,14 +233,6 @@ public class B4769350 { case 0: AuthenticationHandler.errorReply(exchange, "Basic realm=\"realm2\""); - try { - t1Cond2.await(); - } catch (InterruptedException | - BrokenBarrierException e) - { - throw new RuntimeException(e); - } - t1cond2latch.countDown(); break; case 1: AuthenticationHandler.okReply(exchange); @@ -377,9 +358,9 @@ public class B4769350 { exchange.getResponseHeaders().add("Connection", "close"); String response = "Hello ."; exchange.sendResponseHeaders(200, response.getBytes().length); - OutputStream os = exchange.getResponseBody(); - os.write(response.getBytes()); - os.close(); + try (OutputStream os = exchange.getResponseBody()) { + os.write(response.getBytes()); + } exchange.close(); } } @@ -391,10 +372,9 @@ public class B4769350 { static Client c1,c2,c3,c4,c5,c6,c7,c8,c9; - static CountDownLatch t1cond1latch; - static CountDownLatch t1cond2latch; static CountDownLatch t2condlatch; static CountDownLatch t3cond1; + static CyclicBarrier t1Cond1; static void doServerTests (String authority, Server server) throws Exception { @@ -404,10 +384,8 @@ public class B4769350 { c2 = new Client (authority, "/test/realm2/t1b", false); c3 = new Client (authority, "/test/realm1/t1c", false); c4 = new Client (authority, "/test/realm2/t1d", false); - t1cond1latch = new CountDownLatch(1); - t1cond2latch = new CountDownLatch(1); c1.start(); c2.start(); - t1cond1latch.await(); + t1Cond1.await(); c3.start(); c4.start(); c1.join(); c2.join(); c3.join(); c4.join();