From 3b10a3f9b81229e3fec028fe173b3e7de69f65b6 Mon Sep 17 00:00:00 2001 From: Bradford Wetmore Date: Mon, 21 May 2012 15:42:15 -0700 Subject: [PATCH 01/56] 7167656: Multiple Seeders are being created Reviewed-by: smarks, mduigou, ahgross --- .../sun/security/provider/SecureRandom.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/jdk/src/share/classes/sun/security/provider/SecureRandom.java b/jdk/src/share/classes/sun/security/provider/SecureRandom.java index e79e9d7f49a..fa88334e1c3 100644 --- a/jdk/src/share/classes/sun/security/provider/SecureRandom.java +++ b/jdk/src/share/classes/sun/security/provider/SecureRandom.java @@ -56,12 +56,6 @@ implements java.io.Serializable { private static final long serialVersionUID = 3581829991155417889L; - /** - * This static object will be seeded by SeedGenerator, and used - * to seed future instances of SecureRandom - */ - private static SecureRandom seeder; - private static final int DIGEST_SIZE = 20; private transient MessageDigest digest; private byte[] state; @@ -172,6 +166,28 @@ implements java.io.Serializable { state[0]++; } + /** + * This static object will be seeded by SeedGenerator, and used + * to seed future instances of SHA1PRNG SecureRandoms. + * + * Bloch, Effective Java Second Edition: Item 71 + */ + private static class SeederHolder { + + private static final SecureRandom seeder; + + static { + /* + * Call to SeedGenerator.generateSeed() to add additional + * seed material (likely from the Native implementation). + */ + seeder = new SecureRandom(SeedGenerator.getSystemEntropy()); + byte [] b = new byte[DIGEST_SIZE]; + SeedGenerator.generateSeed(b); + seeder.engineSetSeed(b); + } + } + /** * Generates a user-specified number of random bytes. * @@ -183,13 +199,8 @@ implements java.io.Serializable { byte[] output = remainder; if (state == null) { - if (seeder == null) { - seeder = new SecureRandom(SeedGenerator.getSystemEntropy()); - seeder.engineSetSeed(engineGenerateSeed(DIGEST_SIZE)); - } - byte[] seed = new byte[DIGEST_SIZE]; - seeder.engineNextBytes(seed); + SeederHolder.seeder.engineNextBytes(seed); state = digest.digest(seed); } From 52f39f95df16df5d3f5c9c6df42cacb2778f3a45 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Fri, 8 Jun 2012 11:02:47 -0400 Subject: [PATCH 02/56] 7163198: Tightened package accessibility 7169887: Tightened package accessibility Reviewed-by: vinnie, hawtin --- jdk/src/share/lib/security/java.security | 4 ++-- jdk/src/share/lib/security/java.security-macosx | 4 ++-- jdk/src/share/lib/security/java.security-solaris | 4 ++-- jdk/src/share/lib/security/java.security-windows | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jdk/src/share/lib/security/java.security b/jdk/src/share/lib/security/java.security index e8ca7bd7eea..3bb8597654c 100644 --- a/jdk/src/share/lib/security/java.security +++ b/jdk/src/share/lib/security/java.security @@ -145,7 +145,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # List of comma-separated packages that start with or equal this string @@ -157,7 +157,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun. # by default, none of the class loaders supplied with the JDK call # checkPackageDefinition. # -package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # Determines whether this properties file can be appended to diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx index 1c04236e5d6..689172f40d6 100644 --- a/jdk/src/share/lib/security/java.security-macosx +++ b/jdk/src/share/lib/security/java.security-macosx @@ -146,7 +146,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # List of comma-separated packages that start with or equal this string @@ -158,7 +158,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun. # by default, none of the class loaders supplied with the JDK call # checkPackageDefinition. # -package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # Determines whether this properties file can be appended to diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris index 87a6f1ea5b4..1c5062c4c8b 100644 --- a/jdk/src/share/lib/security/java.security-solaris +++ b/jdk/src/share/lib/security/java.security-solaris @@ -147,7 +147,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # List of comma-separated packages that start with or equal this string @@ -159,7 +159,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun. # by default, none of the class loaders supplied with the JDK call # checkPackageDefinition. # -package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # Determines whether this properties file can be appended to diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows index e7c36d8c470..c98c0c95865 100644 --- a/jdk/src/share/lib/security/java.security-windows +++ b/jdk/src/share/lib/security/java.security-windows @@ -146,7 +146,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # List of comma-separated packages that start with or equal this string @@ -158,7 +158,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun. # by default, none of the class loaders supplied with the JDK call # checkPackageDefinition. # -package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils. +package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal. # # Determines whether this properties file can be appended to From a15896d20e9470d22e8cb97c1e51d94d7b9d760c Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 15 Jun 2012 09:51:09 +0800 Subject: [PATCH 03/56] 6631398: FilePermission improved path checking Reviewed-by: mullan, skoivu, jdn --- jdk/src/share/classes/java/io/FilePermission.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/io/FilePermission.java b/jdk/src/share/classes/java/io/FilePermission.java index a5781f3fb00..2555a77644d 100644 --- a/jdk/src/share/classes/java/io/FilePermission.java +++ b/jdk/src/share/classes/java/io/FilePermission.java @@ -418,7 +418,7 @@ public final class FilePermission extends Permission implements Serializable { */ public int hashCode() { - return this.cpath.hashCode(); + return 0; } /** From d87e57ac8aaa1902baeadb3a73aa757a3505fda1 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 18 Jun 2012 10:00:55 -0400 Subject: [PATCH 04/56] 7172522: Improve DomainCombiner checking Reviewed-by: vinnie, ahgross --- jdk/src/share/classes/java/security/AccessController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/java/security/AccessController.java b/jdk/src/share/classes/java/security/AccessController.java index 97383f54a46..8a8eadea62d 100644 --- a/jdk/src/share/classes/java/security/AccessController.java +++ b/jdk/src/share/classes/java/security/AccessController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -293,7 +293,7 @@ public final class AccessController { DomainCombiner dc = null; AccessControlContext acc = getStackAccessControlContext(); if (acc == null || (dc = acc.getAssignedCombiner()) == null) { - return AccessController.doPrivileged(action); + return AccessController.doPrivileged(action, acc); } return AccessController.doPrivileged(action, preserveCombiner(dc)); } @@ -389,7 +389,7 @@ public final class AccessController { DomainCombiner dc = null; AccessControlContext acc = getStackAccessControlContext(); if (acc == null || (dc = acc.getAssignedCombiner()) == null) { - return AccessController.doPrivileged(action); + return AccessController.doPrivileged(action, acc); } return AccessController.doPrivileged(action, preserveCombiner(dc)); } From 63cf10e50057789d99c83d231c14cb3005c663ad Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Thu, 21 Jun 2012 00:20:49 -0700 Subject: [PATCH 05/56] 7093490: adjust package access in rmiregistry Reviewed-by: ahgross, coffeys, dmocek --- jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java index 34579c204de..e086f79c1bf 100644 --- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java +++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java @@ -405,7 +405,8 @@ public class RegistryImpl extends java.rmi.server.RemoteServer */ perms.add(new SocketPermission("*", "connect,accept")); - perms.add(new RuntimePermission("accessClassInPackage.sun.*")); + perms.add(new RuntimePermission("accessClassInPackage.sun.jvmstat.*")); + perms.add(new RuntimePermission("accessClassInPackage.sun.jvm.hotspot.*")); perms.add(new FilePermission("<>", "read")); From 9a307c8287e7cc0594d41bf877ef6263a0ec1b4c Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Fri, 22 Jun 2012 16:22:22 +0400 Subject: [PATCH 06/56] 7158796: Tighten properties checking in EnvHelp Move getProperty call out of computeBooleanFromString Reviewed-by: skoivu, sla --- .../remote/internal/ServerNotifForwarder.java | 6 +- .../com/sun/jmx/remote/util/EnvHelp.java | 76 +++++-------------- .../management/remote/rmi/RMIConnector.java | 6 +- .../remote/rmi/RMIConnectorServer.java | 5 +- 4 files changed, 26 insertions(+), 67 deletions(-) diff --git a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java index ba071411608..58ccfb45280 100644 --- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java +++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java @@ -68,9 +68,9 @@ public class ServerNotifForwarder { this.notifBuffer = notifBuffer; this.connectionId = connectionId; connectionTimeout = EnvHelp.getServerConnectionTimeout(env); - checkNotificationEmission = EnvHelp.computeBooleanFromString( - env, - "jmx.remote.x.check.notification.emission",false); + + String stringBoolean = (String) env.get("jmx.remote.x.check.notification.emission"); + checkNotificationEmission = EnvHelp.computeBooleanFromString( stringBoolean ); notificationAccessController = EnvHelp.getNotificationAccessController(env); } diff --git a/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java b/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java index e61d9d09d60..b8bf9d37a0f 100644 --- a/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java +++ b/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java @@ -665,97 +665,57 @@ public class EnvHelp { * Computes a boolean value from a string value retrieved from a * property in the given map. * - * @param env the environment map. - * @param prop the name of the property in the environment map whose - * returned string value must be converted into a boolean value. - * @param systemProperty if true, consult a system property of the - * same name if there is no entry in the environment map. + * @param stringBoolean the string value that must be converted + * into a boolean value. * * @return *
    - *
  • {@code false} if {@code env.get(prop)} is {@code null}
  • + *
  • {@code false} if {@code stringBoolean} is {@code null}
  • *
  • {@code false} if - * {@code ((String)env.get(prop)).equalsIgnoreCase("false")} + * {@code stringBoolean.equalsIgnoreCase("false")} * is {@code true}
  • *
  • {@code true} if - * {@code ((String)env.get(prop)).equalsIgnoreCase("true")} + * {@code stringBoolean.equalsIgnoreCase("true")} * is {@code true}
  • *
* - * @throws IllegalArgumentException if {@code env} is {@code null} or - * {@code env.get(prop)} is not {@code null} and + * @throws IllegalArgumentException if * {@code ((String)env.get(prop)).equalsIgnoreCase("false")} and * {@code ((String)env.get(prop)).equalsIgnoreCase("true")} are * {@code false}. - * @throws ClassCastException if {@code env.get(prop)} cannot be cast - * to {@code String}. */ - public static boolean computeBooleanFromString( - Map env, String prop, boolean systemProperty) { - - if (env == null) - throw new IllegalArgumentException("env map cannot be null"); - + public static boolean computeBooleanFromString(String stringBoolean) { // returns a default value of 'false' if no property is found... - return computeBooleanFromString(env,prop,systemProperty,false); + return computeBooleanFromString(stringBoolean,false); } /** * Computes a boolean value from a string value retrieved from a * property in the given map. * - * @param env the environment map. - * @param prop the name of the property in the environment map whose - * returned string value must be converted into a boolean value. - * @param systemProperty if true, consult a system property of the - * same name if there is no entry in the environment map. + * @param stringBoolean the string value that must be converted + * into a boolean value. * @param defaultValue a default value to return in case no property * was defined. * * @return *
    - *
  • {@code defaultValue} if {@code env.get(prop)} is {@code null} - * and {@code systemProperty} is {@code false}
  • - *
  • {@code defaultValue} if {@code env.get(prop)} is {@code null} - * and {@code systemProperty} is {@code true} and - * {@code System.getProperty(prop)} is {@code null}
  • - *
  • {@code false} if {@code env.get(prop)} is {@code null} - * and {@code systemProperty} is {@code true} and - * {@code System.getProperty(prop).equalsIgnoreCase("false")} - * is {@code true}
  • - *
  • {@code true} if {@code env.get(prop)} is {@code null} - * and {@code systemProperty} is {@code true} and - * {@code System.getProperty(prop).equalsIgnoreCase("true")} - * is {@code true}
  • + *
  • {@code defaultValue} if {@code stringBoolean} + * is {@code null}
  • *
  • {@code false} if - * {@code ((String)env.get(prop)).equalsIgnoreCase("false")} + * {@code stringBoolean.equalsIgnoreCase("false")} * is {@code true}
  • *
  • {@code true} if - * {@code ((String)env.get(prop)).equalsIgnoreCase("true")} + * {@code stringBoolean.equalsIgnoreCase("true")} * is {@code true}
  • *
* - * @throws IllegalArgumentException if {@code env} is {@code null} or - * {@code env.get(prop)} is not {@code null} and + * @throws IllegalArgumentException if * {@code ((String)env.get(prop)).equalsIgnoreCase("false")} and * {@code ((String)env.get(prop)).equalsIgnoreCase("true")} are * {@code false}. - * @throws ClassCastException if {@code env.get(prop)} cannot be cast - * to {@code String}. */ - public static boolean computeBooleanFromString( - Map env, String prop, - boolean systemProperty, boolean defaultValue) { - - if (env == null) - throw new IllegalArgumentException("env map cannot be null"); - - String stringBoolean = (String) env.get(prop); - if (stringBoolean == null && systemProperty) { - stringBoolean = - AccessController.doPrivileged(new GetPropertyAction(prop)); - } - + public static boolean computeBooleanFromString( String stringBoolean, boolean defaultValue) { if (stringBoolean == null) return defaultValue; else if (stringBoolean.equalsIgnoreCase("true")) @@ -763,8 +723,8 @@ public class EnvHelp { else if (stringBoolean.equalsIgnoreCase("false")) return false; else - throw new IllegalArgumentException(prop + - " must be \"true\" or \"false\" instead of \"" + + throw new IllegalArgumentException( + "Property value must be \"true\" or \"false\" instead of \"" + stringBoolean + "\""); } diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java index f5359f9b12c..f6d17d6cc08 100644 --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java @@ -277,9 +277,9 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable // Check for secure RMIServer stub if the corresponding // client-side environment property is set to "true". // - boolean checkStub = EnvHelp.computeBooleanFromString( - usemap, - "jmx.remote.x.check.stub",false); + String stringBoolean = (String) usemap.get("jmx.remote.x.check.stub"); + boolean checkStub = EnvHelp.computeBooleanFromString(stringBoolean); + if (checkStub) checkStub(stub, rmiServerImplStubClass); // Connect IIOP Stub if needed. diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java index 909b9cb0d47..da92f49f70b 100644 --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java @@ -412,9 +412,8 @@ public class RMIConnectorServer extends JMXConnectorServer { if (tracing) logger.trace("start", "Using external directory: " + jndiUrl); - final boolean rebind = EnvHelp.computeBooleanFromString( - attributes, - JNDI_REBIND_ATTRIBUTE,false); + String stringBoolean = (String) attributes.get(JNDI_REBIND_ATTRIBUTE); + final boolean rebind = EnvHelp.computeBooleanFromString( stringBoolean ); if (tracing) logger.trace("start", JNDI_REBIND_ATTRIBUTE + "=" + rebind); From 5e84600efcf5392e04e12a6b56aa4104c241022d Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Fri, 22 Jun 2012 18:19:48 +0400 Subject: [PATCH 07/56] 7169888: Narrowing resource definitions in JMX RMI connector CPU bug, we can't put offending calls outside doPrivileged, but narrow granted permissions. Reviewed-by: ahgross, fparain --- .../remote/rmi/RMIConnectionImpl.java | 89 ++++++++++--------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java index f322af0f2bc..9449210e897 100644 --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java @@ -25,6 +25,30 @@ package javax.management.remote.rmi; +import java.io.IOException; +import java.rmi.MarshalledObject; +import java.rmi.UnmarshalException; +import java.rmi.server.Unreferenced; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.security.ProtectionDomain; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import javax.management.*; +import javax.management.remote.JMXServerErrorException; +import javax.management.remote.NotificationResult; +import javax.management.remote.TargetedNotification; +import javax.security.auth.Subject; + import static com.sun.jmx.mbeanserver.Util.cast; import com.sun.jmx.remote.internal.ServerCommunicatorAdmin; import com.sun.jmx.remote.internal.ServerNotifForwarder; @@ -35,44 +59,6 @@ import com.sun.jmx.remote.util.ClassLogger; import com.sun.jmx.remote.util.EnvHelp; import com.sun.jmx.remote.util.OrderClassLoaders; -import java.io.IOException; -import java.rmi.MarshalledObject; -import java.rmi.UnmarshalException; -import java.rmi.server.Unreferenced; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.IntrospectionException; -import javax.management.InvalidAttributeValueException; -import javax.management.ListenerNotFoundException; -import javax.management.MBeanException; -import javax.management.MBeanInfo; -import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; -import javax.management.NotCompliantMBeanException; -import javax.management.NotificationFilter; -import javax.management.ObjectInstance; -import javax.management.ObjectName; -import javax.management.QueryExp; -import javax.management.ReflectionException; -import javax.management.RuntimeOperationsException; -import javax.management.remote.JMXServerErrorException; -import javax.management.remote.NotificationResult; -import javax.management.remote.TargetedNotification; -import javax.security.auth.Subject; - /** *

Implementation of the {@link RMIConnection} interface. User * code will not usually reference this class.

@@ -143,6 +129,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { this.mbeanServer = rmiServer.getMBeanServer(); final ClassLoader dcl = defaultClassLoader; + this.classLoaderWithRepository = AccessController.doPrivileged( new PrivilegedAction() { @@ -151,13 +138,29 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { mbeanServer.getClassLoaderRepository(), dcl); } - }); + }, + + withPermissions( new MBeanPermission("*", "getClassLoaderRepository"), + new RuntimePermission("createClassLoader")) + ); + serverCommunicatorAdmin = new RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env)); this.env = env; } + private static AccessControlContext withPermissions(Permission ... perms){ + Permissions col = new Permissions(); + + for (Permission thePerm : perms ) { + col.add(thePerm); + } + + final ProtectionDomain pd = new ProtectionDomain(null, col); + return new AccessControlContext( new ProtectionDomain[] { pd }); + } + private synchronized ServerNotifForwarder getServerNotifFwd() { // Lazily created when first use. Mainly when // addNotificationListener is first called. @@ -1330,7 +1333,9 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { public ClassLoader run() throws InstanceNotFoundException { return mbeanServer.getClassLoader(name); } - }); + }, + withPermissions(new MBeanPermission("*", "getClassLoader")) + ); } catch (PrivilegedActionException pe) { throw (InstanceNotFoundException) extractException(pe); } @@ -1345,7 +1350,9 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { public Object run() throws InstanceNotFoundException { return mbeanServer.getClassLoaderFor(name); } - }); + }, + withPermissions(new MBeanPermission("*", "getClassLoaderFor")) + ); } catch (PrivilegedActionException pe) { throw (InstanceNotFoundException) extractException(pe); } From 1c29d4299bf222478eb9fb59540a8f631c5aaa7d Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Sat, 28 Jul 2012 19:42:50 -0700 Subject: [PATCH 08/56] 7186286: TLS implementation to better adhere to RFC Also reviewed by Alexander Fomin , Andrew Gross, Sean Coffey Reviewed-by: valeriep, wetmore --- .../sun/security/ssl/HandshakeInStream.java | 13 ++++- .../classes/sun/security/ssl/Handshaker.java | 4 +- .../security/ssl/RSAClientKeyExchange.java | 56 ++++++++++++------- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java b/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java index f6ca477efe2..81c84643f14 100644 --- a/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java +++ b/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -190,6 +190,7 @@ public class HandshakeInStream extends InputStream { byte[] getBytes8() throws IOException { int len = getInt8(); + verifyLength(len); byte b[] = new byte[len]; read(b, 0, len); @@ -198,6 +199,7 @@ public class HandshakeInStream extends InputStream { public byte[] getBytes16() throws IOException { int len = getInt16(); + verifyLength(len); byte b[] = new byte[len]; read(b, 0, len); @@ -206,10 +208,19 @@ public class HandshakeInStream extends InputStream { byte[] getBytes24() throws IOException { int len = getInt24(); + verifyLength(len); byte b[] = new byte[len]; read(b, 0, len); return b; } + // Is a length greater than available bytes in the record? + private void verifyLength(int len) throws SSLException { + if (len > available()) { + throw new SSLException( + "Not enough data to fill declared vector size"); + } + } + } diff --git a/jdk/src/share/classes/sun/security/ssl/Handshaker.java b/jdk/src/share/classes/sun/security/ssl/Handshaker.java index 4fb7fec7d61..38dd491f99f 100644 --- a/jdk/src/share/classes/sun/security/ssl/Handshaker.java +++ b/jdk/src/share/classes/sun/security/ssl/Handshaker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -1063,7 +1063,6 @@ abstract class Handshaker { if (debug != null && Debug.isOn("handshake")) { System.out.println("RSA master secret generation error:"); e.printStackTrace(System.out); - System.out.println("Generating new random premaster secret"); } if (requestedVersion != null) { @@ -1130,7 +1129,6 @@ abstract class Handshaker { System.out.println("RSA PreMasterSecret version error: expected" + protocolVersion + " or " + requestedVersion + ", decrypted: " + premasterVersion); - System.out.println("Generating new random premaster secret"); } preMasterSecret = RSAClientKeyExchange.generateDummySecret(requestedVersion); diff --git a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java index 1c0d6921091..36fda8c39cb 100644 --- a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java +++ b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -36,6 +36,7 @@ import javax.crypto.spec.*; import javax.net.ssl.*; import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; +import sun.security.util.KeyLength; /** * This is the client key exchange message (CLIENT --> SERVER) used with @@ -192,26 +193,38 @@ final class RSAClientKeyExchange extends HandshakeMessage { "unable to get the plaintext of the premaster secret"); } - // We are not always able to get the encoded key of the - // premaster secret. Pass the cheking to master secret + int keySize = KeyLength.getKeySize(secretKey); + if (keySize > 0 && keySize != 384) { // 384 = 48 * 8 + if (debug != null && Debug.isOn("handshake")) { + System.out.println( + "incorrect length of premaster secret: " + + (keySize/8)); + } + + return generateDummySecret(clientHelloVersion); + } + + // The key size is exactly 48 bytes or not accessible. + // + // Conservatively, pass the checking to master secret // calculation. return secretKey; } else if (encoded.length == 48) { // check the version if (clientHelloVersion.major == encoded[0] && clientHelloVersion.minor == encoded[1]) { + return secretKey; - } else if (clientHelloVersion.v <= ProtocolVersion.TLS10.v) { + } else if (clientHelloVersion.v <= ProtocolVersion.TLS10.v && + currentVersion.major == encoded[0] && + currentVersion.minor == encoded[1]) { /* - * we never checked the client_version in server side - * for TLS v1.0 and SSL v3.0. For compatibility, we - * maintain this behavior. + * For compatibility, we maintain the behavior that the + * version in pre_master_secret can be the negotiated + * version for TLS v1.0 and SSL v3.0. */ - if (currentVersion.major == encoded[0] && - currentVersion.minor == encoded[1]) { - this.protocolVersion = currentVersion; - return secretKey; - } + this.protocolVersion = currentVersion; + return secretKey; } if (debug != null && Debug.isOn("handshake")) { @@ -220,22 +233,23 @@ final class RSAClientKeyExchange extends HandshakeMessage { ", while PreMasterSecret.client_version is " + ProtocolVersion.valueOf(encoded[0], encoded[1])); } + + return generateDummySecret(clientHelloVersion); } else { if (debug != null && Debug.isOn("handshake")) { System.out.println( "incorrect length of premaster secret: " + encoded.length); } + + return generateDummySecret(clientHelloVersion); } } - if (debug != null && Debug.isOn("handshake")) { - if (failoverException != null) { - System.out.println("Error decrypting premaster secret:"); - failoverException.printStackTrace(System.out); - } - - System.out.println("Generating random secret"); + if (debug != null && Debug.isOn("handshake") && + failoverException != null) { + System.out.println("Error decrypting premaster secret:"); + failoverException.printStackTrace(System.out); } return generateDummySecret(clientHelloVersion); @@ -243,6 +257,10 @@ final class RSAClientKeyExchange extends HandshakeMessage { // generate a premaster secret with the specified version number static SecretKey generateDummySecret(ProtocolVersion version) { + if (debug != null && Debug.isOn("handshake")) { + System.out.println("Generating a random fake premaster secret"); + } + try { String s = ((version.v >= ProtocolVersion.TLS12.v) ? "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret"); From e5fbf0148998595f148f340e8f663afa5a99eefa Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Wed, 15 Aug 2012 15:31:30 -0400 Subject: [PATCH 09/56] 7189490: More improvements to DomainCombiner checking Reviewed-by: ahgross, jdn, vinnie --- .../java/security/AccessController.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/java/security/AccessController.java b/jdk/src/share/classes/java/security/AccessController.java index 8a8eadea62d..4e790ffc8da 100644 --- a/jdk/src/share/classes/java/security/AccessController.java +++ b/jdk/src/share/classes/java/security/AccessController.java @@ -290,11 +290,11 @@ public final class AccessController { */ public static T doPrivilegedWithCombiner(PrivilegedAction action) { - DomainCombiner dc = null; AccessControlContext acc = getStackAccessControlContext(); - if (acc == null || (dc = acc.getAssignedCombiner()) == null) { - return AccessController.doPrivileged(action, acc); + if (acc == null) { + return AccessController.doPrivileged(action); } + DomainCombiner dc = acc.getAssignedCombiner(); return AccessController.doPrivileged(action, preserveCombiner(dc)); } @@ -386,11 +386,11 @@ public final class AccessController { public static T doPrivilegedWithCombiner (PrivilegedExceptionAction action) throws PrivilegedActionException { - DomainCombiner dc = null; AccessControlContext acc = getStackAccessControlContext(); - if (acc == null || (dc = acc.getAssignedCombiner()) == null) { - return AccessController.doPrivileged(action, acc); + if (acc == null) { + return AccessController.doPrivileged(action); } + DomainCombiner dc = acc.getAssignedCombiner(); return AccessController.doPrivileged(action, preserveCombiner(dc)); } @@ -417,7 +417,12 @@ public final class AccessController { // perform 'combine' on the caller of doPrivileged, // even if the caller is from the bootclasspath ProtectionDomain[] pds = new ProtectionDomain[] {callerPd}; - return new AccessControlContext(combiner.combine(pds, null), combiner); + if (combiner == null) { + return new AccessControlContext(pds); + } else { + return new AccessControlContext(combiner.combine(pds, null), + combiner); + } } From 9f27d2af4c0366b2ae376c510b28a80c17ac90ee Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 16 Aug 2012 15:02:34 +0100 Subject: [PATCH 10/56] 7189103: Executors needs to maintain state Reviewed-by: dholmes, hawtin --- .../java/util/concurrent/Executors.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/jdk/src/share/classes/java/util/concurrent/Executors.java b/jdk/src/share/classes/java/util/concurrent/Executors.java index 4ff71418422..78708f8d773 100644 --- a/jdk/src/share/classes/java/util/concurrent/Executors.java +++ b/jdk/src/share/classes/java/util/concurrent/Executors.java @@ -530,18 +530,17 @@ public class Executors { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public T run() throws Exception { - ClassLoader savedcl = null; Thread t = Thread.currentThread(); - try { - ClassLoader cl = t.getContextClassLoader(); - if (ccl != cl) { - t.setContextClassLoader(ccl); - savedcl = cl; - } + ClassLoader cl = t.getContextClassLoader(); + if (ccl == cl) { return task.call(); - } finally { - if (savedcl != null) - t.setContextClassLoader(savedcl); + } else { + t.setContextClassLoader(ccl); + try { + return task.call(); + } finally { + t.setContextClassLoader(cl); + } } } }, acc); From 6b158b4089e2baccdbc8c2c90b28b6440c2fa76a Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 10 Oct 2012 17:04:33 -0400 Subject: [PATCH 11/56] 7199068: NPG: SharedSkipVerify is meaningless Remove the SharedSkipVerify flag Reviewed-by: kamg, sspitsyn, coleenp --- hotspot/src/share/vm/classfile/javaClasses.cpp | 3 +-- hotspot/src/share/vm/memory/universe.cpp | 4 ---- hotspot/src/share/vm/oops/klass.cpp | 7 +++---- hotspot/src/share/vm/runtime/globals.hpp | 4 ---- hotspot/src/share/vm/runtime/handles.cpp | 2 +- hotspot/src/share/vm/runtime/handles.hpp | 8 ++++---- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 7e8c39cdd3b..d74a6174a99 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -413,8 +413,7 @@ char* java_lang_String::as_utf8_string(oop java_string, int start, int len) { } bool java_lang_String::equals(oop java_string, jchar* chars, int len) { - assert(SharedSkipVerify || - java_string->klass() == SystemDictionary::String_klass(), + assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string"); typeArrayOop value = java_lang_String::value(java_string); int offset = java_lang_String::offset(java_string); diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index f8e733bb49b..8fe747939af 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -1243,10 +1243,6 @@ void Universe::print_heap_after_gc(outputStream* st, bool ignore_extended) { } void Universe::verify(bool silent, VerifyOption option) { - if (SharedSkipVerify) { - return; - } - // The use of _verify_in_progress is a temporary work around for // 6320749. Don't bother with a creating a class to set and clear // it since it is only used in this method and the control flow is diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 94546f0d71a..06a99aff6b0 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -356,12 +356,11 @@ void Klass::set_next_sibling(Klass* s) { } void Klass::append_to_sibling_list() { - debug_only(if (!SharedSkipVerify) verify();) + debug_only(verify();) // add ourselves to superklass' subklass list InstanceKlass* super = superklass(); if (super == NULL) return; // special case: class Object - assert(SharedSkipVerify || - (!super->is_interface() // interfaces cannot be supers + assert((!super->is_interface() // interfaces cannot be supers && (super->superklass() == NULL || !is_interface())), "an interface can only be a subklass of Object"); Klass* prev_first_subklass = super->subklass_oop(); @@ -371,7 +370,7 @@ void Klass::append_to_sibling_list() { } // make ourselves the superklass' first subklass super->set_subklass(this); - debug_only(if (!SharedSkipVerify) verify();) + debug_only(verify();) } void Klass::remove_from_sibling_list() { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 0bef41fadab..cdefd82e4f5 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3542,10 +3542,6 @@ class CommandLineFlags { product(uintx, SharedDummyBlockSize, 0, \ "Size of dummy block used to shift heap addresses (in bytes)") \ \ - diagnostic(bool, SharedSkipVerify, false, \ - "Skip assert() and verify() which page-in unwanted shared " \ - "objects. ") \ - \ diagnostic(bool, EnableInvokeDynamic, true, \ "support JSR 292 (method handles, invokedynamic, " \ "anonymous classes") \ diff --git a/hotspot/src/share/vm/runtime/handles.cpp b/hotspot/src/share/vm/runtime/handles.cpp index 0ba6c984ef8..cb53088ee69 100644 --- a/hotspot/src/share/vm/runtime/handles.cpp +++ b/hotspot/src/share/vm/runtime/handles.cpp @@ -48,7 +48,7 @@ oop* HandleArea::allocate_handle(oop obj) { assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark"); assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark"); - assert(SharedSkipVerify || obj->is_oop(), "sanity check"); + assert(obj->is_oop(), "sanity check"); return real_allocate_handle(obj); } diff --git a/hotspot/src/share/vm/runtime/handles.hpp b/hotspot/src/share/vm/runtime/handles.hpp index 4a2e9ff8252..cab3dc581f9 100644 --- a/hotspot/src/share/vm/runtime/handles.hpp +++ b/hotspot/src/share/vm/runtime/handles.hpp @@ -110,11 +110,11 @@ class Handle VALUE_OBJ_CLASS_SPEC { /* Constructors */ \ type##Handle () : Handle() {} \ type##Handle (type##Oop obj) : Handle((oop)obj) { \ - assert(SharedSkipVerify || is_null() || ((oop)obj)->is_a(), \ + assert(is_null() || ((oop)obj)->is_a(), \ "illegal type"); \ } \ type##Handle (Thread* thread, type##Oop obj) : Handle(thread, (oop)obj) { \ - assert(SharedSkipVerify || is_null() || ((oop)obj)->is_a(), "illegal type"); \ + assert(is_null() || ((oop)obj)->is_a(), "illegal type"); \ } \ \ /* Operators for ease of use */ \ @@ -201,11 +201,11 @@ class instanceKlassHandle : public KlassHandle { /* Constructors */ instanceKlassHandle () : KlassHandle() {} instanceKlassHandle (const Klass* k) : KlassHandle(k) { - assert(SharedSkipVerify || k == NULL || k->oop_is_instance(), + assert(k == NULL || k->oop_is_instance(), "illegal type"); } instanceKlassHandle (Thread* thread, const Klass* k) : KlassHandle(thread, k) { - assert(SharedSkipVerify || k == NULL || k->oop_is_instance(), + assert(k == NULL || k->oop_is_instance(), "illegal type"); } /* Access to klass part */ From 04a9a141937e4781ba1ebd793d69e94296097b81 Mon Sep 17 00:00:00 2001 From: Keith McGuigan Date: Thu, 11 Oct 2012 14:27:54 -0400 Subject: [PATCH 12/56] 7054345: Support version 52.0 class file in HotSpot Accept classfiles with major version 52 Reviewed-by: coleenp, acorn --- hotspot/src/share/vm/classfile/classFileParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 5d260d56492..c9a2c44d002 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -67,7 +67,7 @@ #define JAVA_CLASSFILE_MAGIC 0xCAFEBABE #define JAVA_MIN_SUPPORTED_VERSION 45 -#define JAVA_MAX_SUPPORTED_VERSION 51 +#define JAVA_MAX_SUPPORTED_VERSION 52 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0 // Used for two backward compatibility reasons: From b296b69382c85f74286499dc941fb18b5c53fb03 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Mon, 15 Oct 2012 16:48:48 +0100 Subject: [PATCH 13/56] 7195151: Multiplatform tescase for 6929067 Reviewed-by: kamg, kvn --- hotspot/test/runtime/6929067/Test6929067.sh | 89 ++++++++++++++++++--- 1 file changed, 78 insertions(+), 11 deletions(-) diff --git a/hotspot/test/runtime/6929067/Test6929067.sh b/hotspot/test/runtime/6929067/Test6929067.sh index c08aa6b8f09..e4b649df82b 100644 --- a/hotspot/test/runtime/6929067/Test6929067.sh +++ b/hotspot/test/runtime/6929067/Test6929067.sh @@ -4,6 +4,7 @@ ## @test Test6929067.sh ## @bug 6929067 ## @summary Stack guard pages should be removed when thread is detached +## @compile T.java ## @run shell Test6929067.sh ## @@ -33,31 +34,97 @@ case "$OS" in ;; esac -# Choose arch: i386 or amd64 (test is Linux-specific) +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1 + +# Bitness: # Cannot simply look at TESTVMOPTS as -d64 is not # passed if there is only a 64-bit JVM available. -${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>1 | grep "64-Bit" >/dev/null +grep "64-Bit" vm_version.out > ${NULL} if [ "$?" = "0" ] then - ARCH=amd64 + COMP_FLAG="-m64" else - ARCH=i386 + COMP_FLAG="-m32" fi -LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/client:/usr/openwin/lib:/usr/dt/lib:/usr/lib:$LD_LIBRARY_PATH + +# Architecture: +# Translate uname output to JVM directory name, but permit testing +# 32-bit x86 on an x64 platform. +ARCH=`uname -m` +case "$ARCH" in + x86_64) + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=i386 + else + ARCH=amd64 + fi + ;; + ppc64) + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=ppc + else + ARCH=ppc64 + fi + ;; + sparc64) + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=sparc + else + ARCH=sparc64 + fi + ;; + arm*) + # 32-bit ARM machine: compiler may not recognise -m32 + COMP_FLAG="" + ARCH=arm + ;; + aarch64) + # 64-bit arm machine, could be testing 32 or 64-bit: + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=arm + else + ARCH=aarch64 + fi + ;; + i586) + ARCH=i386 + ;; + i686) + ARCH=i386 + ;; + # Assuming other ARCH values need no translation +esac + + +# VM type: need to know server or client +VMTYPE=client +grep Server vm_version.out > ${NULL} +if [ "$?" = "0" ] +then + VMTYPE=server +fi + + +LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH -THIS_DIR=`pwd` - -cp ${TESTSRC}${FS}invoke.c ${THIS_DIR} -cp ${TESTSRC}${FS}T.java ${THIS_DIR} +cp ${TESTSRC}${FS}invoke.c . +# Copy the result of our @compile action: +cp ${TESTCLASSES}${FS}T.class . ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -fullversion -${TESTJAVA}${FS}bin${FS}javac T.java +echo "Architecture: ${ARCH}" +echo "Compilation flag: ${COMP_FLAG}" +echo "VM type: ${VMTYPE}" + +gcc -DLINUX ${COMP_FLAG} -o invoke \ + -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \ + -L${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE} \ + -ljvm -lpthread invoke.c -gcc -o invoke -I${TESTJAVA}/include -I${TESTJAVA}/include/linux invoke.c ${TESTJAVA}/jre/lib/${ARCH}/client/libjvm.so ./invoke exit $? From 228b4f6d7f0b8e27a5eddb7e31f0abe16e33c395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rickard=20B=C3=A4ckman?= Date: Tue, 28 Aug 2012 15:15:29 +0200 Subject: [PATCH 14/56] 7093328: JVMTI: jvmtiPrimitiveFieldCallback always report 0's for static primitives Reviewed-by: dholmes, dcubed --- hotspot/src/share/vm/prims/jvmtiTagMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp index 22871642434..c3e744bd32e 100644 --- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp +++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp @@ -1135,7 +1135,7 @@ static jint invoke_primitive_field_callback_for_static_fields // get offset and field value int offset = field->field_offset(); - address addr = (address)klass + offset; + address addr = (address)klass->java_mirror() + offset; jvalue value; copy_to_jvalue(&value, addr, value_type); From 84603e4d94b7a0504aa1284a341c24a8ab9284f2 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 29 Aug 2012 14:05:37 +0100 Subject: [PATCH 15/56] 7189567: java net obselete protocol Reviewed-by: alanb, ahgross --- jdk/make/sun/net/FILES_java.gmk | 2 - .../net/www/protocol/gopher/GopherClient.java | 357 ------------------ .../sun/net/www/protocol/gopher/Handler.java | 100 ----- jdk/test/java/net/URL/Test.java | 4 - 4 files changed, 463 deletions(-) delete mode 100644 jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java delete mode 100644 jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java diff --git a/jdk/make/sun/net/FILES_java.gmk b/jdk/make/sun/net/FILES_java.gmk index 6c140abc68b..9c5feb4457e 100644 --- a/jdk/make/sun/net/FILES_java.gmk +++ b/jdk/make/sun/net/FILES_java.gmk @@ -128,8 +128,6 @@ FILES_java = \ sun/net/www/content/audio/x_wav.java \ sun/net/www/protocol/ftp/Handler.java \ sun/net/www/protocol/ftp/FtpURLConnection.java \ - sun/net/www/protocol/gopher/GopherClient.java \ - sun/net/www/protocol/gopher/Handler.java \ sun/net/www/protocol/mailto/Handler.java \ sun/net/www/protocol/mailto/MailToURLConnection.java \ sun/net/idn/Punycode.java \ diff --git a/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java b/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java deleted file mode 100644 index 03470634a37..00000000000 --- a/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 1996, 2004, 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.net.www.protocol.gopher; - -import java.io.*; -import java.util.*; -import java.net.*; -import sun.net.www.*; -import sun.net.NetworkClient; -import java.net.URL; -import java.net.URLStreamHandler; - -import sun.security.action.GetBooleanAction; - -/** Class to maintain the state of a gopher fetch and handle the protocol */ -public class GopherClient extends NetworkClient implements Runnable { - - /* The following three data members are left in for binary - * backwards-compatibility. Unfortunately, HotJava sets them directly - * when it wants to change the settings. The new design has us not - * cache these, so this is unnecessary, but eliminating the data members - * would break HJB 1.1 under JDK 1.2. - * - * These data members are not used, and their values are meaningless. - * REMIND: Take them out for JDK 2.0! - */ - - /** - * @deprecated - */ - @Deprecated - public static boolean useGopherProxy; - - /** - * @deprecated - */ - @Deprecated - public static String gopherProxyHost; - - /** - * @deprecated - */ - @Deprecated - public static int gopherProxyPort; - - - static { - useGopherProxy = java.security.AccessController.doPrivileged( - new sun.security.action.GetBooleanAction("gopherProxySet")) - .booleanValue(); - - gopherProxyHost = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("gopherProxyHost")); - - gopherProxyPort = java.security.AccessController.doPrivileged( - new sun.security.action.GetIntegerAction("gopherProxyPort", 80)) - .intValue(); - } - - PipedOutputStream os; - URL u; - int gtype; - String gkey; - sun.net.www.URLConnection connection; - - GopherClient(sun.net.www.URLConnection connection) { - this.connection = connection; - } - - /** - * @return true if gopher connections should go through a proxy, according - * to system properties. - */ - public static boolean getUseGopherProxy() { - return java.security.AccessController.doPrivileged( - new GetBooleanAction("gopherProxySet")).booleanValue(); - } - - /** - * @return the proxy host to use, or null if nothing is set. - */ - public static String getGopherProxyHost() { - String host = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("gopherProxyHost")); - if ("".equals(host)) { - host = null; - } - return host; - } - - /** - * @return the proxy port to use. Will default reasonably. - */ - public static int getGopherProxyPort() { - return java.security.AccessController.doPrivileged( - new sun.security.action.GetIntegerAction("gopherProxyPort", 80)) - .intValue(); - } - - /** Given a url, setup to fetch the gopher document it refers to */ - InputStream openStream(URL u) throws IOException { - this.u = u; - this.os = os; - int i = 0; - String s = u.getFile(); - int limit = s.length(); - int c = '1'; - while (i < limit && (c = s.charAt(i)) == '/') - i++; - gtype = c == '/' ? '1' : c; - if (i < limit) - i++; - gkey = s.substring(i); - - openServer(u.getHost(), u.getPort() <= 0 ? 70 : u.getPort()); - - MessageHeader msgh = new MessageHeader(); - - switch (gtype) { - case '0': - case '7': - msgh.add("content-type", "text/plain"); - break; - case '1': - msgh.add("content-type", "text/html"); - break; - case 'g': - case 'I': - msgh.add("content-type", "image/gif"); - break; - default: - msgh.add("content-type", "content/unknown"); - break; - } - if (gtype != '7') { - serverOutput.print(decodePercent(gkey) + "\r\n"); - serverOutput.flush(); - } else if ((i = gkey.indexOf('?')) >= 0) { - serverOutput.print(decodePercent(gkey.substring(0, i) + "\t" + - gkey.substring(i + 1) + "\r\n")); - serverOutput.flush(); - msgh.add("content-type", "text/html"); - } else { - msgh.add("content-type", "text/html"); - } - connection.setProperties(msgh); - if (msgh.findValue("content-type") == "text/html") { - os = new PipedOutputStream(); - PipedInputStream ret = new PipedInputStream(); - ret.connect(os); - new Thread(this).start(); - return ret; - } - return new GopherInputStream(this, serverInput); - } - - /** Translate all the instances of %NN into the character they represent */ - private String decodePercent(String s) { - if (s == null || s.indexOf('%') < 0) - return s; - int limit = s.length(); - char d[] = new char[limit]; - int dp = 0; - for (int sp = 0; sp < limit; sp++) { - int c = s.charAt(sp); - if (c == '%' && sp + 2 < limit) { - int s1 = s.charAt(sp + 1); - int s2 = s.charAt(sp + 2); - if ('0' <= s1 && s1 <= '9') - s1 = s1 - '0'; - else if ('a' <= s1 && s1 <= 'f') - s1 = s1 - 'a' + 10; - else if ('A' <= s1 && s1 <= 'F') - s1 = s1 - 'A' + 10; - else - s1 = -1; - if ('0' <= s2 && s2 <= '9') - s2 = s2 - '0'; - else if ('a' <= s2 && s2 <= 'f') - s2 = s2 - 'a' + 10; - else if ('A' <= s2 && s2 <= 'F') - s2 = s2 - 'A' + 10; - else - s2 = -1; - if (s1 >= 0 && s2 >= 0) { - c = (s1 << 4) | s2; - sp += 2; - } - } - d[dp++] = (char) c; - } - return new String(d, 0, dp); - } - - /** Turn special characters into the %NN form */ - private String encodePercent(String s) { - if (s == null) - return s; - int limit = s.length(); - char d[] = null; - int dp = 0; - for (int sp = 0; sp < limit; sp++) { - int c = s.charAt(sp); - if (c <= ' ' || c == '"' || c == '%') { - if (d == null) - d = s.toCharArray(); - if (dp + 3 >= d.length) { - char nd[] = new char[dp + 10]; - System.arraycopy(d, 0, nd, 0, dp); - d = nd; - } - d[dp] = '%'; - int dig = (c >> 4) & 0xF; - d[dp + 1] = (char) (dig < 10 ? '0' + dig : 'A' - 10 + dig); - dig = c & 0xF; - d[dp + 2] = (char) (dig < 10 ? '0' + dig : 'A' - 10 + dig); - dp += 3; - } else { - if (d != null) { - if (dp >= d.length) { - char nd[] = new char[dp + 10]; - System.arraycopy(d, 0, nd, 0, dp); - d = nd; - } - d[dp] = (char) c; - } - dp++; - } - } - return d == null ? s : new String(d, 0, dp); - } - - /** This method is run as a seperate thread when an incoming gopher - document requires translation to html */ - public void run() { - int qpos = -1; - try { - if (gtype == '7' && (qpos = gkey.indexOf('?')) < 0) { - PrintStream ps = new PrintStream(os, false, encoding); - ps.print("Searchable Gopher Index\n

Searchable Gopher Index

\n\n"); - } else if (gtype != '1' && gtype != '7') { - byte buf[] = new byte[2048]; - try { - int n; - while ((n = serverInput.read(buf)) >= 0) - os.write(buf, 0, n); - } catch(Exception e) { - } - } else { - PrintStream ps = new PrintStream(os, false, encoding); - String title = null; - if (gtype == '7') - title = "Results of searching for \"" + gkey.substring(qpos + 1) - + "\" on " + u.getHost(); - else - title = "Gopher directory " + gkey + " from " + u.getHost(); - ps.print(""); - ps.print(title); - ps.print("\n\n

"); - ps.print(title); - ps.print("

\n"); - BufferedReader ds = new BufferedReader(new InputStreamReader(serverInput)); - String s; - while ((s = ds.readLine()) != null) { - int len = s.length(); - while (len > 0 && s.charAt(len - 1) <= ' ') - len--; - if (len <= 0) - continue; - int key = s.charAt(0); - int t1 = s.indexOf('\t'); - int t2 = t1 > 0 ? s.indexOf('\t', t1 + 1) : -1; - int t3 = t2 > 0 ? s.indexOf('\t', t2 + 1) : -1; - if (t3 < 0) { - // ps.print("
"+s+"\n"); - continue; - } - String port = t3 + 1 < len ? ":" + s.substring(t3 + 1, len) : ""; - String host = t2 + 1 < t3 ? s.substring(t2 + 1, t3) : u.getHost(); - ps.print("
\n"); - ps.print("
\n"); - ps.print(s.substring(1, t1) + "\n"); - } - ps.print("
\n"); - ps.close(); - } - - } catch (UnsupportedEncodingException e) { - throw new InternalError(encoding+ " encoding not found", e); - } catch (IOException e) { - } finally { - try { - closeServer(); - os.close(); - } catch (IOException e2) { - } - } - } -} - -/** An input stream that does nothing more than hold on to the NetworkClient - that created it. This is used when only the input stream is needed, and - the network client needs to be closed when the input stream is closed. */ -class GopherInputStream extends FilterInputStream { - NetworkClient parent; - - GopherInputStream(NetworkClient o, InputStream fd) { - super(fd); - parent = o; - } - - public void close() { - try { - parent.closeServer(); - super.close(); - } catch (IOException e) { - } - } -} diff --git a/jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java b/jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java deleted file mode 100644 index 800985960a3..00000000000 --- a/jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 1995, 2003, 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.net.www.protocol.gopher; - -import java.io.*; -import java.util.*; -import sun.net.NetworkClient; -import java.net.URL; -import java.net.URLStreamHandler; -import java.net.Proxy; -import java.net.InetSocketAddress; -import java.net.SocketPermission; -import java.security.Permission; -import sun.net.www.protocol.http.HttpURLConnection; - -/** - * A class to handle the gopher protocol. - */ - -public class Handler extends java.net.URLStreamHandler { - - protected int getDefaultPort() { - return 70; - } - - public java.net.URLConnection openConnection(URL u) - throws IOException { - return openConnection(u, null); - } - - public java.net.URLConnection openConnection(URL u, Proxy p) - throws IOException { - - - /* if set for proxy usage then go through the http code to get */ - /* the url connection. */ - if (p == null && GopherClient.getUseGopherProxy()) { - String host = GopherClient.getGopherProxyHost(); - if (host != null) { - InetSocketAddress saddr = InetSocketAddress.createUnresolved(host, GopherClient.getGopherProxyPort()); - - p = new Proxy(Proxy.Type.HTTP, saddr); - } - } - if (p != null) { - return new HttpURLConnection(u, p); - } - - return new GopherURLConnection(u); - } -} - -class GopherURLConnection extends sun.net.www.URLConnection { - - Permission permission; - - GopherURLConnection(URL u) { - super(u); - } - - public void connect() throws IOException { - } - - public InputStream getInputStream() throws IOException { - return new GopherClient(this).openStream(url); - } - - public Permission getPermission() { - if (permission == null) { - int port = url.getPort(); - port = port < 0 ? 70 : port; - String host = url.getHost() + ":" + url.getPort(); - permission = new SocketPermission(host, "connect"); - } - return permission; - } -} diff --git a/jdk/test/java/net/URL/Test.java b/jdk/test/java/net/URL/Test.java index 58c88182723..5a0909efe26 100644 --- a/jdk/test/java/net/URL/Test.java +++ b/jdk/test/java/net/URL/Test.java @@ -322,10 +322,6 @@ public class Test { test("ftp://ftp.is.co.za/rfc/rfc1808.txt") .s("ftp").h("ftp.is.co.za").p("/rfc/rfc1808.txt").z(); - test("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles") - .s("gopher").h("spinaltap.micro.umn.edu") - .p("/00/Weather/California/Los%20Angeles").z(); - test("http://www.math.uio.no/faq/compression-faq/part1.html") .s("http").h("www.math.uio.no").p("/faq/compression-faq/part1.html").z(); From c6f43f359973f7ee8826c4ed250f38668e94e5dc Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Sat, 8 Sep 2012 20:31:42 +0100 Subject: [PATCH 16/56] 7169884: LogManager checks do not work correctly for sub-types Reviewed-by: mchung, ahgross --- .../java/util/logging/FileHandler.java | 12 +++++----- .../classes/java/util/logging/Handler.java | 16 ++++++------- .../classes/java/util/logging/LogManager.java | 23 ++++++++++--------- .../classes/java/util/logging/Logger.java | 16 ++++++------- .../java/util/logging/MemoryHandler.java | 2 +- .../java/util/logging/StreamHandler.java | 2 +- 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java index fb3b67c4d92..b9a5d73c341 100644 --- a/jdk/src/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/share/classes/java/util/logging/FileHandler.java @@ -220,7 +220,7 @@ public class FileHandler extends StreamHandler { * @exception NullPointerException if pattern property is an empty String. */ public FileHandler() throws IOException, SecurityException { - checkAccess(); + checkPermission(); configure(); openFiles(); } @@ -246,7 +246,7 @@ public class FileHandler extends StreamHandler { if (pattern.length() < 1 ) { throw new IllegalArgumentException(); } - checkAccess(); + checkPermission(); configure(); this.pattern = pattern; this.limit = 0; @@ -278,7 +278,7 @@ public class FileHandler extends StreamHandler { if (pattern.length() < 1 ) { throw new IllegalArgumentException(); } - checkAccess(); + checkPermission(); configure(); this.pattern = pattern; this.limit = 0; @@ -315,7 +315,7 @@ public class FileHandler extends StreamHandler { if (limit < 0 || count < 1 || pattern.length() < 1) { throw new IllegalArgumentException(); } - checkAccess(); + checkPermission(); configure(); this.pattern = pattern; this.limit = limit; @@ -354,7 +354,7 @@ public class FileHandler extends StreamHandler { if (limit < 0 || count < 1 || pattern.length() < 1) { throw new IllegalArgumentException(); } - checkAccess(); + checkPermission(); configure(); this.pattern = pattern; this.limit = limit; @@ -367,7 +367,7 @@ public class FileHandler extends StreamHandler { // configured instance variables. private void openFiles() throws IOException { LogManager manager = LogManager.getLogManager(); - manager.checkAccess(); + manager.checkPermission(); if (count < 1) { throw new IllegalArgumentException("file count = " + count); } diff --git a/jdk/src/share/classes/java/util/logging/Handler.java b/jdk/src/share/classes/java/util/logging/Handler.java index 1317b572d92..fd04c2cb496 100644 --- a/jdk/src/share/classes/java/util/logging/Handler.java +++ b/jdk/src/share/classes/java/util/logging/Handler.java @@ -111,7 +111,7 @@ public abstract class Handler { * the caller does not have LoggingPermission("control"). */ public void setFormatter(Formatter newFormatter) throws SecurityException { - checkAccess(); + checkPermission(); // Check for a null pointer: newFormatter.getClass(); formatter = newFormatter; @@ -140,7 +140,7 @@ public abstract class Handler { */ public void setEncoding(String encoding) throws SecurityException, java.io.UnsupportedEncodingException { - checkAccess(); + checkPermission(); if (encoding != null) { try { if(!java.nio.charset.Charset.isSupported(encoding)) { @@ -175,7 +175,7 @@ public abstract class Handler { * the caller does not have LoggingPermission("control"). */ public void setFilter(Filter newFilter) throws SecurityException { - checkAccess(); + checkPermission(); filter = newFilter; } @@ -199,7 +199,7 @@ public abstract class Handler { * the caller does not have LoggingPermission("control"). */ public void setErrorManager(ErrorManager em) { - checkAccess(); + checkPermission(); if (em == null) { throw new NullPointerException(); } @@ -213,7 +213,7 @@ public abstract class Handler { * the caller does not have LoggingPermission("control"). */ public ErrorManager getErrorManager() { - checkAccess(); + checkPermission(); return errorManager; } @@ -253,7 +253,7 @@ public abstract class Handler { if (newLevel == null) { throw new NullPointerException(); } - checkAccess(); + checkPermission(); logLevel = newLevel; } @@ -296,9 +296,9 @@ public abstract class Handler { // If "sealed" is true, we check that the caller has // appropriate security privileges to update Handler // state and if not throw a SecurityException. - void checkAccess() throws SecurityException { + void checkPermission() throws SecurityException { if (sealed) { - manager.checkAccess(); + manager.checkPermission(); } } } diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java index 24f61b46f74..bfdf83f93da 100644 --- a/jdk/src/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/share/classes/java/util/logging/LogManager.java @@ -314,7 +314,7 @@ public class LogManager { */ public void addPropertyChangeListener(PropertyChangeListener l) throws SecurityException { PropertyChangeListener listener = Objects.requireNonNull(l); - checkAccess(); + checkPermission(); synchronized (listenerMap) { // increment the registration count if already registered Integer value = listenerMap.get(listener); @@ -338,7 +338,7 @@ public class LogManager { * the caller does not have LoggingPermission("control"). */ public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException { - checkAccess(); + checkPermission(); if (l != null) { PropertyChangeListener listener = l; synchronized (listenerMap) { @@ -793,7 +793,7 @@ public class LogManager { * @exception IOException if there are IO problems reading the configuration. */ public void readConfiguration() throws IOException, SecurityException { - checkAccess(); + checkPermission(); // if a configuration class is specified, load it and use it. String cname = System.getProperty("java.util.logging.config.class"); @@ -851,7 +851,7 @@ public class LogManager { */ public void reset() throws SecurityException { - checkAccess(); + checkPermission(); synchronized (this) { props = new Properties(); // Since we are doing a reset we no longer want to initialize @@ -936,7 +936,7 @@ public class LogManager { * @exception IOException if there are problems reading from the stream. */ public void readConfiguration(InputStream ins) throws IOException, SecurityException { - checkAccess(); + checkPermission(); reset(); // Load the properties @@ -1113,8 +1113,13 @@ public class LogManager { loadLoggerHandlers(rootLogger, null, "handlers"); } + private final Permission controlPermission = new LoggingPermission("control", null); - private Permission ourPermission = new LoggingPermission("control", null); + void checkPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkPermission(controlPermission); + } /** * Check that the current context is trusted to modify the logging @@ -1127,11 +1132,7 @@ public class LogManager { * the caller does not have LoggingPermission("control"). */ public void checkAccess() throws SecurityException { - SecurityManager sm = System.getSecurityManager(); - if (sm == null) { - return; - } - sm.checkPermission(ourPermission); + checkPermission(); } // Nested class to represent a node in our tree of named loggers. diff --git a/jdk/src/share/classes/java/util/logging/Logger.java b/jdk/src/share/classes/java/util/logging/Logger.java index aebf63ed5e8..f1d6f729b91 100644 --- a/jdk/src/share/classes/java/util/logging/Logger.java +++ b/jdk/src/share/classes/java/util/logging/Logger.java @@ -276,13 +276,13 @@ public class Logger { this.manager = manager; } - private void checkAccess() throws SecurityException { + private void checkPermission() throws SecurityException { if (!anonymous) { if (manager == null) { // Complete initialization of the global Logger. manager = LogManager.getLogManager(); } - manager.checkAccess(); + manager.checkPermission(); } } @@ -482,7 +482,7 @@ public class Logger { * the caller does not have LoggingPermission("control"). */ public void setFilter(Filter newFilter) throws SecurityException { - checkAccess(); + checkPermission(); filter = newFilter; } @@ -1168,7 +1168,7 @@ public class Logger { * the caller does not have LoggingPermission("control"). */ public void setLevel(Level newLevel) throws SecurityException { - checkAccess(); + checkPermission(); synchronized (treeLock) { levelObject = newLevel; updateEffectiveLevel(); @@ -1223,7 +1223,7 @@ public class Logger { public void addHandler(Handler handler) throws SecurityException { // Check for null handler handler.getClass(); - checkAccess(); + checkPermission(); handlers.add(handler); } @@ -1237,7 +1237,7 @@ public class Logger { * the caller does not have LoggingPermission("control"). */ public void removeHandler(Handler handler) throws SecurityException { - checkAccess(); + checkPermission(); if (handler == null) { return; } @@ -1265,7 +1265,7 @@ public class Logger { * the caller does not have LoggingPermission("control"). */ public void setUseParentHandlers(boolean useParentHandlers) { - checkAccess(); + checkPermission(); this.useParentHandlers = useParentHandlers; } @@ -1420,7 +1420,7 @@ public class Logger { if (parent == null) { throw new NullPointerException(); } - manager.checkAccess(); + manager.checkPermission(); doSetParent(parent); } diff --git a/jdk/src/share/classes/java/util/logging/MemoryHandler.java b/jdk/src/share/classes/java/util/logging/MemoryHandler.java index 2c297301d92..06c0930ed5c 100644 --- a/jdk/src/share/classes/java/util/logging/MemoryHandler.java +++ b/jdk/src/share/classes/java/util/logging/MemoryHandler.java @@ -238,7 +238,7 @@ public class MemoryHandler extends Handler { throw new NullPointerException(); } LogManager manager = LogManager.getLogManager(); - checkAccess(); + checkPermission(); pushLevel = newLevel; } diff --git a/jdk/src/share/classes/java/util/logging/StreamHandler.java b/jdk/src/share/classes/java/util/logging/StreamHandler.java index 9ed9e57b768..f6407ec2bfd 100644 --- a/jdk/src/share/classes/java/util/logging/StreamHandler.java +++ b/jdk/src/share/classes/java/util/logging/StreamHandler.java @@ -249,7 +249,7 @@ public class StreamHandler extends Handler { } private synchronized void flushAndClose() throws SecurityException { - checkAccess(); + checkPermission(); if (writer != null) { try { if (!doneHeader) { From 7004635879b74a308e9f47af207cc4972d974ccd Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Mon, 10 Sep 2012 16:05:53 -0700 Subject: [PATCH 17/56] 7195919: (sl) ServiceLoader can throw CCE without needing to create instance Reviewed-by: ahgross, alanb, dmeetry --- .../share/classes/java/util/ServiceLoader.java | 15 +++++++++++---- jdk/src/share/classes/sun/misc/Service.java | 12 ++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/classes/java/util/ServiceLoader.java b/jdk/src/share/classes/java/util/ServiceLoader.java index 62aa9dd2453..37176c677a9 100644 --- a/jdk/src/share/classes/java/util/ServiceLoader.java +++ b/jdk/src/share/classes/java/util/ServiceLoader.java @@ -358,14 +358,21 @@ public final class ServiceLoader } String cn = nextName; nextName = null; + Class c = null; try { - S p = service.cast(Class.forName(cn, true, loader) - .newInstance()); - providers.put(cn, p); - return p; + 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 { + S p = service.cast(c.newInstance()); + providers.put(cn, p); + return p; } catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, diff --git a/jdk/src/share/classes/sun/misc/Service.java b/jdk/src/share/classes/sun/misc/Service.java index 37d39b43019..d74abbd1cb3 100644 --- a/jdk/src/share/classes/sun/misc/Service.java +++ b/jdk/src/share/classes/sun/misc/Service.java @@ -284,12 +284,20 @@ public final class Service { } String cn = nextName; nextName = null; + Class c = null; try { - return service.cast(Class.forName(cn, true, loader).newInstance()); + c = Class.forName(cn, false, loader); } catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); - } catch (Exception x) { + } + 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); From e539ff810a49ab7948c7a7194b371849b5afedad Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 11 Sep 2012 12:57:09 +0400 Subject: [PATCH 18/56] 7195549: Better bean object persistence Reviewed-by: art, ahgross --- .../sun/beans/decoder/PropertyElementHandler.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java b/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java index f20829385d4..8f4c40cac93 100644 --- a/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java +++ b/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -35,6 +35,8 @@ import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import sun.reflect.misc.MethodUtil; + /** * This class is intended to handle <property> element. * This element simplifies access to the properties. @@ -168,11 +170,11 @@ final class PropertyElementHandler extends AccessorElementHandler { private static Object getPropertyValue(Object bean, String name, Integer index) throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException { Class type = bean.getClass(); if (index == null) { - return findGetter(type, name).invoke(bean); + return MethodUtil.invoke(findGetter(type, name), bean, new Object[] {}); } else if (type.isArray() && (name == null)) { return Array.get(bean, index); } else { - return findGetter(type, name, int.class).invoke(bean, index); + return MethodUtil.invoke(findGetter(type, name, int.class), bean, new Object[] {index}); } } @@ -197,11 +199,11 @@ final class PropertyElementHandler extends AccessorElementHandler { : null; if (index == null) { - findSetter(type, name, param).invoke(bean, value); + MethodUtil.invoke(findSetter(type, name, param), bean, new Object[] {value}); } else if (type.isArray() && (name == null)) { Array.set(bean, index, value); } else { - findSetter(type, name, int.class, param).invoke(bean, index, value); + MethodUtil.invoke(findSetter(type, name, int.class, param), bean, new Object[] {index, value}); } } From 41e85e364f92496350236119d170ae7544ca7518 Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Tue, 11 Sep 2012 15:59:24 +0400 Subject: [PATCH 19/56] 7195194: Better data validation for Swing Reviewed-by: art, ahgross --- jdk/src/share/classes/javax/swing/text/DefaultFormatter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java index 5e003b55bca..b67966ab70a 100644 --- a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java +++ b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java @@ -24,6 +24,8 @@ */ package javax.swing.text; +import sun.reflect.misc.ConstructorUtil; + import java.io.Serializable; import java.lang.reflect.*; import java.text.ParseException; @@ -245,7 +247,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter Constructor cons; try { - cons = vc.getConstructor(new Class[] { String.class }); + cons = ConstructorUtil.getConstructor(vc, new Class[]{String.class}); } catch (NoSuchMethodException nsme) { cons = null; From 1a3e1b43e0f5a1b16abc8a127dd20680dfa6624c Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 19 Sep 2012 21:42:21 +0400 Subject: [PATCH 20/56] 7195917: XMLDecoder parsing at close-time should be improved Reviewed-by: art, ahgross --- .../sun/beans/decoder/DocumentHandler.java | 55 ++++++++++++------- .../share/classes/java/beans/XMLDecoder.java | 16 +++++- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java b/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java index f454006ab7e..4bbb8f4a201 100644 --- a/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java +++ b/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -37,6 +37,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; @@ -46,6 +49,8 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; +import sun.misc.SharedSecrets; + /** * The main class to parse JavaBeans XML archive. * @@ -56,11 +61,10 @@ import org.xml.sax.helpers.DefaultHandler; * @see ElementHandler */ public final class DocumentHandler extends DefaultHandler { - private final Map> handlers = new HashMap>(); - - private final Map environment = new HashMap(); - - private final List objects = new ArrayList(); + private final AccessControlContext acc = AccessController.getContext(); + private final Map> handlers = new HashMap<>(); + private final Map environment = new HashMap<>(); + private final List objects = new ArrayList<>(); private Reference loader; private ExceptionListener listener; @@ -351,23 +355,32 @@ public final class DocumentHandler extends DefaultHandler { * * @param input the input source to parse */ - public void parse(InputSource input) { - try { - SAXParserFactory.newInstance().newSAXParser().parse(input, this); + public void parse(final InputSource input) { + if ((this.acc == null) && (null != System.getSecurityManager())) { + throw new SecurityException("AccessControlContext is not set"); } - catch (ParserConfigurationException exception) { - handleException(exception); - } - catch (SAXException wrapper) { - Exception exception = wrapper.getException(); - if (exception == null) { - exception = wrapper; + AccessControlContext stack = AccessController.getContext(); + SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction() { + public Void run() { + try { + SAXParserFactory.newInstance().newSAXParser().parse(input, DocumentHandler.this); + } + catch (ParserConfigurationException exception) { + handleException(exception); + } + catch (SAXException wrapper) { + Exception exception = wrapper.getException(); + if (exception == null) { + exception = wrapper; + } + handleException(exception); + } + catch (IOException exception) { + handleException(exception); + } + return null; } - handleException(exception); - } - catch (IOException exception) { - handleException(exception); - } + }, stack, this.acc); } /** diff --git a/jdk/src/share/classes/java/beans/XMLDecoder.java b/jdk/src/share/classes/java/beans/XMLDecoder.java index accef1199c9..2fb2fd0ef4d 100644 --- a/jdk/src/share/classes/java/beans/XMLDecoder.java +++ b/jdk/src/share/classes/java/beans/XMLDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -29,6 +29,9 @@ import com.sun.beans.decoder.DocumentHandler; import java.io.Closeable; import java.io.InputStream; import java.io.IOException; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; import org.xml.sax.InputSource; import org.xml.sax.helpers.DefaultHandler; @@ -61,6 +64,7 @@ import org.xml.sax.helpers.DefaultHandler; * @author Philip Milne */ public class XMLDecoder implements AutoCloseable { + private final AccessControlContext acc = AccessController.getContext(); private final DocumentHandler handler = new DocumentHandler(); private final InputSource input; private Object owner; @@ -189,7 +193,15 @@ public class XMLDecoder implements AutoCloseable { return false; } if (this.array == null) { - this.handler.parse(this.input); + if ((this.acc == null) && (null != System.getSecurityManager())) { + throw new SecurityException("AccessControlContext is not set"); + } + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + XMLDecoder.this.handler.parse(XMLDecoder.this.input); + return null; + } + }, this.acc); this.array = this.handler.getObjects(); } return true; From 0a735e76f68ae912e6eb380c98cc1d7f20d314aa Mon Sep 17 00:00:00 2001 From: John R Rose Date: Thu, 20 Sep 2012 14:02:55 -0700 Subject: [PATCH 21/56] 7196190: Improve method of handling MethodHandles Bind callers to caller-sensitive methods. Reviewed-by: twisti, jjh, vlivanov, ahgross --- .../java/lang/invoke/MethodHandleImpl.java | 171 ++++++++++++++++- .../java/lang/invoke/MethodHandleNatives.java | 97 ++++++++++ .../java/lang/invoke/MethodHandleStatics.java | 4 +- .../java/lang/invoke/MethodHandles.java | 15 +- .../sun/invoke/anon/AnonymousClassLoader.java | 76 +------- .../sun/invoke/util/ValueConversions.java | 14 +- .../lang/invoke/7196190/ClassForNameTest.java | 98 ++++++++++ .../lang/invoke/7196190/GetUnsafeTest.java | 112 +++++++++++ .../java/lang/invoke/7196190/MHProxyTest.java | 181 ++++++++++++++++++ .../lang/invoke/7196190/jtreg.security.policy | 9 + 10 files changed, 699 insertions(+), 78 deletions(-) create mode 100644 jdk/test/java/lang/invoke/7196190/ClassForNameTest.java create mode 100644 jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java create mode 100644 jdk/test/java/lang/invoke/7196190/MHProxyTest.java create mode 100644 jdk/test/java/lang/invoke/7196190/jtreg.security.policy diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java index d9822bd7189..6013a417cc5 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -25,13 +25,14 @@ package java.lang.invoke; -import sun.invoke.util.VerifyType; - +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import sun.invoke.empty.Empty; import sun.invoke.util.ValueConversions; +import sun.invoke.util.VerifyType; import sun.invoke.util.Wrapper; import static java.lang.invoke.LambdaForm.*; import static java.lang.invoke.MethodHandleStatics.*; @@ -781,4 +782,168 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; return mh; } + /** + * Create an alias for the method handle which, when called, + * appears to be called from the same class loader and protection domain + * as hostClass. + * This is an expensive no-op unless the method which is called + * is sensitive to its caller. A small number of system methods + * are in this category, including Class.forName and Method.invoke. + */ + static + MethodHandle bindCaller(MethodHandle mh, Class hostClass) { + return BindCaller.bindCaller(mh, hostClass); + } + + // Put the whole mess into its own nested class. + // That way we can lazily load the code and set up the constants. + private static class BindCaller { + static + MethodHandle bindCaller(MethodHandle mh, Class hostClass) { + // Do not use this function to inject calls into system classes. + if (hostClass == null) { + hostClass = C_Trampoline; + } else if (hostClass.isArray() || + hostClass.isPrimitive() || + hostClass.getName().startsWith("java.") || + hostClass.getName().startsWith("sun.")) { + throw new InternalError(); // does not happen, and should not anyway + } + // For simplicity, convert mh to a varargs-like method. + MethodHandle vamh = prepareForInvoker(mh); + // Cache the result of makeInjectedInvoker once per argument class. + MethodHandle bccInvoker = CV_makeInjectedInvoker.get(hostClass); + return restoreToType(bccInvoker.bindTo(vamh), mh.type()); + } + + // This class ("Trampoline") is known to be inside a dead-end class loader. + // Inject all doubtful calls into this class. + private static Class C_Trampoline; + static { + Class tramp = null; + try { + final int FRAME_COUNT_ARG = 1; // [0] Reflection [1] Trampoline + java.lang.reflect.Method gcc = sun.reflect.Reflection.class.getMethod("getCallerClass", int.class); + tramp = (Class) sun.reflect.misc.MethodUtil.invoke(gcc, null, new Object[]{ FRAME_COUNT_ARG }); + if (tramp.getClassLoader() == BindCaller.class.getClassLoader()) + throw new RuntimeException(tramp.getName()+" class loader"); + } catch (Throwable ex) { + throw new InternalError(ex); + } + C_Trampoline = tramp; + } + + private static MethodHandle makeInjectedInvoker(Class hostClass) { + Class bcc = UNSAFE.defineAnonymousClass(hostClass, T_BYTES, null); + if (hostClass.getClassLoader() != bcc.getClassLoader()) + throw new InternalError(hostClass.getName()+" (CL)"); + try { + if (hostClass.getProtectionDomain() != bcc.getProtectionDomain()) + throw new InternalError(hostClass.getName()+" (PD)"); + } catch (SecurityException ex) { + // Self-check was blocked by security manager. This is OK. + // In fact the whole try body could be turned into an assertion. + } + try { + MethodHandle init = IMPL_LOOKUP.findStatic(bcc, "init", MethodType.methodType(void.class)); + init.invokeExact(); // force initialization of the class + } catch (Throwable ex) { + throw uncaughtException(ex); + } + MethodHandle bccInvoker; + try { + MethodType invokerMT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class); + bccInvoker = IMPL_LOOKUP.findStatic(bcc, "invoke_V", invokerMT); + } catch (ReflectiveOperationException ex) { + throw uncaughtException(ex); + } + // Test the invoker, to ensure that it really injects into the right place. + try { + MethodHandle vamh = prepareForInvoker(MH_checkCallerClass); + Object ok = bccInvoker.invokeExact(vamh, new Object[]{hostClass, bcc}); + } catch (Throwable ex) { + throw new InternalError(ex); + } + return bccInvoker; + } + private static ClassValue CV_makeInjectedInvoker = new ClassValue() { + @Override protected MethodHandle computeValue(Class hostClass) { + return makeInjectedInvoker(hostClass); + } + }; + + // Adapt mh so that it can be called directly from an injected invoker: + private static MethodHandle prepareForInvoker(MethodHandle mh) { + mh = mh.asFixedArity(); + MethodType mt = mh.type(); + int arity = mt.parameterCount(); + MethodHandle vamh = mh.asType(mt.generic()); + vamh.internalForm().compileToBytecode(); // eliminate LFI stack frames + vamh = vamh.asSpreader(Object[].class, arity); + vamh.internalForm().compileToBytecode(); // eliminate LFI stack frames + return vamh; + } + + // Undo the adapter effect of prepareForInvoker: + private static MethodHandle restoreToType(MethodHandle vamh, MethodType type) { + return vamh.asCollector(Object[].class, type.parameterCount()).asType(type); + } + + private static final MethodHandle MH_checkCallerClass; + static { + final Class THIS_CLASS = BindCaller.class; + assert(checkCallerClass(THIS_CLASS, THIS_CLASS)); + try { + MH_checkCallerClass = IMPL_LOOKUP + .findStatic(THIS_CLASS, "checkCallerClass", + MethodType.methodType(boolean.class, Class.class, Class.class)); + assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS, THIS_CLASS)); + } catch (Throwable ex) { + throw new InternalError(ex); + } + } + + private static boolean checkCallerClass(Class expected, Class expected2) { + final int FRAME_COUNT_ARG = 2; // [0] Reflection [1] BindCaller [2] Expected + Class actual = sun.reflect.Reflection.getCallerClass(FRAME_COUNT_ARG); + if (actual != expected && actual != expected2) + throw new InternalError("found "+actual.getName()+", expected "+expected.getName() + +(expected == expected2 ? "" : ", or else "+expected2.getName())); + return true; + } + + private static final byte[] T_BYTES; + static { + final Object[] values = {null}; + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + try { + Class tClass = T.class; + String tName = tClass.getName(); + String tResource = tName.substring(tName.lastIndexOf('.')+1)+".class"; + java.net.URLConnection uconn = tClass.getResource(tResource).openConnection(); + int len = uconn.getContentLength(); + byte[] bytes = new byte[len]; + try (java.io.InputStream str = uconn.getInputStream()) { + int nr = str.read(bytes); + if (nr != len) throw new java.io.IOException(tResource); + } + values[0] = bytes; + } catch (java.io.IOException ex) { + throw new InternalError(ex); + } + return null; + } + }); + T_BYTES = (byte[]) values[0]; + } + + // The following class is used as a template for Unsafe.defineAnonymousClass: + private static class T { + static void init() { } // side effect: initializes this class + static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable { + return vamh.invokeExact(args); + } + } + } } diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java index d27256fb337..06a9ba20e69 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java @@ -385,4 +385,101 @@ class MethodHandleNatives { throw err; } } + + /** + * Is this method a caller-sensitive method? + * I.e., does it call Reflection.getCallerClass or a similer method + * to ask about the identity of its caller? + */ + // FIXME: Replace this pattern match by an annotation @sun.reflect.CallerSensitive. + static boolean isCallerSensitive(MemberName mem) { + assert(mem.isInvocable()); + Class defc = mem.getDeclaringClass(); + switch (mem.getName()) { + case "doPrivileged": + return defc == java.security.AccessController.class; + case "getUnsafe": + return defc == sun.misc.Unsafe.class; + case "lookup": + return defc == java.lang.invoke.MethodHandles.class; + case "invoke": + return defc == java.lang.reflect.Method.class; + case "get": + case "getBoolean": + case "getByte": + case "getChar": + case "getShort": + case "getInt": + case "getLong": + case "getFloat": + case "getDouble": + case "set": + case "setBoolean": + case "setByte": + case "setChar": + case "setShort": + case "setInt": + case "setLong": + case "setFloat": + case "setDouble": + return defc == java.lang.reflect.Field.class; + case "newInstance": + if (defc == java.lang.reflect.Constructor.class) return true; + if (defc == java.lang.Class.class) return true; + break; + case "forName": + case "getClassLoader": + case "getClasses": + case "getFields": + case "getMethods": + case "getConstructors": + case "getDeclaredClasses": + case "getDeclaredFields": + case "getDeclaredMethods": + case "getDeclaredConstructors": + case "getField": + case "getMethod": + case "getConstructor": + case "getDeclaredField": + case "getDeclaredMethod": + case "getDeclaredConstructor": + return defc == java.lang.Class.class; + case "getConnection": + case "getDriver": + case "getDrivers": + case "deregisterDriver": + return defc == java.sql.DriverManager.class; + case "newUpdater": + if (defc == java.util.concurrent.atomic.AtomicIntegerFieldUpdater.class) return true; + if (defc == java.util.concurrent.atomic.AtomicLongFieldUpdater.class) return true; + if (defc == java.util.concurrent.atomic.AtomicReferenceFieldUpdater.class) return true; + break; + case "getContextClassLoader": + return defc == java.lang.Thread.class; + case "getPackage": + case "getPackages": + return defc == java.lang.Package.class; + case "getParent": + case "getSystemClassLoader": + return defc == java.lang.ClassLoader.class; + case "load": + case "loadLibrary": + if (defc == java.lang.Runtime.class) return true; + if (defc == java.lang.System.class) return true; + break; + case "getCallerClass": + if (defc == sun.reflect.Reflection.class) return true; + if (defc == java.lang.System.class) return true; + break; + case "getCallerClassLoader": + return defc == java.lang.ClassLoader.class; + case "getProxyClass": + case "newProxyInstance": + return defc == java.lang.reflect.Proxy.class; + case "getBundle": + case "clearCache": + return defc == java.util.ResourceBundle.class; + } + return false; + } } diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java index 3db5712fdeb..50e273804ec 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -108,7 +108,7 @@ import sun.misc.Unsafe; /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj, Object obj2) { return new IllegalArgumentException(message(message, obj, obj2)); } - /*non-public*/ static Error uncaughtException(Exception ex) { + /*non-public*/ static Error uncaughtException(Throwable ex) { throw new InternalError("uncaught exception", ex); } static Error NYI() { diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java index 5c55f202353..e7007dd2b89 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -329,6 +329,7 @@ public class MethodHandles { * where {@code defcPkg} is the package of {@code defc}. * */ + // FIXME in MR1: clarify that the bytecode behavior of a caller-ID method (like Class.forName) is relative to the lookupClass used to create the method handle, not the dynamic caller of the method handle public static final class Lookup { /** The class on behalf of whom the lookup is being performed. */ @@ -1209,6 +1210,7 @@ return mh1; if (method.isMethodHandleInvoke()) return fakeMethodHandleInvoke(method); MethodHandle mh = DirectMethodHandle.make(refc, method); + mh = maybeBindCaller(method, mh); mh = mh.setVarargs(method); if (doRestrict) mh = restrictReceiver(method, mh, lookupClass()); @@ -1217,6 +1219,16 @@ return mh1; private MethodHandle fakeMethodHandleInvoke(MemberName method) { return throwException(method.getReturnType(), UnsupportedOperationException.class); } + private MethodHandle maybeBindCaller(MemberName method, MethodHandle mh) throws IllegalAccessException { + if (allowedModes == TRUSTED || !MethodHandleNatives.isCallerSensitive(method)) + return mh; + Class hostClass = lookupClass; + if ((allowedModes & PRIVATE) == 0) // caller must use full-power lookup + hostClass = null; + MethodHandle cbmh = MethodHandleImpl.bindCaller(mh, hostClass); + // Note: caller will apply varargs after this step happens. + return cbmh; + } private MethodHandle getDirectField(byte refKind, Class refc, MemberName field) throws IllegalAccessException { checkField(refKind, refc, field); MethodHandle mh = DirectMethodHandle.make(refc, field); @@ -1229,6 +1241,7 @@ return mh1; private MethodHandle getDirectConstructor(Class refc, MemberName ctor) throws IllegalAccessException { assert(ctor.isConstructor()); checkAccess(REF_newInvokeSpecial, refc, ctor); + assert(!MethodHandleNatives.isCallerSensitive(ctor)); // maybeBindCaller not relevant here return DirectMethodHandle.make(ctor).setVarargs(ctor); } diff --git a/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java b/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java index 3005a452f71..32624b40f97 100644 --- a/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java +++ b/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -73,74 +73,14 @@ import sun.misc.IOUtils; public class AnonymousClassLoader { final Class hostClass; - // Note: Do not refactor the calls to checkHostClass unless you - // also adjust this constant: - private static int CHC_CALLERS = 3; - - public AnonymousClassLoader() { - this.hostClass = checkHostClass(null); - } - public AnonymousClassLoader(Class hostClass) { - this.hostClass = checkHostClass(hostClass); + // Privileged constructor. + private AnonymousClassLoader(Class hostClass) { + this.hostClass = hostClass; } - private static Class getTopLevelClass(Class clazz) { - for(Class outer = clazz.getDeclaringClass(); outer != null; - outer = outer.getDeclaringClass()) { - clazz = outer; - } - return clazz; - } - - private static Class checkHostClass(Class hostClass) { - // called only from the constructor - // does a context-sensitive check on caller class - // CC[0..3] = {Reflection, this.checkHostClass, this., caller} - Class caller = sun.reflect.Reflection.getCallerClass(CHC_CALLERS); - - if (caller == null) { - // called from the JVM directly - if (hostClass == null) - return AnonymousClassLoader.class; // anything central will do - return hostClass; - } - - if (hostClass == null) - hostClass = caller; // default value is caller itself - - // anonymous class will access hostClass on behalf of caller - Class callee = hostClass; - - if (caller == callee) - // caller can always nominate itself to grant caller's own access rights - return hostClass; - - // normalize caller and callee to their top-level classes: - caller = getTopLevelClass(caller); - callee = getTopLevelClass(callee); - if (caller == callee) - return caller; - - ClassLoader callerCL = caller.getClassLoader(); - if (callerCL == null) { - // caller is trusted code, so accept the proposed hostClass - return hostClass; - } - - // %%% should do something with doPrivileged, because trusted - // code should have a way to execute on behalf of - // partially-trusted clients - - // Does the caller have the right to access the private - // members of the callee? If not, raise an error. - final int ACC_PRIVATE = 2; - try { - sun.reflect.Reflection.ensureMemberAccess(caller, callee, null, ACC_PRIVATE); - } catch (IllegalAccessException ee) { - throw new IllegalArgumentException(ee); - } - - return hostClass; + public static AnonymousClassLoader make(sun.misc.Unsafe unsafe, Class hostClass) { + if (unsafe == null) throw new NullPointerException(); + return new AnonymousClassLoader(hostClass); } public Class loadClass(byte[] classFile) { @@ -249,7 +189,7 @@ public class AnonymousClassLoader { private static int fakeNameCounter = 99999; // ignore two warnings on this line: - static sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); + private static sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); // preceding line requires that this class be on the boot class path static private final Method defineAnonymousClass; diff --git a/jdk/src/share/classes/sun/invoke/util/ValueConversions.java b/jdk/src/share/classes/sun/invoke/util/ValueConversions.java index 1533f4b2ad2..b2044818f60 100644 --- a/jdk/src/share/classes/sun/invoke/util/ValueConversions.java +++ b/jdk/src/share/classes/sun/invoke/util/ValueConversions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -522,13 +522,19 @@ public class ValueConversions { static { MethodHandle mh = null; try { - java.lang.reflect.Method m = MethodHandles.class + final java.lang.reflect.Method m = MethodHandles.class .getDeclaredMethod("collectArguments", MethodHandle.class, int.class, MethodHandle.class); - m.setAccessible(true); + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + m.setAccessible(true); + return null; + } + }); mh = IMPL_LOOKUP.unreflect(m); - } catch (ReflectiveOperationException | SecurityException ex) { + } catch (ReflectiveOperationException ex) { throw new InternalError(ex); } COLLECT_ARGUMENTS = mh; diff --git a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java new file mode 100644 index 00000000000..48ccb2a6463 --- /dev/null +++ b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 7196190 + * @summary Improve method of handling MethodHandles + * + * @run main/othervm ClassForNameTest + */ + +import java.lang.invoke.*; +import java.lang.reflect.Method; +import java.util.Arrays; + +public class ClassForNameTest { + final static String NAME = ClassForNameTest.class.getName(); + + public static void main(String[] args) throws Throwable { + { + final MethodType mt = MethodType.methodType(Class.class, String.class); + final MethodHandle mh = MethodHandles.lookup() + .findStatic(Class.class, "forName", mt); + + Class.forName(NAME); + + mh.invoke(NAME); + mh.bindTo(NAME).invoke(); + mh.invokeWithArguments(Arrays.asList(NAME)); + mh.invokeWithArguments(NAME); + Class cls = (Class) mh.invokeExact(NAME); + } + + { + final Method fnMethod = Class.class.getMethod("forName", String.class); + final MethodType mt = MethodType.methodType(Object.class, Object.class, Object[].class); + final MethodHandle mh = MethodHandles.lookup() + .findVirtual(Method.class, "invoke", mt) + .bindTo(fnMethod); + + fnMethod.invoke(null, NAME); + + mh.bindTo(null).bindTo(new Object[]{NAME}).invoke(); + mh.invoke(null, new Object[]{NAME}); + mh.invokeWithArguments(null, new Object[]{NAME}); + mh.invokeWithArguments(Arrays.asList(null, new Object[]{NAME})); + Object obj = mh.invokeExact((Object) null, new Object[]{NAME}); + } + + { + final Method fnMethod = Class.class.getMethod("forName", String.class); + final MethodType mt = MethodType.methodType(Object.class, Object.class, Object[].class); + + final MethodHandle mh = MethodHandles.lookup() + .bind(fnMethod, "invoke", mt); + + mh.bindTo(null).bindTo(new Object[]{NAME}).invoke(); + mh.invoke(null, new Object[]{NAME}); + mh.invokeWithArguments(null, NAME); + mh.invokeWithArguments(Arrays.asList(null, NAME)); + Object obj = mh.invokeExact((Object) null, new Object[]{NAME}); + } + + { + final Method fnMethod = Class.class.getMethod("forName", String.class); + final MethodHandle mh = MethodHandles.lookup().unreflect(fnMethod); + + mh.bindTo(NAME).invoke(); + mh.invoke(NAME); + mh.invokeWithArguments(NAME); + mh.invokeWithArguments(Arrays.asList(NAME)); + Class cls = (Class) mh.invokeExact(NAME); + } + + System.out.println("TEST PASSED"); + } +} diff --git a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java new file mode 100644 index 00000000000..0fd3cbd8d0f --- /dev/null +++ b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 7196190 + * @summary Improve method of handling MethodHandles + * + * @run main/othervm/policy=jtreg.security.policy/secure=java.lang.SecurityManager GetUnsafeTest + */ + +import java.lang.invoke.*; +import java.lang.reflect.Method; +import java.util.Arrays; + +public class GetUnsafeTest { + final static String NAME = "sun.misc.Unsafe"; + + private static boolean isTestFailed = false; + + private static void fail() { + isTestFailed = true; + try { throw new Exception(); } catch (Throwable e) { + StackTraceElement frame = e.getStackTrace()[1]; + System.out.printf("Failed at %s:%d\n", frame.getFileName(), frame.getLineNumber()); + } + } + + public static void main(String[] args) throws Throwable { + { + final MethodType mt = MethodType.methodType(Class.class, String.class); + final MethodHandle mh = MethodHandles.lookup() + .findStatic(Class.class, "forName", mt); + + try { Class.forName(NAME); fail(); } catch (Throwable e) {} + + try { mh.invoke(NAME); fail(); } catch (Throwable e) {} + try { mh.bindTo(NAME).invoke(); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(Arrays.asList(NAME)); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(NAME); fail(); } catch (Throwable e) {} + try { Class cls = (Class) mh.invokeExact(NAME); fail(); } catch (Throwable e) {} + } + + { + final Method fnMethod = Class.class.getMethod("forName", String.class); + final MethodType mt = MethodType.methodType(Object.class, Object.class, Object[].class); + final MethodHandle mh = MethodHandles.lookup() + .findVirtual(Method.class, "invoke", mt) + .bindTo(fnMethod); + + try { fnMethod.invoke(null, NAME); fail(); } catch (Throwable e) {} + + try { mh.bindTo(null).bindTo(new Object[]{NAME}).invoke(); fail(); } catch (Throwable e) {} + try { mh.invoke(null, new Object[]{NAME}); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(null, new Object[]{NAME}); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(Arrays.asList(null, new Object[]{NAME})); fail(); } catch (Throwable e) {} + try { Object obj = mh.invokeExact((Object) null, new Object[]{NAME}); fail(); } catch (Throwable e) {} + } + + { + final Method fnMethod = Class.class.getMethod("forName", String.class); + final MethodType mt = MethodType.methodType(Object.class, Object.class, Object[].class); + + final MethodHandle mh = MethodHandles.lookup().bind(fnMethod, "invoke", mt); + + try { mh.bindTo(null).bindTo(new Object[]{NAME}).invoke(); fail(); } catch (Throwable e) {} + try { mh.invoke(null, new Object[]{NAME}); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(null, NAME); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(Arrays.asList(null, NAME)); fail(); } catch (Throwable e) {} + try { Object obj = mh.invokeExact((Object) null, new Object[]{NAME}); fail(); } catch (Throwable e) {} + } + + { + final Method fnMethod = Class.class.getMethod("forName", String.class); + final MethodHandle mh = MethodHandles.lookup().unreflect(fnMethod); + + try { mh.bindTo(NAME).invoke(); fail(); } catch (Throwable e) {} + try { mh.invoke(NAME); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(NAME); fail(); } catch (Throwable e) {} + try { mh.invokeWithArguments(Arrays.asList(NAME)); fail(); } catch (Throwable e) {} + try { Class cls = (Class) mh.invokeExact(NAME); fail(); } catch (Throwable e) {} + } + + if (!isTestFailed) { + System.out.println("TEST PASSED"); + } else { + System.out.println("TEST FAILED"); + System.exit(1); + } + } +} diff --git a/jdk/test/java/lang/invoke/7196190/MHProxyTest.java b/jdk/test/java/lang/invoke/7196190/MHProxyTest.java new file mode 100644 index 00000000000..5e07f393cb1 --- /dev/null +++ b/jdk/test/java/lang/invoke/7196190/MHProxyTest.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 7196190 + * @summary Improve method of handling MethodHandles + * + * @run main/othervm MHProxyTest + */ + +import java.lang.invoke.*; +import java.security.*; +import static java.lang.invoke.MethodHandles.*; +import static java.lang.invoke.MethodType.*; + +public class MHProxyTest { + private static final Class C_Unsafe; + private static final MethodHandle MH_getUnsafe; + static { + // Do these before there is a SM installed. + C_Unsafe = sun.misc.Unsafe.class; // EXPECT A WARNING ON THIS LINE + Lookup lookup = lookup(); + MethodHandle gumh = null; + try { + gumh = lookup.findStatic(C_Unsafe, "getUnsafe", methodType(C_Unsafe)); + } catch (ReflectiveOperationException ex) { + throw new InternalError(ex.toString()); + } + MH_getUnsafe = gumh; + // Try some different lookups: + try { + lookup.in(Object.class).findStatic(C_Unsafe, "getUnsafe", methodType(C_Unsafe)); + } catch (ReflectiveOperationException ex) { + throw new InternalError(ex.toString()); + } + lookup = lookup().in(C_Unsafe); + try { + lookup.in(C_Unsafe).findStatic(C_Unsafe, "getUnsafe", methodType(C_Unsafe)); + } catch (ReflectiveOperationException ex) { + throw new InternalError(ex.toString()); + } + } + + public static void main(String[] args) throws Throwable { + System.setSecurityManager(new SecurityManager()); + Lookup lookup = lookup(); + testBasic(lookup); + testDoPriv(lookup); + testSetVar(); + Lookup l2 = lookup.in(Object.class); + System.out.println("=== "+l2); + testBasic(l2); + testDoPriv(l2); + Lookup l3 = lookup.in(C_Unsafe); + System.out.println("=== "+l3); + testBasic(l3); + testDoPriv(l3); + if (failure != null) + throw failure; + } + + private static Throwable failure; + private static void fail(Throwable ex) { + if (failure == null) + failure = ex; + StackTraceElement frame = new Exception().getStackTrace()[1]; + System.out.printf("Failed at %s:%d: %s\n", frame.getFileName(), frame.getLineNumber(), ex); + } + private static void ok(Throwable ex) { + StackTraceElement frame = new Exception().getStackTrace()[1]; + System.out.printf("OK at %s:%d: %s\n", frame.getFileName(), frame.getLineNumber(), ex); + } + + private static void testBasic(Lookup lookup) throws Throwable { + // Verify that we can't get to this guy under the SM: + try { + MethodHandle badmh = lookup.findStatic(C_Unsafe, "getUnsafe", methodType(C_Unsafe)); + assert(badmh.type() == methodType(C_Unsafe)); + badmh = badmh.asType(badmh.type().generic()); + Object u = C_Unsafe.cast(badmh.invokeExact()); + assert(C_Unsafe.isInstance(u)); + fail(new AssertionError("got mh to getUnsafe!")); + } catch (SecurityException ex) { + ok(ex); + } + try { + Object u = MH_getUnsafe.invokeWithArguments(); + assert(C_Unsafe.isInstance(u)); + fail(new AssertionError("got the Unsafe object! (MH invoke)")); + } catch (SecurityException ex) { + ok(ex); + } + try { + MethodHandle mh = MH_getUnsafe; + mh = mh.asType(mh.type().generic()); + mh = foldArguments(identity(Object.class), mh); + mh = filterReturnValue(mh, identity(Object.class)); + Object u = mh.invokeExact(); + assert(C_Unsafe.isInstance(u)); + fail(new AssertionError("got the Unsafe object! (MH invokeWithArguments)")); + } catch (SecurityException ex) { + ok(ex); + } + } + + private static void testDoPriv(Lookup lookup) throws Throwable { + PrivilegedAction privAct = MethodHandleProxies.asInterfaceInstance(PrivilegedAction.class, MH_getUnsafe); + try { + Object u = AccessController.doPrivileged(privAct); + assert(C_Unsafe.isInstance(u)); + fail(new AssertionError("got the Unsafe object! (static doPriv)")); + } catch (SecurityException ex) { + ok(ex); + } + MethodHandle MH_doPriv = lookup.findStatic(AccessController.class, "doPrivileged", + methodType(Object.class, PrivilegedAction.class)); + MH_doPriv = MH_doPriv.bindTo(privAct); + try { + Object u = MH_doPriv.invoke(); + assert(C_Unsafe.isInstance(u)); + fail(new AssertionError("got the Unsafe object! (MH + doPriv)")); + } catch (SecurityException ex) { + ok(ex); + } + // try one more layer of indirection: + Runnable rbl = MethodHandleProxies.asInterfaceInstance(Runnable.class, MH_doPriv); + try { + rbl.run(); + fail(new AssertionError("got the Unsafe object! (Runnable + MH + doPriv)")); + } catch (SecurityException ex) { + ok(ex); + } + } + + private static void testSetVar() throws Throwable { + { + // Test the box pattern: + Object[] box = new Object[1]; + MethodHandle MH_getFoo = identity(Object.class).bindTo("foo"); + MethodHandle MH_storeToBox = insertArguments(arrayElementSetter(Object[].class), 0, box, 0); + MethodHandle mh = filterReturnValue(MH_getFoo, MH_storeToBox); + mh.invokeExact(); + assert(box[0] == "foo"); + } + { + Object[] box = new Object[1]; + MethodHandle MH_storeToBox = insertArguments(arrayElementSetter(Object[].class), 0, box, 0); + MethodHandle mh = filterReturnValue(MH_getUnsafe.asType(MH_getUnsafe.type().generic()), MH_storeToBox); + try { + mh.invokeExact(); + Object u = box[0]; + assert(C_Unsafe.isInstance(u)); + fail(new AssertionError("got the Unsafe object! (MH + setElement)")); + } catch (SecurityException ex) { + ok(ex); + } + } + } +} diff --git a/jdk/test/java/lang/invoke/7196190/jtreg.security.policy b/jdk/test/java/lang/invoke/7196190/jtreg.security.policy new file mode 100644 index 00000000000..d32c7af9b3f --- /dev/null +++ b/jdk/test/java/lang/invoke/7196190/jtreg.security.policy @@ -0,0 +1,9 @@ +/* + * security policy used by the test process + * must allow file reads so that jtreg itself can run + */ + +grant { + // standard test activation permissions + permission java.io.FilePermission "*", "read"; +}; From 898b21ebf3d77c37c54cb8e6f2a50d78d6446bd7 Mon Sep 17 00:00:00 2001 From: Frederic Parain Date: Mon, 24 Sep 2012 16:15:27 +0400 Subject: [PATCH 22/56] 7198296: Problem with classloader in JMX Wb classes have to be available for hotspot tests Co-authored-by: Daniel Fuchs Co-authored-by: Jean-Francois Denise Reviewed-by: ahgross, asaha --- .../remote/rmi/RMIConnectionImpl.java | 61 +++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java index 9449210e897..3f880d0a8f9 100644 --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -144,6 +144,17 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { new RuntimePermission("createClassLoader")) ); + + this.defaultContextClassLoader = + AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public ClassLoader run() { + return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(), + dcl); + } + }); + serverCommunicatorAdmin = new RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env)); @@ -510,7 +521,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); - queryValue = unwrap(query, defaultClassLoader, QueryExp.class); + queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); try { final Object params[] = new Object[] { name, queryValue }; @@ -545,7 +556,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); - queryValue = unwrap(query, defaultClassLoader, QueryExp.class); + queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); try { final Object params[] = new Object[] { name, queryValue }; @@ -1579,7 +1590,8 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { ClassLoader orderCL = AccessController.doPrivileged( new PrivilegedExceptionAction() { public ClassLoader run() throws Exception { - return new OrderClassLoaders(cl1, cl2); + return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(), + new OrderClassLoaders(cl1, cl2)); } } ); @@ -1671,6 +1683,8 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { private final ClassLoader defaultClassLoader; + private final ClassLoader defaultContextClassLoader; + private final ClassLoaderWithRepository classLoaderWithRepository; private boolean terminated = false; @@ -1753,4 +1767,43 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { private static final ClassLogger logger = new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl"); + + private static final class CombinedClassLoader extends ClassLoader { + + private final static class ClassLoaderWrapper extends ClassLoader { + ClassLoaderWrapper(ClassLoader cl) { + super(cl); + } + + @Override + protected Class loadClass(String name, boolean resolve) + throws ClassNotFoundException { + return super.loadClass(name, resolve); + } + }; + + final ClassLoaderWrapper defaultCL; + + private CombinedClassLoader(ClassLoader parent, ClassLoader defaultCL) { + super(parent); + this.defaultCL = new ClassLoaderWrapper(defaultCL); + } + + @Override + protected Class loadClass(String name, boolean resolve) + throws ClassNotFoundException { + try { + super.loadClass(name, resolve); + } catch(Exception e) { + for(Throwable t = e; t != null; t = t.getCause()) { + if(t instanceof SecurityException) { + throw t==e?(SecurityException)t:new SecurityException(t.getMessage(), e); + } + } + } + final Class cl = defaultCL.loadClass(name, resolve); + return cl; + } + + } } From 12bf2c7d5201ace92e558c217dafc89354796f29 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Mon, 24 Sep 2012 17:00:40 +0400 Subject: [PATCH 23/56] 7192975: Issue with JMX reflection Make security check unconditional Reviewed-by: ahgross, asaha --- .../javax/management/modelmbean/DescriptorSupport.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java b/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java index 57b4b46365e..068047967ea 100644 --- a/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java +++ b/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java @@ -1245,13 +1245,12 @@ public class DescriptorSupport return s.substring(1, s.length() - 1); } final String className = s.substring(1, slash); + final Constructor constr; try { + ReflectUtil.checkPackageAccess(className); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - if (contextClassLoader == null) { - ReflectUtil.checkPackageAccess(className); - } final Class c = Class.forName(className, false, contextClassLoader); constr = c.getConstructor(new Class[] {String.class}); From fd15ca5e44fd8e2a88905449ea29146dc8c97470 Mon Sep 17 00:00:00 2001 From: Kaushik Srenevasan Date: Sat, 6 Oct 2012 01:17:44 -0700 Subject: [PATCH 24/56] 7127708: G1: change task num types from int to uint in concurrent mark Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich. Reviewed-by: johnc --- .../gc_implementation/g1/concurrentMark.cpp | 244 +++++++++--------- .../gc_implementation/g1/concurrentMark.hpp | 34 +-- .../g1/concurrentMark.inline.hpp | 26 +- .../g1/g1OopClosures.inline.hpp | 4 +- 4 files changed, 154 insertions(+), 154 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index a06b01cae37..2684be80872 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -426,11 +426,11 @@ ConcurrentMark::ConcurrentMark(ReservedSpace rs, uint max_regions) : _markStack(this), // _finger set in set_non_marking_state - _max_task_num(MAX2((uint)ParallelGCThreads, 1U)), + _max_worker_id(MAX2((uint)ParallelGCThreads, 1U)), // _active_tasks set in set_non_marking_state // _tasks set inside the constructor - _task_queues(new CMTaskQueueSet((int) _max_task_num)), - _terminator(ParallelTaskTerminator((int) _max_task_num, _task_queues)), + _task_queues(new CMTaskQueueSet((int) _max_worker_id)), + _terminator(ParallelTaskTerminator((int) _max_worker_id, _task_queues)), _has_overflown(false), _concurrent(false), @@ -481,17 +481,17 @@ ConcurrentMark::ConcurrentMark(ReservedSpace rs, uint max_regions) : _root_regions.init(_g1h, this); - _tasks = NEW_C_HEAP_ARRAY(CMTask*, _max_task_num, mtGC); - _accum_task_vtime = NEW_C_HEAP_ARRAY(double, _max_task_num, mtGC); + _tasks = NEW_C_HEAP_ARRAY(CMTask*, _max_worker_id, mtGC); + _accum_task_vtime = NEW_C_HEAP_ARRAY(double, _max_worker_id, mtGC); - _count_card_bitmaps = NEW_C_HEAP_ARRAY(BitMap, _max_task_num, mtGC); - _count_marked_bytes = NEW_C_HEAP_ARRAY(size_t*, _max_task_num, mtGC); + _count_card_bitmaps = NEW_C_HEAP_ARRAY(BitMap, _max_worker_id, mtGC); + _count_marked_bytes = NEW_C_HEAP_ARRAY(size_t*, _max_worker_id, mtGC); BitMap::idx_t card_bm_size = _card_bm.size(); // so that the assertion in MarkingTaskQueue::task_queue doesn't fail - _active_tasks = _max_task_num; - for (int i = 0; i < (int) _max_task_num; ++i) { + _active_tasks = _max_worker_id; + for (uint i = 0; i < _max_worker_id; ++i) { CMTaskQueue* task_queue = new CMTaskQueue(); task_queue->initialize(); _task_queues->register_queue(i, task_queue); @@ -638,7 +638,7 @@ void ConcurrentMark::reset() { // We do reset all of them, since different phases will use // different number of active threads. So, it's easiest to have all // of them ready. - for (int i = 0; i < (int) _max_task_num; ++i) { + for (uint i = 0; i < _max_worker_id; ++i) { _tasks[i]->reset(_nextMarkBitMap); } @@ -648,7 +648,7 @@ void ConcurrentMark::reset() { } void ConcurrentMark::set_phase(uint active_tasks, bool concurrent) { - assert(active_tasks <= _max_task_num, "we should not have more"); + assert(active_tasks <= _max_worker_id, "we should not have more"); _active_tasks = active_tasks; // Need to update the three data structures below according to the @@ -659,7 +659,7 @@ void ConcurrentMark::set_phase(uint active_tasks, bool concurrent) { _concurrent = concurrent; // We propagate this to all tasks, not just the active ones. - for (int i = 0; i < (int) _max_task_num; ++i) + for (uint i = 0; i < _max_worker_id; ++i) _tasks[i]->set_concurrent(concurrent); if (concurrent) { @@ -818,9 +818,9 @@ void ConcurrentMark::checkpointRootsInitialPost() { * doesn't manipulate any data structures afterwards. */ -void ConcurrentMark::enter_first_sync_barrier(int task_num) { +void ConcurrentMark::enter_first_sync_barrier(uint worker_id) { if (verbose_low()) { - gclog_or_tty->print_cr("[%d] entering first barrier", task_num); + gclog_or_tty->print_cr("[%u] entering first barrier", worker_id); } if (concurrent()) { @@ -834,11 +834,11 @@ void ConcurrentMark::enter_first_sync_barrier(int task_num) { // more work if (verbose_low()) { - gclog_or_tty->print_cr("[%d] leaving first barrier", task_num); + gclog_or_tty->print_cr("[%u] leaving first barrier", worker_id); } - // let task 0 do this - if (task_num == 0) { + // let the task associated with with worker 0 do this + if (worker_id == 0) { // task 0 is responsible for clearing the global data structures // We should be here because of an overflow. During STW we should // not clear the overflow flag since we rely on it being true when @@ -858,9 +858,9 @@ void ConcurrentMark::enter_first_sync_barrier(int task_num) { // then go into the second barrier } -void ConcurrentMark::enter_second_sync_barrier(int task_num) { +void ConcurrentMark::enter_second_sync_barrier(uint worker_id) { if (verbose_low()) { - gclog_or_tty->print_cr("[%d] entering second barrier", task_num); + gclog_or_tty->print_cr("[%u] entering second barrier", worker_id); } if (concurrent()) { @@ -873,7 +873,7 @@ void ConcurrentMark::enter_second_sync_barrier(int task_num) { // at this point everything should be re-initialised and ready to go if (verbose_low()) { - gclog_or_tty->print_cr("[%d] leaving second barrier", task_num); + gclog_or_tty->print_cr("[%u] leaving second barrier", worker_id); } } @@ -2113,9 +2113,9 @@ class G1CMParKeepAliveAndDrainClosure: public OopClosure { if (!_cm->has_overflown()) { oop obj = oopDesc::load_decode_heap_oop(p); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("\t[%d] we're looking at location " + gclog_or_tty->print_cr("\t[%u] we're looking at location " "*"PTR_FORMAT" = "PTR_FORMAT, - _task->task_id(), p, (void*) obj); + _task->worker_id(), p, (void*) obj); } _task->deal_with_reference(obj); @@ -2144,7 +2144,7 @@ class G1CMParKeepAliveAndDrainClosure: public OopClosure { } } else { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("\t[%d] CM Overflow", _task->task_id()); + gclog_or_tty->print_cr("\t[%u] CM Overflow", _task->worker_id()); } } } @@ -2160,8 +2160,8 @@ class G1CMParDrainMarkingStackClosure: public VoidClosure { void do_void() { do { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("\t[%d] Drain: Calling do marking_step", - _task->task_id()); + gclog_or_tty->print_cr("\t[%u] Drain: Calling do marking_step", + _task->worker_id()); } // We call CMTask::do_marking_step() to completely drain the local and @@ -2300,7 +2300,7 @@ void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { // We use the work gang from the G1CollectedHeap and we utilize all // the worker threads. uint active_workers = g1h->workers() ? g1h->workers()->active_workers() : 1U; - active_workers = MAX2(MIN2(active_workers, _max_task_num), 1U); + active_workers = MAX2(MIN2(active_workers, _max_worker_id), 1U); G1CMRefProcTaskExecutor par_task_executor(g1h, this, g1h->workers(), active_workers); @@ -2619,7 +2619,7 @@ void ConcurrentMark::clearRangeBothBitmaps(MemRegion mr) { } HeapRegion* -ConcurrentMark::claim_region(int task_num) { +ConcurrentMark::claim_region(uint worker_id) { // "checkpoint" the finger HeapWord* finger = _finger; @@ -2657,10 +2657,10 @@ ConcurrentMark::claim_region(int task_num) { HeapWord* limit = curr_region->next_top_at_mark_start(); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] curr_region = "PTR_FORMAT" " + gclog_or_tty->print_cr("[%u] curr_region = "PTR_FORMAT" " "["PTR_FORMAT", "PTR_FORMAT"), " "limit = "PTR_FORMAT, - task_num, curr_region, bottom, end, limit); + worker_id, curr_region, bottom, end, limit); } // Is the gap between reading the finger and doing the CAS too long? @@ -2673,22 +2673,22 @@ ConcurrentMark::claim_region(int task_num) { assert(_finger >= end, "the finger should have moved forward"); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] we were successful with region = " - PTR_FORMAT, task_num, curr_region); + gclog_or_tty->print_cr("[%u] we were successful with region = " + PTR_FORMAT, worker_id, curr_region); } if (limit > bottom) { if (verbose_low()) { - gclog_or_tty->print_cr("[%d] region "PTR_FORMAT" is not empty, " - "returning it ", task_num, curr_region); + gclog_or_tty->print_cr("[%u] region "PTR_FORMAT" is not empty, " + "returning it ", worker_id, curr_region); } return curr_region; } else { assert(limit == bottom, "the region limit should be at bottom"); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] region "PTR_FORMAT" is empty, " - "returning NULL", task_num, curr_region); + gclog_or_tty->print_cr("[%u] region "PTR_FORMAT" is empty, " + "returning NULL", worker_id, curr_region); } // we return NULL and the caller should try calling // claim_region() again. @@ -2697,10 +2697,10 @@ ConcurrentMark::claim_region(int task_num) { } else { assert(_finger > finger, "the finger should have moved forward"); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] somebody else moved the finger, " + gclog_or_tty->print_cr("[%u] somebody else moved the finger, " "global finger = "PTR_FORMAT", " "our finger = "PTR_FORMAT, - task_num, _finger, finger); + worker_id, _finger, finger); } // read it again @@ -2783,7 +2783,7 @@ void ConcurrentMark::verify_no_cset_oops(bool verify_stacks, _markStack.oops_do(&cl); // Verify entries on the task queues - for (int i = 0; i < (int) _max_task_num; i += 1) { + for (uint i = 0; i < _max_worker_id; i += 1) { cl.set_phase(VerifyNoCSetOopsQueues, i); OopTaskQueue* queue = _task_queues->queue(i); queue->oops_do(&cl); @@ -2822,7 +2822,7 @@ void ConcurrentMark::verify_no_cset_oops(bool verify_stacks, } // Verify the task fingers - assert(parallel_marking_threads() <= _max_task_num, "sanity"); + assert(parallel_marking_threads() <= _max_worker_id, "sanity"); for (int i = 0; i < (int) parallel_marking_threads(); i += 1) { CMTask* task = _tasks[i]; HeapWord* task_finger = task->finger(); @@ -2849,7 +2849,7 @@ void ConcurrentMark::clear_marking_state(bool clear_overflow) { } _finger = _heap_start; - for (int i = 0; i < (int)_max_task_num; ++i) { + for (uint i = 0; i < _max_worker_id; ++i) { OopTaskQueue* queue = _task_queues->queue(i); queue->set_empty(); } @@ -2862,15 +2862,15 @@ class AggregateCountDataHRClosure: public HeapRegionClosure { ConcurrentMark* _cm; CardTableModRefBS* _ct_bs; BitMap* _cm_card_bm; - size_t _max_task_num; + uint _max_worker_id; public: AggregateCountDataHRClosure(G1CollectedHeap* g1h, BitMap* cm_card_bm, - size_t max_task_num) : + uint max_worker_id) : _g1h(g1h), _cm(g1h->concurrent_mark()), _ct_bs((CardTableModRefBS*) (g1h->barrier_set())), - _cm_card_bm(cm_card_bm), _max_task_num(max_task_num) { } + _cm_card_bm(cm_card_bm), _max_worker_id(max_worker_id) { } bool doHeapRegion(HeapRegion* hr) { if (hr->continuesHumongous()) { @@ -2927,7 +2927,7 @@ class AggregateCountDataHRClosure: public HeapRegionClosure { uint hrs_index = hr->hrs_index(); size_t marked_bytes = 0; - for (int i = 0; (size_t)i < _max_task_num; i += 1) { + for (uint i = 0; i < _max_worker_id; i += 1) { size_t* marked_bytes_array = _cm->count_marked_bytes_array_for(i); BitMap* task_card_bm = _cm->count_card_bitmap_for(i); @@ -2935,7 +2935,7 @@ class AggregateCountDataHRClosure: public HeapRegionClosure { // add it to the running total for this region. marked_bytes += marked_bytes_array[hrs_index]; - // Now union the bitmaps[0,max_task_num)[start_idx..limit_idx) + // Now union the bitmaps[0,max_worker_id)[start_idx..limit_idx) // into the global card bitmap. BitMap::idx_t scan_idx = task_card_bm->get_next_one_offset(start_idx, limit_idx); @@ -2967,22 +2967,22 @@ protected: G1CollectedHeap* _g1h; ConcurrentMark* _cm; BitMap* _cm_card_bm; - size_t _max_task_num; + uint _max_worker_id; int _active_workers; public: G1AggregateCountDataTask(G1CollectedHeap* g1h, ConcurrentMark* cm, BitMap* cm_card_bm, - size_t max_task_num, + uint max_worker_id, int n_workers) : AbstractGangTask("Count Aggregation"), _g1h(g1h), _cm(cm), _cm_card_bm(cm_card_bm), - _max_task_num(max_task_num), + _max_worker_id(max_worker_id), _active_workers(n_workers) { } void work(uint worker_id) { - AggregateCountDataHRClosure cl(_g1h, _cm_card_bm, _max_task_num); + AggregateCountDataHRClosure cl(_g1h, _cm_card_bm, _max_worker_id); if (G1CollectedHeap::use_parallel_gc_threads()) { _g1h->heap_region_par_iterate_chunked(&cl, worker_id, @@ -3001,7 +3001,7 @@ void ConcurrentMark::aggregate_count_data() { 1); G1AggregateCountDataTask g1_par_agg_task(_g1h, this, &_card_bm, - _max_task_num, n_workers); + _max_worker_id, n_workers); if (G1CollectedHeap::use_parallel_gc_threads()) { assert(_g1h->check_heap_region_claim_values(HeapRegion::InitialClaimValue), @@ -3030,9 +3030,9 @@ void ConcurrentMark::clear_all_count_data() { _region_bm.clear(); uint max_regions = _g1h->max_regions(); - assert(_max_task_num != 0, "unitialized"); + assert(_max_worker_id > 0, "uninitialized"); - for (int i = 0; (size_t) i < _max_task_num; i += 1) { + for (uint i = 0; i < _max_worker_id; i += 1) { BitMap* task_card_bm = count_card_bitmap_for(i); size_t* marked_bytes_array = count_marked_bytes_array_for(i); @@ -3062,7 +3062,7 @@ void ConcurrentMark::abort() { clear_all_count_data(); // Empty mark stack clear_marking_state(); - for (int i = 0; i < (int)_max_task_num; ++i) { + for (uint i = 0; i < _max_worker_id; ++i) { _tasks[i]->clear_region_fields(); } _has_aborted = true; @@ -3154,8 +3154,8 @@ bool ConcurrentMark::containing_cards_are_marked(void* start, void ConcurrentMark::print_finger() { gclog_or_tty->print_cr("heap ["PTR_FORMAT", "PTR_FORMAT"), global finger = "PTR_FORMAT, _heap_start, _heap_end, _finger); - for (int i = 0; i < (int) _max_task_num; ++i) { - gclog_or_tty->print(" %d: "PTR_FORMAT, i, _tasks[i]->finger()); + for (uint i = 0; i < _max_worker_id; ++i) { + gclog_or_tty->print(" %u: "PTR_FORMAT, i, _tasks[i]->finger()); } gclog_or_tty->print_cr(""); } @@ -3165,8 +3165,8 @@ void CMTask::scan_object(oop obj) { assert(_nextMarkBitMap->isMarked((HeapWord*) obj), "invariant"); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] we're scanning object "PTR_FORMAT, - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] we're scanning object "PTR_FORMAT, + _worker_id, (void*) obj); } size_t obj_size = obj->size(); @@ -3245,8 +3245,8 @@ void CMTask::setup_for_region(HeapRegion* hr) { "claim_region() should have filtered out continues humongous regions"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] setting up for region "PTR_FORMAT, - _task_id, hr); + gclog_or_tty->print_cr("[%u] setting up for region "PTR_FORMAT, + _worker_id, hr); } _curr_region = hr; @@ -3261,9 +3261,9 @@ void CMTask::update_region_limit() { if (limit == bottom) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] found an empty region " + gclog_or_tty->print_cr("[%u] found an empty region " "["PTR_FORMAT", "PTR_FORMAT")", - _task_id, bottom, limit); + _worker_id, bottom, limit); } // The region was collected underneath our feet. // We set the finger to bottom to ensure that the bitmap @@ -3294,8 +3294,8 @@ void CMTask::update_region_limit() { void CMTask::giveup_current_region() { assert(_curr_region != NULL, "invariant"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] giving up region "PTR_FORMAT, - _task_id, _curr_region); + gclog_or_tty->print_cr("[%u] giving up region "PTR_FORMAT, + _worker_id, _curr_region); } clear_region_fields(); } @@ -3321,7 +3321,7 @@ void CMTask::reset(CMBitMap* nextMarkBitMap) { guarantee(nextMarkBitMap != NULL, "invariant"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] resetting", _task_id); + gclog_or_tty->print_cr("[%u] resetting", _worker_id); } _nextMarkBitMap = nextMarkBitMap; @@ -3415,9 +3415,9 @@ void CMTask::regular_clock_call() { _all_clock_intervals_ms.add(last_interval_ms); if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] regular clock, interval = %1.2lfms, " + gclog_or_tty->print_cr("[%u] regular clock, interval = %1.2lfms, " "scanned = %d%s, refs reached = %d%s", - _task_id, last_interval_ms, + _worker_id, last_interval_ms, _words_scanned, (_words_scanned >= _words_scanned_limit) ? " (*)" : "", _refs_reached, @@ -3449,8 +3449,8 @@ void CMTask::regular_clock_call() { SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); if (!_draining_satb_buffers && satb_mq_set.process_completed_buffers()) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] aborting to deal with pending SATB buffers", - _task_id); + gclog_or_tty->print_cr("[%u] aborting to deal with pending SATB buffers", + _worker_id); } // we do need to process SATB buffers, we'll abort and restart // the marking task to do so @@ -3475,7 +3475,7 @@ void CMTask::decrease_limits() { // scanning limit so that the clock is called earlier. if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] decreasing limits", _task_id); + gclog_or_tty->print_cr("[%u] decreasing limits", _worker_id); } _words_scanned_limit = _real_words_scanned_limit - @@ -3503,16 +3503,16 @@ void CMTask::move_entries_to_global_stack() { if (!_cm->mark_stack_push(buffer, n)) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] aborting due to global stack overflow", - _task_id); + gclog_or_tty->print_cr("[%u] aborting due to global stack overflow", + _worker_id); } set_has_aborted(); } else { // the transfer was successful if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] pushed %d entries to the global stack", - _task_id, n); + gclog_or_tty->print_cr("[%u] pushed %d entries to the global stack", + _worker_id, n); } statsOnly( int tmp_size = _cm->mark_stack_size(); if (tmp_size > _global_max_size) { @@ -3539,8 +3539,8 @@ void CMTask::get_entries_from_global_stack() { statsOnly( ++_global_transfers_from; _global_pops += n ); if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] popped %d entries from the global stack", - _task_id, n); + gclog_or_tty->print_cr("[%u] popped %d entries from the global stack", + _worker_id, n); } for (int i = 0; i < n; ++i) { bool success = _task_queue->push(buffer[i]); @@ -3575,8 +3575,8 @@ void CMTask::drain_local_queue(bool partially) { if (_task_queue->size() > target_size) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] draining local queue, target size = %d", - _task_id, target_size); + gclog_or_tty->print_cr("[%u] draining local queue, target size = %d", + _worker_id, target_size); } oop obj; @@ -3585,7 +3585,7 @@ void CMTask::drain_local_queue(bool partially) { statsOnly( ++_local_pops ); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] popped "PTR_FORMAT, _task_id, + gclog_or_tty->print_cr("[%u] popped "PTR_FORMAT, _worker_id, (void*) obj); } @@ -3603,8 +3603,8 @@ void CMTask::drain_local_queue(bool partially) { } if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] drained local queue, size = %d", - _task_id, _task_queue->size()); + gclog_or_tty->print_cr("[%u] drained local queue, size = %d", + _worker_id, _task_queue->size()); } } } @@ -3631,8 +3631,8 @@ void CMTask::drain_global_stack(bool partially) { if (_cm->mark_stack_size() > target_size) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] draining global_stack, target size %d", - _task_id, target_size); + gclog_or_tty->print_cr("[%u] draining global_stack, target size %d", + _worker_id, target_size); } while (!has_aborted() && _cm->mark_stack_size() > target_size) { @@ -3641,8 +3641,8 @@ void CMTask::drain_global_stack(bool partially) { } if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] drained global stack, size = %d", - _task_id, _cm->mark_stack_size()); + gclog_or_tty->print_cr("[%u] drained global stack, size = %d", + _worker_id, _cm->mark_stack_size()); } } } @@ -3663,7 +3663,7 @@ void CMTask::drain_satb_buffers() { CMObjectClosure oc(this); SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.set_par_closure(_task_id, &oc); + satb_mq_set.set_par_closure(_worker_id, &oc); } else { satb_mq_set.set_closure(&oc); } @@ -3672,9 +3672,9 @@ void CMTask::drain_satb_buffers() { // until we run out of buffers or we need to abort. if (G1CollectedHeap::use_parallel_gc_threads()) { while (!has_aborted() && - satb_mq_set.par_apply_closure_to_completed_buffer(_task_id)) { + satb_mq_set.par_apply_closure_to_completed_buffer(_worker_id)) { if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] processed an SATB buffer", _task_id); + gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id); } statsOnly( ++_satb_buffers_processed ); regular_clock_call(); @@ -3683,7 +3683,7 @@ void CMTask::drain_satb_buffers() { while (!has_aborted() && satb_mq_set.apply_closure_to_completed_buffer()) { if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] processed an SATB buffer", _task_id); + gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id); } statsOnly( ++_satb_buffers_processed ); regular_clock_call(); @@ -3693,7 +3693,7 @@ void CMTask::drain_satb_buffers() { if (!concurrent() && !has_aborted()) { // We should only do this during remark. if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.par_iterate_closure_all_threads(_task_id); + satb_mq_set.par_iterate_closure_all_threads(_worker_id); } else { satb_mq_set.iterate_closure_all_threads(); } @@ -3706,7 +3706,7 @@ void CMTask::drain_satb_buffers() { satb_mq_set.completed_buffers_num() == 0, "invariant"); if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.set_par_closure(_task_id, NULL); + satb_mq_set.set_par_closure(_worker_id, NULL); } else { satb_mq_set.set_closure(NULL); } @@ -3717,8 +3717,8 @@ void CMTask::drain_satb_buffers() { } void CMTask::print_stats() { - gclog_or_tty->print_cr("Marking Stats, task = %d, calls = %d", - _task_id, _calls); + gclog_or_tty->print_cr("Marking Stats, task = %u, calls = %d", + _worker_id, _calls); gclog_or_tty->print_cr(" Elapsed time = %1.2lfms, Termination time = %1.2lfms", _elapsed_time_ms, _termination_time_ms); gclog_or_tty->print_cr(" Step Times (cum): num = %d, avg = %1.2lfms, sd = %1.2lfms", @@ -3866,7 +3866,7 @@ void CMTask::do_marking_step(double time_target_ms, G1CollectorPolicy* g1_policy = _g1h->g1_policy(); assert(_task_queues != NULL, "invariant"); assert(_task_queue != NULL, "invariant"); - assert(_task_queues->queue(_task_id) == _task_queue, "invariant"); + assert(_task_queues->queue(_worker_id) == _task_queue, "invariant"); assert(!_claimed, "only one thread should claim this task at any one time"); @@ -3898,9 +3898,9 @@ void CMTask::do_marking_step(double time_target_ms, ++_calls; if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] >>>>>>>>>> START, call = %d, " + gclog_or_tty->print_cr("[%u] >>>>>>>>>> START, call = %d, " "target = %1.2lfms >>>>>>>>>>", - _task_id, _calls, _time_target_ms); + _worker_id, _calls, _time_target_ms); } // Set up the bitmap and oop closures. Anything that uses them is @@ -3948,10 +3948,10 @@ void CMTask::do_marking_step(double time_target_ms, MemRegion mr = MemRegion(_finger, _region_limit); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] we're scanning part " + gclog_or_tty->print_cr("[%u] we're scanning part " "["PTR_FORMAT", "PTR_FORMAT") " "of region "PTR_FORMAT, - _task_id, _finger, _region_limit, _curr_region); + _worker_id, _finger, _region_limit, _curr_region); } // Let's iterate over the bitmap of the part of the @@ -4007,17 +4007,17 @@ void CMTask::do_marking_step(double time_target_ms, assert(_finger == NULL, "invariant"); assert(_region_limit == NULL, "invariant"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] trying to claim a new region", _task_id); + gclog_or_tty->print_cr("[%u] trying to claim a new region", _worker_id); } - HeapRegion* claimed_region = _cm->claim_region(_task_id); + HeapRegion* claimed_region = _cm->claim_region(_worker_id); if (claimed_region != NULL) { // Yes, we managed to claim one statsOnly( ++_regions_claimed ); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] we successfully claimed " + gclog_or_tty->print_cr("[%u] we successfully claimed " "region "PTR_FORMAT, - _task_id, claimed_region); + _worker_id, claimed_region); } setup_for_region(claimed_region); @@ -4044,7 +4044,7 @@ void CMTask::do_marking_step(double time_target_ms, "at this point we should be out of regions"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] all regions claimed", _task_id); + gclog_or_tty->print_cr("[%u] all regions claimed", _worker_id); } // Try to reduce the number of available SATB buffers so that @@ -4068,17 +4068,17 @@ void CMTask::do_marking_step(double time_target_ms, "only way to reach here"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] starting to steal", _task_id); + gclog_or_tty->print_cr("[%u] starting to steal", _worker_id); } while (!has_aborted()) { oop obj; statsOnly( ++_steal_attempts ); - if (_cm->try_stealing(_task_id, &_hash_seed, obj)) { + if (_cm->try_stealing(_worker_id, &_hash_seed, obj)) { if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] stolen "PTR_FORMAT" successfully", - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] stolen "PTR_FORMAT" successfully", + _worker_id, (void*) obj); } statsOnly( ++_steals ); @@ -4116,7 +4116,7 @@ void CMTask::do_marking_step(double time_target_ms, assert(_task_queue->size() == 0, "only way to reach here"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] starting termination protocol", _task_id); + gclog_or_tty->print_cr("[%u] starting termination protocol", _worker_id); } _termination_start_time_ms = os::elapsedVTime() * 1000.0; @@ -4131,7 +4131,7 @@ void CMTask::do_marking_step(double time_target_ms, if (finished) { // We're all done. - if (_task_id == 0) { + if (_worker_id == 0) { // let's allow task 0 to do this if (concurrent()) { assert(_cm->concurrent_marking_in_progress(), "invariant"); @@ -4153,15 +4153,15 @@ void CMTask::do_marking_step(double time_target_ms, guarantee(!_cm->mark_stack_overflow(), "only way to reach here"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] all tasks terminated", _task_id); + gclog_or_tty->print_cr("[%u] all tasks terminated", _worker_id); } } else { // Apparently there's more work to do. Let's abort this task. It // will restart it and we can hopefully find more things to do. if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] apparently there is more work to do", - _task_id); + gclog_or_tty->print_cr("[%u] apparently there is more work to do", + _worker_id); } set_has_aborted(); @@ -4200,10 +4200,10 @@ void CMTask::do_marking_step(double time_target_ms, // will achieve this with the use of two barrier sync points. if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] detected overflow", _task_id); + gclog_or_tty->print_cr("[%u] detected overflow", _worker_id); } - _cm->enter_first_sync_barrier(_task_id); + _cm->enter_first_sync_barrier(_worker_id); // When we exit this sync barrier we know that all tasks have // stopped doing marking work. So, it's now safe to // re-initialise our data structures. At the end of this method, @@ -4215,39 +4215,39 @@ void CMTask::do_marking_step(double time_target_ms, clear_region_fields(); // ...and enter the second barrier. - _cm->enter_second_sync_barrier(_task_id); + _cm->enter_second_sync_barrier(_worker_id); // At this point everything has bee re-initialised and we're // ready to restart. } if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] <<<<<<<<<< ABORTING, target = %1.2lfms, " + gclog_or_tty->print_cr("[%u] <<<<<<<<<< ABORTING, target = %1.2lfms, " "elapsed = %1.2lfms <<<<<<<<<<", - _task_id, _time_target_ms, elapsed_time_ms); + _worker_id, _time_target_ms, elapsed_time_ms); if (_cm->has_aborted()) { - gclog_or_tty->print_cr("[%d] ========== MARKING ABORTED ==========", - _task_id); + gclog_or_tty->print_cr("[%u] ========== MARKING ABORTED ==========", + _worker_id); } } } else { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] <<<<<<<<<< FINISHED, target = %1.2lfms, " + gclog_or_tty->print_cr("[%u] <<<<<<<<<< FINISHED, target = %1.2lfms, " "elapsed = %1.2lfms <<<<<<<<<<", - _task_id, _time_target_ms, elapsed_time_ms); + _worker_id, _time_target_ms, elapsed_time_ms); } } _claimed = false; } -CMTask::CMTask(int task_id, +CMTask::CMTask(uint worker_id, ConcurrentMark* cm, size_t* marked_bytes, BitMap* card_bm, CMTaskQueue* task_queue, CMTaskQueueSet* task_queues) : _g1h(G1CollectedHeap::heap()), - _task_id(task_id), _cm(cm), + _worker_id(worker_id), _cm(cm), _claimed(false), _nextMarkBitMap(NULL), _hash_seed(17), _task_queue(task_queue), diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp index abb46e1065c..5bac7a6b34d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp @@ -399,9 +399,9 @@ protected: // last claimed region // marking tasks - uint _max_task_num; // maximum task number + uint _max_worker_id;// maximum worker id uint _active_tasks; // task num currently active - CMTask** _tasks; // task queue array (max_task_num len) + CMTask** _tasks; // task queue array (max_worker_id len) CMTaskQueueSet* _task_queues; // task queue set ParallelTaskTerminator _terminator; // for termination @@ -492,10 +492,10 @@ protected: ParallelTaskTerminator* terminator() { return &_terminator; } // It claims the next available region to be scanned by a marking - // task. It might return NULL if the next region is empty or we have - // run out of regions. In the latter case, out_of_regions() + // task/thread. It might return NULL if the next region is empty or + // we have run out of regions. In the latter case, out_of_regions() // determines whether we've really run out of regions or the task - // should call claim_region() again. This might seem a bit + // should call claim_region() again. This might seem a bit // awkward. Originally, the code was written so that claim_region() // either successfully returned with a non-empty region or there // were no more regions to be claimed. The problem with this was @@ -505,7 +505,7 @@ protected: // method. So, this way, each task will spend very little time in // claim_region() and is allowed to call the regular clock method // frequently. - HeapRegion* claim_region(int task); + HeapRegion* claim_region(uint worker_id); // It determines whether we've run out of regions to scan. bool out_of_regions() { return _finger == _heap_end; } @@ -537,8 +537,8 @@ protected: bool has_aborted() { return _has_aborted; } // Methods to enter the two overflow sync barriers - void enter_first_sync_barrier(int task_num); - void enter_second_sync_barrier(int task_num); + void enter_first_sync_barrier(uint worker_id); + void enter_second_sync_barrier(uint worker_id); ForceOverflowSettings* force_overflow_conc() { return &_force_overflow_conc; @@ -626,14 +626,14 @@ public: double all_task_accum_vtime() { double ret = 0.0; - for (int i = 0; i < (int)_max_task_num; ++i) + for (uint i = 0; i < _max_worker_id; ++i) ret += _accum_task_vtime[i]; return ret; } // Attempts to steal an object from the task queues of other tasks - bool try_stealing(int task_num, int* hash_seed, oop& obj) { - return _task_queues->steal(task_num, hash_seed, obj); + bool try_stealing(uint worker_id, int* hash_seed, oop& obj) { + return _task_queues->steal(worker_id, hash_seed, obj); } ConcurrentMark(ReservedSpace rs, uint max_regions); @@ -823,7 +823,7 @@ public: // Returns the card bitmap for a given task or worker id. BitMap* count_card_bitmap_for(uint worker_id) { - assert(0 <= worker_id && worker_id < _max_task_num, "oob"); + assert(0 <= worker_id && worker_id < _max_worker_id, "oob"); assert(_count_card_bitmaps != NULL, "uninitialized"); BitMap* task_card_bm = &_count_card_bitmaps[worker_id]; assert(task_card_bm->size() == _card_bm.size(), "size mismatch"); @@ -833,7 +833,7 @@ public: // Returns the array containing the marked bytes for each region, // for the given worker or task id. size_t* count_marked_bytes_array_for(uint worker_id) { - assert(0 <= worker_id && worker_id < _max_task_num, "oob"); + assert(0 <= worker_id && worker_id < _max_worker_id, "oob"); assert(_count_marked_bytes != NULL, "uninitialized"); size_t* marked_bytes_array = _count_marked_bytes[worker_id]; assert(marked_bytes_array != NULL, "uninitialized"); @@ -939,7 +939,7 @@ private: global_stack_transfer_size = 16 }; - int _task_id; + uint _worker_id; G1CollectedHeap* _g1h; ConcurrentMark* _cm; CMBitMap* _nextMarkBitMap; @@ -1115,8 +1115,8 @@ public: _elapsed_time_ms = os::elapsedTime() * 1000.0 - _elapsed_time_ms; } - // returns the task ID - int task_id() { return _task_id; } + // returns the worker ID associated with this task. + uint worker_id() { return _worker_id; } // From TerminatorTerminator. It determines whether this task should // exit the termination protocol after it's entered it. @@ -1170,7 +1170,7 @@ public: _finger = new_finger; } - CMTask(int task_num, ConcurrentMark *cm, + CMTask(uint worker_id, ConcurrentMark *cm, size_t* marked_bytes, BitMap* card_bm, CMTaskQueue* task_queue, CMTaskQueueSet* task_queues); diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp index 7f69234a5b7..f084bca5a77 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp @@ -279,7 +279,7 @@ inline void CMTask::push(oop obj) { assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] pushing "PTR_FORMAT, _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] pushing "PTR_FORMAT, _worker_id, (void*) obj); } if (!_task_queue->push(obj)) { @@ -287,9 +287,9 @@ inline void CMTask::push(oop obj) { // to the global stack. if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] task queue overflow, " + gclog_or_tty->print_cr("[%u] task queue overflow, " "moving entries to the global stack", - _task_id); + _worker_id); } move_entries_to_global_stack(); @@ -318,8 +318,8 @@ inline void CMTask::push(oop obj) { inline void CMTask::deal_with_reference(oop obj) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] we're dealing with reference = "PTR_FORMAT, - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT, + _worker_id, (void*) obj); } ++_refs_reached; @@ -335,8 +335,8 @@ inline void CMTask::deal_with_reference(oop obj) { HeapRegion* hr = _g1h->heap_region_containing_raw(obj); if (!hr->obj_allocated_since_next_marking(obj)) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] "PTR_FORMAT" is not considered marked", - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] "PTR_FORMAT" is not considered marked", + _worker_id, (void*) obj); } // we need to mark it first @@ -350,8 +350,8 @@ inline void CMTask::deal_with_reference(oop obj) { if (_finger != NULL && objAddr < _finger) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] below the local finger ("PTR_FORMAT"), " - "pushing it", _task_id, _finger); + gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), " + "pushing it", _worker_id, _finger); } push(obj); } else if (_curr_region != NULL && objAddr < _region_limit) { @@ -367,9 +367,9 @@ inline void CMTask::deal_with_reference(oop obj) { // correctness problems. if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] below the global finger " + gclog_or_tty->print_cr("[%u] below the global finger " "("PTR_FORMAT"), pushing it", - _task_id, global_finger); + _worker_id, global_finger); } push(obj); } else { @@ -382,9 +382,9 @@ inline void CMTask::deal_with_reference(oop obj) { // see long comment above if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] below the global finger " + gclog_or_tty->print_cr("[%u] below the global finger " "("PTR_FORMAT"), pushing it", - _task_id, global_finger); + _worker_id, global_finger); } push(obj); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp index c84de6e9e68..e26d2a6951d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp @@ -111,9 +111,9 @@ inline void G1CMOopClosure::do_oop_nv(T* p) { oop obj = oopDesc::load_decode_heap_oop(p); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] we're looking at location " + gclog_or_tty->print_cr("[%u] we're looking at location " "*"PTR_FORMAT" = "PTR_FORMAT, - _task->task_id(), p, (void*) obj); + _task->worker_id(), p, (void*) obj); } _task->deal_with_reference(obj); } From 845106af1373d54cd9ad0cac5e1927348267da16 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Mon, 8 Oct 2012 09:12:31 -0700 Subject: [PATCH 25/56] 8000358: G1: metaspace information not printed in PrintHeapAtGC output nor in hs_err file Missing call to MetaspaceAux::print_on() in G1CollectedHeap::print_on(). Reviewed-by: azeemj, jmasa --- hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index f023f932ab8..471e638de19 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3388,6 +3388,7 @@ void G1CollectedHeap::print_on(outputStream* st) const { st->print("%u survivors (" SIZE_FORMAT "K)", survivor_regions, (size_t) survivor_regions * HeapRegion::GrainBytes / K); st->cr(); + MetaspaceAux::print_on(st); } void G1CollectedHeap::print_extended_on(outputStream* st) const { From 63a30e32686c9967154c841eeaaecd5d408b147c Mon Sep 17 00:00:00 2001 From: Leonid Romanov Date: Tue, 9 Oct 2012 18:00:58 +0400 Subject: [PATCH 26/56] 7185280: Jre7cert: focusgained does not get called for all focus req when do alt + tab Reviewed-by: anthony --- .../windows/native/sun/windows/awt_Window.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/jdk/src/windows/native/sun/windows/awt_Window.cpp b/jdk/src/windows/native/sun/windows/awt_Window.cpp index 5c5f53dba40..b4110ece075 100644 --- a/jdk/src/windows/native/sun/windows/awt_Window.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp @@ -1559,21 +1559,8 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite, BOOL AwtWindow::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest) { - // Fix for 6458497. - // Retreat if current foreground window is out of both our and embedder process. - // The exception is when activation is requested due to a mouse event. - if (!isMouseEventCause) { - HWND fgWindow = ::GetForegroundWindow(); - if (NULL != fgWindow) { - DWORD fgProcessID; - ::GetWindowThreadProcessId(fgWindow, &fgProcessID); - if (fgProcessID != ::GetCurrentProcessId() - && !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID)) - { - return FALSE; - } - } - } + // We used to reject non mouse window activation if our app wasn't active. + // This code since has been removed as the fix for 7185280 HWND proxyContainerHWnd = GetProxyToplevelContainer(); HWND proxyHWnd = GetProxyFocusOwner(); From 743e5c0d91b90231822411769c092220205e8e72 Mon Sep 17 00:00:00 2001 From: Leonid Romanov Date: Tue, 9 Oct 2012 20:59:41 +0400 Subject: [PATCH 27/56] 7124321: [macosx] TrayIcon MouseListener is never triggered Reviewed-by: anthony --- .../classes/sun/lwawt/macosx/CTrayIcon.java | 86 ++++++++++++- jdk/src/macosx/native/sun/awt/CTrayIcon.h | 2 + jdk/src/macosx/native/sun/awt/CTrayIcon.m | 118 ++++++++++++++---- 3 files changed, 179 insertions(+), 27 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java index fac844e4229..4a19e5a064d 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java @@ -26,6 +26,7 @@ package sun.lwawt.macosx; import sun.awt.SunToolkit; +import sun.lwawt.macosx.event.NSEvent; import javax.swing.*; import java.awt.*; @@ -42,6 +43,16 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { private JDialog messageDialog; private DialogEventHandler handler; + // In order to construct MouseEvent object, we need to specify a + // Component target. Because TrayIcon isn't Component's subclass, + // we use this dummy frame instead + private final Frame dummyFrame; + + // A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events + // on MOUSE_RELEASE. Click events are only generated if there were no drag + // events between MOUSE_PRESSED and MOUSE_RELEASED for particular button + private static int mouseClickButtons = 0; + CTrayIcon(TrayIcon target) { super(0, true); @@ -49,6 +60,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { this.handler = null; this.target = target; this.popup = target.getPopupMenu(); + this.dummyFrame = new Frame(); setPtr(createModel()); //if no one else is creating the peer. @@ -119,6 +131,8 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { disposeMessageDialog(); } + dummyFrame.dispose(); + LWCToolkit.targetDisposedPeer(target, this); target = null; @@ -161,17 +175,78 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { private native void setNativeImage(final long model, final long nsimage, final boolean autosize); - //invocation from the AWTTrayIcon.m - public void performAction() { + private void postEvent(final AWTEvent event) { SunToolkit.executeOnEventHandlerThread(target, new Runnable() { public void run() { - final String cmd = target.getActionCommand(); - final ActionEvent event = new ActionEvent(target, ActionEvent.ACTION_PERFORMED, cmd); SunToolkit.postEvent(SunToolkit.targetToAppContext(target), event); } }); } + //invocation from the AWTTrayIcon.m + private void handleMouseEvent(NSEvent nsEvent) { + int buttonNumber = nsEvent.getButtonNumber(); + final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); + if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled()) + || buttonNumber > tk.getNumberOfButtons() - 1) { + return; + } + + int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType()); + + int jbuttonNumber = MouseEvent.NOBUTTON; + int jclickCount = 0; + if (jeventType != MouseEvent.MOUSE_MOVED) { + jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber); + jclickCount = nsEvent.getClickCount(); + } + + int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber, + nsEvent.getModifierFlags()); + boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers); + + int eventButtonMask = (jbuttonNumber > 0)? + MouseEvent.getMaskForButton(jbuttonNumber) : 0; + long when = System.currentTimeMillis(); + + if (jeventType == MouseEvent.MOUSE_PRESSED) { + mouseClickButtons |= eventButtonMask; + } else if (jeventType == MouseEvent.MOUSE_DRAGGED) { + mouseClickButtons = 0; + } + + // The MouseEvent's coordinates are relative to screen + int absX = nsEvent.getAbsX(); + int absY = nsEvent.getAbsY(); + + MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when, + jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger, + jbuttonNumber); + mouseEvent.setSource(target); + postEvent(mouseEvent); + + // fire ACTION event + if (jeventType == MouseEvent.MOUSE_PRESSED && isPopupTrigger) { + final String cmd = target.getActionCommand(); + final ActionEvent event = new ActionEvent(target, + ActionEvent.ACTION_PERFORMED, cmd); + postEvent(event); + } + + // synthesize CLICKED event + if (jeventType == MouseEvent.MOUSE_RELEASED) { + if ((mouseClickButtons & eventButtonMask) != 0) { + MouseEvent clickEvent = new MouseEvent(dummyFrame, + MouseEvent.MOUSE_CLICKED, when, jmodifiers, absX, absY, + absX, absY, jclickCount, isPopupTrigger, jbuttonNumber); + clickEvent.setSource(target); + postEvent(clickEvent); + } + + mouseClickButtons &= ~eventButtonMask; + } + } + private native Point2D nativeGetIconLocation(long trayIconModel); public void displayMessageOnEDT(String caption, String text, @@ -256,6 +331,9 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.setModal(false); + dialog.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE); + dialog.setAlwaysOnTop(true); + dialog.setAutoRequestFocus(false); dialog.setResizable(false); dialog.setContentPane(op); diff --git a/jdk/src/macosx/native/sun/awt/CTrayIcon.h b/jdk/src/macosx/native/sun/awt/CTrayIcon.h index c5ceebf3414..9501e7ddde4 100644 --- a/jdk/src/macosx/native/sun/awt/CTrayIcon.h +++ b/jdk/src/macosx/native/sun/awt/CTrayIcon.h @@ -53,6 +53,7 @@ extern "C" { - (jobject) peer; - (void) setImage:(NSImage *) imagePtr sizing:(BOOL)autosize; - (NSPoint) getLocationOnScreen; +- (void) deliverJavaMouseEvent:(NSEvent*) event; @end //AWTTrayIcon @@ -68,6 +69,7 @@ extern "C" { -(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon; -(void)setHighlighted:(BOOL)aFlag; -(void)setImage:(NSImage*)anImage; +-(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon; @end //AWTTrayIconView diff --git a/jdk/src/macosx/native/sun/awt/CTrayIcon.m b/jdk/src/macosx/native/sun/awt/CTrayIcon.m index b9c2942f1b7..a69995f84aa 100644 --- a/jdk/src/macosx/native/sun/awt/CTrayIcon.m +++ b/jdk/src/macosx/native/sun/awt/CTrayIcon.m @@ -29,6 +29,7 @@ #import "CTrayIcon.h" #import "ThreadUtilities.h" #include "GeomUtilities.h" +#import "LWCToolkit.h" #define kImageInset 4.0 @@ -76,8 +77,9 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { // Its a bad idea to force the item to release our view by setting // the item's view to nil: it can lead to a crash in some scenarios. // The item will release the view later on, so just set the view's image - // to nil since we are done with it. + // and tray icon to nil since we are done with it. [view setImage: nil]; + [view setTrayIcon: nil]; [view release]; [theItem release]; @@ -115,6 +117,45 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { return [[view window] convertBaseToScreen: NSZeroPoint]; } +-(void) deliverJavaMouseEvent: (NSEvent *) event { + [AWTToolkit eventCountPlusPlus]; + + JNIEnv *env = [ThreadUtilities getJNIEnv]; + + NSPoint eventLocation = [event locationInWindow]; + NSPoint localPoint = [view convertPoint: eventLocation fromView: nil]; + localPoint.y = [view bounds].size.height - localPoint.y; + + NSPoint absP = [NSEvent mouseLocation]; + NSEventType type = [event type]; + + NSRect screenRect = [[NSScreen mainScreen] frame]; + absP.y = screenRect.size.height - absP.y; + jint clickCount; + + clickCount = [event clickCount]; + + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent"); + static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V"); + jobject jEvent = JNFNewObject(env, jctor_NSEvent, + [event type], + [event modifierFlags], + clickCount, + [event buttonNumber], + (jint)localPoint.x, (jint)localPoint.y, + (jint)absP.x, (jint)absP.y, + [event deltaY], + [event deltaX]); + if (jEvent == nil) { + // Unable to create event by some reason. + return; + } + + static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon"); + static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V"); + JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent); +} + @end //AWTTrayIcon //================================================ @@ -123,7 +164,7 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { -(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon { self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)]; - trayIcon = theTrayIcon; + [self setTrayIcon: theTrayIcon]; isHighlighted = NO; image = nil; @@ -153,6 +194,10 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { } } +-(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon { + trayIcon = theTrayIcon; +} + - (void)menuWillOpen:(NSMenu *)menu { [self setHighlighted:YES]; @@ -191,30 +236,57 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) { ]; } -- (void) mouseDown:(NSEvent *)e { - //find CTrayIcon.getPopupMenuModel method and call it to get popup menu ptr. - JNIEnv *env = [ThreadUtilities getJNIEnv]; - static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon"); - static JNF_MEMBER_CACHE(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J"); - static JNF_MEMBER_CACHE(jm_performAction, jc_CTrayIcon, "performAction", "()V"); - jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel); - if (res != 0) { - CPopupMenu *cmenu = jlong_to_ptr(res); - NSMenu* menu = [cmenu menu]; - [menu setDelegate:self]; - [trayIcon.theItem popUpStatusItemMenu:menu]; - [self setNeedsDisplay:YES]; - } else { - JNFCallVoidMethod(env, trayIcon.peer, jm_performAction); +- (void)mouseDown:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; + + // don't show the menu on ctrl+click: it triggers ACTION event, like right click + if (([event modifierFlags] & NSControlKeyMask) == 0) { + //find CTrayIcon.getPopupMenuModel method and call it to get popup menu ptr. + JNIEnv *env = [ThreadUtilities getJNIEnv]; + static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon"); + static JNF_MEMBER_CACHE(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J"); + jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel); + + if (res != 0) { + CPopupMenu *cmenu = jlong_to_ptr(res); + NSMenu* menu = [cmenu menu]; + [menu setDelegate:self]; + [trayIcon.theItem popUpStatusItemMenu:menu]; + [self setNeedsDisplay:YES]; + } } } -- (void) rightMouseDown:(NSEvent *)e { - // Call CTrayIcon.performAction() method on right mouse press - JNIEnv *env = [ThreadUtilities getJNIEnv]; - static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon"); - static JNF_MEMBER_CACHE(jm_performAction, jc_CTrayIcon, "performAction", "()V"); - JNFCallVoidMethod(env, trayIcon.peer, jm_performAction); +- (void) mouseUp:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) mouseDragged:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) rightMouseDown:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) rightMouseUp:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) rightMouseDragged:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) otherMouseDown:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) otherMouseUp:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; +} + +- (void) otherMouseDragged:(NSEvent *)event { + [trayIcon deliverJavaMouseEvent: event]; } From 724e5ecfb34c6080d9e044111f3b3d2a96b294fd Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 9 Oct 2012 22:12:25 +0200 Subject: [PATCH 28/56] 8000659: NPG: ClassCastExceptions are unexpectedly thrown when testing nashorn Treat the oops in invoke_method_table() as strong roots when ClassUnloading is enabled. Reviewed-by: kamg, coleenp --- hotspot/src/share/vm/classfile/systemDictionary.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 081007c4eb9..5c0d99258b2 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1749,6 +1749,9 @@ void SystemDictionary::always_strong_oops_do(OopClosure* blk) { blk->do_oop(&_system_loader_lock_obj); dictionary()->always_strong_oops_do(blk); + + // Visit extra methods + invoke_method_table()->oops_do(blk); } void SystemDictionary::always_strong_classes_do(KlassClosure* closure) { From 2cae43552d67e11b6488ce5bef54ac3c700e0a65 Mon Sep 17 00:00:00 2001 From: Konstantin Shefov Date: Fri, 12 Oct 2012 18:46:15 +0400 Subject: [PATCH 29/56] 7184326: TEST_BUG: java/awt/Frame/7024749/bug7024749.java has a typo Reviewed-by: anthony --- jdk/test/java/awt/Frame/7024749/bug7024749.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/java/awt/Frame/7024749/bug7024749.java b/jdk/test/java/awt/Frame/7024749/bug7024749.java index 5eb28b6723d..4e7f682aeec 100644 --- a/jdk/test/java/awt/Frame/7024749/bug7024749.java +++ b/jdk/test/java/awt/Frame/7024749/bug7024749.java @@ -25,7 +25,7 @@ * @test * @bug 7024749 * @summary JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75 - * @library ../../../regtesthelpers + * @library ../../regtesthelpers * @build Util * @author Oleg Pekhovskiy: area=awt.toplevel @run main bug7024749 From 515f1281e1ebe385747945d8b26fd5fc83e2bb82 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 12 Oct 2012 14:06:27 -0700 Subject: [PATCH 30/56] 8000834: new hotspot build - hs25-b06 Reviewed-by: jcoomes --- hotspot/make/hotspot_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index ef0a7519680..14577a1280c 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2012 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=05 +HS_BUILD_NUMBER=06 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From 9abdcd4a3ccffcc2e8d86a557a57327a830ffef4 Mon Sep 17 00:00:00 2001 From: John Cuthbertson Date: Mon, 15 Oct 2012 10:02:42 -0700 Subject: [PATCH 31/56] 8000831: Heap verification output incorrect/incomplete Restore non-silent output of heap verification. Reviewed-by: ysr, brutisso, jmasa --- .../concurrentMarkSweepGeneration.cpp | 14 +++++++------- .../concurrentMarkSweep/vmCMSOperations.cpp | 4 ++-- .../vm/gc_implementation/g1/concurrentMark.cpp | 16 ++++++++-------- .../parallelScavenge/psMarkSweep.cpp | 4 ++-- .../parallelScavenge/psParallelCompact.cpp | 4 ++-- .../parallelScavenge/psScavenge.cpp | 4 ++-- hotspot/src/share/vm/memory/genCollectedHeap.cpp | 4 ++-- hotspot/src/share/vm/memory/universe.hpp | 10 ++++++++-- hotspot/src/share/vm/utilities/debug.cpp | 2 +- 9 files changed, 34 insertions(+), 28 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 203821d2fcd..0dcea6313ee 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -2395,7 +2395,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { if (VerifyBeforeGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { - Universe::verify(true); + Universe::verify(); } // Snapshot the soft reference policy to be used in this collection cycle. @@ -2419,7 +2419,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before initial mark: "); - Universe::verify(true); + Universe::verify(); } { bool res = markFromRoots(false); @@ -2431,7 +2431,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before re-mark: "); - Universe::verify(true); + Universe::verify(); } checkpointRootsFinal(false, clear_all_soft_refs, init_mark_was_synchronous); @@ -2443,7 +2443,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before sweep: "); - Universe::verify(true); + Universe::verify(); } sweep(false); assert(_collectorState == Resizing, "Incorrect state"); @@ -2459,7 +2459,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before reset: "); - Universe::verify(true); + Universe::verify(); } reset(false); assert(_collectorState == Idling, "Collector state should " @@ -2486,7 +2486,7 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs) { if (VerifyAfterGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { - Universe::verify(true); + Universe::verify(); } if (TraceCMSState) { gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT @@ -5668,7 +5668,7 @@ void CMSCollector::do_remark_non_parallel() { if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification - Universe::verify(true); + Universe::verify(); } { TraceTime t("root rescan", PrintGCDetails, false, gclog_or_tty); diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp index 3b8d5aa0878..7b5f44a1832 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp @@ -64,7 +64,7 @@ void VM_CMS_Operation::verify_before_gc() { FreelistLocker x(_collector); MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); Universe::heap()->prepare_for_verify(); - Universe::verify(true); + Universe::verify(); } } @@ -74,7 +74,7 @@ void VM_CMS_Operation::verify_after_gc() { HandleMark hm; FreelistLocker x(_collector); MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); - Universe::verify(true); + Universe::verify(); } } diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 2684be80872..d3dc1eb7bb7 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -1120,8 +1120,8 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) { HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(before)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UsePrevMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UsePrevMarking); } G1CollectorPolicy* g1p = g1h->g1_policy(); @@ -1159,8 +1159,8 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) { HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(after)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UseNextMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UseNextMarking); } assert(!restart_for_overflow(), "sanity"); } @@ -1811,8 +1811,8 @@ void ConcurrentMark::cleanup() { HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(before)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UsePrevMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UsePrevMarking); } G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy(); @@ -1966,8 +1966,8 @@ void ConcurrentMark::cleanup() { HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(after)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UsePrevMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UsePrevMarking); } g1h->verify_region_sets_optional(); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp index 44e764f7ae7..a37555d2c3b 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @@ -139,7 +139,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } // Verify object start arrays @@ -341,7 +341,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } // Re-verify object start arrays diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index 7a077621277..fc6d5ef59d3 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -983,7 +983,7 @@ void PSParallelCompact::pre_compact(PreGCValues* pre_gc_values) if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } // Verify object start arrays @@ -2184,7 +2184,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } // Re-verify object start arrays diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index 370311d1c9c..f68b1b5a446 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -315,7 +315,7 @@ bool PSScavenge::invoke_no_policy() { if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } { @@ -639,7 +639,7 @@ bool PSScavenge::invoke_no_policy() { if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } heap->print_heap_after_gc(); diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index 0b6db282497..13778b06d50 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -447,7 +447,7 @@ void GenCollectedHeap::do_collection(bool full, prepared_for_verification = true; } gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } COMPILER2_PRESENT(DerivedPointerTable::clear()); @@ -519,7 +519,7 @@ void GenCollectedHeap::do_collection(bool full, total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } if (PrintGCDetails) { diff --git a/hotspot/src/share/vm/memory/universe.hpp b/hotspot/src/share/vm/memory/universe.hpp index 818f9d3405a..2ef48762466 100644 --- a/hotspot/src/share/vm/memory/universe.hpp +++ b/hotspot/src/share/vm/memory/universe.hpp @@ -403,8 +403,14 @@ class Universe: AllStatic { // Debugging static bool verify_in_progress() { return _verify_in_progress; } - static void verify(bool silent = false, - VerifyOption option = VerifyOption_Default ); + static void verify(bool silent, VerifyOption option); + static void verify(bool silent) { + verify(silent, VerifyOption_Default /* option */); + } + static void verify() { + verify(false /* silent */); + } + static int verify_count() { return _verify_count; } // The default behavior is to call print_on() on gclog_or_tty. static void print(); diff --git a/hotspot/src/share/vm/utilities/debug.cpp b/hotspot/src/share/vm/utilities/debug.cpp index 76164058e01..51d59c44532 100644 --- a/hotspot/src/share/vm/utilities/debug.cpp +++ b/hotspot/src/share/vm/utilities/debug.cpp @@ -477,7 +477,7 @@ extern "C" void verify() { } // Ensure Eden top is correct before verification Universe::heap()->prepare_for_verify(); - Universe::verify(true); + Universe::verify(); if (!safe) SafepointSynchronize::set_is_not_at_safepoint(); } From 1fd51fa05e4009813dbe772b50c7e507ff7caa22 Mon Sep 17 00:00:00 2001 From: Mikhail Cherkasov Date: Tue, 16 Oct 2012 20:11:19 +0400 Subject: [PATCH 32/56] 6818083: When DISPLAY is bad, InternalError thrown, not AWTError Throw AWTError instead of InternalError if the DISPLAY is bad Reviewed-by: anthony, serb --- .../solaris/native/sun/awt/awt_GraphicsEnv.c | 4 +- .../BadDisplayTest/BadDisplayTest.java | 48 +++++++++++++++++++ .../Toolkit/BadDisplayTest/BadDisplayTest.sh | 42 ++++++++++++++++ 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java create mode 100644 jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh diff --git a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c index 2cc122c3476..7ae4cdd3259 100644 --- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c +++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -753,7 +753,7 @@ awt_init_Display(JNIEnv *env, jobject this) sizeof(errmsg), "Can't connect to X11 window server using '%s' as the value of the DISPLAY variable.", (getenv("DISPLAY") == NULL) ? ":0.0" : getenv("DISPLAY")); - JNU_ThrowInternalError(env, errmsg); + JNU_ThrowByName(env, "java/awt/AWTError", errmsg); return NULL; } diff --git a/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java new file mode 100644 index 00000000000..a5bed9c1331 --- /dev/null +++ b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test + * @summary Test that Toolkit.getDefaultToolkit throws AWTError exception if bad DISPLAY variable was set + * @bug 6818083 + * + * @run shell/timeout=240 BadDisplayTest.sh + */ + +import java.awt.*; + +public class BadDisplayTest{ + public static void main(String[] args) { + + Throwable th = null; + try { + Toolkit.getDefaultToolkit(); + } catch (Throwable x) { + th = x; + } + if ( !(th instanceof AWTError)) { + System.exit(1); + } + } +} diff --git a/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh new file mode 100644 index 00000000000..f4a54d300c7 --- /dev/null +++ b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh @@ -0,0 +1,42 @@ +# Copyright (c) 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. +# +# 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. + +${TESTJAVA}/bin/javac -cp ${TESTSRC} -d . ${TESTSRC}/BadDisplayTest.java + + +export DISPLAY= + +OS=`uname -s` +case "$OS" in + SunOS ) + ${TESTJAVA}/bin/java BadDisplayTest + ;; + Linux ) + ${TESTJAVA}/bin/java BadDisplayTest + ;; + * ) + echo "Unsupported System: ${OS}" + exit 0; + ;; +esac + +exit $? + From 336948d5145438df3f96a9bfd61d50d41bf745e2 Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Wed, 17 Oct 2012 14:32:15 +0400 Subject: [PATCH 33/56] 7175704: [macosx] "8" PIT: NPE in GetDisplayMode fullscreen test Reviewed-by: serb, leonidr --- jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java b/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java index 431a1e000d4..6cdebce8f09 100644 --- a/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java +++ b/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java @@ -194,6 +194,9 @@ public class CGraphicsDevice extends GraphicsDevice { @Override public void setDisplayMode(DisplayMode dm) { + if (dm == null) { + throw new IllegalArgumentException("Invalid display mode"); + } nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(), dm.getBitDepth(), dm.getRefreshRate()); if (isFullScreenSupported() && getFullScreenWindow() != null) { getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight()); From 721264460ada4f9e32f01fc3da5ed014bb6a4706 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 17 Oct 2012 17:33:26 +0400 Subject: [PATCH 34/56] 8000969: [macosx] Directories are not deselected when JFileChooser has FILES_ONLY selection mode Reviewed-by: rupashka --- .../classes/com/apple/laf/AquaFileChooserUI.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java index f5dba5bd1c5..b7598f99d6d 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -379,6 +379,19 @@ public class AquaFileChooserUI extends FileChooserUI { } } updateButtonState(getFileChooser()); + } else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) { + JFileChooser fileChooser = getFileChooser(); + if (!fileChooser.isDirectorySelectionEnabled()) { + final File[] files = (File[]) e.getNewValue(); + if (files != null) { + for (int selectedRow : fFileList.getSelectedRows()) { + File file = (File) fFileList.getValueAt(selectedRow, 0); + if (fileChooser.isTraversable(file)) { + fFileList.removeSelectedIndex(selectedRow); + } + } + } + } } else if (prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) { fFileList.clearSelection(); final File currentDirectory = getFileChooser().getCurrentDirectory(); From 45dd15087f81d87670b075d120c7ef99c65b5f31 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 17 Oct 2012 10:16:26 -0400 Subject: [PATCH 35/56] 8000626: Implement dead key detection for KeyEvent on Linux Reviewed-by: kizune --- .../solaris/classes/sun/awt/X11/XKeysym.java | 19 +++++++ .../solaris/classes/sun/awt/X11/XWindow.java | 24 ++++++--- .../solaris/classes/sun/awt/X11/keysym2ucs.h | 54 ++++++++++++------- 3 files changed, 71 insertions(+), 26 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java b/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java index 6ba84a8800e..7d63625d8c6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java @@ -379,6 +379,25 @@ public class XKeysym { keysym2UCSHash.put( (long)0xFFB8, (char)0x0038); // XK_KP_8 --> DIGIT EIGHT keysym2UCSHash.put( (long)0xFFB9, (char)0x0039); // XK_KP_9 --> DIGIT NINE keysym2UCSHash.put( (long)0xFE20, (char)0x0009); // XK_ISO_Left_Tab --> + keysym2UCSHash.put( (long)0xFE50, (char)0x02CB); // XK_dead_grave --> MODIFIER LETTER GRAVE ACCENT + keysym2UCSHash.put( (long)0xFE51, (char)0x02CA); // XK_dead_acute --> MODIFIER LETTER ACUTE ACCENT + keysym2UCSHash.put( (long)0xFE52, (char)0x02C6); // XK_dead_circumflex --> MODIFIER LETTER CIRCUMFLEX ACCENT + keysym2UCSHash.put( (long)0xFE53, (char)0x02DC); // XK_dead_tilde --> SMALL TILDE + keysym2UCSHash.put( (long)0xFE54, (char)0x02C9); // XK_dead_macron --> MODIFIER LETTER MACRON + keysym2UCSHash.put( (long)0xFE55, (char)0x02D8); // XK_dead_breve --> BREVE + keysym2UCSHash.put( (long)0xFE56, (char)0x02D9); // XK_dead_abovedot --> DOT ABOVE + keysym2UCSHash.put( (long)0xFE57, (char)0x00A8); // XK_dead_diaeresis --> DIAERESIS + keysym2UCSHash.put( (long)0xFE58, (char)0x02DA); // XK_dead_abovering --> RING ABOVE + keysym2UCSHash.put( (long)0xFE59, (char)0x02DD); // XK_dead_doubleacute --> DOUBLE ACUTE ACCENT + keysym2UCSHash.put( (long)0xFE5A, (char)0x02C7); // XK_dead_caron --> CARON + keysym2UCSHash.put( (long)0xFE5B, (char)0x00B8); // XK_dead_cedilla --> CEDILLA + keysym2UCSHash.put( (long)0xFE5C, (char)0x02DB); // XK_dead_ogonek --> OGONEK + keysym2UCSHash.put( (long)0xFE5D, (char)0x0269); // XK_dead_iota --> LATIN SMALL LETTER IOTA + keysym2UCSHash.put( (long)0xFE5E, (char)0x3099); // XK_dead_voiced_sound --> COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK + keysym2UCSHash.put( (long)0xFE5F, (char)0x309A); // XK_dead_semivoiced_sound --> COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK + keysym2UCSHash.put( (long)0xFE60, (char)0x0323); // XK_dead_belowdot --> COMBINING DOT BELOW + keysym2UCSHash.put( (long)0xFE61, (char)0x0321); // XK_dead_hook --> COMBINING PALATALIZED HOOK BELOW + keysym2UCSHash.put( (long)0xFE62, (char)0x031B); // XK_dead_horn --> COMBINING HORN keysym2UCSHash.put( (long)0x1a1, (char)0x0104); // XK_Aogonek --> LATIN CAPITAL LETTER A WITH OGONEK keysym2UCSHash.put( (long)0x1a2, (char)0x02d8); // XK_breve --> BREVE keysym2UCSHash.put( (long)0x1a3, (char)0x0141); // XK_Lstroke --> LATIN CAPITAL LETTER L WITH STROKE diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java index a4c039c2074..0eebbd45c9a 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java @@ -1115,7 +1115,10 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { // (1) either XIM could not handle it or // (2) it was Latin 1:1 mapping. // - XKeysym.Keysym2JavaKeycode jkc = XKeysym.getJavaKeycode(ev); + // Preserve modifiers to get Java key code for dead keys + boolean isDeadKey = isDeadKey(keysym[0]); + XKeysym.Keysym2JavaKeycode jkc = isDeadKey ? XKeysym.getJavaKeycode(keysym[0]) + : XKeysym.getJavaKeycode(ev); if( jkc == null ) { jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN); } @@ -1141,7 +1144,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { jkc.getJavaKeycode(); postKeyEvent( java.awt.event.KeyEvent.KEY_PRESSED, ev.get_time(), - jkeyToReturn, + isDeadKey ? jkeyExtended : jkeyToReturn, (unicodeKey == 0 ? java.awt.event.KeyEvent.CHAR_UNDEFINED : unicodeKey), jkc.getKeyLocation(), ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)(ev.get_keycode()), @@ -1149,7 +1152,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { jkeyExtended); - if( unicodeKey > 0 ) { + if (unicodeKey > 0 && !isDeadKey) { keyEventLog.fine("fire _TYPED on "+unicodeKey); postKeyEvent( java.awt.event.KeyEvent.KEY_TYPED, ev.get_time(), @@ -1176,9 +1179,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } // un-private it if you need to call it from elsewhere private void handleKeyRelease(XKeyEvent ev) { - long keysym[] = new long[2]; int unicodeKey = 0; - keysym[0] = XConstants.NoSymbol; if (keyEventLog.isLoggable(PlatformLogger.FINE)) { logIncomingKeyEvent( ev ); @@ -1187,7 +1188,11 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { // and Java KeyEvent keycode should be calculated. // For release we should post released event. // - XKeysym.Keysym2JavaKeycode jkc = XKeysym.getJavaKeycode(ev); + // Preserve modifiers to get Java key code for dead keys + long keysym = xkeycodeToKeysym(ev); + boolean isDeadKey = isDeadKey(keysym); + XKeysym.Keysym2JavaKeycode jkc = isDeadKey ? XKeysym.getJavaKeycode(keysym) + : XKeysym.getJavaKeycode(ev); if( jkc == null ) { jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN); } @@ -1219,7 +1224,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { jkc.getJavaKeycode(); postKeyEvent( java.awt.event.KeyEvent.KEY_RELEASED, ev.get_time(), - jkeyToReturn, + isDeadKey ? jkeyExtended : jkeyToReturn, (unicodeKey == 0 ? java.awt.event.KeyEvent.CHAR_UNDEFINED : unicodeKey), jkc.getKeyLocation(), ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)(ev.get_keycode()), @@ -1229,6 +1234,11 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer { } + + private boolean isDeadKey(long keysym){ + return XKeySymConstants.XK_dead_grave <= keysym && keysym <= XKeySymConstants.XK_dead_semivoiced_sound; + } + /* * XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are * unreliable, since mapping changes can happen for a virtual desktop diff --git a/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h b/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h index deb7a8d0864..f8168876f72 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h +++ b/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h @@ -695,25 +695,25 @@ SOFTWARE. 0x0000 #define XK_ISO_Center_Object 0xFE33 0x0000 #define XK_ISO_Enter 0xFE34 -0x0000 #define XK_dead_grave 0xFE50 -0x0000 #define XK_dead_acute 0xFE51 -0x0000 #define XK_dead_circumflex 0xFE52 -0x0000 #define XK_dead_tilde 0xFE53 -0x0000 #define XK_dead_macron 0xFE54 -0x0000 #define XK_dead_breve 0xFE55 -0x0000 #define XK_dead_abovedot 0xFE56 -0x0000 #define XK_dead_diaeresis 0xFE57 -0x0000 #define XK_dead_abovering 0xFE58 -0x0000 #define XK_dead_doubleacute 0xFE59 -0x0000 #define XK_dead_caron 0xFE5A -0x0000 #define XK_dead_cedilla 0xFE5B -0x0000 #define XK_dead_ogonek 0xFE5C -0x0000 #define XK_dead_iota 0xFE5D -0x0000 #define XK_dead_voiced_sound 0xFE5E -0x0000 #define XK_dead_semivoiced_sound 0xFE5F -0x0000 #define XK_dead_belowdot 0xFE60 -0x0000 #define XK_dead_hook 0xFE61 -0x0000 #define XK_dead_horn 0xFE62 +0x02CB #define XK_dead_grave 0xFE50 +0x02CA #define XK_dead_acute 0xFE51 +0x02C6 #define XK_dead_circumflex 0xFE52 +0x02DC #define XK_dead_tilde 0xFE53 +0x02C9 #define XK_dead_macron 0xFE54 +0x02D8 #define XK_dead_breve 0xFE55 +0x02D9 #define XK_dead_abovedot 0xFE56 +0x00A8 #define XK_dead_diaeresis 0xFE57 +0x02DA #define XK_dead_abovering 0xFE58 +0x02DD #define XK_dead_doubleacute 0xFE59 +0x02C7 #define XK_dead_caron 0xFE5A +0x00B8 #define XK_dead_cedilla 0xFE5B +0x02DB #define XK_dead_ogonek 0xFE5C +0x0269 #define XK_dead_iota 0xFE5D +0x3099 #define XK_dead_voiced_sound 0xFE5E +0x309A #define XK_dead_semivoiced_sound 0xFE5F +0x0323 #define XK_dead_belowdot 0xFE60 +0x0321 #define XK_dead_hook 0xFE61 +0x031B #define XK_dead_horn 0xFE62 0x0000 #define XK_First_Virtual_Screen 0xFED0 0x0000 #define XK_Prev_Virtual_Screen 0xFED1 @@ -2466,6 +2466,7 @@ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Alt_ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Meta_L), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_META, java.awt.event.KeyEvent.KEY_LOCATION_LEFT)); tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Meta_R), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_META, java.awt.event.KeyEvent.KEY_LOCATION_RIGHT)); tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Caps_Lock), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_CAPS_LOCK, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Shift_Lock), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_CAPS_LOCK, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); tojava tojava /* Misc Functions */ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Print), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_PRINTSCREEN, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); @@ -2640,6 +2641,21 @@ tojava /* Type 5c Japanese keyboard: henkan */ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Kanji), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_CONVERT, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); tojava /* Type 5c Japanese keyboard: nihongo */ tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Henkan_Mode), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF, java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Eisu_Shift ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_ALPHANUMERIC , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Eisu_toggle ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_ALPHANUMERIC , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Zenkaku ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_FULL_WIDTH , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Hankaku ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_HALF_WIDTH , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Hiragana ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_HIRAGANA , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Katakana ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_KATAKANA , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Romaji ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_JAPANESE_ROMAN , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Kana_Shift ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_KANA , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Kana_Lock ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_KANA_LOCK , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Muhenkan ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_NONCONVERT , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Zen_Koho ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_ALL_CANDIDATES , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Kanji_Bangou ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_CODE_INPUT , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava keysym2JavaKeycodeHash.put( Long.valueOf(XKeySymConstants.XK_Mae_Koho ), new Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_PREVIOUS_CANDIDATE , java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)); +tojava +tojava tojava /* VK_KANA_LOCK is handled separately because it generates the tojava * same keysym as ALT_GRAPH in spite of its different behavior. tojava */ From 953bec36abbe6a1cf4f291a5f41a03e77a9f13f6 Mon Sep 17 00:00:00 2001 From: Nils Loodin Date: Wed, 17 Oct 2012 17:36:48 +0200 Subject: [PATCH 36/56] 8000617: It should be possible to allocate memory without the VM dying Reviewed-by: coleenp, kamg --- hotspot/src/share/vm/memory/allocation.cpp | 39 ++++++++++++++--- hotspot/src/share/vm/memory/allocation.hpp | 42 ++++++++++++++----- .../src/share/vm/memory/allocation.inline.hpp | 16 ++++--- hotspot/src/share/vm/memory/resourceArea.cpp | 12 +++--- hotspot/src/share/vm/memory/resourceArea.hpp | 4 +- hotspot/src/share/vm/runtime/thread.cpp | 5 ++- hotspot/src/share/vm/runtime/thread.hpp | 2 +- 7 files changed, 87 insertions(+), 33 deletions(-) diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index b5067c2f6ea..56c7b63fbe5 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -92,6 +92,26 @@ void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flag return res; } +void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags) { + //should only call this with std::nothrow, use other operator new() otherwise + address res; + switch (type) { + case C_HEAP: + res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL); + DEBUG_ONLY(if (res!= NULL) set_allocation_type(res, C_HEAP);) + break; + case RESOURCE_AREA: + // new(size) sets allocation type RESOURCE_AREA. + res = (address)operator new(size, std::nothrow); + break; + default: + ShouldNotReachHere(); + } + return res; +} + + void ResourceObj::operator delete(void* p) { assert(((ResourceObj *)p)->allocated_on_C_heap(), "delete only allowed for C_HEAP objects"); @@ -506,7 +526,7 @@ void Arena::signal_out_of_memory(size_t sz, const char* whence) const { } // Grow a new Chunk -void* Arena::grow( size_t x ) { +void* Arena::grow(size_t x, AllocFailType alloc_failmode) { // Get minimal required size. Either real big, or even bigger for giant objs size_t len = MAX2(x, (size_t) Chunk::size); @@ -514,7 +534,10 @@ void* Arena::grow( size_t x ) { _chunk = new (len) Chunk(len); if (_chunk == NULL) { - signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow"); + if (alloc_failmode == AllocFailStrategy::EXIT_OOM) { + signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow"); + } + return NULL; } if (k) k->set_next(_chunk); // Append new chunk to end of linked list else _first = _chunk; @@ -529,13 +552,16 @@ void* Arena::grow( size_t x ) { // Reallocate storage in Arena. -void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size) { +void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) { assert(new_size >= 0, "bad size"); if (new_size == 0) return NULL; #ifdef ASSERT if (UseMallocOnly) { // always allocate a new object (otherwise we'll free this one twice) - char* copy = (char*)Amalloc(new_size); + char* copy = (char*)Amalloc(new_size, alloc_failmode); + if (copy == NULL) { + return NULL; + } size_t n = MIN2(old_size, new_size); if (n > 0) memcpy(copy, old_ptr, n); Afree(old_ptr,old_size); // Mostly done to keep stats accurate @@ -561,7 +587,10 @@ void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size) { } // Oops, got to relocate guts - void *new_ptr = Amalloc(new_size); + void *new_ptr = Amalloc(new_size, alloc_failmode); + if (new_ptr == NULL) { + return NULL; + } memcpy( new_ptr, c_old, old_size ); Afree(c_old,old_size); // Mostly done to keep stats accurate return new_ptr; diff --git a/hotspot/src/share/vm/memory/allocation.hpp b/hotspot/src/share/vm/memory/allocation.hpp index 6bae79f8133..30662b8e5da 100644 --- a/hotspot/src/share/vm/memory/allocation.hpp +++ b/hotspot/src/share/vm/memory/allocation.hpp @@ -53,6 +53,12 @@ #endif #endif +class AllocFailStrategy { +public: + enum AllocFailEnum { EXIT_OOM, RETURN_NULL }; +}; +typedef AllocFailStrategy::AllocFailEnum AllocFailType; + // All classes in the virtual machine must be subclassed // by one of the following allocation classes: // @@ -315,7 +321,8 @@ protected: Chunk *_first; // First chunk Chunk *_chunk; // current chunk char *_hwm, *_max; // High water mark and max in current chunk - void* grow(size_t x); // Get a new Chunk of at least size x + // Get a new Chunk of at least size x + void* grow(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); size_t _size_in_bytes; // Size of arena (used for native memory tracking) NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start @@ -350,14 +357,14 @@ protected: void operator delete(void* p); // Fast allocate in the arena. Common case is: pointer test + increment. - void* Amalloc(size_t x) { + void* Amalloc(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2"); x = ARENA_ALIGN(x); debug_only(if (UseMallocOnly) return malloc(x);) check_for_overflow(x, "Arena::Amalloc"); NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { - return grow(x); + return grow(x, alloc_failmode); } else { char *old = _hwm; _hwm += x; @@ -365,13 +372,13 @@ protected: } } // Further assume size is padded out to words - void *Amalloc_4(size_t x) { + void *Amalloc_4(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); debug_only(if (UseMallocOnly) return malloc(x);) check_for_overflow(x, "Arena::Amalloc_4"); NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { - return grow(x); + return grow(x, alloc_failmode); } else { char *old = _hwm; _hwm += x; @@ -381,7 +388,7 @@ protected: // Allocate with 'double' alignment. It is 8 bytes on sparc. // In other cases Amalloc_D() should be the same as Amalloc_4(). - void* Amalloc_D(size_t x) { + void* Amalloc_D(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); debug_only(if (UseMallocOnly) return malloc(x);) #if defined(SPARC) && !defined(_LP64) @@ -392,7 +399,7 @@ protected: check_for_overflow(x, "Arena::Amalloc_D"); NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { - return grow(x); // grow() returns a result aligned >= 8 bytes. + return grow(x, alloc_failmode); // grow() returns a result aligned >= 8 bytes. } else { char *old = _hwm; _hwm += x; @@ -412,7 +419,8 @@ protected: if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr; } - void *Arealloc( void *old_ptr, size_t old_size, size_t new_size ); + void *Arealloc( void *old_ptr, size_t old_size, size_t new_size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); // Move contents of this arena into an empty arena Arena *move_contents(Arena *empty_arena); @@ -458,9 +466,12 @@ private: //%note allocation_1 -extern char* resource_allocate_bytes(size_t size); -extern char* resource_allocate_bytes(Thread* thread, size_t size); -extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size); +extern char* resource_allocate_bytes(size_t size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +extern char* resource_allocate_bytes(Thread* thread, size_t size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); extern void resource_free_bytes( char *old, size_t size ); //---------------------------------------------------------------------- @@ -496,6 +507,8 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { public: void* operator new(size_t size, allocation_type type, MEMFLAGS flags); + void* operator new(size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags); void* operator new(size_t size, Arena *arena) { address res = (address)arena->Amalloc(size); DEBUG_ONLY(set_allocation_type(res, ARENA);) @@ -506,6 +519,13 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) return res; } + + void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { + address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL); + DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);) + return res; + } + void operator delete(void* p); }; diff --git a/hotspot/src/share/vm/memory/allocation.inline.hpp b/hotspot/src/share/vm/memory/allocation.inline.hpp index 804faa2a17a..ead6fb12b21 100644 --- a/hotspot/src/share/vm/memory/allocation.inline.hpp +++ b/hotspot/src/share/vm/memory/allocation.inline.hpp @@ -48,7 +48,8 @@ inline void inc_stat_counter(volatile julong* dest, julong add_value) { #endif // allocate using malloc; will fail if no memory available -inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0) { +inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { if (pc == 0) { pc = CURRENT_PC; } @@ -56,16 +57,17 @@ inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0) { #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p); #endif - if (p == NULL) vm_exit_out_of_memory(size, "AllocateHeap"); + if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "AllocateHeap"); return p; } -inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags) { +inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { char* p = (char*) os::realloc(old, size, flags, CURRENT_PC); #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p); #endif - if (p == NULL) vm_exit_out_of_memory(size, "ReallocateHeap"); + if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "ReallocateHeap"); return p; } @@ -91,11 +93,13 @@ template void* CHeapObj::operator new(size_t size, template void* CHeapObj::operator new (size_t size, const std::nothrow_t& nothrow_constant, address caller_pc) { #ifdef ASSERT - void* p = os::malloc(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); + void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), + AllocFailStrategy::RETURN_NULL); if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); return p; #else - return os::malloc(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); + return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), + AllocFailStrategy::RETURN_NULL); #endif } diff --git a/hotspot/src/share/vm/memory/resourceArea.cpp b/hotspot/src/share/vm/memory/resourceArea.cpp index 28d5943b592..12a56d0f4be 100644 --- a/hotspot/src/share/vm/memory/resourceArea.cpp +++ b/hotspot/src/share/vm/memory/resourceArea.cpp @@ -45,15 +45,15 @@ debug_only(int ResourceArea::_warned;) // to suppress multiple warnings // The following routines are declared in allocation.hpp and used everywhere: // Allocation in thread-local resource area -extern char* resource_allocate_bytes(size_t size) { - return Thread::current()->resource_area()->allocate_bytes(size); +extern char* resource_allocate_bytes(size_t size, AllocFailType alloc_failmode) { + return Thread::current()->resource_area()->allocate_bytes(size, alloc_failmode); } -extern char* resource_allocate_bytes(Thread* thread, size_t size) { - return thread->resource_area()->allocate_bytes(size); +extern char* resource_allocate_bytes(Thread* thread, size_t size, AllocFailType alloc_failmode) { + return thread->resource_area()->allocate_bytes(size, alloc_failmode); } -extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size){ - return (char*)Thread::current()->resource_area()->Arealloc(old, old_size, new_size); +extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size, AllocFailType alloc_failmode){ + return (char*)Thread::current()->resource_area()->Arealloc(old, old_size, new_size, alloc_failmode); } extern void resource_free_bytes( char *old, size_t size ) { diff --git a/hotspot/src/share/vm/memory/resourceArea.hpp b/hotspot/src/share/vm/memory/resourceArea.hpp index 567f41d400a..f42c0f62457 100644 --- a/hotspot/src/share/vm/memory/resourceArea.hpp +++ b/hotspot/src/share/vm/memory/resourceArea.hpp @@ -68,7 +68,7 @@ public: debug_only(_nesting = 0;); } - char* allocate_bytes(size_t size) { + char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { #ifdef ASSERT if (_nesting < 1 && !_warned++) fatal("memory leak: allocating without ResourceMark"); @@ -78,7 +78,7 @@ public: return (*save = (char*)os::malloc(size, mtThread)); } #endif - return (char*)Amalloc(size); + return (char*)Amalloc(size, alloc_failmode); } debug_only(int nesting() const { return _nesting; }); diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 6c46e129835..0ed9a4b1fee 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -177,7 +177,8 @@ void* Thread::allocate(size_t size, bool throw_excpt, MEMFLAGS flags) { const int alignment = markOopDesc::biased_lock_alignment; size_t aligned_size = size + (alignment - sizeof(intptr_t)); void* real_malloc_addr = throw_excpt? AllocateHeap(aligned_size, flags, CURRENT_PC) - : os::malloc(aligned_size, flags, CURRENT_PC); + : AllocateHeap(aligned_size, flags, CURRENT_PC, + AllocFailStrategy::RETURN_NULL); void* aligned_addr = (void*) align_size_up((intptr_t) real_malloc_addr, alignment); assert(((uintptr_t) aligned_addr + (uintptr_t) size) <= ((uintptr_t) real_malloc_addr + (uintptr_t) aligned_size), @@ -191,7 +192,7 @@ void* Thread::allocate(size_t size, bool throw_excpt, MEMFLAGS flags) { return aligned_addr; } else { return throw_excpt? AllocateHeap(size, flags, CURRENT_PC) - : os::malloc(size, flags, CURRENT_PC); + : AllocateHeap(size, flags, CURRENT_PC, AllocFailStrategy::RETURN_NULL); } } diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index ec2f7852fe0..ed747fb6cdd 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -110,7 +110,7 @@ class Thread: public ThreadShadow { void* _real_malloc_address; public: void* operator new(size_t size) { return allocate(size, true); } - void* operator new(size_t size, std::nothrow_t& nothrow_constant) { return allocate(size, false); } + void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { return allocate(size, false); } void operator delete(void* p); protected: From 80d1115eb73f08de58e3c7778d98831db43e62e3 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 18 Oct 2012 17:50:43 +0400 Subject: [PATCH 37/56] 7199708: FileChooser crashs when opening large folder Reviewed-by: bagiras --- .../classes/sun/awt/shell/Win32ShellFolder2.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java index 06331ba973b..c6cde3c73f4 100644 --- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -1099,7 +1099,7 @@ final class Win32ShellFolder2 extends ShellFolder { ? SwingConstants.CENTER : SwingConstants.LEADING); - column.setComparator(new ColumnComparator(getIShellFolder(), i)); + column.setComparator(new ColumnComparator(Win32ShellFolder2.this, i)); notNullColumns.add(column); } @@ -1135,7 +1135,7 @@ final class Win32ShellFolder2 extends ShellFolder { // synchronize the whole code of the sort method once invoke(new Callable() { public Void call() { - Collections.sort(files, new ColumnComparator(getIShellFolder(), 0)); + Collections.sort(files, new ColumnComparator(Win32ShellFolder2.this, 0)); return null; } @@ -1143,12 +1143,12 @@ final class Win32ShellFolder2 extends ShellFolder { } private static class ColumnComparator implements Comparator { - private final long parentIShellFolder; + private final Win32ShellFolder2 shellFolder; private final int columnIdx; - public ColumnComparator(long parentIShellFolder, int columnIdx) { - this.parentIShellFolder = parentIShellFolder; + public ColumnComparator(Win32ShellFolder2 shellFolder, int columnIdx) { + this.shellFolder = shellFolder; this.columnIdx = columnIdx; } @@ -1159,7 +1159,7 @@ final class Win32ShellFolder2 extends ShellFolder { if (o instanceof Win32ShellFolder2 && o1 instanceof Win32ShellFolder2) { // delegates comparison to native method - return compareIDsByColumn(parentIShellFolder, + return compareIDsByColumn(shellFolder.getIShellFolder(), ((Win32ShellFolder2) o).getRelativePIDL(), ((Win32ShellFolder2) o1).getRelativePIDL(), columnIdx); From 9a39ec25ca05dd62aebbeaa09e9a676e39b418fc Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 18 Oct 2012 18:28:42 +0400 Subject: [PATCH 38/56] 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again Reviewed-by: serb, anthony --- .../sun/lwawt/macosx/CPlatformWindow.java | 4 ++-- jdk/src/macosx/native/sun/awt/AWTWindow.m | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 15502d1f8d7..6146ca25576 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -65,7 +65,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo private static native void nativeDispose(long nsWindowPtr); private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse(); - private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr); + private static native int nativeGetNSWindowDisplayID(long nsWindowPtr); // Loger to report issues happened during execution but that do not affect functionality private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow"); @@ -444,7 +444,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo public GraphicsDevice getGraphicsDevice() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); CGraphicsEnvironment cge = (CGraphicsEnvironment)ge; - int displayID = nativeGetNSWindowDisplayID_AppKitThread(getNSWindowPtr()); + int displayID = nativeGetNSWindowDisplayID(getNSWindowPtr()); GraphicsDevice gd = cge.getScreenDevice(displayID); if (gd == null) { // this could possibly happen during device removal diff --git a/jdk/src/macosx/native/sun/awt/AWTWindow.m b/jdk/src/macosx/native/sun/awt/AWTWindow.m index 2e2b854f35b..f2958e38894 100644 --- a/jdk/src/macosx/native/sun/awt/AWTWindow.m +++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m @@ -324,6 +324,13 @@ AWT_ASSERT_APPKIT_THREAD; } } ++ (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window { + AWT_ASSERT_APPKIT_THREAD; + NSScreen *screen = [window screen]; + NSDictionary *deviceDescription = [screen deviceDescription]; + return [deviceDescription objectForKey:@"NSScreenNumber"]; +} + - (void) dealloc { AWT_ASSERT_APPKIT_THREAD; @@ -1113,19 +1120,22 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID_1AppKitThread +Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID (JNIEnv *env, jclass clazz, jlong windowPtr) { - jint ret; // CGDirectDisplayID + __block jint ret; // CGDirectDisplayID JNF_COCOA_ENTER(env); -AWT_ASSERT_APPKIT_THREAD; NSWindow *window = OBJC(windowPtr); - NSScreen *screen = [window screen]; - NSDictionary *deviceDescription = [screen deviceDescription]; - NSNumber *displayID = [deviceDescription objectForKey:@"NSScreenNumber"]; - ret = (jint)[displayID intValue]; + + if ([NSThread isMainThread]) { + ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue]; + } else { + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue]; + }]; + } JNF_COCOA_EXIT(env); From f88b8fb20f8e79da06467ac3435cbafa49b5ebff Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:07:40 -0700 Subject: [PATCH 39/56] Added tag jdk8-b61 for changeset 0623a2cf29df --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index dba7899a1e6..7e43143f19e 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -182,3 +182,4 @@ b85b44cced2406792cfb9baab1377ff03e7001d8 jdk8-b55 9367024804874faf8e958adeb333682bab1c0c47 jdk8-b58 dae9821589ccd2611bdf7084269b98e819091770 jdk8-b59 e07f499b9dccb529ecf74172cf6ac11a195ec57a jdk8-b60 +20ff117b509075c3aec4ee3a57990ecd5db5df9c jdk8-b61 From c7df814ec7b99cad14d9b5fcb34742dfbb83cf72 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:07:46 -0700 Subject: [PATCH 40/56] Added tag jdk8-b61 for changeset e4251351a6dd --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 8f91b19e721..68fb9749256 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -182,3 +182,4 @@ f3ab4163ae012965fc8acdfc25ce0fece8d6906d jdk8-b57 18462a19f7bd66d38015f61ea549a5e0c0c889a3 jdk8-b58 d54dc53e223ed9ce7d5f4d2cd02ad9d5def3c2db jdk8-b59 207ef43ba69ead6cbbab415d81834545e4d46747 jdk8-b60 +0e08ba7648fb3faa0986cb217887d7c4990977f3 jdk8-b61 From 3e188b477513166619ca588dfdbcc06146d1d824 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:08:05 -0700 Subject: [PATCH 41/56] Added tag jdk8-b61 for changeset 929432f0c3b6 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 4f1b3692f38..29c43257ae4 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -285,3 +285,4 @@ f2e12eb74117c917c0bb264694c02de4a6a15a10 hs25-b03 1cc7a2a11d00832e3d07f81f3744a6883422db7e hs25-b04 3cfd05b2219a29649741a52637696f06acf24a4e jdk8-b60 b261523fe66c40a02968f0aa7e73602491bb3386 hs25-b05 +4547dc71db765276e027b0c2780b724bae0a07d3 jdk8-b61 From 0f95eb5efc3430dc639b82e359cdb6af8d95c132 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:08:30 -0700 Subject: [PATCH 42/56] Added tag jdk8-b61 for changeset 877dd5308e32 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index c07ba52711e..5c329132e45 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -182,3 +182,4 @@ f19d63b2119a0092f016203981ffef5cc31bc3c5 jdk8-b56 1cb19abb3f7b40bf233b349cd2f51f02d37a9f5b jdk8-b58 af9e8b0f1900b631a8a0fcccff9f1514fe58c808 jdk8-b59 2d1dff5310daaf226421a8c92823cb8afcf35f31 jdk8-b60 +6b1db0b41d2f6e2a7b3bdbc8a8db823b47752906 jdk8-b61 From 4dae92ce29c55a688664d8df5aff10e05a3b3096 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:08:36 -0700 Subject: [PATCH 43/56] Added tag jdk8-b61 for changeset 3d833bc526da --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index f0a4da5c4ba..7d6a6df637a 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -182,3 +182,4 @@ b51b611209f159f94dd2ce3dc2c56daa6d6ac1df jdk8-b57 cac4c393706343df778a13dc6c84cad0f8c237c9 jdk8-b58 ae107401be116f9e384d3a23192f543828e03da5 jdk8-b59 5c5a65ad5291b7cefcdc308f627cf2b195cf2b69 jdk8-b60 +97e5e74e2a341d9142ce28043912a3c255e28e03 jdk8-b61 From d9aab5025ed57d0f721e19731f4482a81338586d Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:09:00 -0700 Subject: [PATCH 44/56] Added tag jdk8-b61 for changeset 1a8b3b760f60 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 804a1e63a0c..c0a4c320b0f 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -182,3 +182,4 @@ e8569a473cee7f4955bd9e76a9bdf6c6a07ced27 jdk8-b52 d94613ac03d8de375ef60493e2bb76dbd30d875d jdk8-b58 abad1f417bd3df4296631fc943cd3b7f5062c88a jdk8-b59 cec8fa02f15634acd7d02d04b0b2d8c044cdbaaa jdk8-b60 +61ddb3fd000a09ab05bff1940b0ac211661e94cf jdk8-b61 From 8bb18682d47b6001c9a54298946148e44a6772d6 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 18 Oct 2012 11:09:45 -0700 Subject: [PATCH 45/56] Added tag jdk8-b61 for changeset 539f9d08a9e5 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index a4299977f60..080bdc4ab61 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -182,3 +182,4 @@ e48e7e1f026b82d921433150180799898c088890 jdk8-b55 804a3fbc86e28a4d9e77c30aa0bd4aa68056f23f jdk8-b58 f299927fc31689385f67ab7322c18eb41d8bd71e jdk8-b59 3d2b98ffcb534b0e5be87bb1f9f68d1518ad7729 jdk8-b60 +26020b247ad3806dbca33e029ee12e1b191f59f9 jdk8-b61 From b61d0d9772bd778c4ccd1ad7827cb4561a95b45c Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 19 Oct 2012 15:23:14 +0400 Subject: [PATCH 46/56] 7124520: [macosx] re:6373505 Toolkit.getScreenResolution() != GraphicsConfiguration.getNormalizingTransform() Reviewed-by: anthony, kizune --- .../classes/sun/awt/CGraphicsDevice.java | 9 +-- .../classes/sun/lwawt/macosx/LWCToolkit.java | 8 +-- .../NormalizingTransformTest.java | 55 +++++++++++++++++++ 3 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 jdk/test/java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java diff --git a/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java b/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java index 6cdebce8f09..2b884538839 100644 --- a/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java +++ b/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java @@ -33,9 +33,7 @@ import java.awt.DisplayMode; import sun.java2d.opengl.CGLGraphicsConfig; -import sun.awt.FullScreenCapable; - -public class CGraphicsDevice extends GraphicsDevice { +public final class CGraphicsDevice extends GraphicsDevice { // CoreGraphics display ID private final int displayID; @@ -108,11 +106,6 @@ public class CGraphicsDevice extends GraphicsDevice { return nativeGetYResolution(displayID); } - public int getScreenResolution() { - // TODO: report non-72 value when HiDPI is turned on - return 72; - } - private static native double nativeGetXResolution(int displayID); private static native double nativeGetYResolution(int displayID); diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 23df4fbf9eb..32a980898c0 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -53,7 +53,7 @@ class NamedCursor extends Cursor { /** * Mac OS X Cocoa-based AWT Toolkit. */ -public class LWCToolkit extends LWToolkit { +public final class LWCToolkit extends LWToolkit { // While it is possible to enumerate all mouse devices // and query them for the number of buttons, the code // that does it is rather complex. Instead, we opt for @@ -278,7 +278,6 @@ public class LWCToolkit extends LWToolkit { return new CMouseInfoPeer(); } - @Override protected int getScreenHeight() { return GraphicsEnvironment.getLocalGraphicsEnvironment() @@ -333,8 +332,9 @@ public class LWCToolkit extends LWToolkit { @Override public int getScreenResolution() throws HeadlessException { - return ((CGraphicsDevice) GraphicsEnvironment - .getLocalGraphicsEnvironment().getDefaultScreenDevice()).getScreenResolution(); + return (int) ((CGraphicsDevice) GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice()) + .getXResolution(); } @Override diff --git a/jdk/test/java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java b/jdk/test/java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java new file mode 100644 index 00000000000..0e5e46b789b --- /dev/null +++ b/jdk/test/java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 6373505 + * @summary Tests that the result of Toolkit.getScreenResolution() is + * consistent with GraphicsConfiguration.getNormalizingTransform(). + * @author Dmitri.Trembovetski@Sun.COM: area=GraphicsConfiguration + * @run main NormalizingTransformTest + */ + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Toolkit; +import java.awt.geom.AffineTransform; + +public class NormalizingTransformTest { + + public static void main(String[] args) { + GraphicsConfiguration gc = + GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(); + AffineTransform normTransform = gc.getNormalizingTransform(); + int dpiX = Toolkit.getDefaultToolkit().getScreenResolution(); + int normDpiX = (int)(normTransform.getScaleX() * 72.0); + if (dpiX != normDpiX) { + throw new RuntimeException( + "Test FAILED. Toolkit.getScreenResolution()=" + dpiX + + " GraphicsConfiguration.getNormalizingTransform()="+normDpiX); + } + System.out.println("Test PASSED. DPI="+normDpiX); + } + +} From 65c322fa7075d4df64940de1beff43f5f5781fb6 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Fri, 19 Oct 2012 11:03:04 -0700 Subject: [PATCH 47/56] Added tag hs25-b06 for changeset 57dfd29e4742 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 29c43257ae4..0da4f9dddd5 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -286,3 +286,4 @@ f2e12eb74117c917c0bb264694c02de4a6a15a10 hs25-b03 3cfd05b2219a29649741a52637696f06acf24a4e jdk8-b60 b261523fe66c40a02968f0aa7e73602491bb3386 hs25-b05 4547dc71db765276e027b0c2780b724bae0a07d3 jdk8-b61 +d0337c31c8be7716369b4e7c3bd5f352983c6a06 hs25-b06 From 01d0ba69cedc8f397c089be257fa8e8cf2f4f4ef Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Fri, 19 Oct 2012 17:04:35 -0700 Subject: [PATCH 48/56] 8000989: smaller code changes to make future JSR 292 backports easier Reviewed-by: jrose --- .../java/lang/invoke/BoundMethodHandle.java | 22 +++++++++---------- .../classes/java/lang/invoke/CallSite.java | 2 +- .../java/lang/invoke/DirectMethodHandle.java | 6 ++--- .../lang/invoke/InvokerBytecodeGenerator.java | 6 ++--- .../classes/java/lang/invoke/Invokers.java | 12 +++++----- .../classes/java/lang/invoke/LambdaForm.java | 4 ++-- .../classes/java/lang/invoke/MemberName.java | 2 +- .../java/lang/invoke/MethodHandle.java | 4 ++-- .../java/lang/invoke/MethodHandleImpl.java | 2 +- .../java/lang/invoke/MethodHandleStatics.java | 8 ++++++- .../sun/invoke/util/ValueConversions.java | 15 +++++++++---- jdk/test/java/lang/invoke/BigArityTest.java | 2 +- .../java/lang/invoke/PrivateInvokeTest.java | 6 ++--- 13 files changed, 52 insertions(+), 39 deletions(-) diff --git a/jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java index 4071305abc5..dfc6e9d41fe 100644 --- a/jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -79,7 +79,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; default : throw new InternalError("unexpected xtype: " + xtype); } } catch (Throwable t) { - throw new InternalError(t); + throw newInternalError(t); } } @@ -97,7 +97,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; case 'D': return cloneExtendD(type, form, (double) x); } } catch (Throwable t) { - throw new InternalError(t); + throw newInternalError(t); } throw new InternalError("unexpected type: " + xtype); } @@ -115,7 +115,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; try { return clone(srcType, form); } catch (Throwable t) { - throw new InternalError(t); + throw newInternalError(t); } } @@ -124,7 +124,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; try { return clone(newType, form.permuteArguments(1, reorder, basicTypes(newType.parameterList()))); } catch (Throwable t) { - throw new InternalError(t); + throw newInternalError(t); } } @@ -166,7 +166,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; case 'J': return argJ(i); } } catch (Throwable ex) { - throw new InternalError(ex); + throw newInternalError(ex); } throw new InternalError("unexpected type: " + speciesData().types+"."+i); } @@ -192,7 +192,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; try { return (MethodHandle) argL(0); } catch (Throwable ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } @@ -464,7 +464,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; } } } catch (Throwable e) { - throw new InternalError(e); + throw newInternalError(e); } for (SpeciesData d : CACHE.values()) { @@ -748,7 +748,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; try { return LOOKUP.findGetter(cbmhClass, fieldName, fieldType); } catch (NoSuchFieldException | IllegalAccessException e) { - throw new InternalError(e); + throw newInternalError(e); } } @@ -776,7 +776,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA"); return (SpeciesData) F_SPECIES_DATA.get(null); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } @@ -802,7 +802,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; try { return linkConstructor(LOOKUP.findConstructor(cbmh, MethodType.fromMethodDescriptorString(makeSignature(types, true), null))); } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | TypeNotPresentException e) { - throw new InternalError(e); + throw newInternalError(e); } } @@ -833,7 +833,7 @@ import com.sun.xml.internal.ws.org.objectweb.asm.Type; linkerMN = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linkerMN, null, NoSuchMethodException.class); assert(linkerMN.isStatic()); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } // extend arguments array Object[] newArgs = Arrays.copyOf(initName.arguments, initName.arguments.length + 1); diff --git a/jdk/src/share/classes/java/lang/invoke/CallSite.java b/jdk/src/share/classes/java/lang/invoke/CallSite.java index 7beb101b755..5d637b96d4f 100644 --- a/jdk/src/share/classes/java/lang/invoke/CallSite.java +++ b/jdk/src/share/classes/java/lang/invoke/CallSite.java @@ -222,7 +222,7 @@ public class CallSite { GET_TARGET = IMPL_LOOKUP. findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class)); } catch (ReflectiveOperationException e) { - throw new InternalError(e); + throw newInternalError(e); } } diff --git a/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java index b1c7f82da9a..2adc8e82bd8 100644 --- a/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -218,7 +218,7 @@ class DirectMethodHandle extends MethodHandle { try { linker = IMPL_NAMES.resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } final int DMH_THIS = 0; final int ARG_BASE = 1; @@ -554,7 +554,7 @@ class DirectMethodHandle extends MethodHandle { try { linker = IMPL_NAMES.resolveOrFail(REF_invokeVirtual, linker, null, NoSuchMethodException.class); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } // What is the external type of the lambda form? @@ -653,7 +653,7 @@ class DirectMethodHandle extends MethodHandle { nf.resolve(); } } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } } diff --git a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 48f88adeecc..0def847d38c 100644 --- a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -138,7 +138,7 @@ class InvokerBytecodeGenerator { DUMP_CLASS_FILES_DIR = dumpDir; System.out.println("Dumping class files to "+DUMP_CLASS_FILES_DIR+"/..."); } catch (Exception e) { - throw new InternalError(e); + throw newInternalError(e); } } else { DUMP_CLASS_FILES_COUNTERS = null; @@ -162,7 +162,7 @@ class InvokerBytecodeGenerator { file.close(); return null; } catch (IOException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } }); @@ -279,7 +279,7 @@ class InvokerBytecodeGenerator { try { member = MEMBERNAME_FACTORY.resolveOrFail(REF_invokeStatic, member, HOST_CLASS, ReflectiveOperationException.class); } catch (ReflectiveOperationException e) { - throw new InternalError(e); + throw newInternalError(e); } //System.out.println("resolveInvokerMember => "+member); return member; diff --git a/jdk/src/share/classes/java/lang/invoke/Invokers.java b/jdk/src/share/classes/java/lang/invoke/Invokers.java index 0e3dcf64bc7..0e40396a96f 100644 --- a/jdk/src/share/classes/java/lang/invoke/Invokers.java +++ b/jdk/src/share/classes/java/lang/invoke/Invokers.java @@ -27,6 +27,7 @@ package java.lang.invoke; import java.util.Arrays; import sun.invoke.empty.Empty; +import static java.lang.invoke.MethodHandleStatics.*; import static java.lang.invoke.MethodHandleNatives.Constants.*; import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; import static java.lang.invoke.LambdaForm.*; @@ -128,9 +129,8 @@ class Invokers { try { //Lookup.findVirtual(MethodHandle.class, name, type); return IMPL_LOOKUP.resolveOrFail(REF_invokeVirtual, MethodHandle.class, name, type); - } catch (ReflectiveOperationException ex) { - throw new InternalError("JVM cannot find invoker for "+type, ex); + throw newInternalError("JVM cannot find invoker for "+type, ex); } } @@ -176,7 +176,7 @@ class Invokers { .findVirtual(MethodHandle.class, "asSpreader", MethodType.methodType(MethodHandle.class, Class.class, int.class)); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } makeSpreader = MethodHandles.insertArguments(makeSpreader, 1, Object[].class, spreadArgCount); vaInvoker = MethodHandles.filterArgument(arrayInvoker, 0, makeSpreader); @@ -215,7 +215,7 @@ class Invokers { .findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Empty.class)); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } invoker = MethodHandles.explicitCastArguments(invoker, MethodType.methodType(targetType.returnType())); @@ -389,7 +389,7 @@ class Invokers { form.genericInvoker = gamh; return gamh; } catch (Exception ex) { - throw new InternalError("Exception while resolving inexact invoke", ex); + throw newInternalError("Exception while resolving inexact invoke", ex); } } @@ -456,7 +456,7 @@ class Invokers { NF_getCallSiteTarget.resolve(); // bound } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } diff --git a/jdk/src/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/share/classes/java/lang/invoke/LambdaForm.java index e39896afecb..f1da24379c0 100644 --- a/jdk/src/share/classes/java/lang/invoke/LambdaForm.java +++ b/jdk/src/share/classes/java/lang/invoke/LambdaForm.java @@ -457,7 +457,7 @@ class LambdaForm { isCompiled = true; return vmentry; } catch (Error | Exception ex) { - throw new InternalError(this.toString(), ex); + throw newInternalError(this.toString(), ex); } } @@ -1547,7 +1547,7 @@ class LambdaForm { try { zmem = IMPL_NAMES.resolveOrFail(REF_invokeStatic, zmem, null, NoSuchMethodException.class); } catch (IllegalAccessException|NoSuchMethodException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } NamedFunction zcon = new NamedFunction(zmem); Name n = new Name(zcon).newIndex(0); diff --git a/jdk/src/share/classes/java/lang/invoke/MemberName.java b/jdk/src/share/classes/java/lang/invoke/MemberName.java index 595b1145fe1..e2bd9b068d4 100644 --- a/jdk/src/share/classes/java/lang/invoke/MemberName.java +++ b/jdk/src/share/classes/java/lang/invoke/MemberName.java @@ -558,7 +558,7 @@ import java.util.Objects; try { return (MemberName) super.clone(); } catch (CloneNotSupportedException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java index a5e4e584d18..2a6b8c1b789 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java @@ -1372,7 +1372,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); NF_reinvokerTarget = new LambdaForm.NamedFunction(MethodHandle.class .getDeclaredMethod("reinvokerTarget")); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } @@ -1397,7 +1397,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); try { FORM_OFFSET = UNSAFE.objectFieldOffset(MethodHandle.class.getDeclaredField("form")); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } } diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java index d9822bd7189..636bfeb72ce 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -478,7 +478,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; .getDeclaredMethod("checkSpreadArgument", Object.class, int.class)); NF_checkSpreadArgument.resolve(); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } } diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java index 3db5712fdeb..1c069aa1047 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -93,6 +93,12 @@ import sun.misc.Unsafe; } // handy shared exception makers (they simplify the common case code) + /*non-public*/ static InternalError newInternalError(String message, Throwable cause) { + return new InternalError(message, cause); + } + /*non-public*/ static InternalError newInternalError(Throwable cause) { + return new InternalError(cause); + } /*non-public*/ static RuntimeException newIllegalStateException(String message) { return new IllegalStateException(message); } @@ -109,7 +115,7 @@ import sun.misc.Unsafe; return new IllegalArgumentException(message(message, obj, obj2)); } /*non-public*/ static Error uncaughtException(Exception ex) { - throw new InternalError("uncaught exception", ex); + throw newInternalError("uncaught exception", ex); } static Error NYI() { throw new AssertionError("NYI"); diff --git a/jdk/src/share/classes/sun/invoke/util/ValueConversions.java b/jdk/src/share/classes/sun/invoke/util/ValueConversions.java index 1533f4b2ad2..bf8d0336afa 100644 --- a/jdk/src/share/classes/sun/invoke/util/ValueConversions.java +++ b/jdk/src/share/classes/sun/invoke/util/ValueConversions.java @@ -475,7 +475,7 @@ public class ValueConversions { .findStatic(THIS_CLASS, "fillNewTypedArray", MethodType.methodType(Object[].class, Object[].class, Integer.class, Object[].class)); } catch (NoSuchMethodException | IllegalAccessException ex) { - throw new InternalError("uncaught exception", ex); + throw newInternalError("uncaught exception", ex); } } @@ -489,7 +489,7 @@ public class ValueConversions { COPY_AS_PRIMITIVE_ARRAY = IMPL_LOOKUP.findStatic(THIS_CLASS, "copyAsPrimitiveArray", MethodType.methodType(Object.class, Wrapper.class, Object[].class)); MAKE_LIST = IMPL_LOOKUP.findStatic(THIS_CLASS, "makeList", MethodType.methodType(List.class, Object[].class)); } catch (ReflectiveOperationException ex) { - throw new InternalError("uncaught exception", ex); + throw newInternalError("uncaught exception", ex); } } } @@ -527,9 +527,8 @@ public class ValueConversions { MethodHandle.class, int.class, MethodHandle.class); m.setAccessible(true); mh = IMPL_LOOKUP.unreflect(m); - } catch (ReflectiveOperationException | SecurityException ex) { - throw new InternalError(ex); + throw newInternalError(ex); } COLLECT_ARGUMENTS = mh; } @@ -1209,4 +1208,12 @@ public class ValueConversions { private static MethodHandle buildVarargsList(int nargs) { return MethodHandles.filterReturnValue(varargsArray(nargs), LazyStatics.MAKE_LIST); } + + // handy shared exception makers (they simplify the common case code) + private static InternalError newInternalError(String message, Throwable cause) { + return new InternalError(message, cause); + } + private static InternalError newInternalError(Throwable cause) { + return new InternalError(cause); + } } diff --git a/jdk/test/java/lang/invoke/BigArityTest.java b/jdk/test/java/lang/invoke/BigArityTest.java index 9aeaa79af0b..fa4d5975fc4 100644 --- a/jdk/test/java/lang/invoke/BigArityTest.java +++ b/jdk/test/java/lang/invoke/BigArityTest.java @@ -70,7 +70,7 @@ public class BigArityTest { MethodHandles.lookup().unreflect( BigArityTest.class.getDeclaredMethod("hashArguments", Object[].class)); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw new Error(ex); } } static MethodHandle MH_hashArguments(int arity) { diff --git a/jdk/test/java/lang/invoke/PrivateInvokeTest.java b/jdk/test/java/lang/invoke/PrivateInvokeTest.java index 4741f4b675a..434b8e82ca2 100644 --- a/jdk/test/java/lang/invoke/PrivateInvokeTest.java +++ b/jdk/test/java/lang/invoke/PrivateInvokeTest.java @@ -145,21 +145,21 @@ public class PrivateInvokeTest { MH_DEBUG_STRING = DIRECT_INVOKER_LOOKUP .findVirtual(MethodHandle.class, "debugString", methodType(String.class)); } catch (ReflectiveOperationException ex) { - throw new InternalError(ex); + throw new Error(ex); } } private Object internalMemberName(MethodHandle mh) { try { return MH_INTERNAL_MEMBER_NAME.invokeExact(mh); } catch (Throwable ex) { - throw new InternalError(ex); + throw new Error(ex); } } private String debugString(MethodHandle mh) { try { return (String) MH_DEBUG_STRING.invokeExact(mh); } catch (Throwable ex) { - throw new InternalError(ex); + throw new Error(ex); } } private static MethodHandle directInvoker(int refKind, MethodType mtype) { From 9322a179db0bfe573129237238e69c97423767bf Mon Sep 17 00:00:00 2001 From: Keith McGuigan Date: Mon, 22 Oct 2012 20:12:19 -0400 Subject: [PATCH 49/56] 8001225: Disable jdk regression test java/lang/System/Versions.java until jdk's classfile version code is updated Exclude java/lang/System/Versions.java test Reviewed-by: sspitsyn, coleenp --- jdk/test/ProblemList.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 35aaa99f931..23c91cf3a92 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -143,6 +143,11 @@ java/lang/management/MemoryMXBean/CollectionUsageThresholdSerialGC.sh generic-al java/lang/management/MemoryMXBean/MemoryTest.java generic-all java/lang/management/MemoryMXBean/MemoryTestAllGC.sh generic-all +# Exclude until hotspot/jdk repos are sync'd w.r.t. JAVA_MAX_SUPPORTED_VERSION +# Needed when hotspot fix 7054345 is present. Remove when the JDK source is +# updated accordingly. +java/lang/System/Versions.java generic-all + ############################################################################ # jdk_management From 433715e09c6de4a510a34da1539605994c110479 Mon Sep 17 00:00:00 2001 From: Andrew Brygin Date: Tue, 23 Oct 2012 13:10:52 +0400 Subject: [PATCH 50/56] 7051394: NullPointerException when running regression tests LoadProfileTest by using openjdk-7-b144 Reviewed-by: jgodinez, prr --- jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c b/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c index 1195f7c5067..910969f95b2 100644 --- a/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c +++ b/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c @@ -253,6 +253,16 @@ JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_loadProfile if (sProf.pf == NULL) { JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); + } else { + /* Sanity check: try to save the profile in order + * to force basic validation. + */ + cmsUInt32Number pfSize = 0; + if (!cmsSaveProfileToMem(sProf.pf, NULL, &pfSize) || + pfSize < sizeof(cmsICCHeader)) + { + JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); + } } return sProf.j; From 3c6c782cf3f6fb0dc74abb8c5ce0052e848b4c6b Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Tue, 23 Oct 2012 14:30:41 +0400 Subject: [PATCH 51/56] 6624200: Regression test fails: test/closed/javax/swing/JMenuItem/4654927/bug4654927.java Reviewed-by: rupashka --- .../swing/JMenuItem/4654927/bug4654927.java | 152 ++++++++++++++++++ jdk/test/javax/swing/regtesthelpers/Util.java | 30 ++++ 2 files changed, 182 insertions(+) create mode 100644 jdk/test/javax/swing/JMenuItem/4654927/bug4654927.java diff --git a/jdk/test/javax/swing/JMenuItem/4654927/bug4654927.java b/jdk/test/javax/swing/JMenuItem/4654927/bug4654927.java new file mode 100644 index 00000000000..cac3386567a --- /dev/null +++ b/jdk/test/javax/swing/JMenuItem/4654927/bug4654927.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4654927 + * @summary Clicking on Greyed Menuitems closes the Menubar Dropdown + * @author Alexander Potochkin + * @library ../../regtesthelpers + * @build Util + * @run main bug4654927 + */ + +import javax.swing.*; + +import java.awt.*; +import java.awt.event.InputEvent; +import java.util.concurrent.Callable; +import sun.awt.SunToolkit; + +public class bug4654927 { + + private static volatile JMenu menu; + private static volatile JMenuItem menuItem; + + public static void main(String[] args) throws Exception { + String systemLAF = UIManager.getSystemLookAndFeelClassName(); + // the test is not applicable to Motif L&F + if(systemLAF.endsWith("MotifLookAndFeel")){ + return; + } + + UIManager.setLookAndFeel(systemLAF); + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); + robot.setAutoDelay(10); + + SwingUtilities.invokeAndWait(new Runnable() { + + public void run() { + createAndShowUI(); + } + }); + toolkit.realSync(); + + // test mouse press + Point point = Util.getCenterPoint(menu); + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + point = Util.getCenterPoint(menuItem); + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + if (!isMenuItemShowing()) { + throw new RuntimeException("Popup is unexpectedly closed"); + } + + // test mouse drag + point = Util.getCenterPoint(menu); + robot.mouseMove(point.x, point.y); + Point menuLocation = Util.invokeOnEDT(new Callable() { + + @Override + public Point call() throws Exception { + return menu.getLocationOnScreen(); + } + }); + + Point itemLocation = Util.invokeOnEDT(new Callable() { + + @Override + public Point call() throws Exception { + return menuItem.getLocationOnScreen(); + } + }); + + int x0 = menuLocation.x + 10; + int y0 = menuLocation.y + 10; + int x1 = itemLocation.x + 10; + int y1 = itemLocation.y + 10; + + // close menu + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + robot.mousePress(InputEvent.BUTTON1_MASK); + Util.glide(robot, x0, y0, x1, y1); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + if (!isMenuItemShowing()) { + throw new RuntimeException("Popup is unexpectedly closed"); + } + } + + private static boolean isMenuItemShowing() throws Exception { + return Util.invokeOnEDT(new Callable() { + + @Override + public Boolean call() throws Exception { + return menuItem.isShowing(); + } + }); + } + + private static void createAndShowUI() { + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + menu = new JMenu("Menu"); + menu.add(new JMenuItem("menuItem")); + menuItem = new JMenuItem("menuItem"); + menuItem.setEnabled(false); + menu.add(menuItem); + menu.add(new JMenuItem("menuItem")); + + JMenuBar bar = new JMenuBar(); + bar.add(menu); + frame.setJMenuBar(bar); + + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + } +} diff --git a/jdk/test/javax/swing/regtesthelpers/Util.java b/jdk/test/javax/swing/regtesthelpers/Util.java index 68bc0f8c404..a9df4934583 100644 --- a/jdk/test/javax/swing/regtesthelpers/Util.java +++ b/jdk/test/javax/swing/regtesthelpers/Util.java @@ -156,6 +156,36 @@ public class Util { } } + /** + * Moves mouse smoothly from (x0, y0) to (x1, y1). + */ + public static void glide(Robot robot, int x0, int y0, int x1, int y1) throws AWTException { + float dmax = (float) Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0)); + float dx = (x1 - x0) / dmax; + float dy = (y1 - y0) / dmax; + + for (int i = 0; i <= dmax; i += 10) { + robot.mouseMove((int) (x0 + dx * i), (int) (y0 + dy * i)); + } + } + + /** + * Gets component center point + * + * @return center point of the component + */ + public static Point getCenterPoint(final Component component) throws Exception { + return Util.invokeOnEDT(new Callable() { + + @Override + public Point call() throws Exception { + Point p = component.getLocationOnScreen(); + Dimension size = component.getSize(); + return new Point(p.x + size.width / 2, p.y + size.height / 2); + } + }); + } + /** * Invokes the task on the EDT thread. * From 906081c12dfee398446ef175a14cef9cb8fb5e57 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Tue, 23 Oct 2012 10:10:23 -0700 Subject: [PATCH 52/56] 7152336: Enable builds on Windows with MinGW/MSYS Minimal makefile changes to enable building OpenJDK using MSYS on Windows7 Reviewed-by: ohair, tbell --- jdk/make/com/sun/java/pack/Makefile | 8 +- jdk/make/common/Defs-windows.gmk | 18 +-- jdk/make/common/Demo.gmk | 6 +- jdk/make/common/Library.gmk | 6 +- jdk/make/common/Program.gmk | 10 +- jdk/make/common/Release.gmk | 17 +++ jdk/make/common/shared/Defs-utils.gmk | 12 +- jdk/make/common/shared/Defs-windows.gmk | 114 ++++++++++-------- jdk/make/common/shared/Platform.gmk | 45 +++---- jdk/make/common/shared/Sanity-Settings.gmk | 9 +- jdk/make/common/shared/Sanity.gmk | 20 ++- jdk/make/jdk_generic_profile.sh | 30 ++++- jdk/make/tools/freetypecheck/Makefile | 8 +- jdk/make/tools/msys_build_scripts/dospath.sh | 42 +++++++ jdk/make/tools/msys_build_scripts/dospath.vbs | 34 ++++++ 15 files changed, 263 insertions(+), 116 deletions(-) create mode 100644 jdk/make/tools/msys_build_scripts/dospath.sh create mode 100644 jdk/make/tools/msys_build_scripts/dospath.vbs diff --git a/jdk/make/com/sun/java/pack/Makefile b/jdk/make/com/sun/java/pack/Makefile index 5882683fe04..e8c256d3e9b 100644 --- a/jdk/make/com/sun/java/pack/Makefile +++ b/jdk/make/com/sun/java/pack/Makefile @@ -94,9 +94,9 @@ ifeq ($(PLATFORM), windows) LDOUTPUT = -Fe # JDK name required here - RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \ - /D "JDK_INTERNAL_NAME=$(PGRM)" \ - /D "JDK_FTYPE=0x1L" + RC_FLAGS += -D "JDK_FNAME=$(PGRM).exe" \ + -D "JDK_INTERNAL_NAME=$(PGRM)" \ + -D "JDK_FTYPE=0x1L" RES = $(OBJDIR)/$(PGRM).res else @@ -161,7 +161,7 @@ $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres $(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers $(LINKER) $(LDDFLAGS) $(sort $(UNPACK_EXE_FILES_o)) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX) ifdef MT - $(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1 + $(MT) -manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest -outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1 endif $(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE) @$(call binary_file_verification,$@) diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk index 7afe0b515e0..50a5a66c477 100644 --- a/jdk/make/common/Defs-windows.gmk +++ b/jdk/make/common/Defs-windows.gmk @@ -78,7 +78,7 @@ ifeq ($(COMPILER_VERSION), VS2010) MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL) endif -EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH) +EXTRA_LFLAGS += -LIBPATH:$(DXSDK_LIB_PATH) # Full Debug Symbols has been enabled on Windows since JDK1.4.1. # The Full Debug Symbols (FDS) default for VARIANT == OPT builds is @@ -198,7 +198,7 @@ CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL)) # -MTd Use static debug version (better than -MDd, no runtime issues) # -D_DEBUG Change use of malloc/free/etc to use special debug ones (-MTd) # -# NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll +# NOTE: We also will use -D _STATIC_CPPLIB so we don't need msvcpnn.dll # # If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer # supported by VS2010 @@ -223,12 +223,12 @@ ifeq ($(MFC_DEBUG), true) endif # Always add _STATIC_CPPLIB definition -STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB +STATIC_CPPLIB_OPTION = -D _STATIC_CPPLIB # Silence the warning about using _STATIC_CPPLIB ifneq ($(SHOW_ALL_WARNINGS),true) # Needed with VS2010 to turn off the deprecated warning. - STATIC_CPPLIB_OPTION += /D _DISABLE_DEPRECATE_STATIC_CPPLIB + STATIC_CPPLIB_OPTION += -D _DISABLE_DEPRECATE_STATIC_CPPLIB endif MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION) @@ -242,7 +242,7 @@ ifeq ($(CC_VERSION),msvc) # -Od Turns off optimization and speeds compilation # -YX -Fp/.../foobar.pch Use precompiled headers (try someday?) # -nologo Don't print out startup message - # /D _STATIC_CPPLIB + # -D _STATIC_CPPLIB # Use static link for the C++ runtime (so msvcpnn.dll not needed) # ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) @@ -258,12 +258,12 @@ ifeq ($(CC_VERSION),msvc) CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION)) ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - LDEBUG = /debug + LDEBUG = -debug endif ifeq ($(VTUNE_SUPPORT), true) OTHER_CFLAGS = -Z7 -Ox - LDEBUG += /pdb:NONE + LDEBUG += -pdb:NONE endif # VS2010, always need safe exception handlers, not needed on 64bit @@ -272,7 +272,7 @@ ifeq ($(CC_VERSION),msvc) endif # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file - BASELFLAGS = -nologo /opt:REF /incremental:no + BASELFLAGS = -nologo -opt:REF -incremental:no LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION)) LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION)) @@ -404,7 +404,7 @@ else JDK_UPDATE_VER := 0 endif -RC_FLAGS = /l 0x409 /r +RC_FLAGS = -l 0x409 -r ifeq ($(VARIANT), OPT) RC_FLAGS += -d NDEBUG diff --git a/jdk/make/common/Demo.gmk b/jdk/make/common/Demo.gmk index 3aba9a62c07..9163cf76513 100644 --- a/jdk/make/common/Demo.gmk +++ b/jdk/make/common/Demo.gmk @@ -292,9 +292,9 @@ endif ifeq ($(PLATFORM),windows) # JDK name required here -RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \ - /D "JDK_INTERNAL_NAME=$(LIBRARY)" \ - /D "JDK_FTYPE=0x2L" +RC_FLAGS += -D "JDK_FNAME=$(LIBRARY).dll" \ + -D "JDK_INTERNAL_NAME=$(LIBRARY)" \ + -D "JDK_FTYPE=0x2L" endif # Native library building diff --git a/jdk/make/common/Library.gmk b/jdk/make/common/Library.gmk index b04095c93e2..4b080304d1f 100644 --- a/jdk/make/common/Library.gmk +++ b/jdk/make/common/Library.gmk @@ -206,9 +206,9 @@ endif @$(ECHO) Created $@ # JDK name required here -RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \ - /D "JDK_INTERNAL_NAME=$(LIBRARY)" \ - /D "JDK_FTYPE=0x2L" +RC_FLAGS += -D "JDK_FNAME=$(LIBRARY).dll" \ + -D "JDK_INTERNAL_NAME=$(LIBRARY)" \ + -D "JDK_FTYPE=0x2L" $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE) ifndef LOCAL_RESOURCE_FILE diff --git a/jdk/make/common/Program.gmk b/jdk/make/common/Program.gmk index 094d18ff997..b319ee41889 100644 --- a/jdk/make/common/Program.gmk +++ b/jdk/make/common/Program.gmk @@ -157,9 +157,9 @@ $(ACTUAL_PROGRAM):: classes $(INIT) # ifeq ($(PLATFORM), windows) # JDK name required here - RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \ - /D "JDK_INTERNAL_NAME=$(PROGRAM)" \ - /D "JDK_FTYPE=0x1L" + RC_FLAGS += -D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \ + -D "JDK_INTERNAL_NAME=$(PROGRAM)" \ + -D "JDK_FTYPE=0x1L" $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE) @$(prep-target) @@ -201,11 +201,11 @@ endif @$(prep-target) @set -- $?; \ $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...}; - $(LINK) -out:$@ /STACK:$(STACK_SIZE) \ + $(LINK) -out:$@ -STACK:$(STACK_SIZE) \ $(MAP_OPTION) $(LFLAGS) $(LDFLAGS) \ @$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS) ifdef MT - $(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1 + $(MT) -manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1 endif @$(call binary_file_verification,$@) ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) diff --git a/jdk/make/common/Release.gmk b/jdk/make/common/Release.gmk index 7d04d3e14e2..2f2b1693384 100644 --- a/jdk/make/common/Release.gmk +++ b/jdk/make/common/Release.gmk @@ -784,11 +784,22 @@ initial-image-jre:: initial-image-jre-setup \ $(RT_JAR) $(RESOURCES_JAR) $(JSSE_JAR) $(JFR_JAR) \ $(BUILDMETAINDEX_JARFILE) @# Copy in bin directory +ifeq ($(USING_MSYS),true) + # No cpio in MinGW/MSYS + $(CD) $(OUTPUTDIR) && $(TAR) -cf - bin | ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -xpf -) +else $(CD) $(OUTPUTDIR) && $(FIND) bin -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR) +endif @# CTE plugin security change require new empty directory lib/applet $(MKDIR) -p $(JRE_IMAGE_DIR)/lib/applet @# Copy in lib directory +ifeq ($(USING_MSYS),true) + # No cpio in MinGW/MSYS + $(CD) $(OUTPUTDIR) && $(TAR) -cf - lib | ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -xpf -) +else $(CD) $(OUTPUTDIR) && $(FIND) lib -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR) +endif + ifeq ($(USING_CYGWIN),true) $(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]: $(RM) -rf $(OUTPUTDIR)/[A-Za-z]: @@ -919,11 +930,17 @@ endif # only places from which we copy everything), but because the presence # of this file causes cygwin's find to bomb out, thus breaking the build # in "install". + initial-image-jdk-setup: $(RM) -r $(JDK_IMAGE_DIR) $(MKDIR) -p $(JDK_IMAGE_DIR)/jre +ifeq ($(USING_MSYS),true) + ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -cf - . \ + | ($(CD) $(JDK_IMAGE_DIR)/jre && $(TAR) -xpf -)) +else ($(CD) $(JRE_IMAGE_DIR) && $(FIND) . -depth -print \ | $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre ) +endif ifeq ($(USING_CYGWIN),true) $(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]: $(RM) -rf $(JDK_IMAGE_DIR)/jre/[A-Za-z]: diff --git a/jdk/make/common/shared/Defs-utils.gmk b/jdk/make/common/shared/Defs-utils.gmk index 9bc05d6f69b..573f7ccaa80 100644 --- a/jdk/make/common/shared/Defs-utils.gmk +++ b/jdk/make/common/shared/Defs-utils.gmk @@ -169,15 +169,19 @@ CD = cd # intrinsic unix command ifeq ($(PLATFORM),windows) ifdef USING_CYGWIN # Intrinsic unix command, with backslash-escaped character interpretation - ECHO = $(UNIXCOMMAND_PATH)echo -e - ZIPEXE = $(UNIXCOMMAND_PATH)zip - UNZIP = $(UNIXCOMMAND_PATH)unzip + ECHO = $(UNIXCOMMAND_PATH)echo -e + ZIPEXE = $(UNIXCOMMAND_PATH)zip + UNZIP = $(UNIXCOMMAND_PATH)unzip # Some CYGWIN nawk versions require BINMODE=w for proper '\r' interpretation - NAWK = $(UNIXCOMMAND_PATH)awk -v BINMODE=w + NAWK = $(UNIXCOMMAND_PATH)awk -v BINMODE=w else ZIPEXE = $(UTILS_DEVTOOL_PATH)zip UNZIP = $(UTILS_DEVTOOL_PATH)unzip NAWK = $(UNIXCOMMAND_PATH)awk + ifdef USING_MSYS + ECHO = $(UTILS_COMMAND_PATH)echo -e + AR = $(UTILS_DEVTOOL_PATH)ar + endif endif # Re-define some utilities LEX =# override GNU Make intrinsic: no lex on windows diff --git a/jdk/make/common/shared/Defs-windows.gmk b/jdk/make/common/shared/Defs-windows.gmk index af611f3aab2..c4ccdbca4ea 100644 --- a/jdk/make/common/shared/Defs-windows.gmk +++ b/jdk/make/common/shared/Defs-windows.gmk @@ -112,6 +112,15 @@ define OptFullPath $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1" 2> $(DEV_NULL); else echo "$1"; fi) endef else +ifdef USING_MSYS +DOSPATH_CMD:=$(shell cd $(JDK_TOPDIR) 2> $(DEV_NULL) && pwd)/make/tools/msys_build_scripts/dospath.sh +define FullPath +$(subst \,/,$(shell $(DOSPATH_CMD) $1)) +endef +define OptFullPath +$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi) +endef +else # Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path define FullPath $(shell cd $1 2> $(DEV_NULL) && pwd) @@ -120,6 +129,7 @@ define OptFullPath $(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi) endef endif +endif # System drive ifdef SYSTEMDRIVE @@ -146,43 +156,47 @@ else ifdef USING_CYGWIN UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin) else - ifdef ROOTDIR - xROOTDIR :="$(subst \,/,$(ROOTDIR))" - _rootdir :=$(call FullPath,$(xROOTDIR)) + ifdef USING_MSYS + UNIXCOMMAND_PATH :=$(call PrefixPath,/bin) else - xROOTDIR :="$(_system_drive)/mksnt" - _rootdir :=$(call FullPath,$(xROOTDIR)) - endif - ifneq ($(_rootdir),) - UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt) - endif - endif + ifdef ROOTDIR + xROOTDIR :="$(subst \,/,$(ROOTDIR))" + _rootdir :=$(call FullPath,$(xROOTDIR)) + else + xROOTDIR :="$(_system_drive)/mksnt" + _rootdir :=$(call FullPath,$(xROOTDIR)) + endif + ifneq ($(_rootdir),) + UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt) + endif + endif # USING_MSYS + endif # USING_CYGWIN endif UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH) # Get version of MKS or CYGWIN -ifndef USING_CYGWIN -_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@') -MKS_VER :=$(call GetVersion,$(_MKS_VER)) -# At this point, we can re-define FullPath to use DOSNAME_CMD -CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7) -TRY_DOSNAME:=false -ifeq ($(CHECK_MKS87),same) -TRY_DOSNAME:=true -endif -# Newer should be ok -ifeq ($(CHECK_MKS87),newer) -TRY_DOSNAME:=true -endif -ifeq ($(TRY_DOSNAME),true) -ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/) -_DOSNAME=$(UNIXCOMMAND_PATH)dosname -DOSNAME_CMD:=$(_DOSNAME) -s +ifdef USING_MKS + _MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@') + MKS_VER :=$(call GetVersion,$(_MKS_VER)) + # At this point, we can re-define FullPath to use DOSNAME_CMD + CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7) + TRY_DOSNAME:=false + ifeq ($(CHECK_MKS87),same) + TRY_DOSNAME:=true + endif + # Newer should be ok + ifeq ($(CHECK_MKS87),newer) + TRY_DOSNAME:=true + endif + ifeq ($(TRY_DOSNAME),true) + ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/) + _DOSNAME=$(UNIXCOMMAND_PATH)dosname + DOSNAME_CMD:=$(_DOSNAME) -s define FullPath $(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL))) endef -endif # test dosname -s -endif # TRY_DOSNAME + endif # test dosname -s + endif # TRY_DOSNAME endif # MKS # We try to get references to what we need via the default component @@ -440,10 +454,14 @@ else ifdef USING_CYGWIN DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH) else - xDEVTOOLS_PATH :="$(_system_drive)/utils" - fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH)) - DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH)) - endif + ifdef USING_MSYS + DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH) + else + xDEVTOOLS_PATH :="$(_system_drive)/utils" + fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH)) + DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH)) + endif # USING_MSYS + endif # USING_CYGWIN endif DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH) @@ -636,7 +654,7 @@ HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH) # Special define for checking the binaries -# All windows dll and exe files should have been built with /NXCOMPAT +# All windows dll and exe files should have been built with -NXCOMPAT # and be setup for dynamic base addresses. # In addition, we should not be dependent on certain dll files that # we do not or cannot redistribute. @@ -648,37 +666,37 @@ else BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll endif -# Check for /safeseh (only used on 32bit) +# Check for -safeseh (only used on 32bit) define binary_file_safeseh_verification # binary_file ( \ - $(ECHO) "Checking for /SAFESEH usage in: $1" && \ - if [ "`$(DUMPBIN) /loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \ + $(ECHO) "Checking for -SAFESEH usage in: $1" && \ + if [ "`$(DUMPBIN) -loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \ $(ECHO) "ERROR: Did not find 'Safe Exception Handler Table' in loadconfig: $1" ; \ - $(DUMPBIN) /loadconfig $1 ; \ + $(DUMPBIN) -loadconfig $1 ; \ exit 6 ; \ fi ; \ ) endef -# Check for /NXCOMPAT usage +# Check for -NXCOMPAT usage define binary_file_nxcompat_verification # binary_file ( \ - $(ECHO) "Checking for /NXCOMPAT usage in: $1" && \ - if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \ + $(ECHO) "Checking for -NXCOMPAT usage in: $1" && \ + if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \ $(ECHO) "ERROR: Did not find 'NX compatible' in headers: $1" ; \ - $(DUMPBIN) /headers $1 ; \ + $(DUMPBIN) -headers $1 ; \ exit 7 ; \ fi ; \ ) endef -# Check for /DYNAMICBASE usage +# Check for -DYNAMICBASE usage define binary_file_dynamicbase_verification # binary_file ( \ - $(ECHO) "Checking for /DYNAMICBASE usage in: $1" && \ - if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \ + $(ECHO) "Checking for -DYNAMICBASE usage in: $1" && \ + if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \ $(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \ - $(DUMPBIN) /headers $1 ; \ + $(DUMPBIN) -headers $1 ; \ exit 8 ; \ fi ; \ ) @@ -688,9 +706,9 @@ endef define binary_file_dll_verification # binary_file ( \ $(ECHO) "Checking for banned dependencies in: $1" && \ - if [ "`$(DUMPBIN) /dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \ + if [ "`$(DUMPBIN) -dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \ $(ECHO) "ERROR: Found use of $(BANNED_DLLS)"; \ - $(DUMPBIN) /dependents $1 ; \ + $(DUMPBIN) -dependents $1 ; \ exit 9 ; \ fi ; \ ) diff --git a/jdk/make/common/shared/Platform.gmk b/jdk/make/common/shared/Platform.gmk index 49e6cbda78e..aeaeabe42f6 100644 --- a/jdk/make/common/shared/Platform.gmk +++ b/jdk/make/common/shared/Platform.gmk @@ -70,6 +70,8 @@ PLATFORM_SHARED=done # LIBARCH32 solaris only: sparc or i386 # LIBARCH64 solaris only: sparcv9 or amd64 # USING_CYGWIN windows only: true or false +# USING_MSYS windows only: true or false +# USING_MKS windows only: true or false # ISHIELD_TEMP_MIN windows only: minimum disk space in temp area # Only run uname once in this make session. @@ -306,6 +308,8 @@ endif # Windows with and without CYGWIN will be slightly different ifeq ($(SYSTEM_UNAME), Windows_NT) PLATFORM = windows + USING_MKS = true + export USING_MKS endif ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME))) PLATFORM = windows @@ -318,6 +322,11 @@ ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME))) export CYGWIN_HOME endif endif +ifneq (,$(findstring MINGW,$(SYSTEM_UNAME))) + PLATFORM = windows + USING_MSYS = true + export USING_MSYS +endif # Platform settings specific to Windows ifeq ($(PLATFORM), windows) @@ -395,11 +404,12 @@ ifeq ($(PLATFORM), windows) endif ARCH_FAMILY = $(ARCH) # Where is unwanted output to be delivered? - # MKS uses the special file "NUL", cygwin uses the customary unix file. - ifeq ($(USING_CYGWIN),true) - DEV_NULL = /dev/null - else + # MKS uses the special file "NUL"; Cygwin and MinGW/MSYS use the + # customary unix file. + ifeq ($(USING_MKS),true) DEV_NULL = NUL + else + DEV_NULL = /dev/null endif export DEV_NULL # Classpath separator @@ -440,28 +450,11 @@ ifeq ($(PLATFORM), windows) _MB_OF_MEMORY := \ $(shell free -m | grep Mem: | awk '{print $$2;}' ) else - # Windows 2000 has the mem utility, but two memory areas - # extended memory is what is beyond 1024M - _B_OF_EXT_MEMORY := \ - $(shell mem 2> $(DEV_NULL) | \ - grep 'total contiguous extended memory' | awk '{print $$1;}') - ifeq ($(_B_OF_EXT_MEMORY),) - _B_OF_MEMORY := \ - $(shell mem 2> $(DEV_NULL) | \ - grep 'total conventional memory' | awk '{print $$1;}') - else - _B_OF_MEMORY := \ - $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL)) - endif - ifeq ($(_B_OF_MEMORY),) - # Windows 2003 has the systeminfo utility use it if mem doesn't work - _MB_OF_MEMORY := \ - $(shell systeminfo 2> $(DEV_NULL) | \ - grep 'Total Physical Memory:' | \ - awk '{print $$4;}' | sed -e 's@,@@') - else - _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL)) - endif + # Windows XP and higher has the systeminfo utility + _MB_OF_MEMORY := \ + $(shell systeminfo 2> $(DEV_NULL) | \ + grep 'Total Physical Memory:' | \ + awk '{print $$4;}' | sed -e 's@,@@') endif ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY)) MB_OF_MEMORY := $(_MB_OF_MEMORY) diff --git a/jdk/make/common/shared/Sanity-Settings.gmk b/jdk/make/common/shared/Sanity-Settings.gmk index e571b068f82..b6b0fdcf19d 100644 --- a/jdk/make/common/shared/Sanity-Settings.gmk +++ b/jdk/make/common/shared/Sanity-Settings.gmk @@ -182,8 +182,13 @@ ifeq ($(PLATFORM),windows) ALL_SETTINGS+=$(call addRequiredVersionSetting,CYGWIN_VER) ALL_SETTINGS+=$(call addRequiredSetting,CYGPATH_CMD) else - ALL_SETTINGS+=$(call addRequiredVersionSetting,MKS_VER) - ALL_SETTINGS+=$(call addOptionalSetting,DOSNAME_CMD) + ifdef USING_MSYS + ALL_SETTINGS+=$(call addRequiredSetting,USING_MSYS) + ALL_SETTINGS+=$(call addRequiredSetting,DOSPATH_CMD) + else + ALL_SETTINGS+=$(call addRequiredVersionSetting,MKS_VER) + ALL_SETTINGS+=$(call addOptionalSetting,DOSNAME_CMD) + endif endif endif ifeq ($(PLATFORM),linux) diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk index b6c340cfe91..845418bcecc 100644 --- a/jdk/make/common/shared/Sanity.gmk +++ b/jdk/make/common/shared/Sanity.gmk @@ -395,7 +395,7 @@ endif ifeq ($(PLATFORM), windows) MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER)) sane-mks: - ifndef USING_CYGWIN + ifdef USING_MKS ifeq ($(MKS_CHECK),missing) @$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER)) endif @@ -905,14 +905,25 @@ sane-unixcommand_path: "" >> $(ERROR_FILE) ; \ fi ifeq ($(PLATFORM), windows) - @for utility in cpio ar file m4 ; do \ +ifeq ($(USING_MSYS), true) + @for utility in $(AR) $(FILE) $(M4) ; do \ if [ ! -r "`$(WHICH) $${utility}`" ]; then \ $(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \ " directory $(UNIXCOMMAND_PATH). \n" \ - " The utilities cpio, ar, file, and m4 are required. \n" \ + " The utilities ar, file and m4 are required. \n" \ "" >> $(WARNING_FILE) ; \ fi; \ done +else + @for utility in $(AR) $(CPIO) $(FILE) $(M4) ; do \ + if [ ! -r "`$(WHICH) $${utility}`" ]; then \ + $(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \ + " directory $(UNIXCOMMAND_PATH). \n" \ + " The utilities ar, cpio, file and m4 are required. \n" \ + "" >> $(WARNING_FILE) ; \ + fi; \ + done +endif endif ###################################################### @@ -999,7 +1010,8 @@ ifeq ($(PLATFORM), windows) " This is normally obtained from the WINDOWSSDKDIR." \ "" >> $(ERROR_FILE) endif - ifeq ($(wildcard $(DUMPBIN)),) + # MinGW/MSYS make 3.81 will not tolerate a path with a quoted substring + ifeq ($(wildcard $(subst ",,$(DUMPBIN))),) @$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \ " This is normally obtained from the COMPILER_PATH." \ "" >> $(ERROR_FILE) diff --git a/jdk/make/jdk_generic_profile.sh b/jdk/make/jdk_generic_profile.sh index 93aa1cd4d25..6836d8bd0b8 100644 --- a/jdk/make/jdk_generic_profile.sh +++ b/jdk/make/jdk_generic_profile.sh @@ -176,17 +176,38 @@ else else windows_arch=i586 fi + + repo=`hg root | sed -e 's@\\\\@/@g'` # We need to check if we are running a CYGWIN shell - if [ "$(uname -a | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then + if [ "$(echo ${osname} | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist # Utility to convert to short pathnames without spaces cygpath="/usr/bin/cygpath -a -m -s" + cygpathp="/usr/bin/cygpath -p" # Most unix utilities are in the /usr/bin unixcommand_path="/usr/bin" # Make the prompt tell you CYGWIN export PS1="CYGWIN:${COMPUTERNAME}:${USERNAME}[\!] " + elif [ "$(echo ${osname} | fgrep MINGW)" != "" ] ; then + # Utility to convert to short pathnames without spaces + cygpath="${repo}/make/tools/msys_build_scripts/dospath.sh" + if [ ! -f ${cygpath} ] ; then + echo "ERROR: Cannot find cygpath or equivalent on this machine" + exit 1 + fi + # Utility to fix a path to MinGW/MSYS format - the equivalent of 'cygpath -p' + for tfile in "${repo}/make/scripts/fixpath.pl" "${repo}/../make/scripts/fixpath.pl"; do + if [ -f ${tfile} ] ; then + cygpathp="/bin/perl ${tfile} -m" + fi + done; + if [ -z "${cygpathp}" ] ; then + echo "ERROR: Cannot find make/scripts/fixpath.pl on this machine" + exit 1 + fi + unixcommand_path="/usr/bin" else - echo "ERROR: Cannot find CYGWIN on this machine" + echo "ERROR: Cannot find CYGWIN or MinGW/MSYS on this machine" exit 1 fi if [ "${ALT_UNIXCOMMAND_PATH}" != "" ] ; then @@ -204,17 +225,18 @@ else else sys_root=$(${cygpath} "C:/WINNT") fi - path4sdk="${unixcommand_path};${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem" if [ ! -d "${sys_root}" ] ; then echo "WARNING: No system root found at: ${sys_root}" fi + # Build a : separated path making sure each segment is acceptable to ${osname} + path4sdk="${unixcommand_path}:"`${cygpathp} "${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"` + # Compiler setup (nasty part) # NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE. # NOTE: CYGWIN has a link.exe too, make sure the compilers are first # Use supplied vsvars.sh - repo=`hg root` if [ -f "${repo}/make/scripts/vsvars.sh" ] ; then eval `sh ${repo}/make/scripts/vsvars.sh -v10` elif [ -f "${repo}/../make/scripts/vsvars.sh" ] ; then diff --git a/jdk/make/tools/freetypecheck/Makefile b/jdk/make/tools/freetypecheck/Makefile index 0b18de0c17c..5bed801916a 100644 --- a/jdk/make/tools/freetypecheck/Makefile +++ b/jdk/make/tools/freetypecheck/Makefile @@ -37,11 +37,11 @@ ifeq ($(OPENJDK),true) # Start with CFLAGS (which gets us the required -xarch setting on solaris) ifeq ($(PLATFORM), windows) - FT_OPTIONS = /nologo /c + FT_OPTIONS = -nologo -c FREETYPE_DLL = $(FREETYPE_LIB_PATH)/freetype.dll FT_LD_OPTIONS = $(FREETYPE_LIB_PATH)/freetype.lib ifdef MT - FT_LD_OPTIONS += /manifest + FT_LD_OPTIONS += -manifest endif else FT_OPTIONS = $(CFLAGS) @@ -72,11 +72,11 @@ $(FT_TEST): freetypecheck.c $(prep-target) ifeq ($(PLATFORM), windows) $(CC) $(FT_OPTIONS) $(CC_OBJECT_OUTPUT_FLAG)$(FT_OBJ) $< - $(LINK) $(FT_LD_OPTIONS) /OUT:$(FT_TEST) $(FT_OBJ) + $(LINK) $(FT_LD_OPTIONS) -OUT:$(FT_TEST) $(FT_OBJ) $(CP) $(FREETYPE_DLL) $(@D)/ ifdef MT $(CP) $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL) $(@D)/ - $(MT) /manifest $(FT_TEST).manifest /outputresource:$(FT_TEST);#1 + $(MT) -manifest $(FT_TEST).manifest -outputresource:$(FT_TEST);#1 endif else @$(CC) $(FT_OPTIONS) -o $@ $< $(FT_LD_OPTIONS) diff --git a/jdk/make/tools/msys_build_scripts/dospath.sh b/jdk/make/tools/msys_build_scripts/dospath.sh new file mode 100644 index 00000000000..d674aba29ec --- /dev/null +++ b/jdk/make/tools/msys_build_scripts/dospath.sh @@ -0,0 +1,42 @@ +# +# Copyright (c) 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. +# + +# A shell script which converts its first argument, which must be an existing +# path name, into a DOS (aka 8.3) path name. If the path is a file, only the +# directory part of the whole path will be converted. +# This shell script executes the Visual Basic helper script 'dospath.vbs' +# which must be located in the same directory as this script itself. +# The Visual Basic script will be invoked trough the "Windows Script Host" +# which is available by default on Windows since Windows 98. + +pushd `dirname "$0"` > /dev/null +ABS_PATH=`pwd` +popd > /dev/null +if [ -d "$1" ]; then + echo `cd "$1" && cscript.exe -nologo $ABS_PATH/dospath.vbs`; +elif [ -f "$1" ]; then + DIR=`dirname "$1"`; + echo `cd "$DIR" && cscript.exe -nologo $ABS_PATH/dospath.vbs`\\`basename "$1"`; +fi diff --git a/jdk/make/tools/msys_build_scripts/dospath.vbs b/jdk/make/tools/msys_build_scripts/dospath.vbs new file mode 100644 index 00000000000..55ff34bcabe --- /dev/null +++ b/jdk/make/tools/msys_build_scripts/dospath.vbs @@ -0,0 +1,34 @@ +' +' Copyright (c) 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. +' + +' +' Visual Basic Script which returns the DOS (aka 8.3) filename of the current +' directory. +' Only called from 'dospath.sh' during a Windows build under MinGW/MSYS. +' + +Set fso=CreateObject("Scripting.FileSystemObject") +Set path = fso.GetFolder(".") +WScript.Echo path.ShortPath From 9c0b5ee904c87f3c81bfb067ab7fe766a3f610d3 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Tue, 23 Oct 2012 10:10:39 -0700 Subject: [PATCH 53/56] 7152336: Enable builds on Windows with MinGW/MSYS Minimal makefile changes to enable building OpenJDK using MSYS on Windows7 Reviewed-by: ohair, tbell --- corba/make/common/shared/Defs-utils.gmk | 22 ++++-- corba/make/common/shared/Defs-windows.gmk | 89 ++++++++++++++--------- corba/make/common/shared/Platform.gmk | 9 +++ 3 files changed, 78 insertions(+), 42 deletions(-) diff --git a/corba/make/common/shared/Defs-utils.gmk b/corba/make/common/shared/Defs-utils.gmk index 40bf4687263..1de3dde0ba5 100644 --- a/corba/make/common/shared/Defs-utils.gmk +++ b/corba/make/common/shared/Defs-utils.gmk @@ -151,16 +151,26 @@ CD = cd # intrinsic unix command ifeq ($(PLATFORM),windows) ifdef USING_CYGWIN # Intrinsic unix command, with backslash-escaped character interpretation - ECHO = $(UNIXCOMMAND_PATH)echo -e - ZIPEXE = $(UNIXCOMMAND_PATH)zip - UNZIP = $(UNIXCOMMAND_PATH)unzip + ECHO = $(UNIXCOMMAND_PATH)echo -e + ZIPEXE = $(UNIXCOMMAND_PATH)zip + UNZIP = $(UNIXCOMMAND_PATH)unzip + # Some CYGWIN nawk versions require BINMODE=w for proper '\r' interpretation + NAWK = $(UNIXCOMMAND_PATH)awk -v BINMODE=w else - ZIPEXE = $(UTILS_DEVTOOL_PATH)zip - UNZIP = $(UTILS_DEVTOOL_PATH)unzip + ifdef USING_MSYS + ECHO = $(UTILS_COMMAND_PATH)echo -e + ZIPEXE = $(UTILS_DEVTOOL_PATH)zip + UNZIP = $(UTILS_DEVTOOL_PATH)unzip + NAWK = $(UNIXCOMMAND_PATH)awk + else + ZIPEXE = $(UTILS_DEVTOOL_PATH)zip + UNZIP = $(UTILS_DEVTOOL_PATH)unzip + NAWK = $(UNIXCOMMAND_PATH)awk + endif endif # Re-define some utilities LEX =# override GNU Make intrinsic: no lex on windows - NAWK = $(UNIXCOMMAND_PATH)awk + SHA1SUM = $(UNIXCOMMAND_PATH)openssl sha1 endif # Linux specific diff --git a/corba/make/common/shared/Defs-windows.gmk b/corba/make/common/shared/Defs-windows.gmk index 1521d9461c3..812e6038dda 100644 --- a/corba/make/common/shared/Defs-windows.gmk +++ b/corba/make/common/shared/Defs-windows.gmk @@ -91,6 +91,15 @@ define OptFullPath $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1"; else echo "$1"; fi) endef else +ifdef USING_MSYS +DOSPATH_CMD:=$(shell cd $(JDK_TOPDIR) 2> $(DEV_NULL) && pwd)/make/tools/msys_build_scripts/dospath.sh +define FullPath +$(subst \,/,$(shell $(DOSPATH_CMD) $1)) +endef +define OptFullPath +$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi) +endef +else # Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path define FullPath $(shell cd $1 2> $(DEV_NULL) && pwd) @@ -99,6 +108,7 @@ define OptFullPath $(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi) endef endif +endif # System drive ifdef SYSTEMDRIVE @@ -112,14 +122,21 @@ _system_drive:=$(call CheckValue,_system_drive,C:) # UNIXCOMMAND_PATH: path to where the most common Unix commands are. # NOTE: Must end with / so that it could be empty, allowing PATH usage. -ifndef UNIXCOMMAND_PATH - ifdef ALT_UNIXCOMMAND_PATH +# With cygwin, use this as is; don't use FullPath on it. +ifdef ALT_UNIXCOMMAND_PATH + ifdef USING_CYGWIN + UNIXCOMMAND_PATH :=$(call PrefixPath,$(ALT_UNIXCOMMAND_PATH)) + else xALT_UNIXCOMMAND_PATH :="$(subst \,/,$(ALT_UNIXCOMMAND_PATH))" fxALT_UNIXCOMMAND_PATH :=$(call FullPath,$(xALT_UNIXCOMMAND_PATH)) UNIXCOMMAND_PATH :=$(call PrefixPath,$(fxALT_UNIXCOMMAND_PATH)) + endif +else + ifdef USING_CYGWIN + UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin) else - ifdef USING_CYGWIN - UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin) + ifdef USING_MSYS + UNIXCOMMAND_PATH :=$(call PrefixPath,/bin) else ifdef ROOTDIR xROOTDIR :="$(subst \,/,$(ROOTDIR))" @@ -131,41 +148,35 @@ ifndef UNIXCOMMAND_PATH ifneq ($(_rootdir),) UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt) endif - endif - endif - UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH) - export UNIXCOMMAND_PATH + endif # USING_MSYS + endif # USING_CYGWIN endif +UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH) +export UNIXCOMMAND_PATH # Get version of MKS or CYGWIN -ifdef USING_CYGWIN - ifndef CYGWIN_VER - _CYGWIN_VER :=$(shell $(UNAME)) - CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER)) - export CYGWIN_VER +ifdef USING_MKS + _MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@') + MKS_VER :=$(call GetVersion,$(_MKS_VER)) + # At this point, we can re-define FullPath to use DOSNAME_CMD + CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7) + TRY_DOSNAME:=false + ifeq ($(CHECK_MKS87),same) + TRY_DOSNAME:=true endif -else # MKS -_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@') -MKS_VER :=$(call GetVersion,$(_MKS_VER)) -# At this point, we can re-define FullPath to use DOSNAME_CMD -CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7) -TRY_DOSNAME:=false -ifeq ($(CHECK_MKS87),same) -TRY_DOSNAME:=true -endif -# Newer should be ok -ifeq ($(CHECK_MKS87),newer) -TRY_DOSNAME:=true -endif -ifeq ($(TRY_DOSNAME),true) -ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/) -_DOSNAME=$(UNIXCOMMAND_PATH)dosname -DOSNAME_CMD:=$(_DOSNAME) -s + # Newer should be ok + ifeq ($(CHECK_MKS87),newer) + TRY_DOSNAME:=true + endif + ifeq ($(TRY_DOSNAME),true) + ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/) + _DOSNAME=$(UNIXCOMMAND_PATH)dosname + DOSNAME_CMD:=$(_DOSNAME) -s define FullPath $(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL))) endef -endif # test dosname -s -endif # TRY_DOSNAME + endif # test dosname -s + endif # TRY_DOSNAME endif # MKS # We try to get references to what we need via the default component @@ -240,6 +251,8 @@ endif # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.) # NOTE: Must end with / so that it could be empty, allowing PATH usage. ifndef DEVTOOLS_PATH + # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.) + # NOTE: Must end with / so that it could be empty, allowing PATH usage. ifdef ALT_DEVTOOLS_PATH xALT_DEVTOOLS_PATH :="$(subst \,/,$(ALT_DEVTOOLS_PATH))" fxALT_DEVTOOLS_PATH :=$(call FullPath,$(xALT_DEVTOOLS_PATH)) @@ -248,10 +261,14 @@ ifndef DEVTOOLS_PATH ifdef USING_CYGWIN DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH) else - xDEVTOOLS_PATH :="$(_system_drive)/utils" - fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH)) - DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH)) - endif + ifdef USING_MSYS + DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH) + else + xDEVTOOLS_PATH :="$(_system_drive)/utils" + fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH)) + DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH)) + endif # USING_MSYS + endif # USING_CYGWIN endif DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH) export DEVTOOLS_PATH diff --git a/corba/make/common/shared/Platform.gmk b/corba/make/common/shared/Platform.gmk index 822c1e787b8..0b3edf4fa8b 100644 --- a/corba/make/common/shared/Platform.gmk +++ b/corba/make/common/shared/Platform.gmk @@ -65,6 +65,8 @@ PLATFORM_SHARED=done # REQUIRED_WINDOWS_NAME windows only: basic name of windows # REQUIRED_WINDOWS_VERSION windows only: specific version of windows # USING_CYGWIN windows only: true or false +# USING_MSYS windows only: true or false +# USING_MKS windows only: true or false # WINDOWS_NT_VERSION_STRING windows only: long version name # REQUIRED_OS_VERSION required OS version, e.g. 5.10, 2.4 # REQUIRED_FREE_SPACE minimum disk space needed for outputdir @@ -327,6 +329,8 @@ endif # Windows with and without CYGWIN will be slightly different ifeq ($(SYSTEM_UNAME), Windows_NT) PLATFORM = windows + USING_MKS = true + export USING_MKS OS_VERSION := $(shell uname -r) WINDOWS_NT_VERSION_STRING=Windows_NT REQUIRED_MKS_VER=6.1 @@ -339,6 +343,11 @@ ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME))) WINDOWS_NT_VERSION_STRING=CYGWIN_NT REQUIRED_CYGWIN_VER=4.0 endif +ifneq (,$(findstring MINGW,$(SYSTEM_UNAME))) + PLATFORM = windows + USING_MSYS = true + export USING_MSYS +endif # Platform settings specific to Windows ifeq ($(PLATFORM), windows) From 5b56f65379114f84c3ba30cd1c8ec710bbce7872 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Tue, 23 Oct 2012 10:10:49 -0700 Subject: [PATCH 54/56] 7152336: Enable builds on Windows with MinGW/MSYS Minimal makefile changes to enable building OpenJDK using MSYS on Windows7 Reviewed-by: ohair, tbell --- README-builds.html | 372 ++++++++++++++++++++++++++-------------- make/scripts/fixpath.pl | 169 ++++++++++++++++++ make/scripts/vsvars.sh | 153 +++++++++++------ 3 files changed, 515 insertions(+), 179 deletions(-) create mode 100644 make/scripts/fixpath.pl diff --git a/README-builds.html b/README-builds.html index 57ded784f9a..446588f7a36 100644 --- a/README-builds.html +++ b/README-builds.html @@ -96,7 +96,8 @@
  • Windows only:
  • @@ -161,7 +162,7 @@
    This file often describes specific requirements for what we call the "minimum build environments" (MBE) for this - specific release of the JDK, + specific release of the JDK, Building with the MBE will generate the most compatible bits that install on, and run correctly on, the most variations of the same base OS and hardware architecture. @@ -241,16 +242,16 @@

    - These same sources do indeed build on many more systems than the - above older generation systems, again the above is just a minimum. + These same sources do indeed build on many more systems than the + above older generation systems, again the above is just a minimum.

    - Compilation problems with newer or different C/C++ compilers is a - common problem. - Similarly, compilation problems related to changes to the + Compilation problems with newer or different C/C++ compilers is a + common problem. + Similarly, compilation problems related to changes to the /usr/include or system header files is also a - common problem with newer or unreleased OS versions. - Please report these types of problems as bugs so that they - can be dealt with accordingly. + common problem with newer or unreleased OS versions. + Please report these types of problems as bugs so that they + can be dealt with accordingly.


    @@ -266,15 +267,15 @@

    After installing Fedora 9 - you need to install several build dependencies. The simplest - way to do it is to execute the following commands as user + you need to install several build dependencies. The simplest + way to do it is to execute the following commands as user root:

    yum-builddep java-1.6.0-openjdk

    yum install gcc gcc-c++

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-openjdk @@ -283,15 +284,15 @@

    After installing Fedora 10 - you need to install several build dependencies. The simplest - way to do it is to execute the following commands as user + you need to install several build dependencies. The simplest + way to do it is to execute the following commands as user root:

    yum-builddep java-1.6.0-openjdk

    yum install gcc gcc-c++

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-openjdk @@ -300,15 +301,15 @@

    After installing Fedora 11 - you need to install several build dependencies. The simplest - way to do it is to execute the following commands as user + you need to install several build dependencies. The simplest + way to do it is to execute the following commands as user root:

    yum-builddep java-1.6.0-openjdk

    yum install gcc gcc-c++

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-openjdk @@ -360,16 +361,16 @@

    Debian 5.0 (Lenny)

    - After installing Debian 5 - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands as user root: + After installing Debian 5 + you need to install several build dependencies. + The simplest way to install the build dependencies is to + execute the following commands as user root:

    aptitude build-dep openjdk-6

    aptitude install openjdk-6-jdk libmotif-dev

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk

    @@ -380,52 +381,52 @@

    Ubuntu 8.04

    - After installing Ubuntu 8.04 - you need to install several build dependencies. + After installing Ubuntu 8.04 + you need to install several build dependencies.

    - First, you need to enable the universe repository in the - Software Sources application and reload the repository - information. The Software Sources application is available - under the System/Administration menu. + First, you need to enable the universe repository in the + Software Sources application and reload the repository + information. The Software Sources application is available + under the System/Administration menu.

    - The simplest way to install the build dependencies is to - execute the following commands: + The simplest way to install the build dependencies is to + execute the following commands:

    sudo aptitude build-dep openjdk-6

    sudo aptitude install openjdk-6-jdk

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk

    Ubuntu 8.10

    - After installing Ubuntu 8.10 - you need to install several build dependencies. The simplest - way to do it is to execute the following commands: + After installing Ubuntu 8.10 + you need to install several build dependencies. The simplest + way to do it is to execute the following commands:

    sudo aptitude build-dep openjdk-6

    sudo aptitude install openjdk-6-jdk

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk

    Ubuntu 9.04

    - After installing Ubuntu 9.04 - you need to install several build dependencies. The simplest - way to do it is to execute the following commands: + After installing Ubuntu 9.04 + you need to install several build dependencies. The simplest + way to do it is to execute the following commands:

    sudo aptitude build-dep openjdk-6

    sudo aptitude install openjdk-6-jdk

    - In addition, it's necessary to set a few environment variables for the build: + In addition, it's necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk

    @@ -436,20 +437,20 @@

    OpenSUSE 11.1

    - After installing OpenSUSE 11.1 - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands: + After installing OpenSUSE 11.1 + you need to install several build dependencies. + The simplest way to install the build dependencies is to + execute the following commands:

    sudo zypper source-install -d java-1_6_0-openjdk

    sudo zypper install make

    - In addition, it is necessary to set a few environment variables for the build: + In addition, it is necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-1.6.0-openjdk

    - Finally, you need to unset the JAVA_HOME environment variable: + Finally, you need to unset the JAVA_HOME environment variable:

    export -n JAVA_HOME

    @@ -460,14 +461,14 @@

    Mandriva Linux One 2009 Spring

    - After installing Mandriva Linux One 2009 Spring - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands as user root: + After installing Mandriva Linux One 2009 Spring + you need to install several build dependencies. + The simplest way to install the build dependencies is to + execute the following commands as user root:

    urpmi java-1.6.0-openjdk-devel ant make gcc gcc-c++ freetype-devel zip unzip libcups2-devel libxrender1-devel libalsa2-devel libstc++-static-devel libxtst6-devel libxi-devel

    - In addition, it is necessary to set a few environment variables for the build: + In addition, it is necessary to set a few environment variables for the build:

    export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-1.6.0-openjdk

    @@ -478,18 +479,18 @@

    OpenSolaris 2009.06

    - After installing OpenSolaris 2009.06 - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands: + After installing OpenSolaris 2009.06 + you need to install several build dependencies. + The simplest way to install the build dependencies is to + execute the following commands:

    pfexec pkg install SUNWgmake SUNWj6dev SUNWant sunstudioexpress SUNWcups SUNWzip SUNWunzip SUNWxwhl SUNWxorg-headers SUNWaudh SUNWfreetype2

    - In addition, it is necessary to set a few environment variables for the build: + In addition, it is necessary to set a few environment variables for the build:

    export LANG=C ALT_COMPILER_PATH=/opt/SunStudioExpress/bin/ ALT_CUPS_HEADERS_PATH=/usr/include/

    - Finally, you need to make sure that the build process can find the Sun Studio compilers: + Finally, you need to make sure that the build process can find the Sun Studio compilers:

    export PATH=$PATH:/opt/SunStudioExpress/bin/

    @@ -687,31 +688,20 @@
  • Windows: - Make sure you start your build inside a bash/sh/ksh shell - and are using a make.exe utility built for that - environment (a cygwin make.exe is not the same - as a make.exe built for something like - MKS). -
    - WARNING: Watch out on some make 3.81 versions, it may - not work due to a lack of support for MS-DOS drive letter paths - like C:/ or C:\. -
    - You may be able to use the information at the - - mozilla developer center - on this topic. -
    - It's hoped that when make 3.82 starts shipping in a future cygwin - release that this MS-DOS path issue will be fixed. -
    - It may be possible to download the version at - - www.cmake.org make.exe. -
    - It might be necessary for you to build your own GNU make 3.81, - see the "Building GNU make" section - in that case. + Make sure you start your build inside a bash/sh/ksh shell and are + using a make.exe utility built for that environment.
    + MKS builds need a native Windows version of GNU make + (see Building GNU make).
    + Cygwin builds need + a make version which was specially compiled for the Cygwin environment + (see Building GNU make). WARNING: + the OpenJDK build with the make utility provided by Cygwin will not + work because it does not support drive letters in paths. Make sure that + your version of make will be found before the Cygwins default make by + setting an appropriate PATH environment variable or by removing + Cygwin's make after you built your own make version.
    + MinGW/MSYS builds can use the default make which + comes with the environment.
  • @@ -727,7 +717,7 @@

    Building GNU make

    - First step is to get the GNU make 3.81 source from + First step is to get the GNU make 3.81 (or newer) source from ftp.gnu.org/pub/gnu/make/. Building is a little different depending on the OS and unix toolset @@ -742,12 +732,24 @@ ./configure && gmake CC=gcc
  • - Windows for CYGWIN: - ./configure && make + Windows for CYGWIN:
    + ./configure
    + Add the line #define HAVE_CYGWIN_SHELL 1 to the end of config.h
    + make
    +
    + This should produce make.exe in the current directory.
  • - Windows for MKS: (CYGWIN is recommended) - ./configure && make -f Makefile.win32 + Windows for MKS:
    + Edit config.h.W32 and uncomment the line #define HAVE_MKS_SHELL 1
    + Set the environment for your native compiler (e.g. by calling:
    + "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /Release /xp /x64) + nmake -f NMakefile.win32 +
    + This should produce WinDebug/make.exe and WinRel/make.exe +
    + If you get the error: NMAKE : fatal error U1045: spawn failed : Permission denied + you have to set the Read & execute permission for the file subproc.bat.
  • @@ -894,39 +896,135 @@

    Windows Paths

    Windows: - Note that GNU make is a historic utility and is based very - heavily on shell scripting, so it does not tolerate the Windows habit + Note that GNU make, the shell and other Unix-tools required during the build + do not tolerate the Windows habit of having spaces in pathnames or the use of the \characters in pathnames. - Luckily on most Windows systems, you can use /instead of \, and - there is always a 'short' pathname without spaces for any path that - contains spaces. - Unfortunately, this short pathname can be somewhat dynamic and the - formula is difficult to explain. - You can use cygpath utility to map pathnames with spaces - or the \character into the C:/ style of pathname - (called 'mixed'), e.g. - cygpath -s -m "path". + Luckily on most Windows systems, you can use /instead of \, and + there is always a short + "8.3" pathname without spaces for any path that contains spaces. + Unfortunately, this short pathname is somewhat dynamic (i.e. dependant on the + other files and directories inside a given directory) and can not be + algorithmicly calculated by only looking at a specific path name.

    The makefiles will try to translate any pathnames supplied to it into the C:/ style automatically. +

    - Note that use of CYGWIN creates a unique problem with regards to + Special care has to be taken if native Windows applications + like nmake or cl are called with file arguments processed + by Unix-tools like make or sh! +

    +
    + +

    Windows build environments

    +
    + Building on Windows requires a Unix-like environment, notably a Unix-like shell. + There are several such environments available of which + MKS, + Cygwin and + MinGW/MSYS are currently supported for + the OpenJDK build. One of the differences of these three systems is the way + they handle Windows path names, particularly path names which contain + spaces, backslashes as path separators and possibly drive letters. Depending + on the use case and the specifics of each environment these path problems can + be solved by a combination of quoting whole paths, translating backslashes to + forward slashes, escaping backslashes with additional backslashes and + translating the path names to their + "8.3" version. +

    + As of this writing (MKS ver. 9.4, Cygwin ver. 1.7.9, MinGW/MSYS 1.0.17), + MKS builds are known to be the fastest Windows builds while MingGW/MSYS + builds are slightly slower (about 10%) than MKS builds and Cygwin builds + require nearly twice the time (about 180%) of MKS builds (e.g. on a + DualCore i7 notebook with 8GB of RAM, HDD and 64-bit Windows 7 operating system + the complete OpenJDK 8 product build takes about 49min with MKS, 54min with + MinGW/MSYS and 88min with Cygwin). +

    +

    + Mixing tools from the different Unix emulation environments is not a good + idea and will probably not work! +

    +

    + MKS: is a commercial product which includes + all the Unix utilities which are required to build the OpenJDK except GNU + make. In pre-OpenJDK times it was the only supported build environment on + Windows. The MKS tools support Windows paths with drive letters and + forward slashes as path separator. Paths in environment variables like (for + example) PATH are separated by semicolon ';'. +

    +

    + Recent versions of MKS provide the dosname utility to convert paths + with spaces to short (8.3) path names,e .g. + dosname -s "path". +

    +

    + If you are using the MKS environment, you need a native Windows version + of Gnu make which you can easily build yourself. +

    +

    + Cygwin: + is an open source, Linux-like environment which tries to emulate + a complete POSIX layer on Windows. It tries to be smart about path names + and can usually handle all kinds of paths if they are correctly quoted + or escaped although internally it maps drive letters <drive>: + to a virtual directory /cygdrive/<drive>. +

    +

    + You can always use the cygpath utility to map pathnames with spaces + or the backslash character into the C:/ style of pathname + (called 'mixed'), e.g. cygpath -s -m "path". +

    +

    + Note that the use of CYGWIN creates a unique problem with regards to setting PATH. Normally on Windows the PATH variable contains directories - separated with the ";" character (Solaris and Linux uses ":"). + separated with the ";" character (Solaris and Linux use ":"). With CYGWIN, it uses ":", but that means that paths like "C:/path" cannot be placed in the CYGWIN version of PATH and instead CYGWIN uses something like /cygdrive/c/path which CYGWIN understands, but only CYGWIN understands. - So be careful with paths on Windows. +

    +

    + If you are using the Cygwin environment, you need to + compile your own version + of GNU make because the default Cygwin make can not handle drive letters in paths. +

    +

    + MinGW/MSYS: + MinGW ("Minimalist GNU for Windows") is a collection of free Windows + specific header files and import libraries combined with GNU toolsets that + allow one to produce native Windows programs that do not rely on any + 3rd-party C runtime DLLs. MSYS is a supplement to MinGW which allows building + applications and programs which rely on traditional UNIX tools to + be present. Among others this includes tools like bash and make. +

    +

    + Like Cygwin, MinGW/MSYS can handle different types of path formats. They + are internally converted to paths with forward slashes and drive letters + <drive>: replaced by a virtual + directory /<drive>. Additionally, MSYS automatically + detects binaries compiled for the MSYS environment and feeds them with the + internal, Unix-style path names. If native Windows applications are called + from within MSYS programs their path arguments are automatically converted + back to Windows style path names with drive letters and backslashes as + path separators. This may cause problems for Windows applications which + use forward slashes as parameter separator (e.g. cl /nologo /I) + because MSYS may wrongly + replace such parameters by drive letters. +

    +

    + If you are using the MinGW/MSYS system you can use the default make + version supplied by the environment. +

    Basic Windows Check List

    1. - Install the - CYGWIN product. + Install one of the + CYGWIN, MinGW/MSYS or + MKS environments.
    2. Install the @@ -1097,9 +1195,9 @@ Sun Studio 12 Update 1 Compilers (containing version 5.10 of the C and C++ compilers) is required, - including specific patches. + including specific patches.

      - The Solaris SPARC patch list is: + The Solaris SPARC patch list is:

      • 118683-05: SunOS 5.10: Patch for profiling libraries and assembler @@ -1286,7 +1384,8 @@ The XRender header file is included with the other X11 header files in the package SFWxwinc on new enough versions of Solaris and will be installed in - /usr/X11/include/X11/extensions/Xrender.h + /usr/X11/include/X11/extensions/Xrender.h or + /usr/openwin/share/include/X11/extensions/Xrender.h

        Linux: XRender header files are required for building the @@ -1456,7 +1555,9 @@ Devel make The GNU version of the 'make' utility built for CYGWIN.
        - NOTE: See the GNU make section + NOTE: the Cygwin make can not be used to build the + OpenJDK. You only need it to build your own version of make + (see the GNU make section) m4.exe @@ -1521,6 +1622,21 @@ So it's important that the Visual Studio paths in PATH preceed the CYGWIN path /usr/bin.

    + Minimalist GNU for Windows (MinGW/MSYS) +
    + Alternatively, the set of unix command tools for the OpenJDK build on + Windows can be supplied by + MinGW/MSYS. +

    + In addition to the tools which will be installed by default, you have + to manually install the msys-zip and msys-unzip packages. + This can be easily done with the MinGW command line installer:
    +
    + mingw-get.exe install msys-zip
    + mingw-get.exe install msys-unzip
    +
    +

    +
    Microsoft DirectX 9.0 SDK header files and libraries
    Microsoft DirectX 9.0 SDK (Summer 2004) @@ -1781,10 +1897,10 @@
    ALT_OPENWIN_HOME
    - The top-level directory of the libraries and include files for the platform's - graphical programming environment. The default location is platform specific. - For example, on Linux it defaults to /usr/X11R6/. -
    + The top-level directory of the libraries and include files for the platform's + graphical programming environment. The default location is platform specific. + For example, on Linux it defaults to /usr/X11R6/. +
    Windows specific:
    @@ -1792,9 +1908,9 @@
    The location of the Microsoft Windows SDK where some tools will be - located. - The default is whatever WINDOWSSDKDIR is set to - (or WindowsSdkDir) or the path + located. + The default is whatever WINDOWSSDKDIR is set to + (or WindowsSdkDir) or the path
    c:\Program Files\Microsoft SDKs\Windows\v7.0a
    @@ -1823,17 +1939,17 @@ is that ALT_COMPILER_PATH is set to point to the cross-compiler and that any cross-compilation specific flags are passed using EXTRA_CFLAGS. - The ALT_OPENWIN_HOME variable should - also be set to point to the graphical header files (e.g. X11) provided with - the cross-compiler. + The ALT_OPENWIN_HOME variable should + also be set to point to the graphical header files (e.g. X11) provided with + the cross-compiler. When cross-compiling we skip execution of any demos etc that may be built, and also skip binary-file verification.
    EXTRA_CFLAGS
    - Used to pass cross-compilation options to the cross-compiler. + Used to pass cross-compilation options to the cross-compiler. These are added to the CFLAGS and CXXFLAGS variables. -
    +
    USE_ONLY_BOOTDIR_TOOLS
    Used primarily for cross-compilation builds (and always set in that case) @@ -1868,23 +1984,23 @@
    BUILD_HEADLESS_ONLY
    Used when the build environment has no graphical capabilities at all. This - excludes building anything that requires graphical libraries to be available. + excludes building anything that requires graphical libraries to be available.
    JAVASE_EMBEDDED
    - Used to indicate this is a build of the Oracle Java SE Embedded product. - This will enable the directives included in the SE-Embedded specific build - files. + Used to indicate this is a build of the Oracle Java SE Embedded product. + This will enable the directives included in the SE-Embedded specific build + files.
    LIBZIP_CAN_USE_MMAP
    - If set to false, disables the use of mmap by the zip utility. Otherwise, - mmap will be used. + If set to false, disables the use of mmap by the zip utility. Otherwise, + mmap will be used.
    COMPRESS_JARS
    - If set to true, causes certain jar files that would otherwise be built without - compression, to use compression. + If set to true, causes certain jar files that would otherwise be built without + compression, to use compression.
    diff --git a/make/scripts/fixpath.pl b/make/scripts/fixpath.pl new file mode 100644 index 00000000000..36ec981cdf5 --- /dev/null +++ b/make/scripts/fixpath.pl @@ -0,0 +1,169 @@ +#!/bin/perl + +# +# Copyright (c) 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. +# + +# Crunch down the input(s) to Windows short (mangled) form. +# Any elements not actually found in the filesystem will be dropped. +# +# This script needs three modes: +# 1) DOS mode with drive letter followed by : and ; path separator +# 2) Cygwin mode with /cygdrive// and : path separator +# 3) MinGW/MSYS mode with // and : path separator + +use strict; +use warnings; +use Getopt::Std; + +sub Usage() { + print ("Usage:\n $0 -d | -c | -m \\n"); + print (" -d DOS style (drive letter, :, and ; path separator)\n"); + print (" -c Cywgin style (/cygdrive/drive/ and : path separator)\n"); + print (" -m MinGW style (/drive/ and : path separator)\n"); + exit 1; +} +# Process command line options: +my %opts; +getopts('dcm', \%opts) || Usage(); + +if (scalar(@ARGV) != 1) {Usage()}; + +# Translate drive letters such as C:/ +# if MSDOS, Win32::GetShortPathName() does the work (see below). +# if Cygwin, use the /cygdrive/c/ form. +# if MinGW, use the /c/ form. +my $path0; +my $sep2; +if (defined ($opts{'d'})) { + #MSDOS + $path0 = ''; + $sep2 = ';'; +} elsif (defined ($opts{'c'})) { + #Cygwin + $path0 = '/cygdrive'; + $sep2 = ':'; +} elsif (defined ($opts{'m'})) { + #MinGW/MSYS + $path0 = ''; + $sep2 = ':'; +} else { + Usage(); +} + +my $input = $ARGV[0]; +my $sep1; + +# Is the input ';' separated, or ':' separated, or a simple string? +if (($input =~ tr/;/;/) > 0) { + # One or more ';' implies Windows style path. + $sep1 = ';'; +} elsif (($input =~ tr/:/:/) > 1) { + # Two or more ':' implies Cygwin or MinGW/MSYS style path. + $sep1 = ':'; +} else { + # Otherwise, this is not a path - take up to the end of string in + # one piece. + $sep1 = '/$/'; +} + +# Split the input on $sep1 PATH separator and process the pieces. +my @pieces; +for (split($sep1, $input)) { + my $try = $_; + + if (($try =~ /^\/cygdrive\/(.)\/(.*)$/) || ($try =~ /^\/(.)\/(.*)$/)) { + # Special case #1: This is a Cygwin /cygrive/ 1)) { + $result = join ($sep2, @pieces); +} else { + $result = $pieces[0]; +} + +if (defined ($result)) { + + # Change all '\' to '/' + $result =~ s/\\/\//g; + + # Remove duplicate '/' + $result =~ s/\/\//\//g; + + # Map to lower case + $result =~ tr/A-Z/a-z/; + + print ("$result\n"); +} diff --git a/make/scripts/vsvars.sh b/make/scripts/vsvars.sh index 369a04a9ec3..928777cb54f 100644 --- a/make/scripts/vsvars.sh +++ b/make/scripts/vsvars.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 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 @@ -27,22 +27,6 @@ # variables normally set by the vcvars32.bat or vcvars64.bat file or # SetEnv.cmd for older SDKs. -# Use cygpath? -isCygwin="`uname -s | grep CYGWIN`" -if [ "${isCygwin}" != "" ] ; then - cygpath="/usr/bin/cygpath" - cygpath_short="${cygpath} -m -s" - cygpath_windows="${cygpath} -w -s" - cygpath_path="${cygpath} -p" - pathsep=':' -else - cygpath="dosname" - cygpath_short="${cygpath} -s" - cygpath_windows="${cygpath} -s" - cygpath_path="echo" - pathsep=';' -fi - ######################################################################## # Error functions msg() # message @@ -60,8 +44,8 @@ warning() # message } envpath() # path { - if [ "${cygpath_short}" != "" -a -d "$1" ] ; then - ${cygpath_short} "$1" + if [ "${fixpath}" != "" -a -d "$1" ] ; then + ${fixpath} "$1" else echo "$1" fi @@ -72,14 +56,65 @@ envpath() # path # Defaults settings debug="false" verbose="false" -shellStyle="sh" -parentCsh="` ps -p ${PPID} 2> /dev/null | grep csh `" -if [ "${parentCsh}" != "" ] ; then - shellStyle="csh" -fi set -e +CYGWIN="nodosfilewarning ntsec" +export CYGWIN + +# pathsepIn is always ; because the input strings are coming from +# vcvarsxx.bat. This is true under all of MKS, Cygwin, MINGW/msys +pathsepIn=';' + +OS="`uname -s`" +case "${OS}" in + CYGWIN*) + pathflag='-c' + devnull=/dev/null + pathsepOut=':' + ;; + + MINGW*) + pathflag='-m' + devnull=/dev/null + pathsepOut=':' + ;; + + *) + # MKS? + # Continue using dosname -s + pathflag='-s' + fixpath="dosname ${pathflag}" + fixpath_windows="${fixpath}" + fixpath_path="echo" + devnull=NUL + pathsepOut=';' + ;; +esac + +case "${OS}" in + CYGWIN*|MINGW*) + t=`dirname ${0}` + wd=`cd ${t} 2> ${devnull} && pwd` + fixpath_script="${wd}/fixpath.pl" + if [ ! -f "${fixpath_script}" ] ; then + error "Does not exist: ${fixpath_script}" + fi + fixpath="perl ${fixpath_script} ${pathflag}" + fixpath_windows="perl ${fixpath_script} -d" + fixpath_path="${fixpath_windows}" + ;; +esac + +shellStyle="sh" +## As far as I can tell from hg history, this has not worked +## for a long time because PPID is unset. When run under Cygwin +## the script quits due to the 1 return from grep. +##parentCsh="` ps -p ${PPID} 2> ${devnull} | grep csh `" +##if [ "${parentCsh}" != "" ] ; then +## shellStyle="csh" +##fi + # Check environment first if [ "${PROGRAMFILES}" != "" ] ; then progfiles=`envpath "${PROGRAMFILES}"` @@ -96,15 +131,19 @@ fi # Arch data model if [ "${PROCESSOR_IDENTIFIER}" != "" ] ; then arch=`echo "${PROCESSOR_IDENTIFIER}" | cut -d' ' -f1` -elif [ "${MACHTYPE}" != "" ] ; then - if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then - # Assume this is X64, not IA64 - arch="x64" - else - arch="x86" - fi else - arch="`uname -m`" + if [ "${MACHTYPE}" != "" ] ; then + if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then + # Assume this is X64, not IA64 + arch="x64" + else + arch="x86" + fi + else + arch="`uname -m`" + fi + PROCESSOR_IDENTIFIER="${arch}" + export PROCESSOR_IDENTIFIER fi if [ "${arch}" = "X86" -o \ "${arch}" = "386" -o "${arch}" = "i386" -o \ @@ -121,11 +160,11 @@ if [ "${arch}" = "X64" -o \ "${arch}" = "intel64" -o "${arch}" = "Intel64" -o \ "${arch}" = "64" ] ; then arch="x64" - binarch64="/amd64" + binarch64="\\amd64" fi if [ "${arch}" = "IA64" ] ; then arch="ia64" - binarch64="/ia64" + binarch64="\\ia64" fi if [ "${arch}" != "x86" -a "${arch}" != "x64" -a "${arch}" != "ia64" ] ; then error "No PROCESSOR_IDENTIFIER or MACHTYPE environment variables and uname -m is not helping" @@ -324,25 +363,26 @@ checkPaths() # var path sep } # Remove all duplicate entries -removeDeadDups() # string sep +removeDeadDups() # string sepIn sepOut { set -e - sep="$2" + sepIn="$2" + sepOut="$3" pathlist="${tmp}/pathlist" printf "%s\n" "$1" | \ sed -e 's@\\@/@g' | \ sed -e 's@//@/@g' | \ - ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \ + ${awk} -F"${sepIn}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \ > ${pathlist} upaths="${tmp}/upaths" cat ${pathlist} | while read orig; do p="${orig}" - if [ "${cygpath_short}" != "" ] ; then + if [ "${fixpath}" != "" ] ; then if [ "${p}" != "" ] ; then if [ -d "${p}" ] ; then - short=`${cygpath_short} "${p}"` + short=`${fixpath} "${p}"` if [ "${short}" != "" -a -d "${short}" ] ; then - p=`${cygpath} "${short}"` + p="${short}" fi echo "${p}" >> ${upaths} fi @@ -356,11 +396,11 @@ removeDeadDups() # string sep if [ "${newpaths}" = "" ] ; then newpaths="${i}" else - newpaths="${newpaths}${sep}${i}" + newpaths="${newpaths}${sepOut}${i}" fi done printf "%s\n" "${newpaths}" | \ - ${awk} -F"${sep}" \ + ${awk} -F"${sepOut}" \ '{a[$1];printf "%s",$1;for(i=2;i<=NF;i++){if(!($i in a)){a[$i];printf "%s%s",FS,$i;}};printf "\n";}' } @@ -388,7 +428,7 @@ set VCINSTALLDIR= set VSINSTALLDIR= set WindowsSdkDir= REM Run the vcvars bat file, send all output to stderr -call `${cygpath_windows} ${bdir}`\\${command} > `${cygpath_windows} "${stdout}"` +call `${fixpath_windows} ${bdir}`\\${command} > `${fixpath_windows} "${stdout}"` REM Echo out env var settings echo VS_VS71COMNTOOLS="%VS71COMNTOOLS%" echo export VS_VS71COMNTOOLS @@ -427,9 +467,18 @@ EOF # Create env file createEnv() # batfile envfile { - rm -f ${1}.stdout - cmd.exe /Q /C `${cygpath_short} $1` | \ - sed -e 's@\\@/@g' | \ + rm -f ${1}.stdout ${1}.temp1 ${1}.temp2 + batfile=`${fixpath} ${1}` + cmd.exe -Q -C < "$batfile" 1> ${1}.temp1 2> ${1}.temp2 + cat ${1}.temp1 | \ + sed -e 's@^Microsoft.*@@' \ + -e 's@^.*Copyright.*@@' \ + -e 's@^.*>REM.*@@' \ + -e 's@^.*>set.*@@' \ + -e 's@^.*>echo.*@@' \ + -e 's@^.*>call.*@@' \ + -e 's@^.*>$@@' \ + -e 's@\\@/@g' | \ sed -e 's@//@/@g' > $2 if [ -f "${1}.stdout" ] ; then cat ${1}.stdout 1>&2 @@ -465,7 +514,7 @@ printEnv() # name pname vsname val ############################################################################# # Get Visual Studio settings -if [ "${cygpath}" != "" ] ; then +if [ "${fixpath}" != "" ] ; then # Create bat file to run batfile="${tmp}/vs-to-env.bat" @@ -485,11 +534,11 @@ if [ "${cygpath}" != "" ] ; then . ${envfile} # Derive unix style path, save old, and define new (remove dups) - VS_UPATH=`${cygpath_path} "${VS_WPATH}"` + VS_UPATH=`${fixpath_path} "${VS_WPATH}"` export VS_UPATH VS_OPATH=`printf "%s" "${PATH}" | sed -e 's@\\\\@/@g'` export VS_OPATH - VS_PATH=`removeDeadDups "${VS_UPATH}${pathsep}${VS_OPATH}" "${pathsep}"` + VS_PATH=`removeDeadDups "${VS_UPATH}${pathsepIn}${VS_OPATH}" "${pathsepIn}" "${pathsepOut}"` export VS_PATH fi @@ -536,11 +585,13 @@ if [ "${verbose}" = "true" ] ; then checkPaths "Windows PATH" "${VS_WPATH}" ";" checkPaths LIB "${VS_LIB}" ";" checkPaths INCLUDE "${VS_INCLUDE}" ";" - checkPaths PATH "${VS_PATH}" "${pathsep}" + checkPaths PATH "${VS_PATH}" "${pathsepIn}" fi # Remove all temp files -rm -f -r ${tmp} +if [ "${debug}" != "true" ] ; then + rm -f -r ${tmp} +fi exit 0 From 919df15706b94e44d261ee1ee6f09f5de33cd71a Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:26:11 +0200 Subject: [PATCH 55/56] Added tag jdk8-b61 for changeset cdaa6122185f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index fde585f8bbb..bf173376ee4 100644 --- a/.hgtags +++ b/.hgtags @@ -182,3 +182,4 @@ ffe6bce5a521be40146af2ac03c509b7bac30595 jdk8-b56 479d3302a26d7607ba271d66973e59ebf58825b6 jdk8-b58 3bd874584fc01aae92fbc8827e2bd04d8b6ace04 jdk8-b59 5e3adc681779037a2d33b7be6f75680619085492 jdk8-b60 +cdaa6122185f9bf512dcd6600f56bfccc4824e8c jdk8-b61 From bb35ccdbc39d8f72d3346e3a9f167e58a58ea2d9 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 25 Oct 2012 09:54:03 -0700 Subject: [PATCH 56/56] Added tag jdk8-b62 for changeset f0d59eea9c70 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index c0a4c320b0f..de1a543ff2e 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -183,3 +183,4 @@ d94613ac03d8de375ef60493e2bb76dbd30d875d jdk8-b58 abad1f417bd3df4296631fc943cd3b7f5062c88a jdk8-b59 cec8fa02f15634acd7d02d04b0b2d8c044cdbaaa jdk8-b60 61ddb3fd000a09ab05bff1940b0ac211661e94cf jdk8-b61 +50b8b17449d200c66bfd68fb4f3a9197432c9e2b jdk8-b62