From bb6c34adc762828c5dcb2822e70b06cf8696b198 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 12 Mar 2013 18:12:42 +0530 Subject: [PATCH 001/155] 8009757: Package access clean up and refactoring Reviewed-by: jlaskey, lagergren, attila --- .../docs/JavaScriptingProgrammersGuide.html | 8 +-- nashorn/docs/source/javaarray.js | 3 +- nashorn/make/build.xml | 4 +- nashorn/make/java.security.override | 4 +- .../scripting/NashornScriptEngineFactory.java | 10 ++++ .../nashorn/api/scripting/ScriptUtils.java | 48 +++++++++++++++ .../jdk/nashorn/internal/objects/Global.java | 24 +++++++- .../nashorn/internal/objects/NativeDebug.java | 2 +- .../nashorn/internal/objects/NativeJava.java | 17 ++++++ .../jdk/nashorn/internal/runtime/Context.java | 25 ++++++-- .../internal/runtime/NashornLoader.java | 47 ++++++++++++++- .../internal/runtime/ScriptLoader.java | 7 ++- .../internal/runtime/StructureLoader.java | 3 +- .../internal/runtime/linker/Bootstrap.java | 2 +- .../runtime/linker/JavaAdapterFactory.java | 28 ++++++++- .../runtime/linker/ReflectionCheckLinker.java | 60 +++++++++++++++++++ .../runtime/resources/mozilla_compat.js | 18 +++--- .../internal/runtime/resources/parser.js | 10 ++-- nashorn/test/script/basic/JDK-8008448.js | 4 +- nashorn/test/script/basic/NASHORN-401.js | 2 +- nashorn/test/script/basic/consstring.js | 2 +- nashorn/test/script/basic/fileline.js | 4 +- nashorn/test/script/basic/javainnerclasses.js | 18 +++--- nashorn/test/script/basic/list.js | 2 +- nashorn/test/script/basic/map.js | 2 +- nashorn/test/script/basic/stdin.js | 6 +- nashorn/test/script/sandbox/javaextend.js | 2 +- .../script/sandbox/javaextend.js.EXPECTED | 6 +- nashorn/test/script/sandbox/reflection.js | 4 +- .../script/sandbox/reflection.js.EXPECTED | 1 - nashorn/test/script/sandbox/unsafe.js | 4 +- .../test/script/sandbox/unsafe.js.EXPECTED | 4 -- nashorn/test/script/trusted/urlreader.js | 6 +- .../api/scripting/ScriptEngineTest.java | 52 ---------------- .../runtime/TrustedScriptEngineTest.java | 31 +++++++++- .../test/models/ConstructorWithArgument.java | 2 +- .../test/models/DessertTopping.java | 2 +- .../models/DessertToppingFloorWaxDriver.java | 2 +- .../test/models/FinalClass.java | 2 +- .../{internal => }/test/models/FloorWax.java | 2 +- .../models}/Nashorn401TestSubject.java | 2 +- .../models/NoAccessibleConstructorClass.java | 2 +- .../test/models/NonPublicClass.java | 2 +- .../test/models/OuterClass.java | 2 +- .../test/models/OverloadedSam.java | 2 +- .../test/models/OverrideObject.java | 2 +- .../jdk/nashorn/test/models/SourceHelper.java | 55 +++++++++++++++++ .../test/models/StringArgs.java | 2 +- .../test/models/Toothpaste.java | 2 +- 49 files changed, 409 insertions(+), 142 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java delete mode 100644 nashorn/test/script/sandbox/reflection.js.EXPECTED delete mode 100644 nashorn/test/script/sandbox/unsafe.js.EXPECTED rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/ConstructorWithArgument.java (97%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/DessertTopping.java (96%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/DessertToppingFloorWaxDriver.java (97%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/FinalClass.java (96%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/FloorWax.java (96%) rename nashorn/test/src/jdk/nashorn/{internal/runtime => test/models}/Nashorn401TestSubject.java (97%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/NoAccessibleConstructorClass.java (96%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/NonPublicClass.java (96%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/OuterClass.java (98%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/OverloadedSam.java (96%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/OverrideObject.java (97%) create mode 100644 nashorn/test/src/jdk/nashorn/test/models/SourceHelper.java rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/StringArgs.java (97%) rename nashorn/test/src/jdk/nashorn/{internal => }/test/models/Toothpaste.java (97%) diff --git a/nashorn/docs/JavaScriptingProgrammersGuide.html b/nashorn/docs/JavaScriptingProgrammersGuide.html index cf248140c15..dd243d3aa3c 100644 --- a/nashorn/docs/JavaScriptingProgrammersGuide.html +++ b/nashorn/docs/JavaScriptingProgrammersGuide.html @@ -533,9 +533,8 @@ with (SwingGui) {

Creating, Converting and Using Java Arrays

-

While creating a Java object is the same as in Java, to create -Java arrays in JavaScript we can use Java reflection -explicitly. But once created the element access or length access is +

+Array element access or length access is the same as in Java. Also, a script array can be used when a Java method expects a Java array (auto conversion). So in most cases we don't have to create Java arrays explicitly.

@@ -543,7 +542,8 @@ don't have to create Java arrays explicitly.

// javaarray.js // create Java String array of 5 elements -var a = java.lang.reflect.Array.newInstance(java.lang.String.class, 5); +var StringArray = Java.type("java.lang.String[]"); +var a = new StringArray(5); // Accessing elements and length access is by usual Java syntax a[0] = "scripting is great!"; diff --git a/nashorn/docs/source/javaarray.js b/nashorn/docs/source/javaarray.js index b9d93f0d42c..a02aa3ca9f6 100644 --- a/nashorn/docs/source/javaarray.js +++ b/nashorn/docs/source/javaarray.js @@ -30,7 +30,8 @@ */ // create Java String array of 5 elements -var a = java.lang.reflect.Array.newInstance(java.lang.String.class, 5); +var StringArray = Java.type("java.lang.String[]"); +var a = new StringArray(5); // Accessing elements and length access is by usual Java syntax a[0] = "scripting is great!"; diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 34f56e4602b..e2d8f0ccb31 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -191,12 +191,12 @@ - + - + diff --git a/nashorn/make/java.security.override b/nashorn/make/java.security.override index 0021985287e..a7edf33b5ee 100644 --- a/nashorn/make/java.security.override +++ b/nashorn/make/java.security.override @@ -3,7 +3,7 @@ # We ensure that by overriding "package.access" security property. # The following "package.access" value was copied from default java.security -# of jre/lib/security and appended with nashorn IR, Codegen and Parser packages. +# of jre/lib/security and appended with nashorn sensitive packages. # # List of comma-separated packages that start with or equal this string @@ -11,4 +11,4 @@ # 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.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.,jdk.internal.,jdk.nashorn.internal.ir., jdk.nashorn.internal.codegen., jdk.nashorn.internal.lookup., jdk.nashorn.internal.parser. +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.,jdk.internal.,jdk.nashorn.internal.,jdk.nashorn.tools. diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java index 47a0c595236..4672f6a073e 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java @@ -147,6 +147,7 @@ public final class NashornScriptEngineFactory implements ScriptEngineFactory { * @return newly created script engine. */ public ScriptEngine getScriptEngine(final ClassLoader appLoader) { + checkConfigPermission(); return new NashornScriptEngine(this, appLoader); } @@ -157,6 +158,7 @@ public final class NashornScriptEngineFactory implements ScriptEngineFactory { * @return newly created script engine. */ public ScriptEngine getScriptEngine(final String[] args) { + checkConfigPermission(); return new NashornScriptEngine(this, args, getAppClassLoader()); } @@ -168,11 +170,19 @@ public final class NashornScriptEngineFactory implements ScriptEngineFactory { * @return newly created script engine. */ public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader) { + checkConfigPermission(); return new NashornScriptEngine(this, args, appLoader); } // -- Internals only below this point + private void checkConfigPermission() { + final SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("nashorn.setConfig")); + } + } + private static final List names; private static final List mimeTypes; private static final List extensions; diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java new file mode 100644 index 00000000000..63358bd7db9 --- /dev/null +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.api.scripting; + +import jdk.nashorn.internal.runtime.ScriptRuntime; + +/** + * Utilities that are to be called from script code + */ +public final class ScriptUtils { + private ScriptUtils() {} + + /** + * Returns AST as JSON compatible string. This is used to + * implement "parse" function in resources/parse.js script. + * + * @param code code to be parsed + * @param name name of the code source (used for location) + * @param includeLoc tells whether to include location information for nodes or not + * @return JSON string representation of AST of the supplied code + */ + public static String parse(final String code, final String name, final boolean includeLoc) { + return ScriptRuntime.parse(code, name, includeLoc); + } +} diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index b89d207344b..a9835f6fea9 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -34,6 +34,9 @@ import java.io.PrintWriter; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.ref.SoftReference; +import java.lang.reflect.Field; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -1503,8 +1506,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value); // Nashorn extension: global.$OPTIONS (scripting-mode-only) - value = context.getEnv(); - addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, value); + final ScriptObject options = newEmptyInstance(); + final ScriptEnvironment scriptEnv = context.getEnv(); + copyOptions(options, scriptEnv); + addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options); // Nashorn extension: global.$ENV (scripting-mode-only) if (System.getSecurityManager() == null) { @@ -1523,6 +1528,21 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); } + private void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + for (Field f : scriptEnv.getClass().getFields()) { + try { + options.set(f.getName(), f.get(scriptEnv), false); + } catch (final IllegalArgumentException | IllegalAccessException exp) { + throw new RuntimeException(exp); + } + } + return null; + } + }); + } + private void initTypedArray() { this.builtinArrayBuffer = initConstructor("ArrayBuffer"); this.builtinInt8Array = initConstructor("Int8Array"); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java index 3d6fcbc8e7a..8188f426f23 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java @@ -66,7 +66,7 @@ public final class NativeDebug extends ScriptObject { public static Object getContext(final Object self) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPermission(new RuntimePermission("getNashornContext")); + sm.checkPermission(new RuntimePermission("nashorn.getContext")); } return Global.getThisContext(); } diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java index fc16962e185..2519c0284fd 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java @@ -222,6 +222,23 @@ public final class NativeJava { return simpleType(typeName); } + /** + * Returns name of a java type {@link StaticClass}. + * @param self not used + * @param type the type whose name is returned + * @return name of the given type + */ + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) + public static Object typeName(final Object self, final Object type) { + if (type instanceof StaticClass) { + return ((StaticClass)type).getRepresentedClass().getName(); + } else if (type instanceof Class) { + return ((Class)type).getName(); + } else { + return UNDEFINED; + } + } + /** * Given a JavaScript array and a Java type, returns a Java array with the same initial contents, and with the * specified component type. Example: diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 1c4a08c843b..516c0a79892 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -39,10 +39,13 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.Constructor; import java.net.MalformedURLException; import java.net.URL; +import java.security.AccessControlContext; import java.security.AccessController; import java.security.CodeSigner; import java.security.CodeSource; +import java.security.Permissions; import java.security.PrivilegedAction; +import java.security.ProtectionDomain; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.util.CheckClassAdapter; import jdk.nashorn.internal.codegen.Compiler; @@ -123,7 +126,7 @@ public final class Context { if (callerLoader != myLoader && !(callerLoader instanceof StructureLoader) && !(JavaAdapterFactory.isAdapterClass(caller))) { - sm.checkPermission(new RuntimePermission("getNashornGlobal")); + sm.checkPermission(new RuntimePermission("nashorn.getGlobal")); } } @@ -137,7 +140,7 @@ public final class Context { public static void setGlobal(final ScriptObject global) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPermission(new RuntimePermission("setNashornGlobal")); + sm.checkPermission(new RuntimePermission("nashorn.setGlobal")); } if (global != null && !(global instanceof GlobalObject)) { @@ -154,7 +157,7 @@ public final class Context { public static Context getContext() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPermission(new RuntimePermission("getNashornContext")); + sm.checkPermission(new RuntimePermission("nashorn.getContext")); } return getContextTrusted(); } @@ -267,7 +270,7 @@ public final class Context { public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPermission(new RuntimePermission("createNashornContext")); + sm.checkPermission(new RuntimePermission("nashorn.createContext")); } this.env = new ScriptEnvironment(options, out, err); @@ -533,7 +536,13 @@ public final class Context { if (index != -1) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPackageAccess(fullName.substring(0, index)); + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + sm.checkPackageAccess(fullName.substring(0, index)); + return null; + } + }, createNoPermissionsContext()); } } @@ -599,7 +608,7 @@ public final class Context { public ScriptObject newGlobal() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPermission(new RuntimePermission("createNashornGlobal")); + sm.checkPermission(new RuntimePermission("nashorn.newGlobal")); } return newGlobalTrusted(); @@ -676,6 +685,10 @@ public final class Context { return (context != null) ? context : Context.getContextTrusted(); } + private static AccessControlContext createNoPermissionsContext() { + return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, new Permissions()) }); + } + private Object evaluateSource(final Source source, final ScriptObject scope, final ScriptObject thiz) { ScriptFunction script = null; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java b/nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java index 80a0b8e6ef1..5ce31008088 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java @@ -30,6 +30,10 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; import java.security.SecureClassLoader; import jdk.nashorn.tools.Shell; @@ -40,6 +44,28 @@ import jdk.nashorn.tools.Shell; * */ abstract class NashornLoader extends SecureClassLoader { + private static final String OBJECTS_PKG = "jdk.nashorn.internal.objects"; + private static final String RUNTIME_PKG = "jdk.nashorn.internal.runtime"; + private static final String RUNTIME_LINKER_PKG = "jdk.nashorn.internal.runtime.linker"; + private static final String SCRIPTS_PKG = "jdk.nashorn.internal.scripts"; + + private static final Permission[] SCRIPT_PERMISSIONS; + static { + SCRIPT_PERMISSIONS = new Permission[4]; + + /* + * Generated classes get access to runtime, runtime.linker, objects, scripts packages. + * Note that the actual scripts can not access these because Java.type, Packages + * prevent these restricted packages. And Java reflection and JSR292 access is prevented + * for scripts. In other words, nashorn generated portions of script classes can access + * clases in these implementation packages. + */ + SCRIPT_PERMISSIONS[0] = new RuntimePermission("accessClassInPackage." + RUNTIME_PKG); + SCRIPT_PERMISSIONS[1] = new RuntimePermission("accessClassInPackage." + RUNTIME_LINKER_PKG); + SCRIPT_PERMISSIONS[2] = new RuntimePermission("accessClassInPackage." + OBJECTS_PKG); + SCRIPT_PERMISSIONS[3] = new RuntimePermission("accessClassInPackage." + SCRIPTS_PKG); + } + private final Context context; final Context getContext() { @@ -68,11 +94,30 @@ abstract class NashornLoader extends SecureClassLoader { if (i != -1) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { - sm.checkPackageAccess(name.substring(0, i)); + final String pkgName = name.substring(0, i); + switch (pkgName) { + case RUNTIME_PKG: + case RUNTIME_LINKER_PKG: + case OBJECTS_PKG: + case SCRIPTS_PKG: + // allow it. + break; + default: + sm.checkPackageAccess(pkgName); + } } } } + @Override + protected PermissionCollection getPermissions(CodeSource codesource) { + final Permissions permCollection = new Permissions(); + for (final Permission perm : SCRIPT_PERMISSIONS) { + permCollection.add(perm); + } + return permCollection; + } + /** * Create a secure URL class loader for the given classpath * @param classPath classpath for the loader to search from diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java index d632166270a..adecd8a3cbe 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java @@ -26,6 +26,7 @@ package jdk.nashorn.internal.runtime; import java.security.CodeSource; +import java.security.ProtectionDomain; /** * Responsible for loading script generated classes. @@ -57,6 +58,10 @@ final class ScriptLoader extends NashornLoader { * @return Installed class. */ synchronized Class installClass(final String name, final byte[] data, final CodeSource cs) { - return defineClass(name, data, 0, data.length, cs); + if (cs == null) { + return defineClass(name, data, 0, data.length, new ProtectionDomain(null, getPermissions(null))); + } else { + return defineClass(name, data, 0, data.length, cs); + } } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java b/nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java index da64655f9a5..35786b0b85f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java @@ -38,6 +38,7 @@ import java.security.CodeSigner; import java.security.CodeSource; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.security.ProtectionDomain; import jdk.nashorn.internal.codegen.ObjectClassGenerator; /** @@ -129,6 +130,6 @@ final class StructureLoader extends NashornLoader { } final byte[] code = new ObjectClassGenerator(context).generate(descriptor); - return defineClass(name, code, 0, code.length); + return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null))); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java index 3c5e2d81b51..6b55656ba17 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java @@ -57,7 +57,7 @@ public final class Bootstrap { static { final DynamicLinkerFactory factory = new DynamicLinkerFactory(); factory.setPrioritizedLinkers(new NashornLinker(), new NashornPrimitiveLinker(), new NashornStaticClassLinker(), - new JSObjectLinker()); + new JSObjectLinker(), new ReflectionCheckLinker()); factory.setFallbackLinkers(new BeansLinker(), new NashornBottomLinker()); factory.setSyncOnRelink(true); final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java index a9e4bd01469..ba599da1a98 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java @@ -54,6 +54,7 @@ import java.security.CodeSigner; import java.security.CodeSource; import java.security.Permissions; import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; import java.security.SecureClassLoader; import java.security.SecureRandom; @@ -410,9 +411,13 @@ public final class JavaAdapterFactory { */ public static MethodHandle getConstructor(final Class sourceType, final Class targetType) throws Exception { final StaticClass adapterClass = getAdapterClassFor(new Class[] { targetType }); - return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get( - "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, - adapterClass, null)).getInvocation(), adapterClass); + return AccessController.doPrivileged(new PrivilegedExceptionAction() { + public MethodHandle run() throws Exception { + return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get( + "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, + adapterClass, null)).getInvocation(), adapterClass); + } + }); } /** @@ -456,8 +461,25 @@ public final class JavaAdapterFactory { private static ClassLoader createClassLoader(final ClassLoader parentLoader, final String className, final byte[] classBytes, final String privilegedActionClassName) { return new AdapterLoader(parentLoader) { + private final ClassLoader myLoader = getClass().getClassLoader(); private final ProtectionDomain myProtectionDomain = getClass().getProtectionDomain(); + @Override + public Class loadClass(final String name, final boolean resolve) throws ClassNotFoundException { + try { + return super.loadClass(name, resolve); + } catch (final SecurityException se) { + // we may be implementing an interface or extending a class that was + // loaded by a loader that prevents package.access. If so, it'd throw + // SecurityException for nashorn's classes!. For adapter's to work, we + // should be able to refer to nashorn classes. + if (name.startsWith("jdk.nashorn.internal.")) { + return myLoader.loadClass(name); + } + throw se; + } + } + @Override protected Class findClass(final String name) throws ClassNotFoundException { if(name.equals(className)) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java new file mode 100644 index 00000000000..eb8837a8d70 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.runtime.linker; + +import jdk.internal.dynalink.linker.GuardedInvocation; +import jdk.internal.dynalink.linker.LinkRequest; +import jdk.internal.dynalink.linker.LinkerServices; +import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; + +/** + * Check java reflection permission for java reflective and java.lang.invoke access from scripts + */ +final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ + @Override + public boolean canLinkType(final Class type) { + return canLinkTypeStatic(type); + } + + private static boolean canLinkTypeStatic(final Class type) { + if (type == Class.class || ClassLoader.class.isAssignableFrom(type)) { + return true; + } + final String name = type.getName(); + return name.startsWith("java.lang.reflect.") || name.startsWith("java.lang.invoke."); + } + + @Override + public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices) + throws Exception { + final SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("nashorn.JavaReflection")); + } + // let the next linker deal with actual linking + return null; + } +} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js index 15c67f9419b..0b967d69a8d 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, 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. @@ -34,7 +34,7 @@ Object.defineProperty(this, "JavaAdapter", { if (arguments.length < 2) { throw new TypeError("JavaAdapter requires atleast two arguments"); } - + var types = Array.prototype.slice.call(arguments, 0, arguments.length - 1); var NewType = Java.extend.apply(Java, types); return new NewType(arguments[arguments.length - 1]); @@ -56,10 +56,10 @@ Object.defineProperty(this, "importPackage", { return type; } catch (e) {} } - + return oldNoSuchProperty? oldNoSuchProperty(name) : undefined; } - + var prefix = "[JavaPackage "; return function() { for (var i in arguments) { @@ -343,7 +343,9 @@ Object.defineProperty(this, "importClass", { configurable: true, enumerable: false, writable: true, value: function(clazz) { if (Java.isType(clazz)) { - this[clazz.class.getSimpleName()] = clazz; + var className = Java.typeName(clazz); + var simpleName = className.substring(className.lastIndexOf('.') + 1); + this[simpleName] = clazz; } else { throw new TypeError(clazz + " is not a Java class"); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js index b89f7e12873..8671d365902 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, 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. @@ -47,7 +47,7 @@ function parse(/*code, [name], [location]*/) { code = arguments[0]; } - var jsonStr = Packages.jdk.nashorn.internal.runtime.ScriptRuntime.parse(code, name, location); + var jsonStr = Packages.jdk.nashorn.api.scripting.ScriptUtils.parse(code, name, location); return JSON.parse(jsonStr, function (prop, value) { if (typeof(value) == 'string' && prop == "value") { diff --git a/nashorn/test/script/basic/JDK-8008448.js b/nashorn/test/script/basic/JDK-8008448.js index d5ffbd4c729..b30e3417b54 100644 --- a/nashorn/test/script/basic/JDK-8008448.js +++ b/nashorn/test/script/basic/JDK-8008448.js @@ -32,7 +32,7 @@ var File = Java.type("java.io.File"); var FilenameFilter = Java.type("java.io.FilenameFilter"); -var Source = Java.type("jdk.nashorn.internal.runtime.Source") +var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper") // Filter out non .js files var files = new File(__DIR__).listFiles(new FilenameFilter() { @@ -44,5 +44,5 @@ load("nashorn:parser.js"); // parse each file to make sure it does not result in exception for each (var f in files) { - parse(new Source(f.toString(), f).getString()); + parse(SourceHelper.readFully(f)); } diff --git a/nashorn/test/script/basic/NASHORN-401.js b/nashorn/test/script/basic/NASHORN-401.js index b6058a9bdc1..6a663e1a178 100644 --- a/nashorn/test/script/basic/NASHORN-401.js +++ b/nashorn/test/script/basic/NASHORN-401.js @@ -28,7 +28,7 @@ * @run */ -var t = new Packages.jdk.nashorn.internal.runtime.Nashorn401TestSubject(); +var t = new Packages.jdk.nashorn.test.models.Nashorn401TestSubject(); print(t.method2(10)); print(t.method2(10.2)); diff --git a/nashorn/test/script/basic/consstring.js b/nashorn/test/script/basic/consstring.js index b8dc51d88f5..0cc8b1f8c17 100644 --- a/nashorn/test/script/basic/consstring.js +++ b/nashorn/test/script/basic/consstring.js @@ -37,4 +37,4 @@ list.add(String(new String(str + "2"))); // String() called as function with list.add((str + "3").toString()); // toString() called on primitive string list.add(new String(str + "4").toString()); // toString() called on String object -Packages.jdk.nashorn.internal.test.models.StringArgs.checkString(list); +Packages.jdk.nashorn.test.models.StringArgs.checkString(list); diff --git a/nashorn/test/script/basic/fileline.js b/nashorn/test/script/basic/fileline.js index 3323a12640e..ccf879b2454 100644 --- a/nashorn/test/script/basic/fileline.js +++ b/nashorn/test/script/basic/fileline.js @@ -41,8 +41,8 @@ print(file + " : " + __LINE__); load(__DIR__ + "loadedfile.js"); // Add check for base part of a URL. We can't test __DIR__ inside -// a script that is downloaded from a URL. check for Source.baseURL +// a script that is downloaded from a URL. check for SourceHelper.baseURL // which is exposed as __DIR__ for URL case. var url = new java.net.URL("http://www.acme.com:8080/foo/bar.js"); -print(Packages.jdk.nashorn.internal.runtime.Source.baseURL(url)); +print(Packages.jdk.nashorn.test.models.SourceHelper.baseURL(url)); diff --git a/nashorn/test/script/basic/javainnerclasses.js b/nashorn/test/script/basic/javainnerclasses.js index df1e74df191..c84571d718f 100644 --- a/nashorn/test/script/basic/javainnerclasses.js +++ b/nashorn/test/script/basic/javainnerclasses.js @@ -29,25 +29,25 @@ */ // Do it with Java.type() -var outer = new (Java.type("jdk.nashorn.internal.test.models.OuterClass"))("apple") +var outer = new (Java.type("jdk.nashorn.test.models.OuterClass"))("apple") print(outer) -var innerStatic = new (Java.type("jdk.nashorn.internal.test.models.OuterClass$InnerStaticClass"))("orange") +var innerStatic = new (Java.type("jdk.nashorn.test.models.OuterClass$InnerStaticClass"))("orange") print(innerStatic) -var innerNonStatic = new (Java.type("jdk.nashorn.internal.test.models.OuterClass$InnerNonStaticClass"))(outer, "pear") +var innerNonStatic = new (Java.type("jdk.nashorn.test.models.OuterClass$InnerNonStaticClass"))(outer, "pear") print(innerNonStatic) // Now do it with Packages and explicit $ names -var outer = new Packages.jdk.nashorn.internal.test.models.OuterClass("red") +var outer = new Packages.jdk.nashorn.test.models.OuterClass("red") print(outer) -var innerStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass$InnerStaticClass("green") +var innerStatic = new Packages.jdk.nashorn.test.models.OuterClass$InnerStaticClass("green") print(innerStatic) -var innerNonStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass$InnerNonStaticClass(outer, "blue") +var innerNonStatic = new Packages.jdk.nashorn.test.models.OuterClass$InnerNonStaticClass(outer, "blue") print(innerNonStatic) // Now do it with Packages and nested properties -var outer = new Packages.jdk.nashorn.internal.test.models.OuterClass("sweet") +var outer = new Packages.jdk.nashorn.test.models.OuterClass("sweet") print(outer) -var innerStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass.InnerStaticClass("sour") +var innerStatic = new Packages.jdk.nashorn.test.models.OuterClass.InnerStaticClass("sour") print(innerStatic) -var innerNonStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass.InnerNonStaticClass(outer, "bitter") +var innerNonStatic = new Packages.jdk.nashorn.test.models.OuterClass.InnerNonStaticClass(outer, "bitter") print(innerNonStatic) diff --git a/nashorn/test/script/basic/list.js b/nashorn/test/script/basic/list.js index 12e4071b6aa..72ae0be7617 100644 --- a/nashorn/test/script/basic/list.js +++ b/nashorn/test/script/basic/list.js @@ -28,7 +28,7 @@ * @run */ var l = new java.util.ArrayList(); -print("l.class.name=" + l.class.name) // Has "class" property like any POJO +print("l.class.name=" + Java.typeName(l.class)) // Has "class" property like any POJO l.add("foo") l.add("bar") diff --git a/nashorn/test/script/basic/map.js b/nashorn/test/script/basic/map.js index 2ab27aba9cb..c024f6eb17a 100644 --- a/nashorn/test/script/basic/map.js +++ b/nashorn/test/script/basic/map.js @@ -28,7 +28,7 @@ * @run */ var m = new (Java.type("java.util.LinkedHashMap")); -print("m.class.name=" + m.class.name) // Has "class" property like any POJO +print("m.class.name=" + Java.typeName(m.class)) // Has "class" property like any POJO var empty_key = "empty" diff --git a/nashorn/test/script/basic/stdin.js b/nashorn/test/script/basic/stdin.js index ba546d5967f..a3a93324be2 100644 --- a/nashorn/test/script/basic/stdin.js +++ b/nashorn/test/script/basic/stdin.js @@ -28,8 +28,8 @@ * @run */ -print(java.lang.System.in.class.name); +print(Java.typeName(java.lang.System.in.class)); var prop = "in"; -print(java.lang.System[prop].class.name); -print(java.lang.System["in"].class.name); +print(Java.typeName(java.lang.System[prop].class)); +print(Java.typeName(java.lang.System["in"].class)); diff --git a/nashorn/test/script/sandbox/javaextend.js b/nashorn/test/script/sandbox/javaextend.js index 318a679417f..33cc6b01fa0 100644 --- a/nashorn/test/script/sandbox/javaextend.js +++ b/nashorn/test/script/sandbox/javaextend.js @@ -27,7 +27,7 @@ */ function model(n) { - return Java.type("jdk.nashorn.internal.test.models." + n) + return Java.type("jdk.nashorn.test.models." + n) } // Can't extend a final class diff --git a/nashorn/test/script/sandbox/javaextend.js.EXPECTED b/nashorn/test/script/sandbox/javaextend.js.EXPECTED index 2a5ad63a5e1..69c7818929c 100644 --- a/nashorn/test/script/sandbox/javaextend.js.EXPECTED +++ b/nashorn/test/script/sandbox/javaextend.js.EXPECTED @@ -1,6 +1,6 @@ -TypeError: Can not extend final class jdk.nashorn.internal.test.models.FinalClass. -TypeError: Can not extend class jdk.nashorn.internal.test.models.NoAccessibleConstructorClass as it has no public or protected constructors. -TypeError: Can not extend/implement non-public class/interface jdk.nashorn.internal.test.models.NonPublicClass. +TypeError: Can not extend final class jdk.nashorn.test.models.FinalClass. +TypeError: Can not extend class jdk.nashorn.test.models.NoAccessibleConstructorClass as it has no public or protected constructors. +TypeError: Can not extend/implement non-public class/interface jdk.nashorn.test.models.NonPublicClass. TypeError: Can not extend multiple classes java.lang.Number and java.lang.Thread. At most one of the specified types can be a class, the rest must all be interfaces. abcdabcd run-object diff --git a/nashorn/test/script/sandbox/reflection.js b/nashorn/test/script/sandbox/reflection.js index 7364879ddd9..e892c646d44 100644 --- a/nashorn/test/script/sandbox/reflection.js +++ b/nashorn/test/script/sandbox/reflection.js @@ -30,9 +30,7 @@ */ function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { + if (! (e instanceof java.lang.SecurityException)) { fail("expected SecurityException, got " + e); } } diff --git a/nashorn/test/script/sandbox/reflection.js.EXPECTED b/nashorn/test/script/sandbox/reflection.js.EXPECTED deleted file mode 100644 index 202333ead8a..00000000000 --- a/nashorn/test/script/sandbox/reflection.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers") diff --git a/nashorn/test/script/sandbox/unsafe.js b/nashorn/test/script/sandbox/unsafe.js index b273cd0b709..6b3f43af6a5 100644 --- a/nashorn/test/script/sandbox/unsafe.js +++ b/nashorn/test/script/sandbox/unsafe.js @@ -30,9 +30,7 @@ */ function check(e) { - if (e instanceof java.lang.SecurityException) { - print(e); - } else { + if (! (e instanceof java.lang.SecurityException)) { fail("expected SecurityException, got " + e); } } diff --git a/nashorn/test/script/sandbox/unsafe.js.EXPECTED b/nashorn/test/script/sandbox/unsafe.js.EXPECTED deleted file mode 100644 index 3f1cbec0a80..00000000000 --- a/nashorn/test/script/sandbox/unsafe.js.EXPECTED +++ /dev/null @@ -1,4 +0,0 @@ -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun") -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader") diff --git a/nashorn/test/script/trusted/urlreader.js b/nashorn/test/script/trusted/urlreader.js index a5e06ee5328..ca037306df6 100644 --- a/nashorn/test/script/trusted/urlreader.js +++ b/nashorn/test/script/trusted/urlreader.js @@ -9,7 +9,7 @@ var URLReader = Java.type("jdk.nashorn.api.scripting.URLReader"); var URL = Java.type("java.net.URL"); var File = Java.type("java.io.File"); var JString = Java.type("java.lang.String"); -var Source = Java.type("jdk.nashorn.internal.runtime.Source"); +var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper"); var url = new File(__FILE__).toURI().toURL(); var reader = new URLReader(url); @@ -19,9 +19,9 @@ var reader = new URLReader(url); // check URL read // read URL content by directly reading from URL -var str = new Source(url.toString(), url).getString(); +var str = SourceHelper.readFully(url); // read URL content via URLReader -var content = new JString(Source.readFully(reader)); +var content = new JString(SourceHelper.readFully(reader)); // assert that the content is same Assert.assertEquals(str, content); diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index f4fd114fa89..0994b0d26ca 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -47,7 +47,6 @@ import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.script.SimpleScriptContext; -import jdk.nashorn.internal.runtime.Version; import netscape.javascript.JSObject; import org.testng.Assert; import org.testng.annotations.Test; @@ -129,7 +128,6 @@ public class ScriptEngineTest { assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript"); assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1"); assertEquals(fac.getEngineName(), "Oracle Nashorn"); - assertEquals(fac.getEngineVersion(), Version.version()); assertEquals(fac.getOutputStatement("context"), "print(context)"); assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');"); assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript"); @@ -313,27 +311,6 @@ public class ScriptEngineTest { } } - public static void alert(final Object msg) { - System.out.println(msg); - } - - @Test - public void exposeMethodTest() { - final ScriptEngineManager m = new ScriptEngineManager(); - final ScriptEngine e = m.getEngineByName("nashorn"); - - try { - final Method alert = ScriptEngineTest.class.getMethod("alert", Object.class); - // expose a Method object as global var. - e.put("alert", alert); - // call the global var. - e.eval("alert.invoke(null, 'alert! alert!!')"); - } catch (final NoSuchMethodException | SecurityException | ScriptException exp) { - exp.printStackTrace(); - fail(exp.getMessage()); - } - } - @Test public void putGlobalFunctionTest() { final ScriptEngineManager m = new ScriptEngineManager(); @@ -592,13 +569,6 @@ public class ScriptEngineTest { } } - @Test - public void versionTest() { - final ScriptEngineManager m = new ScriptEngineManager(); - final ScriptEngine e = m.getEngineByName("nashorn"); - assertEquals(e.getFactory().getEngineVersion(), Version.version()); - } - @Test public void noEnumerablePropertiesTest() { final ScriptEngineManager m = new ScriptEngineManager(); @@ -874,26 +844,4 @@ public class ScriptEngineTest { fail(se.getMessage()); } } - - @Test - public void factoryOptionsTest() { - final ScriptEngineManager sm = new ScriptEngineManager(); - for (ScriptEngineFactory fac : sm.getEngineFactories()) { - if (fac instanceof NashornScriptEngineFactory) { - final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac; - // specify --no-syntax-extensions flag - final String[] options = new String[] { "--no-syntax-extensions" }; - final ScriptEngine e = nfac.getScriptEngine(options); - try { - // try nashorn specific extension - e.eval("var f = funtion(x) 2*x;"); - fail("should have thrown exception!"); - } catch (final ScriptException se) { - } - return; - } - } - - fail("Cannot find nashorn factory!"); - } } diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java index 0f147562fea..0f740a483c6 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java @@ -25,7 +25,7 @@ package jdk.nashorn.internal.runtime; - +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -40,6 +40,13 @@ import org.testng.annotations.Test; * Tests for trusted client usage of nashorn script engine factory extension API */ public class TrustedScriptEngineTest { + @Test + public void versionTest() { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + assertEquals(e.getFactory().getEngineVersion(), Version.version()); + } + private static class MyClassLoader extends ClassLoader { // to check if script engine uses the specified class loader private final boolean[] reached = new boolean[1]; @@ -116,4 +123,26 @@ public class TrustedScriptEngineTest { fail("Cannot find nashorn factory!"); } + + @Test + public void factoryOptionsTest() { + final ScriptEngineManager sm = new ScriptEngineManager(); + for (ScriptEngineFactory fac : sm.getEngineFactories()) { + if (fac instanceof NashornScriptEngineFactory) { + final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac; + // specify --no-syntax-extensions flag + final String[] options = new String[] { "--no-syntax-extensions" }; + final ScriptEngine e = nfac.getScriptEngine(options); + try { + // try nashorn specific extension + e.eval("var f = funtion(x) 2*x;"); + fail("should have thrown exception!"); + } catch (final ScriptException se) { + } + return; + } + } + + fail("Cannot find nashorn factory!"); + } } diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/ConstructorWithArgument.java b/nashorn/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/test/models/ConstructorWithArgument.java rename to nashorn/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java index ba4a21637d0..9a201575aa5 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/ConstructorWithArgument.java +++ b/nashorn/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public abstract class ConstructorWithArgument { private final String token; diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/DessertTopping.java b/nashorn/test/src/jdk/nashorn/test/models/DessertTopping.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/internal/test/models/DessertTopping.java rename to nashorn/test/src/jdk/nashorn/test/models/DessertTopping.java index 8427c837548..591e032d147 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/DessertTopping.java +++ b/nashorn/test/src/jdk/nashorn/test/models/DessertTopping.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public interface DessertTopping { public String pourOnDessert(); diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/DessertToppingFloorWaxDriver.java b/nashorn/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/test/models/DessertToppingFloorWaxDriver.java rename to nashorn/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java index dc04a0d1059..856029add5f 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/DessertToppingFloorWaxDriver.java +++ b/nashorn/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public class DessertToppingFloorWaxDriver { public void decorateDessert(DessertTopping dt) { diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/FinalClass.java b/nashorn/test/src/jdk/nashorn/test/models/FinalClass.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/internal/test/models/FinalClass.java rename to nashorn/test/src/jdk/nashorn/test/models/FinalClass.java index b20257cb81c..8a3e8432b2b 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/FinalClass.java +++ b/nashorn/test/src/jdk/nashorn/test/models/FinalClass.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public final class FinalClass { //empty diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/FloorWax.java b/nashorn/test/src/jdk/nashorn/test/models/FloorWax.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/internal/test/models/FloorWax.java rename to nashorn/test/src/jdk/nashorn/test/models/FloorWax.java index c094ccf65a1..44ac96e90cb 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/FloorWax.java +++ b/nashorn/test/src/jdk/nashorn/test/models/FloorWax.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public interface FloorWax { public String shineUpTheFloor(); diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/Nashorn401TestSubject.java b/nashorn/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/runtime/Nashorn401TestSubject.java rename to nashorn/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java index ed6475de942..2e7d9c6c8ae 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/Nashorn401TestSubject.java +++ b/nashorn/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.runtime; +package jdk.nashorn.test.models; public class Nashorn401TestSubject { public String method2(int arg) { diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/NoAccessibleConstructorClass.java b/nashorn/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/internal/test/models/NoAccessibleConstructorClass.java rename to nashorn/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java index c79edfbb96e..f0ddb1aab62 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/NoAccessibleConstructorClass.java +++ b/nashorn/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public class NoAccessibleConstructorClass { NoAccessibleConstructorClass() { } diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/NonPublicClass.java b/nashorn/test/src/jdk/nashorn/test/models/NonPublicClass.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/internal/test/models/NonPublicClass.java rename to nashorn/test/src/jdk/nashorn/test/models/NonPublicClass.java index 046cdf244ab..d0a61856c38 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/NonPublicClass.java +++ b/nashorn/test/src/jdk/nashorn/test/models/NonPublicClass.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; class NonPublicClass { public NonPublicClass() { } diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/OuterClass.java b/nashorn/test/src/jdk/nashorn/test/models/OuterClass.java similarity index 98% rename from nashorn/test/src/jdk/nashorn/internal/test/models/OuterClass.java rename to nashorn/test/src/jdk/nashorn/test/models/OuterClass.java index cb9484b94ca..5db86f28c1b 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/OuterClass.java +++ b/nashorn/test/src/jdk/nashorn/test/models/OuterClass.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public class OuterClass { private final String value; diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/OverloadedSam.java b/nashorn/test/src/jdk/nashorn/test/models/OverloadedSam.java similarity index 96% rename from nashorn/test/src/jdk/nashorn/internal/test/models/OverloadedSam.java rename to nashorn/test/src/jdk/nashorn/test/models/OverloadedSam.java index c63da54c2b8..05736bcab3a 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/OverloadedSam.java +++ b/nashorn/test/src/jdk/nashorn/test/models/OverloadedSam.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public interface OverloadedSam { public void sam(String s); diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/OverrideObject.java b/nashorn/test/src/jdk/nashorn/test/models/OverrideObject.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/test/models/OverrideObject.java rename to nashorn/test/src/jdk/nashorn/test/models/OverrideObject.java index 40cf7f97a6e..5312ffbb0f9 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/OverrideObject.java +++ b/nashorn/test/src/jdk/nashorn/test/models/OverrideObject.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public class OverrideObject { @Override diff --git a/nashorn/test/src/jdk/nashorn/test/models/SourceHelper.java b/nashorn/test/src/jdk/nashorn/test/models/SourceHelper.java new file mode 100644 index 00000000000..46b1e488170 --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/test/models/SourceHelper.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.test.models; + +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.net.URL; +import jdk.nashorn.internal.runtime.Source; + +/** + * Helper class to facilitate script access of nashorn Source class. + */ +public final class SourceHelper { + private SourceHelper() {} + + public static String baseURL(final URL url) { + return Source.baseURL(url); + } + + public static String readFully(final File file) throws IOException { + return new String(Source.readFully(file)); + } + + public static String readFully(final URL url) throws IOException { + return new Source(url.toString(), url).getString(); + } + + public static String readFully(final Reader reader) throws IOException { + return new String(Source.readFully(reader)); + } +} diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/StringArgs.java b/nashorn/test/src/jdk/nashorn/test/models/StringArgs.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/test/models/StringArgs.java rename to nashorn/test/src/jdk/nashorn/test/models/StringArgs.java index 8ecdbfd3a4b..1fdcd5dedb5 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/StringArgs.java +++ b/nashorn/test/src/jdk/nashorn/test/models/StringArgs.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; import java.util.List; diff --git a/nashorn/test/src/jdk/nashorn/internal/test/models/Toothpaste.java b/nashorn/test/src/jdk/nashorn/test/models/Toothpaste.java similarity index 97% rename from nashorn/test/src/jdk/nashorn/internal/test/models/Toothpaste.java rename to nashorn/test/src/jdk/nashorn/test/models/Toothpaste.java index 0946eb35078..7eae95f33e6 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/models/Toothpaste.java +++ b/nashorn/test/src/jdk/nashorn/test/models/Toothpaste.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.nashorn.internal.test.models; +package jdk.nashorn.test.models; public abstract class Toothpaste { public void applyToBrush() { From 1af08ef100641385501f65459f0c90c5c88f45f4 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Tue, 12 Mar 2013 15:30:53 +0100 Subject: [PATCH 002/155] 8009718: Lazy execution architecture continued - ScriptFunctionData is either final or recompilable. Moved ScriptFunctionData creation logic away from runtime to compile time. Prepared for method generation/specialization. Got rid of ScriptFunctionImplTrampoline whose semantics could be done as part of the relinking anyway. Merge with the lookup package change Reviewed-by: attila, jlaskey --- .../jdk/nashorn/internal/codegen/Attr.java | 143 ++- .../internal/codegen/BranchOptimizer.java | 1 - .../internal/codegen/CodeGenerator.java | 47 +- .../internal/codegen/CompilationPhase.java | 51 +- .../nashorn/internal/codegen/CompileUnit.java | 20 + .../nashorn/internal/codegen/Compiler.java | 181 ++- .../internal/codegen/FinalizeTypes.java | 14 +- .../internal/codegen/FoldConstants.java | 16 + .../internal/codegen/FunctionSignature.java | 10 +- .../jdk/nashorn/internal/codegen/Lower.java | 5 +- .../nashorn/internal/codegen/Splitter.java | 10 +- .../nashorn/internal/codegen/types/Type.java | 15 +- .../src/jdk/nashorn/internal/ir/Block.java | 19 +- .../jdk/nashorn/internal/ir/FunctionNode.java | 50 +- .../jdk/nashorn/internal/ir/ObjectNode.java | 21 +- .../jdk/nashorn/internal/ir/UnaryNode.java | 6 +- .../internal/ir/annotations/ChildNode.java | 42 - .../internal/ir/annotations/ParentNode.java | 44 - .../internal/ir/annotations/Reference.java | 1 - .../nashorn/internal/ir/debug/ASTWriter.java | 38 +- .../nashorn/internal/objects/NativeArray.java | 4 +- .../nashorn/internal/objects/NativeDebug.java | 15 - .../nashorn/internal/objects/NativeError.java | 2 +- .../internal/objects/ScriptFunctionImpl.java | 11 +- .../objects/ScriptFunctionTrampolineImpl.java | 122 -- .../nashorn/internal/parser/JSONParser.java | 2 +- .../jdk/nashorn/internal/parser/Parser.java | 200 ++-- .../internal/runtime/AccessorProperty.java | 4 +- .../internal/runtime/CodeInstaller.java | 6 +- .../internal/runtime/CompiledFunction.java | 162 +++ .../internal/runtime/CompiledFunctions.java | 73 ++ .../jdk/nashorn/internal/runtime/Context.java | 2 +- .../internal/runtime/ECMAException.java | 2 +- .../runtime/FinalScriptFunctionData.java | 100 ++ .../RecompilableScriptFunctionData.java | 185 +++ .../internal/runtime/ScriptEnvironment.java | 4 + .../internal/runtime/ScriptFunction.java | 115 +- .../internal/runtime/ScriptFunctionData.java | 1019 +++++++---------- .../runtime/SpecializedMethodChooser.java | 99 -- .../linker/JavaArgumentConverters.java | 2 +- .../runtime/linker/NashornGuards.java | 39 - .../runtime/options/OptionTemplate.java | 2 +- .../runtime/resources/Options.properties | 6 + .../script/currently-failing/JDK-8006529.js | 13 +- .../test/script/currently-failing/clone_ir.js | 100 ++ 45 files changed, 1658 insertions(+), 1365 deletions(-) delete mode 100644 nashorn/src/jdk/nashorn/internal/ir/annotations/ChildNode.java delete mode 100644 nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java delete mode 100644 nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionTrampolineImpl.java create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java delete mode 100644 nashorn/src/jdk/nashorn/internal/runtime/SpecializedMethodChooser.java create mode 100644 nashorn/test/script/currently-failing/clone_ir.js diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java index 211140e4123..a441ef4d94c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java @@ -42,6 +42,7 @@ import static jdk.nashorn.internal.ir.Symbol.IS_VAR; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -51,6 +52,7 @@ import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.CallNode.EvalArgs; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.CaseNode; import jdk.nashorn.internal.ir.CatchNode; import jdk.nashorn.internal.ir.ForNode; @@ -332,8 +334,14 @@ final class Attr extends NodeOperatorVisitor { functionNode.setNeedsSelfSymbol(functionNode.getSelfSymbolInit().accept(this)); } + if (functionNode.hasLazyChildren()) { + objectifySymbols(functionNode); + } + functionNode.popFrame(); + functionNode.setState(CompilationState.ATTR); + end(functionNode, false); return null; @@ -957,20 +965,17 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveBIT_AND(final BinaryNode binaryNode) { - newTemporary(Type.INT, binaryNode); - return binaryNode; + return end(coerce(binaryNode, Type.INT)); } @Override public Node leaveBIT_OR(final BinaryNode binaryNode) { - newTemporary(Type.INT, binaryNode); - return binaryNode; + return end(coerce(binaryNode, Type.INT)); } @Override public Node leaveBIT_XOR(final BinaryNode binaryNode) { - newTemporary(Type.INT, binaryNode); - return binaryNode; + return end(coerce(binaryNode, Type.INT)); } @Override @@ -1002,14 +1007,28 @@ final class Attr extends NodeOperatorVisitor { return binaryNode; } + private Node coerce(final BinaryNode binaryNode, final Type operandType, final Type destType) { + // TODO we currently don't support changing inferred type based on uses, only on + // definitions. we would need some additional logic. We probably want to do that + // in the future, if e.g. a specialized method gets parameter that is only used + // as, say, an int : function(x) { return x & 4711 }, and x is not defined in + // the function. to make this work, uncomment the following two type inferences + // and debug. + + //newType(binaryNode.lhs().getSymbol(), operandType); + //newType(binaryNode.rhs().getSymbol(), operandType); + newTemporary(destType, binaryNode); + return binaryNode; + } + + private Node coerce(final BinaryNode binaryNode, final Type type) { + return coerce(binaryNode, type, type); + } + //leave a binary node and inherit the widest type of lhs , rhs private Node leaveBinaryArithmetic(final BinaryNode binaryNode) { - if (!Compiler.shouldUseIntegerArithmetic()) { - newTemporary(Type.NUMBER, binaryNode); - return binaryNode; - } - newTemporary(Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType(), Type.NUMBER), binaryNode); - return binaryNode; + assert !Compiler.shouldUseIntegerArithmetic(); + return end(coerce(binaryNode, Type.NUMBER)); } @Override @@ -1089,23 +1108,17 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveSAR(final BinaryNode binaryNode) { - newTemporary(Type.INT, binaryNode); - end(binaryNode); - return binaryNode; + return end(coerce(binaryNode, Type.INT)); } @Override public Node leaveSHL(final BinaryNode binaryNode) { - newTemporary(Type.INT, binaryNode); - end(binaryNode); - return binaryNode; + return end(coerce(binaryNode, Type.INT)); } @Override public Node leaveSHR(final BinaryNode binaryNode) { - newTemporary(Type.LONG, binaryNode); - end(binaryNode); - return binaryNode; + return end(coerce(binaryNode, Type.LONG)); } @Override @@ -1211,11 +1224,17 @@ final class Attr extends NodeOperatorVisitor { // type or its parameters with the widest (OBJECT) type for safety. functionNode.setReturnType(Type.UNKNOWN); - for (final IdentNode ident : functionNode.getParameters()) { - addLocalDef(ident.getName()); - final Symbol paramSymbol = functionNode.defineSymbol(ident.getName(), IS_PARAM, ident); + for (final IdentNode param : functionNode.getParameters()) { + addLocalDef(param.getName()); + final Symbol paramSymbol = functionNode.defineSymbol(param.getName(), IS_PARAM, param); if (paramSymbol != null) { - newType(paramSymbol, Type.UNKNOWN); + final Type callSiteParamType = functionNode.getSpecializedType(param); + if (callSiteParamType != null) { + LOG.info("Param " + paramSymbol + " has a callsite type " + callSiteParamType + ". Using that."); + + System.err.println("Param " + param + " has a callsite type " + callSiteParamType + ". Using that."); + } + newType(paramSymbol, callSiteParamType == null ? Type.UNKNOWN : callSiteParamType); } LOG.info("Initialized param " + paramSymbol); @@ -1229,36 +1248,29 @@ final class Attr extends NodeOperatorVisitor { * @param functionNode functionNode */ private static void finalizeParameters(final FunctionNode functionNode) { - boolean nonObjectParams = false; - List paramSpecializations = new ArrayList<>(); + final boolean isVarArg = functionNode.isVarArg(); for (final IdentNode ident : functionNode.getParameters()) { final Symbol paramSymbol = ident.getSymbol(); - if (paramSymbol != null) { - Type type = paramSymbol.getSymbolType(); - if (type.isUnknown()) { - type = Type.OBJECT; - } - paramSpecializations.add(type); - if (!type.isObject()) { - nonObjectParams = true; - } - newType(paramSymbol, Type.OBJECT); + + assert paramSymbol != null; + Type type = functionNode.getSpecializedType(ident); + if (type == null) { + type = Type.OBJECT; } - } - if (!nonObjectParams) { - paramSpecializations = null; - // Later, when resolving a call to this method, the linker can say "I have a double, an int and an object" as parameters - // here. If the callee has parameter specializations, we can regenerate it with those particular types for speed. - } else { - LOG.info("parameter specialization possible: " + functionNode.getName() + " " + paramSpecializations); - } + // if we know that a parameter is only used as a certain type throughout + // this function, we can tell the runtime system that no matter what the + // call site is, use this information. TODO + if (!paramSymbol.getSymbolType().isObject()) { + LOG.finest("Parameter " + ident + " could profit from specialization to " + paramSymbol.getSymbolType()); + } - // parameters should not be slots for a function that uses variable arity signature - if (functionNode.isVarArg()) { - for (final IdentNode param : functionNode.getParameters()) { - param.getSymbol().setNeedsSlot(false); + newType(paramSymbol, Type.widest(type, paramSymbol.getSymbolType())); + + // parameters should not be slots for a function that uses variable arity signature + if (isVarArg) { + paramSymbol.setNeedsSlot(false); } } } @@ -1548,6 +1560,39 @@ final class Attr extends NodeOperatorVisitor { localUses.add(name); } + /** + * Pessimistically promote all symbols in current function node to Object types + * This is done when the function contains unevaluated black boxes such as + * lazy sub-function nodes that have not been compiled. + * + * @param functionNode function node in whose scope symbols should conservatively be made objects + */ + private static void objectifySymbols(final FunctionNode functionNode) { + functionNode.accept(new NodeVisitor() { + private void toObject(final Block block) { + for (final Iterator iter = block.symbolIterator(); iter.hasNext();) { + final Symbol symbol = iter.next(); + newType(symbol, Type.OBJECT); + } + } + + @Override + public Node enter(final Block block) { + toObject(block); + return block; + } + + @Override + public Node enter(final FunctionNode node) { + toObject(node); + if (node.isLazy()) { + return null; + } + return node; + } + }); + } + private static String name(final Node node) { final String cn = node.getClass().getName(); int lastDot = cn.lastIndexOf('.'); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/BranchOptimizer.java b/nashorn/src/jdk/nashorn/internal/codegen/BranchOptimizer.java index 84cef43764a..ee922115d15 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/BranchOptimizer.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/BranchOptimizer.java @@ -32,7 +32,6 @@ import static jdk.nashorn.internal.codegen.Condition.LE; import static jdk.nashorn.internal.codegen.Condition.LT; import static jdk.nashorn.internal.codegen.Condition.NE; -import jdk.nashorn.internal.codegen.Label; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Node; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 2ffb5bd887d..71a2eb0fe1e 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -25,10 +25,8 @@ package jdk.nashorn.internal.codegen; -import static jdk.nashorn.internal.codegen.ClassEmitter.Flag.HANDLE_STATIC; import static jdk.nashorn.internal.codegen.ClassEmitter.Flag.PRIVATE; import static jdk.nashorn.internal.codegen.ClassEmitter.Flag.STATIC; -import static jdk.nashorn.internal.codegen.CompilerConstants.ALLOCATE; import static jdk.nashorn.internal.codegen.CompilerConstants.GET_MAP; import static jdk.nashorn.internal.codegen.CompilerConstants.GET_STRING; import static jdk.nashorn.internal.codegen.CompilerConstants.LEAF; @@ -50,7 +48,6 @@ import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALL import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT; import java.io.PrintWriter; -import java.lang.invoke.MethodHandle; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; @@ -84,6 +81,7 @@ import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; import jdk.nashorn.internal.ir.LineNumberNode; import jdk.nashorn.internal.ir.LiteralNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; import jdk.nashorn.internal.ir.Node; @@ -108,14 +106,13 @@ import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Lexer.RegexToken; import jdk.nashorn.internal.parser.TokenType; -import jdk.nashorn.internal.runtime.CodeInstaller; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.Property; import jdk.nashorn.internal.runtime.PropertyMap; +import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData; import jdk.nashorn.internal.runtime.Scope; import jdk.nashorn.internal.runtime.ScriptFunction; -import jdk.nashorn.internal.runtime.ScriptFunctionData; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.Source; @@ -149,8 +146,6 @@ final class CodeGenerator extends NodeOperatorVisitor { /** Name of the ScriptFunctionImpl, cannot be referred to as .class @see FunctionObjectCreator */ private static final String SCRIPTFUNCTION_IMPL_OBJECT = Compiler.OBJECTS_PACKAGE + '/' + "ScriptFunctionImpl"; - private static final String SCRIPTFUNCTION_TRAMPOLINE_OBJECT = Compiler.OBJECTS_PACKAGE + '/' + "ScriptFunctionTrampolineImpl"; - /** Constant data & installation. The only reason the compiler keeps this is because it is assigned * by reflection in class installation */ private final Compiler compiler; @@ -982,6 +977,7 @@ final class CodeGenerator extends NodeOperatorVisitor { method.label(functionNode.getEntryLabel()); initLocals(functionNode); + functionNode.setState(CompilationState.EMITTED); return functionNode; } @@ -3234,42 +3230,23 @@ final class CodeGenerator extends NodeOperatorVisitor { } private void newFunctionObject(final FunctionNode functionNode) { - final boolean isLazy = functionNode.isLazy(); - final Class[] cparams = new Class[] { ScriptFunctionData.class, ScriptObject.class, MethodHandle.class }; + final boolean isLazy = functionNode.isLazy(); + final Class[] cparams = new Class[] { RecompilableScriptFunctionData.class, ScriptObject.class }; new ObjectCreator(this, new ArrayList(), new ArrayList(), false, false) { @Override - protected void makeObject(final MethodEmitter method) { - final String className = isLazy ? SCRIPTFUNCTION_TRAMPOLINE_OBJECT : SCRIPTFUNCTION_IMPL_OBJECT; + protected void makeObject(final MethodEmitter m) { + final String className = SCRIPTFUNCTION_IMPL_OBJECT; - method._new(className).dup(); - if (isLazy) { - loadConstant(compiler.getCodeInstaller()); - loadConstant(functionNode); - } else { - final String signature = new FunctionSignature(true, functionNode.needsCallee(), functionNode.getReturnType(), functionNode.isVarArg() ? null : functionNode.getParameters()).toString(); - method.loadHandle(functionNode.getCompileUnit().getUnitClassName(), functionNode.getName(), signature, EnumSet.of(HANDLE_STATIC)); // function - } - loadConstant(new ScriptFunctionData(functionNode, makeMap())); + m._new(className).dup(); + loadConstant(new RecompilableScriptFunctionData(functionNode, compiler.getCodeInstaller(), Compiler.binaryName(getClassName()), makeMap())); if (isLazy || functionNode.needsParentScope()) { - method.loadScope(); + m.loadScope(); } else { - method.loadNull(); + m.loadNull(); } - - method.loadHandle(getClassName(), ALLOCATE.tag(), methodDescriptor(ScriptObject.class, PropertyMap.class), EnumSet.of(HANDLE_STATIC)); - - final List> cparamList = new ArrayList<>(); - if (isLazy) { - cparamList.add(CodeInstaller.class); - cparamList.add(FunctionNode.class); - } else { - cparamList.add(MethodHandle.class); - } - cparamList.addAll(Arrays.asList(cparams)); - - method.invoke(constructorNoLookup(className, cparamList.toArray(new Class[cparamList.size()]))); + m.invoke(constructorNoLookup(className, cparams)); } }.makeObject(method); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java index e22454cc459..0125efff65e 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java @@ -2,10 +2,10 @@ package jdk.nashorn.internal.codegen; import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.ATTR; import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.CONSTANT_FOLDED; -import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.EMITTED; import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.FINALIZED; import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.INITIALIZED; import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.LOWERED; +import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.PARSED; import static jdk.nashorn.internal.ir.FunctionNode.CompilationState.SPLIT; import java.io.File; @@ -39,7 +39,7 @@ enum CompilationPhase { * default policy. The will get trampolines and only be generated when * called */ - LAZY_INITIALIZATION_PHASE(EnumSet.of(FunctionNode.CompilationState.INITIALIZED)) { + LAZY_INITIALIZATION_PHASE(EnumSet.of(INITIALIZED, PARSED)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { @@ -79,9 +79,11 @@ enum CompilationPhase { if (node == outermostFunctionNode) { return node; } - assert Compiler.LAZY_JIT; + assert compiler.isLazy(); lazy.add(node); + //also needs scope, potentially needs arguments etc etc + return node; } }); @@ -113,7 +115,7 @@ enum CompilationPhase { * Constant folding pass * Simple constant folding that will make elementary constructs go away */ - CONSTANT_FOLDING_PHASE(EnumSet.of(INITIALIZED), CONSTANT_FOLDED) { + CONSTANT_FOLDING_PHASE(EnumSet.of(INITIALIZED, PARSED)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { fn.accept(new FoldConstants()); @@ -134,7 +136,7 @@ enum CompilationPhase { * as runtime nodes where applicable. * */ - LOWERING_PHASE(EnumSet.of(INITIALIZED, CONSTANT_FOLDED), LOWERED) { + LOWERING_PHASE(EnumSet.of(INITIALIZED, PARSED, CONSTANT_FOLDED)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { fn.accept(new Lower()); @@ -150,19 +152,10 @@ enum CompilationPhase { * Attribution * Assign symbols and types to all nodes. */ - ATTRIBUTION_PHASE(EnumSet.of(INITIALIZED, CONSTANT_FOLDED, LOWERED), ATTR) { + ATTRIBUTION_PHASE(EnumSet.of(INITIALIZED, PARSED, CONSTANT_FOLDED, LOWERED)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { - final ScriptEnvironment env = compiler.getEnv(); - fn.accept(new Attr()); - if (env._print_lower_ast) { - env.getErr().println(new ASTWriter(fn)); - } - - if (env._print_lower_parse) { - env.getErr().println(new PrintVisitor(fn)); - } } @Override @@ -178,7 +171,7 @@ enum CompilationPhase { * a + b a ScriptRuntime.ADD with call overhead or a dadd with much * less). Split IR can lead to scope information being changed. */ - SPLITTING_PHASE(EnumSet.of(INITIALIZED, CONSTANT_FOLDED, LOWERED, ATTR), SPLIT) { + SPLITTING_PHASE(EnumSet.of(INITIALIZED, PARSED, CONSTANT_FOLDED, LOWERED, ATTR)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(compiler.firstCompileUnitName()); @@ -212,10 +205,20 @@ enum CompilationPhase { * Contract: all variables must have slot assignments and scope assignments * before type finalization. */ - TYPE_FINALIZATION_PHASE(EnumSet.of(INITIALIZED, CONSTANT_FOLDED, LOWERED, ATTR, SPLIT), FINALIZED) { + TYPE_FINALIZATION_PHASE(EnumSet.of(INITIALIZED, PARSED, CONSTANT_FOLDED, LOWERED, ATTR, SPLIT)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { + final ScriptEnvironment env = compiler.getEnv(); + fn.accept(new FinalizeTypes()); + + if (env._print_lower_ast) { + env.getErr().println(new ASTWriter(fn)); + } + + if (env._print_lower_parse) { + env.getErr().println(new PrintVisitor(fn)); + } } @Override @@ -229,7 +232,7 @@ enum CompilationPhase { * * Generate the byte code class(es) resulting from the compiled FunctionNode */ - BYTECODE_GENERATION_PHASE(EnumSet.of(INITIALIZED, CONSTANT_FOLDED, LOWERED, ATTR, SPLIT, FINALIZED), EMITTED) { + BYTECODE_GENERATION_PHASE(EnumSet.of(INITIALIZED, PARSED, CONSTANT_FOLDED, LOWERED, ATTR, SPLIT, FINALIZED)) { @Override void transform(final Compiler compiler, final FunctionNode fn) { final ScriptEnvironment env = compiler.getEnv(); @@ -306,18 +309,12 @@ enum CompilationPhase { }; private final EnumSet pre; - private final CompilationState post; private long startTime; private long endTime; private boolean isFinished; private CompilationPhase(final EnumSet pre) { - this(pre, null); - } - - private CompilationPhase(final EnumSet pre, final CompilationState post) { - this.pre = pre; - this.post = post; + this.pre = pre; } boolean isApplicable(final FunctionNode functionNode) { @@ -343,10 +340,6 @@ enum CompilationPhase { endTime = System.currentTimeMillis(); Timing.accumulateTime(toString(), endTime - startTime); - if (post != null) { - functionNode.setState(post); - } - isFinished = true; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompileUnit.java b/nashorn/src/jdk/nashorn/internal/codegen/CompileUnit.java index 5e62116b9a1..ff88fa9986a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompileUnit.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompileUnit.java @@ -37,6 +37,8 @@ public class CompileUnit { private long weight; + private Class clazz; + CompileUnit(final String className, final ClassEmitter classEmitter) { this(className, classEmitter, 0L); } @@ -47,6 +49,24 @@ public class CompileUnit { this.weight = initialWeight; } + /** + * Return the class that contains the code for this unit, null if not + * generated yet + * + * @return class with compile unit code + */ + public Class getCode() { + return clazz; + } + + /** + * Set class when it exists. Only accessible from compiler + * @param clazz class with code for this compile unit + */ + void setCode(final Class clazz) { + this.clazz = clazz; + } + /** * Add weight to this compile unit * @param w weight to add diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index ca23c42809e..a799ee0506f 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -45,11 +45,15 @@ import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.logging.Level; + import jdk.internal.dynalink.support.NameCodec; import jdk.nashorn.internal.codegen.ClassEmitter.Flag; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; +import jdk.nashorn.internal.ir.Node; +import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.CodeInstaller; import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.ScriptEnvironment; @@ -71,8 +75,6 @@ public final class Compiler { /** Name of the objects package */ public static final String OBJECTS_PACKAGE = "jdk/nashorn/internal/objects"; - static final boolean LAZY_JIT = Options.getBooleanProperty("nashorn.compiler.lazy"); - private final Map bytecode; private final Set compileUnits; @@ -164,7 +166,7 @@ public final class Compiler { * and JIT it at once. This can lead to long startup time and fewer type * specializations */ - final static CompilationSequence SEQUENCE_NORMAL = new CompilationSequence( + final static CompilationSequence SEQUENCE_EAGER = new CompilationSequence( CompilationPhase.CONSTANT_FOLDING_PHASE, CompilationPhase.LOWERING_PHASE, CompilationPhase.ATTRIBUTION_PHASE, @@ -173,12 +175,15 @@ public final class Compiler { CompilationPhase.BYTECODE_GENERATION_PHASE); final static CompilationSequence SEQUENCE_LAZY = - SEQUENCE_NORMAL.insertFirst(CompilationPhase.LAZY_INITIALIZATION_PHASE); + SEQUENCE_EAGER.insertFirst(CompilationPhase.LAZY_INITIALIZATION_PHASE); - final static CompilationSequence SEQUENCE_DEFAULT = - LAZY_JIT ? - SEQUENCE_LAZY : - SEQUENCE_NORMAL; + private static CompilationSequence sequence(final boolean lazy) { + return lazy ? SEQUENCE_LAZY : SEQUENCE_EAGER; + } + + boolean isLazy() { + return sequence == SEQUENCE_LAZY; + } private static String lazyTag(final FunctionNode functionNode) { if (functionNode.isLazy()) { @@ -213,10 +218,7 @@ public final class Compiler { this.scriptName = sb.toString(); - LOG.info("Initializing compiler for '" + functionNode.getName() + "' scriptName = " + scriptName + ", root function: '" + functionNode.getName() + "'"); - if (functionNode.isLazy()) { - LOG.info(">>> This is a lazy recompilation triggered by a trampoline"); - } + LOG.info("Initializing compiler for '" + functionNode.getName() + "' scriptName = " + scriptName + ", root function: '" + functionNode.getName() + "' lazy=" + functionNode.isLazy()); } /** @@ -227,7 +229,7 @@ public final class Compiler { * @param strict should this compilation use strict mode semantics */ public Compiler(final CodeInstaller installer, final FunctionNode functionNode, final boolean strict) { - this(installer.getOwner(), installer, functionNode, SEQUENCE_DEFAULT, strict); + this(installer.getOwner(), installer, functionNode, sequence(installer.getOwner()._lazy_compilation), strict); } /** @@ -237,7 +239,7 @@ public final class Compiler { * @param functionNode function node (in any available {@link CompilationState}) to compile */ public Compiler(final CodeInstaller installer, final FunctionNode functionNode) { - this(installer.getOwner(), installer, functionNode, SEQUENCE_DEFAULT, installer.getOwner()._strict); + this(installer.getOwner(), installer, functionNode, sequence(installer.getOwner()._lazy_compilation), installer.getOwner()._strict); } /** @@ -247,28 +249,104 @@ public final class Compiler { * @param functionNode functionNode to compile */ public Compiler(final ScriptEnvironment env, final FunctionNode functionNode) { - this(env, null, functionNode, SEQUENCE_DEFAULT, env._strict); + this(env, null, functionNode, sequence(env._lazy_compilation), env._strict); } /** * Execute the compilation this Compiler was created with + * @params param types if known, for specialization * @throws CompilationException if something goes wrong + * @return this compiler, for possible chaining */ - public void compile() throws CompilationException { + public Compiler compile() throws CompilationException { + return compile(null); + } + + /** + * Execute the compilation this Compiler was created with + * @param paramTypes param types if known, for specialization + * @throws CompilationException if something goes wrong + * @return this compiler, for possible chaining + */ + public Compiler compile(final Class paramTypes) throws CompilationException { for (final String reservedName : RESERVED_NAMES) { functionNode.uniqueName(reservedName); } + final boolean fine = !LOG.levelAbove(Level.FINE); + final boolean info = !LOG.levelAbove(Level.INFO); + + long time = 0L; + for (final CompilationPhase phase : sequence) { phase.apply(this, functionNode); - final String end = phase.toString() + " done for function '" + functionNode.getName() + "'"; - if (Timing.isEnabled()) { - final long duration = phase.getEndTime() - phase.getStartTime(); - LOG.info(end + " in " + duration + " ms"); - } else { - LOG.info(end); + + final long duration = Timing.isEnabled() ? (phase.getEndTime() - phase.getStartTime()) : 0L; + time += duration; + + if (fine) { + final StringBuilder sb = new StringBuilder(); + + sb.append(phase.toString()). + append(" done for function '"). + append(functionNode.getName()). + append('\''); + + if (duration > 0L) { + sb.append(" in "). + append(duration). + append(" ms "); + } + + LOG.fine(sb.toString()); } } + + if (info) { + final StringBuilder sb = new StringBuilder(); + sb.append("Compile job for '"). + append(functionNode.getName()). + append("' finished"); + + if (time > 0L) { + sb.append(" in "). + append(time). + append(" ms"); + } + + LOG.info(sb.toString()); + } + + return this; + } + + private Class install(final String className, final byte[] code) { + LOG.fine("Installing class " + className); + + final Class clazz = installer.install(Compiler.binaryName(className), code); + + try { + final Source source = getSource(); + final Object[] constants = getConstantData().toArray(); + // Need doPrivileged because these fields are private + AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override + public Void run() throws Exception { + //use reflection to write source and constants table to installed classes + final Field sourceField = clazz.getDeclaredField(SOURCE.tag()); + final Field constantsField = clazz.getDeclaredField(CONSTANTS.tag()); + sourceField.setAccessible(true); + constantsField.setAccessible(true); + sourceField.set(null, source); + constantsField.set(null, constants); + return null; + } + }); + } catch (final PrivilegedActionException e) { + throw new RuntimeException(e); + } + + return clazz; } /** @@ -280,42 +358,38 @@ public final class Compiler { assert functionNode.hasState(CompilationState.EMITTED) : functionNode.getName() + " has no bytecode and cannot be installed"; - Class rootClass = null; + final Map> installedClasses = new HashMap<>(); + + final String rootClassName = firstCompileUnitName(); + final Class rootClass = install(rootClassName, bytecode.get(rootClassName)); + + installedClasses.put(rootClassName, rootClass); for (final Entry entry : bytecode.entrySet()) { - final String className = entry.getKey(); - LOG.fine("Installing class " + className); - - final byte[] code = entry.getValue(); - final Class clazz = installer.install(Compiler.binaryName(className), code); - - if (rootClass == null && firstCompileUnitName().equals(className)) { - rootClass = clazz; - } - - try { - final Source source = getSource(); - final Object[] constants = getConstantData().toArray(); - // Need doPrivileged because these fields are private - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Void run() throws Exception { - //use reflection to write source and constants table to installed classes - final Field sourceField = clazz.getDeclaredField(SOURCE.tag()); - final Field constantsField = clazz.getDeclaredField(CONSTANTS.tag()); - sourceField.setAccessible(true); - constantsField.setAccessible(true); - sourceField.set(null, source); - constantsField.set(null, constants); - return null; - } - }); - } catch (final PrivilegedActionException e) { - throw new RuntimeException(e); + final String className = entry.getKey(); + if (className.equals(rootClassName)) { + continue; } + installedClasses.put(className, install(className, entry.getValue())); } + for (final CompileUnit unit : compileUnits) { + unit.setCode(installedClasses.get(unit.getUnitClassName())); + } + + functionNode.accept(new NodeVisitor() { + @Override + public Node enter(final FunctionNode node) { + if (node.isLazy()) { + return null; + } + node.setState(CompilationState.INSTALLED); + return node; + } + }); + LOG.info("Installed root class: " + rootClass + " and " + bytecode.size() + " compile unit classes"); + if (Timing.isEnabled()) { final long duration = System.currentTimeMillis() - t0; Timing.accumulateTime("[Code Installation]", duration); @@ -444,8 +518,6 @@ public final class Compiler { * TODO: We currently generate no overflow checks so this is * disabled * - * @see #shouldUseIntegers() - * * @return true if arithmetic operations should not widen integer * operands by default. */ @@ -460,4 +532,5 @@ public final class Compiler { assert !USE_INT_ARITH : "Integer arithmetic is not enabled"; } + } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java index 28dfda7da9a..b302d6fe470 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java @@ -34,6 +34,7 @@ import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.CallNode.EvalArgs; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.CaseNode; import jdk.nashorn.internal.ir.CatchNode; import jdk.nashorn.internal.ir.DoWhileNode; @@ -235,19 +236,19 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leaveBIT_AND(BinaryNode binaryNode) { - assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : binaryNode.getSymbol(); + assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : "int coercion expected: " + binaryNode.getSymbol(); return leaveBinary(binaryNode, Type.INT, Type.INT); } @Override public Node leaveBIT_OR(BinaryNode binaryNode) { - assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger(); + assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : "int coercion expected: " + binaryNode.getSymbol(); return leaveBinary(binaryNode, Type.INT, Type.INT); } @Override public Node leaveBIT_XOR(BinaryNode binaryNode) { - assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger(); + assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isInteger() : "int coercion expected: " + binaryNode.getSymbol(); return leaveBinary(binaryNode, Type.INT, Type.INT); } @@ -255,7 +256,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { public Node leaveCOMMALEFT(final BinaryNode binaryNode) { assert binaryNode.getSymbol() != null; binaryNode.setRHS(discard(binaryNode.rhs())); - // AccessSpecializer - the type of rhs, which is the remaining value of this node may have changed + // AccessSpecializer - the type of lhs, which is the remaining value of this node may have changed // in that case, update the node type as well propagateType(binaryNode, binaryNode.lhs().getType()); return binaryNode; @@ -344,7 +345,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leaveSHR(final BinaryNode binaryNode) { - assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isLong(); + assert binaryNode.getSymbol() != null && binaryNode.getSymbol().getSymbolType().isLong() : "long coercion expected: " + binaryNode.getSymbol(); return leaveBinary(binaryNode, Type.INT, Type.INT); } @@ -432,6 +433,8 @@ final class FinalizeTypes extends NodeOperatorVisitor { } updateSymbols(functionNode); + functionNode.setState(CompilationState.FINALIZED); + return functionNode; } @@ -511,7 +514,6 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leave(final VarNode varNode) { - final Node rhs = varNode.getInit(); if (rhs != null) { Type destType = specialize(varNode); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java index 4ea53a04351..af2b02ab706 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java @@ -30,11 +30,13 @@ import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; +import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.UnaryNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.JSType; @@ -71,6 +73,20 @@ final class FoldConstants extends NodeVisitor { return binaryNode; } + @Override + public Node enter(final FunctionNode functionNode) { + if (functionNode.isLazy()) { + return null; + } + return functionNode; + } + + @Override + public Node leave(final FunctionNode functionNode) { + functionNode.setState(CompilationState.CONSTANT_FOLDED); + return functionNode; + } + @Override public Node leave(final IfNode ifNode) { final Node test = ifNode.getTest(); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java b/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java index ded12b0c007..5f3740a7240 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java @@ -146,7 +146,7 @@ public final class FunctionSignature { /** * Create a function signature given a function node, using as much - * type information for parameters and return types that is availabe + * type information for parameters and return types that is available * * @param functionNode the function node */ @@ -202,6 +202,14 @@ public final class FunctionSignature { return methodType; } + /** + * Return the return type for this function signature + * @return the return type + */ + public Type getReturnType() { + return returnType; + } + private static Type[] objectArgs(final int nArgs) { final Type[] array = new Type[nArgs]; for (int i = 0; i < nArgs; i++) { diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 7a83469bc98..4be28193cc7 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -69,6 +69,7 @@ import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WhileNode; import jdk.nashorn.internal.ir.WithNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; @@ -332,6 +333,8 @@ final class Lower extends NodeOperatorVisitor { LOG.info("END FunctionNode: " + functionNode.getName()); unnest(functionNode); + functionNode.setState(CompilationState.LOWERED); + return null; } @@ -636,7 +639,7 @@ final class Lower extends NodeOperatorVisitor { } else if (conservativeAlwaysTrue(test)) { node = new ForNode(whileNode.getSource(), whileNode.getToken(), whileNode.getFinish()); ((ForNode)node).setBody(body); - ((ForNode)node).accept(this); + node.accept(this); setTerminal(node, !escapes); } } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java index b92f2383b3a..b338ced5f47 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java @@ -39,6 +39,7 @@ import jdk.nashorn.internal.ir.ContinueNode; import jdk.nashorn.internal.ir.DoWhileNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.LabelNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; @@ -92,15 +93,16 @@ final class Splitter extends NodeVisitor { */ void split() { if (functionNode.isLazy()) { - LOG.fine("Postponing split of '" + functionNode.getName() + "' as it's lazy"); + LOG.finest("Postponing split of '" + functionNode.getName() + "' as it's lazy"); return; } - LOG.fine("Initiating split of '" + functionNode.getName() + "'"); + + LOG.finest("Initiating split of '" + functionNode.getName() + "'"); long weight = WeighNodes.weigh(functionNode); if (weight >= SPLIT_THRESHOLD) { - LOG.fine("Splitting '" + functionNode.getName() + "' as its weight " + weight + " exceeds split threshold " + SPLIT_THRESHOLD); + LOG.finest("Splitting '" + functionNode.getName() + "' as its weight " + weight + " exceeds split threshold " + SPLIT_THRESHOLD); functionNode.accept(this); @@ -133,6 +135,8 @@ final class Splitter extends NodeVisitor { for (final FunctionNode function : functionNode.getFunctions()) { new Splitter(compiler, function, outermostCompileUnit).split(); } + + functionNode.setState(CompilationState.SPLIT); } /** diff --git a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java index d36dd20db34..775588352f4 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java @@ -647,21 +647,20 @@ public abstract class Type implements Comparable, BytecodeOps { } private static void swap(final MethodVisitor method, final Type above, final Type below) { - final MethodVisitor mv = method; if (below.isCategory2()) { if (above.isCategory2()) { - mv.visitInsn(DUP2_X2); - mv.visitInsn(POP2); + method.visitInsn(DUP2_X2); + method.visitInsn(POP2); } else { - mv.visitInsn(DUP_X2); - mv.visitInsn(POP); + method.visitInsn(DUP_X2); + method.visitInsn(POP); } } else { if (above.isCategory2()) { - mv.visitInsn(DUP2_X1); - mv.visitInsn(POP2); + method.visitInsn(DUP2_X1); + method.visitInsn(POP2); } else { - mv.visitInsn(SWAP); + method.visitInsn(SWAP); } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/Block.java b/nashorn/src/jdk/nashorn/internal/ir/Block.java index 9449be5b0a5..e729d307b8c 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Block.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Block.java @@ -38,26 +38,25 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import jdk.nashorn.internal.codegen.Frame; import jdk.nashorn.internal.codegen.Label; -import jdk.nashorn.internal.ir.annotations.Ignore; -import jdk.nashorn.internal.ir.annotations.ParentNode; +import jdk.nashorn.internal.ir.annotations.Reference; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.Source; /** * IR representation for a list of statements and functions. All provides the * basis for script body. - * */ public class Block extends Node { /** Parent context */ - @ParentNode @Ignore + @Reference private Block parent; - /** Owning function. */ - @Ignore //don't print it, it is apparent in the tree + /** Owning function - a FunctionNode has itself as function */ + @Reference protected FunctionNode function; /** List of statements */ @@ -273,6 +272,14 @@ public class Block extends Node { return this; } + /** + * Get an iterator for all the symbols defined in this block + * @return symbol iterator + */ + public Iterator symbolIterator() { + return symbols.values().iterator(); + } + /** * Search for symbol. * diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index d928aa71529..63590932d44 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -33,8 +33,10 @@ import static jdk.nashorn.internal.ir.Symbol.IS_TEMP; import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Stack; import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.Compiler; @@ -45,13 +47,13 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Parser; +import jdk.nashorn.internal.runtime.Debug; import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.UserAccessorProperty; import jdk.nashorn.internal.runtime.linker.LinkerCallSite; /** * IR representation for function (or script.) - * */ public class FunctionNode extends Block { @@ -86,7 +88,9 @@ public class FunctionNode extends Block { /** method has had its types finalized */ FINALIZED, /** method has been emitted to bytecode */ - EMITTED + EMITTED, + /** code installed in a class loader */ + INSTALLED } /** External function identifier. */ @@ -173,6 +177,9 @@ public class FunctionNode extends Block { @Ignore private final EnumSet compilationState; + /** Type hints, e.g based on parameters at call site */ + private final Map specializedTypes; + /** Function flags. */ private int flags; @@ -256,22 +263,27 @@ public class FunctionNode extends Block { // constructed, so it can't be seen from other threads. this.function = this; this.compilationState = EnumSet.of(CompilationState.INITIALIZED); + this.specializedTypes = new HashMap<>(); } @SuppressWarnings("LeakingThisInConstructor") private FunctionNode(final FunctionNode functionNode, final CopyState cs) { super(functionNode, cs); + this.functions = new ArrayList<>(); + for (final FunctionNode f : functionNode.getFunctions()) { + this.functions.add((FunctionNode)cs.existingOrCopy(f)); + } + this.ident = (IdentNode)cs.existingOrCopy(functionNode.ident); this.name = functionNode.name; this.kind = functionNode.kind; this.parameters = new ArrayList<>(); for (final IdentNode param : functionNode.getParameters()) { - this.parameters.add((IdentNode) cs.existingOrCopy(param)); + this.parameters.add((IdentNode)cs.existingOrCopy(param)); } - this.functions = new ArrayList<>(); this.firstToken = functionNode.firstToken; this.lastToken = functionNode.lastToken; this.namespace = functionNode.getNamespace(); @@ -300,6 +312,7 @@ public class FunctionNode extends Block { this.function = this; this.compilationState = EnumSet.copyOf(functionNode.compilationState); + this.specializedTypes = new HashMap<>(); } @Override @@ -710,10 +723,14 @@ public class FunctionNode extends Block { * Check if this function's generated Java method needs a {@code callee} parameter. Functions that need access to * their parent scope, functions that reference themselves, and non-strict functions that need an Arguments object * (since it exposes {@code arguments.callee} property) will need to have a callee parameter. + * + * We also conservatively need a callee if we have lazy children, i.e. nested function nodes that have not yet + * been evaluated. _They_ may need the callee and we don't know it + * * @return true if the function's generated Java method needs a {@code callee} parameter. */ public boolean needsCallee() { - return needsParentScope() || needsSelfSymbol() || (needsArguments() && !isStrictMode()); + return hasLazyChildren() || needsParentScope() || needsSelfSymbol() || (needsArguments() && !isStrictMode()); } /** @@ -918,6 +935,27 @@ public class FunctionNode extends Block { this.parameters = parameters; } + /** + * Get a specialized type for an identity, if one exists + * @param node node to check specialized type for + * @return null if no specialization exists, otherwise type + */ + public Type getSpecializedType(final IdentNode node) { + return specializedTypes.get(node); + } + + /** + * Set parameter type hints for specialization. + * @param types types array of length equal to parameter list size + */ + public void setParameterTypes(final Class[] types) { + assert types.length == parameters.size() : "Type vector length doesn't correspond to parameter types"; + //diff - skip the callee and this etc, they are not explicit params in the parse tree + for (int i = 0; i < types.length ; i++) { + specializedTypes.put(parameters.get(i), Type.typeFor(types[i])); + } + } + /** * Get the identifier for the variable in which the function return value * should be stored @@ -1266,7 +1304,7 @@ public class FunctionNode extends Block { * @param parentBlock a block to remember as parent */ public void addReferencingParentBlock(final Block parentBlock) { - assert parentBlock.getFunction() == function.findParentFunction(); // all parent blocks must be in the same function + assert parentBlock.getFunction() == function.findParentFunction() : Debug.id(parentBlock.getFunction()) + "!=" + Debug.id(function.findParentFunction()); // all parent blocks must be in the same function if (parentBlock != function.getParent()) { if (referencingParentBlocks == null) { referencingParentBlocks = new LinkedList<>(); diff --git a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java index ab7e49e4650..8b720de41b0 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java @@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.Source; @@ -36,9 +35,6 @@ import jdk.nashorn.internal.runtime.Source; * IR representation of an object literal. */ public class ObjectNode extends Node { - /** Literal context. */ - @Ignore - private Block context; /** Literal elements. */ private final List elements; @@ -49,13 +45,11 @@ public class ObjectNode extends Node { * @param source the source * @param token token * @param finish finish - * @param context the block for this ObjectNode * @param elements the elements used to initialize this ObjectNode */ - public ObjectNode(final Source source, final long token, final int finish, final Block context, final List elements) { + public ObjectNode(final Source source, final long token, final int finish, final List elements) { super(source, token, finish); - this.context = context; this.elements = elements; } @@ -68,7 +62,6 @@ public class ObjectNode extends Node { newElements.add(cs.existingOrCopy(element)); } - this.context = (Block)cs.existingOrCopy(objectNode.context); this.elements = newElements; } @@ -80,10 +73,6 @@ public class ObjectNode extends Node { @Override public Node accept(final NodeVisitor visitor) { if (visitor.enter(this) != null) { - if (context != null) { - context = (Block)context.accept(visitor); - } - for (int i = 0, count = elements.size(); i < count; i++) { elements.set(i, elements.get(i).accept(visitor)); } @@ -116,14 +105,6 @@ public class ObjectNode extends Node { sb.append('}'); } - /** - * Get the block that is this ObjectNode's literal context - * @return the block - */ - public Block getContext() { - return context; - } - /** * Get the elements of this literal node * @return a list of elements diff --git a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java index 7b608edf7ac..491151fa296 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java @@ -152,9 +152,9 @@ public class UnaryNode extends Node implements Assignment { if (isConvert) { convertPos = sb.length(); - sb.append("(("); + sb.append("("); sb.append(getType()); - sb.append(")"); + sb.append(")("); } if (!isPostfix && !isConvert) { @@ -191,8 +191,6 @@ public class UnaryNode extends Node implements Assignment { sb.setCharAt(convertPos, ' '); } } - - //TODO - conversions still have too many parenthesis - makes --print-lower-parse hard to read } /** diff --git a/nashorn/src/jdk/nashorn/internal/ir/annotations/ChildNode.java b/nashorn/src/jdk/nashorn/internal/ir/annotations/ChildNode.java deleted file mode 100644 index 181c63d8322..00000000000 --- a/nashorn/src/jdk/nashorn/internal/ir/annotations/ChildNode.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.ir.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * This is a child node, a real node, not a reference, to an IR node that should - * be traversed. - *

- * TODO Currently not in use. Would make e.g. accept methods simple and unified - * @see jdk.nashorn.internal.ir.Node - */ -@Retention(value=RetentionPolicy.RUNTIME) -public @interface ChildNode { - /** order of traversal compared to other children */ - public int order() default -1; -} diff --git a/nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java b/nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java deleted file mode 100644 index 6a9de3a455d..00000000000 --- a/nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.ir.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Signifies a parent of a node, i.e. node that should not be traversed if we - * go down the AST. In automatic parsing this can be handled by @Reference - * annotations instead, as all parents are references. - *

- * TODO The use case is automating and creating one implementation of something like - * Node.getParent() - * - * @see jdk.nashorn.internal.ir.Node - */ -@Retention(value=RetentionPolicy.RUNTIME) -public @interface ParentNode { - // EMPTY -} diff --git a/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java b/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java index 1dd002c1f5f..20c8ffca53b 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java +++ b/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java @@ -33,7 +33,6 @@ import java.lang.annotation.RetentionPolicy; * AST traversal and cloning. Cloning currently as a rule uses * existingOrSame for references and otherwise existingOrCopy *

- * TODO this could probably be automated using the @Reference annotation. */ @Retention(value=RetentionPolicy.RUNTIME) diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java b/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java index 3c66aa12d0e..7bbe3836694 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir.debug; import java.lang.reflect.Field; import java.util.ArrayDeque; +import java.util.ArrayList; import java.util.Collection; import java.util.Deque; import java.util.Iterator; @@ -36,10 +37,10 @@ import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.annotations.Ignore; -import jdk.nashorn.internal.ir.annotations.ParentNode; import jdk.nashorn.internal.ir.annotations.Reference; import jdk.nashorn.internal.parser.Token; import jdk.nashorn.internal.runtime.Context; +import jdk.nashorn.internal.runtime.Debug; /** * AST-as-text visualizer. Sometimes you want tree form and not source @@ -47,7 +48,6 @@ import jdk.nashorn.internal.runtime.Context; * * see the flags --print-ast and --print-ast-lower */ - public final class ASTWriter { /** Root node from which to start the traversal */ private final Node root; @@ -71,12 +71,22 @@ public final class ASTWriter { @Override public String toString() { final StringBuilder sb = new StringBuilder(); - printAST(sb, null, "root", root, 0); + printAST(sb, null, null, "root", root, 0); return sb.toString(); } + /** + * Return the visited nodes in an ordered list + * @return the list of nodes in order + */ + public Node[] toArray() { + final List preorder = new ArrayList<>(); + printAST(new StringBuilder(), preorder, null, "root", root, 0); + return preorder.toArray(new Node[preorder.size()]); + } + @SuppressWarnings("unchecked") - private void printAST(final StringBuilder sb, final Field field, final String name, final Node node, final int indent) { + private void printAST(final StringBuilder sb, final List preorder, final Field field, final String name, final Node node, final int indent) { ASTWriter.indent(sb, indent); if (node == null) { sb.append("[Object "); @@ -85,13 +95,23 @@ public final class ASTWriter { return; } + if (preorder != null) { + preorder.add(node); + } + final boolean isReference = field != null && field.getAnnotation(Reference.class) != null; Class clazz = node.getClass(); String type = clazz.getName(); type = type.substring(type.lastIndexOf('.') + 1, type.length()); -// type += "@" + Debug.id(node) + "#" + node.getSymbol(); + if (isReference) { + type = "ref: " + type; + } + type += "@" + Debug.id(node); + if (node.getSymbol() != null) { + type += "#" + node.getSymbol(); + } final List children = new LinkedList<>(); @@ -153,9 +173,7 @@ public final class ASTWriter { append('\n'); for (final Field child : children) { - if (child.getAnnotation(ParentNode.class) != null) { - continue; - } else if (child.getAnnotation(Ignore.class) != null) { + if (child.getAnnotation(Ignore.class) != null) { continue; } @@ -168,7 +186,7 @@ public final class ASTWriter { } if (value instanceof Node) { - printAST(sb, child, child.getName(), (Node)value, indent + 1); + printAST(sb, preorder, child, child.getName(), (Node)value, indent + 1); } else if (value instanceof Collection) { int pos = 0; ASTWriter.indent(sb, indent + 1); @@ -180,7 +198,7 @@ public final class ASTWriter { append('\n'); for (final Node member : (Collection)value) { - printAST(sb, child, child.getName() + "[" + pos++ + "]", member, indent + 2); + printAST(sb, preorder, child, child.getName() + "[" + pos++ + "]", member, indent + 2); } } } diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java index 31c1d972cad..16e237ba521 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArray.java @@ -605,7 +605,7 @@ public final class NativeArray extends ScriptObject { final boolean strict = sobj.isStrictContext(); if (bulkable(sobj)) { - return ((NativeArray)sobj).getArray().pop(); + return sobj.getArray().pop(); } final long len = JSType.toUint32(sobj.getLength()); @@ -725,7 +725,7 @@ public final class NativeArray extends ScriptObject { first = sobj.get(0); if (bulkable(sobj)) { - ((NativeArray) sobj).getArray().shiftLeft(1); + sobj.getArray().shiftLeft(1); } else { for (long k = 1; k < len; k++) { sobj.set(k - 1, sobj.get(k), strict); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java index 8188f426f23..b311981e655 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java @@ -161,21 +161,6 @@ public final class NativeDebug extends ScriptObject { return UNDEFINED; } - /** - * Nashorn extension: get invocation handle from {@link ScriptFunction} - * - * @param self self reference - * @param obj script function - * @return the invocation handle for the given ScriptFunction - */ - @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static Object methodHandle(final Object self, final Object obj) { - if (obj instanceof ScriptFunction) { - return ((ScriptFunction)obj).getInvokeHandle(); - } - return UNDEFINED; - } - /** * Check object identity comparison regardless of type * diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java index 8cea0c70271..433f9317469 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java @@ -317,7 +317,7 @@ public final class NativeError extends ScriptObject { return name; } // Step 10 : return name + ": " + msg - return (String)name + ": " + (String)msg; + return name + ": " + msg; } private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { diff --git a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java b/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java index 0514bd25bf0..46b353f1421 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java +++ b/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java @@ -31,6 +31,7 @@ import java.lang.invoke.MethodHandle; import jdk.nashorn.internal.runtime.GlobalFunctions; import jdk.nashorn.internal.runtime.Property; import jdk.nashorn.internal.runtime.PropertyMap; +import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptFunctionData; import jdk.nashorn.internal.runtime.ScriptObject; @@ -86,8 +87,8 @@ public class ScriptFunctionImpl extends ScriptFunction { * @param builtin is this a built-in function * @param isConstructor can the function be used as a constructor (most can; some built-ins are restricted). */ - ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final boolean strict, final boolean builtin, final boolean isConstructor) { - super(name, methodHandle, getMap(strict), scope, specs, strict, builtin, isConstructor); + ScriptFunctionImpl(final String name, final MethodHandle methodHandle, final ScriptObject scope, final MethodHandle[] specs, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) { + super(name, methodHandle, getMap(isStrict), scope, specs, isStrict, isBuiltin, isConstructor); init(); } @@ -95,14 +96,10 @@ public class ScriptFunctionImpl extends ScriptFunction { * Constructor called by (compiler) generated code for {@link ScriptObject}s. * * @param data static function data - * @param methodHandle handle for invocation * @param scope scope object - * @param allocator instance constructor for function */ - public ScriptFunctionImpl(final MethodHandle methodHandle, final ScriptFunctionData data, final ScriptObject scope, final MethodHandle allocator) { + public ScriptFunctionImpl(final RecompilableScriptFunctionData data, final ScriptObject scope) { super(data, getMap(data.isStrict()), scope); - // Set method handles in script data - data.setMethodHandles(methodHandle, allocator); init(); } diff --git a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionTrampolineImpl.java b/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionTrampolineImpl.java deleted file mode 100644 index 4d3df5093ed..00000000000 --- a/nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionTrampolineImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -package jdk.nashorn.internal.objects; - -import static jdk.nashorn.internal.lookup.Lookup.MH; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import jdk.nashorn.internal.codegen.CompilationException; -import jdk.nashorn.internal.codegen.Compiler; -import jdk.nashorn.internal.codegen.FunctionSignature; -import jdk.nashorn.internal.codegen.types.Type; -import jdk.nashorn.internal.ir.FunctionNode; -import jdk.nashorn.internal.runtime.CodeInstaller; -import jdk.nashorn.internal.runtime.Context; -import jdk.nashorn.internal.runtime.ScriptEnvironment; -import jdk.nashorn.internal.runtime.ScriptFunction; -import jdk.nashorn.internal.runtime.ScriptFunctionData; -import jdk.nashorn.internal.runtime.ScriptObject; - -/** - * A trampoline is a promise to compile a {@link ScriptFunction} later. It just looks like - * the call to the script function, but when invoked it will compile the script function - * (in a new compile unit) and invoke it - */ -public final class ScriptFunctionTrampolineImpl extends ScriptFunctionImpl { - - private CodeInstaller installer; - - /** Function node to lazily recompile when trampoline is hit */ - private FunctionNode functionNode; - - /** - * Constructor - * - * @param installer opaque code installer from context - * @param functionNode function node to lazily compile when trampoline is hit - * @param data {@link ScriptFunctionData} for function - * @param scope scope - * @param allocator allocator - */ - public ScriptFunctionTrampolineImpl(final CodeInstaller installer, final FunctionNode functionNode, final ScriptFunctionData data, final ScriptObject scope, final MethodHandle allocator) { - super(null, data, scope, allocator); - - this.installer = installer; - this.functionNode = functionNode; - - data.setMethodHandles(makeTrampoline(), allocator); - } - - private final MethodHandle makeTrampoline() { - final MethodType mt = - new FunctionSignature( - true, - functionNode.needsCallee(), - Type.OBJECT, - functionNode.getParameters().size()). - getMethodType(); - - return - MH.bindTo( - MH.asCollector( - findOwnMH( - "trampoline", - Object.class, - Object[].class), - Object[].class, - mt.parameterCount()), - this); - } - - private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { - return MH.findVirtual(MethodHandles.lookup(), ScriptFunctionTrampolineImpl.class, name, MH.type(rtype, types)); - } - - @Override - protected ScriptFunction makeBoundFunction(final ScriptFunctionData data) { - //prevent trampoline recompilation cycle if a function is bound before use - compile(); - return super.makeBoundFunction(data); - } - - private MethodHandle compile() throws CompilationException { - final Compiler compiler = new Compiler(installer, functionNode); - - compiler.compile(); - - final Class clazz = compiler.install(); - /* compute function signature for lazy method. this can be done first after compilation, as only then do we know - * the final state about callees, scopes and specialized parameter types */ - final FunctionSignature signature = new FunctionSignature(true, functionNode.needsCallee(), Type.OBJECT, functionNode.getParameters().size()); - final MethodType mt = signature.getMethodType(); - - MethodHandle mh = MH.findStatic(MethodHandles.publicLookup(), clazz, functionNode.getName(), mt); - if (functionNode.needsCallee()) { - mh = MH.bindTo(mh, this); - } - - // now the invoker method looks like the one our superclass is expecting - resetInvoker(mh); - - return mh; - } - - @SuppressWarnings("unused") - private Object trampoline(final Object... args) throws CompilationException { - Compiler.LOG.info(">>> TRAMPOLINE: Hitting trampoline for '" + functionNode.getName() + "'"); - MethodHandle mh = compile(); - - Compiler.LOG.info("<<< COMPILED TO: " + mh); - // spread the array to invididual args of the correct type - mh = MH.asSpreader(mh, Object[].class, mh.type().parameterCount()); - - try { - //invoke the real method the trampoline points to. this only happens once - return mh.invoke(args); - } catch (final RuntimeException | Error e) { - throw e; - } catch (final Throwable t) { - throw new RuntimeException(t); - } - } -} diff --git a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java index 39cf549e50a..5468ca3d74e 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/JSONParser.java @@ -313,7 +313,7 @@ loop: } // Construct new object literal. - return new ObjectNode(source, objectToken, finish, null, elements); + return new ObjectNode(source, objectToken, finish, elements); } /** diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index 41149e4b9f6..bfc96abf47c 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -59,6 +59,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Stack; + import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.codegen.Namespace; import jdk.nashorn.internal.ir.AccessNode; @@ -96,7 +97,7 @@ import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WhileNode; import jdk.nashorn.internal.ir.WithNode; -import jdk.nashorn.internal.runtime.Context; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.ErrorManager; import jdk.nashorn.internal.runtime.JSErrorType; @@ -116,9 +117,6 @@ public class Parser extends AbstractParser { /** Is scripting mode. */ private final boolean scripting; - /** Top level script being parsed. */ - private FunctionNode script; - /** Current function being parsed. */ private FunctionNode function; @@ -304,6 +302,7 @@ loop: final FunctionNode functionBlock = new FunctionNode(source, token, Token.descPosition(token), namespace, block, ident, name); block = function = functionBlock; function.setStrictMode(isStrictMode); + function.setState(errors.hasErrors() ? CompilationState.PARSE_ERROR : CompilationState.PARSED); return functionBlock; } @@ -312,7 +311,7 @@ loop: * Restore the current block. */ private void restoreBlock() { - block = block.getParent(); + block = block.getParent(); function = block.getFunction(); } @@ -338,7 +337,7 @@ loop: popControlNode(); } - final int possibleEnd = Token.descPosition(token) + Token.descLength(token); + final int possibleEnd = Token.descPosition(token) + Token.descLength(token); // Block closing brace. if (needsBraces) { @@ -438,7 +437,7 @@ loop: } if (lhs instanceof IdentNode) { - if (! checkIdentLValue((IdentNode)lhs)) { + if (!checkIdentLValue((IdentNode)lhs)) { return referenceError(lhs, rhs); } verifyStrictIdent((IdentNode)lhs, "assignment"); @@ -621,15 +620,13 @@ loop: // Make a fake token for the script. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the script to append elements. - script = newFunctionBlock(new IdentNode(source, functionToken, Token.descPosition(functionToken), scriptName)); - // set kind to be SCRIPT + + final FunctionNode script = newFunctionBlock(new IdentNode(source, functionToken, Token.descPosition(functionToken), scriptName)); + script.setKind(FunctionNode.Kind.SCRIPT); - // Set the first token of the script. script.setFirstToken(functionToken); - // Gather source elements. sourceElements(); expect(EOF); - // Set the last token of the script. script.setLastToken(token); script.setFinish(source.getLength() - 1); @@ -1231,7 +1228,7 @@ loop: } if (init instanceof IdentNode) { - if (! checkIdentLValue((IdentNode)init)) { + if (!checkIdentLValue((IdentNode)init)) { error(AbstractParser.message("not.lvalue.for.in.loop"), init.getToken()); } verifyStrictIdent((IdentNode)init, "for-in iterator"); @@ -2026,7 +2023,7 @@ loop: break; default: - if (! elision) { + if (!elision) { error(AbstractParser.message("expected.comma", type.getNameOrType())); } // Add expression element. @@ -2067,15 +2064,11 @@ loop: next(); // Object context. - Block objectContext = null; // Prepare to accumulate elements. final List elements = new ArrayList<>(); final Map map = new HashMap<>(); - try { - // Create a block for the object literal. - objectContext = newBlock(); - + // Create a block for the object literal. boolean commaSeen = true; loop: while (true) { @@ -2090,97 +2083,90 @@ loop: break; default: - if (! commaSeen) { + if (!commaSeen) { error(AbstractParser.message("expected.comma", type.getNameOrType())); - } - - commaSeen = false; - // Get and add the next property. - final PropertyNode property = propertyAssignment(); - final Object key = property.getKeyName(); - final PropertyNode existingProperty = map.get(key); - - if (existingProperty != null) { - // ECMA section 11.1.5 Object Initialiser - // point # 4 on property assignment production - final Node value = property.getValue(); - final Node getter = property.getGetter(); - final Node setter = property.getSetter(); - - final Node prevValue = existingProperty.getValue(); - final Node prevGetter = existingProperty.getGetter(); - final Node prevSetter = existingProperty.getSetter(); - - boolean redefinitionOk = true; - // ECMA 11.1.5 strict mode restrictions - if (isStrictMode) { - if (value != null && prevValue != null) { - redefinitionOk = false; - } - } - - final boolean isPrevAccessor = prevGetter != null || prevSetter != null; - final boolean isAccessor = getter != null || setter != null; - - // data property redefined as accessor property - if (prevValue != null && isAccessor) { - redefinitionOk = false; - } - - // accessor property redefined as data - if (isPrevAccessor && value != null) { - redefinitionOk = false; - } - - if (isAccessor && isPrevAccessor) { - if (getter != null && prevGetter != null || - setter != null && prevSetter != null) { - redefinitionOk = false; - } - } - - if (! redefinitionOk) { - error(AbstractParser.message("property.redefinition", key.toString()), property.getToken()); - } - - if (value != null) { - final Node existingValue = existingProperty.getValue(); - - if (existingValue == null) { - existingProperty.setValue(value); - } else { - final long propertyToken = Token.recast(existingProperty.getToken(), COMMARIGHT); - existingProperty.setValue(new BinaryNode(source, propertyToken, existingValue, value)); - } - - existingProperty.setGetter(null); - existingProperty.setSetter(null); - } - - if (getter != null) { - existingProperty.setGetter(getter); - } - - if (setter != null) { - existingProperty.setSetter(setter); - } - } else { - map.put(key, property); - elements.add(property); - } - - break; } + + commaSeen = false; + // Get and add the next property. + final PropertyNode property = propertyAssignment(); + final Object key = property.getKeyName(); + final PropertyNode existingProperty = map.get(key); + + if (existingProperty != null) { + // ECMA section 11.1.5 Object Initialiser + // point # 4 on property assignment production + final Node value = property.getValue(); + final Node getter = property.getGetter(); + final Node setter = property.getSetter(); + + final Node prevValue = existingProperty.getValue(); + final Node prevGetter = existingProperty.getGetter(); + final Node prevSetter = existingProperty.getSetter(); + + boolean redefinitionOk = true; + // ECMA 11.1.5 strict mode restrictions + if (isStrictMode) { + if (value != null && prevValue != null) { + redefinitionOk = false; + } + } + + final boolean isPrevAccessor = prevGetter != null || prevSetter != null; + final boolean isAccessor = getter != null || setter != null; + + // data property redefined as accessor property + if (prevValue != null && isAccessor) { + redefinitionOk = false; + } + + // accessor property redefined as data + if (isPrevAccessor && value != null) { + redefinitionOk = false; + } + + if (isAccessor && isPrevAccessor) { + if (getter != null && prevGetter != null || + setter != null && prevSetter != null) { + redefinitionOk = false; + } + } + + if (!redefinitionOk) { + error(AbstractParser.message("property.redefinition", key.toString()), property.getToken()); + } + + if (value != null) { + final Node existingValue = existingProperty.getValue(); + + if (existingValue == null) { + existingProperty.setValue(value); + } else { + final long propertyToken = Token.recast(existingProperty.getToken(), COMMARIGHT); + existingProperty.setValue(new BinaryNode(source, propertyToken, existingValue, value)); + } + + existingProperty.setGetter(null); + existingProperty.setSetter(null); + } + + if (getter != null) { + existingProperty.setGetter(getter); + } + + if (setter != null) { + existingProperty.setSetter(setter); + } + } else { + map.put(key, property); + elements.add(property); + } + + break; } - } finally { - restoreBlock(); } - // Construct new object literal. - objectContext.setFinish(finish); - objectContext.setStart(Token.descPosition(objectToken)); - - return new ObjectNode(source, objectToken, finish, objectContext, elements); + return new ObjectNode(source, objectToken, finish, elements); } /** @@ -2845,7 +2831,7 @@ loop: } if (lhs instanceof IdentNode) { - if (! checkIdentLValue((IdentNode)lhs)) { + if (!checkIdentLValue((IdentNode)lhs)) { return referenceError(lhs, null); } verifyStrictIdent((IdentNode)lhs, "operand for " + opType.getName() + " operator"); @@ -2872,7 +2858,7 @@ loop: return referenceError(lhs, null); } if (lhs instanceof IdentNode) { - if (! checkIdentLValue((IdentNode)lhs)) { + if (!checkIdentLValue((IdentNode)lhs)) { next(); return referenceError(lhs, null); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java index 9f6867ddaf8..996bea35166 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/AccessorProperty.java @@ -164,7 +164,6 @@ public class AccessorProperty extends Property { super(key, flags, slot); /* - * * primitiveGetter and primitiveSetter are only used in dual fields mode. Setting them to null also * works in dual field mode, it only means that the property never has a primitive * representation. @@ -348,11 +347,10 @@ public class AccessorProperty extends Property { private MethodHandle debug(final MethodHandle mh, final Class forType, final Class type, final String tag) { if (DEBUG_FIELDS) { - final MethodHandle mhd = MethodHandleFactory.addDebugPrintout( + return MethodHandleFactory.addDebugPrintout( LOG, mh, tag + " '" + getKey() + "' (property="+ Debug.id(this) + ", forType=" + stripName(forType) + ", type=" + stripName(type) + ')'); - return mhd; } return mh; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/CodeInstaller.java b/nashorn/src/jdk/nashorn/internal/runtime/CodeInstaller.java index 5fd16528e22..80fac179cb0 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/CodeInstaller.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/CodeInstaller.java @@ -25,6 +25,8 @@ package jdk.nashorn.internal.runtime; +import jdk.nashorn.internal.codegen.ClassEmitter; + /** * Interface for installing classes passed to the compiler. * As only the code generating package (i.e. Context) knows about @@ -52,12 +54,12 @@ public interface CodeInstaller { */ public Class install(final String className, final byte[] bytecode); - /* + /** * Verify generated bytecode before emission. This is called back from the * {@link ClassEmitter} or the {@link Compiler}. If the "--verify-code" parameter * hasn't been given, this is a nop * - * @param bytecode bytecode to verify + * @param code bytecode to verify */ public void verify(final byte[] code); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java new file mode 100644 index 00000000000..3cc9f09d238 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.runtime; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodType; + +import jdk.nashorn.internal.codegen.types.Type; + +/** + * An version of a JavaScript function, native or JavaScript. + * Supports lazily generating a constructor version of the invocation. + */ +final class CompiledFunction implements Comparable { + + private final MethodHandle invoker; + private MethodHandle constructor; + + CompiledFunction(final MethodHandle invoker) { + this(invoker, null); + } + + CompiledFunction(final MethodHandle invoker, final MethodHandle constructor) { + this.invoker = invoker; + this.constructor = constructor; //isConstructor + } + + @Override + public String toString() { + return ""; + } + + MethodHandle getInvoker() { + return invoker; + } + + MethodHandle getConstructor() { + return constructor; + } + + void setConstructor(final MethodHandle constructor) { + this.constructor = constructor; + } + + boolean hasConstructor() { + return constructor != null; + } + + MethodType type() { + return invoker.type(); + } + + @Override + public int compareTo(final CompiledFunction o) { + return weight() - o.weight(); + } + + private int weight() { + return weight(type()); + } + + private static int weight(final MethodType type) { + if (isVarArgsType(type)) { + return Integer.MAX_VALUE; //if there is a varargs it should be the heavist and last fallback + } + + int weight = Type.typeFor(type.returnType()).getWeight(); + for (final Class paramType : type.parameterArray()) { + final int pweight = Type.typeFor(paramType).getWeight(); + weight += pweight; + } + return weight; + } + + private static boolean isVarArgsType(final MethodType type) { + assert type.parameterCount() >= 1 : type; + return type.parameterType(type.parameterCount() - 1) == Object[].class; + } + + boolean moreGenericThan(final CompiledFunction o) { + return weight() > o.weight(); + } + + boolean moreGenericThan(final MethodType type) { + return weight() > weight(type); + } + + /** + * Check whether a given method descriptor is compatible with this invocation. + * It is compatible if the types are narrower than the invocation type so that + * a semantically equivalent linkage can be performed. + * + * @param typesc + * @return + */ + boolean typeCompatible(final MethodType type) { + final Class[] wantedParams = type.parameterArray(); + final Class[] existingParams = type().parameterArray(); + + //if we are not examining a varargs type, the number of parameters must be the same + if (wantedParams.length != existingParams.length && !isVarArgsType(type)) { + return false; + } + + //we only go as far as the shortest array. the only chance to make this work if + //parameters lengths do not match is if our type ends with a varargs argument. + //then every trailing parameter in the given callsite can be folded into it, making + //us compatible (albeit slower than a direct specialization) + final int lastParamIndex = Math.min(wantedParams.length, existingParams.length); + for (int i = 0; i < lastParamIndex; i++) { + final Type w = Type.typeFor(wantedParams[i]); + final Type e = Type.typeFor(existingParams[i]); + + //don't specialize on booleans, we have the "true" vs int 1 ambiguity in resolution + //we also currently don't support boolean as a javascript function callsite type. + //it will always box. + if (w.isBoolean()) { + return false; + } + + //This callsite type has a vararg here. it will swallow all remaining args. + //for consistency, check that it's the last argument + if (e.isArray()) { + return true; + } + + //Our arguments must be at least as wide as the wanted one, if not wider + if (Type.widest(w, e) != e) { + //e.g. this invocation takes double and callsite says "object". reject. won't fit + //but if invocation takes a double and callsite says "int" or "long" or "double", that's fine + return false; + } + } + + return true; // anything goes for return type, take the convenient one and it will be upcasted thru dynalink magic. + } + + + +} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java new file mode 100644 index 00000000000..ff660d3d3b4 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunctions.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.runtime; + +import java.lang.invoke.MethodType; +import java.util.Iterator; +import java.util.TreeSet; + +/** + * This is a list of code versions of a function. + * The list is sorted in ascending order of generic descriptors + */ +@SuppressWarnings("serial") +final class CompiledFunctions extends TreeSet { + + CompiledFunction best(final MethodType type) { + final Iterator iter = iterator(); + while (iter.hasNext()) { + final CompiledFunction next = iter.next(); + if (next.typeCompatible(type)) { + return next; + } + } + return mostGeneric(); + } + + boolean needsCallee() { + for (final CompiledFunction inv : this) { + assert ScriptFunctionData.needsCallee(inv.getInvoker()) == ScriptFunctionData.needsCallee(mostGeneric().getInvoker()); + } + return ScriptFunctionData.needsCallee(mostGeneric().getInvoker()); + } + + CompiledFunction mostGeneric() { + return last(); + } + + /** + * Is the given type even more specific than this entire list? That means + * we have an opportunity for more specific versions of the method + * through lazy code generation + * + * @param type type to check against + * @return true if the given type is more specific than all invocations available + */ + boolean isLessSpecificThan(final MethodType type) { + return best(type).moreGenericThan(type); + } + + +} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 516c0a79892..151615c07df 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -80,7 +80,7 @@ public final class Context { /** * Return the context for this installer - * @return context + * @return ScriptEnvironment */ @Override public ScriptEnvironment getOwner() { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java b/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java index a07fb580d69..a32e721cc46 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ECMAException.java @@ -237,7 +237,7 @@ public final class ECMAException extends NashornException { return (String)name; } - return (String)name + ": " + (String)msg; + return name + ": " + msg; } private static Throwable asThrowable(final Object obj) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java new file mode 100644 index 00000000000..ed54b2e92a3 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.runtime; + +import static jdk.nashorn.internal.lookup.Lookup.MH; + +import java.lang.invoke.MethodHandle; + +/** + * This is a subclass that represents a script function that may not be regenerated. + * This is used for example for bound functions and builtins. + */ +public final class FinalScriptFunctionData extends ScriptFunctionData { + + /** + * Constructor - used for bind + * + * @param name name + * @param arity arity + * @param list precompiled code + * @param isStrict strict + * @param isBuiltin builtin + * @param isConstructor constructor + */ + FinalScriptFunctionData(final String name, int arity, CompiledFunctions functions, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) { + super(name, arity, isStrict, isBuiltin, isConstructor); + code.addAll(functions); + } + + /** + * Constructor - used from ScriptFunction. This assumes that we have code alraedy for the + * method (typically a native method) and possibly specializations. + * + * @param name name + * @param mh method handle for generic version of method + * @param specs specializations + * @param isStrict strict + * @param isBuiltin builtin + * @param isConstructor constructor + */ + FinalScriptFunctionData(final String name, final MethodHandle mh, final MethodHandle[] specs, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) { + super(name, arity(mh), isStrict, isBuiltin, isConstructor); + + addInvoker(mh); + if (specs != null) { + for (final MethodHandle spec : specs) { + addInvoker(spec); + } + } + } + + private void addInvoker(final MethodHandle mh) { + boolean needsCallee = needsCallee(mh); + if (isConstructor(mh)) { + //only nasgen constructors: (boolean, self, args) are subject to binding a boolean newObj. isConstructor + //is too conservative a check. However, isConstructor(mh) always implies isConstructor param + assert isConstructor(); + code.add(new CompiledFunction(MH.insertArguments(mh, 0, false), composeConstructor(MH.insertArguments(mh, 0, true), needsCallee))); //make sure callee state can be determined when we reach constructor + } else { + code.add(new CompiledFunction(mh)); + } + } + + private static int arity(final MethodHandle mh) { + if (isVarArg(mh)) { + return -1; + } + + //drop self, callee and boolean constructor flag to get real arity + return mh.type().parameterCount() - 1 - (needsCallee(mh) ? 1 : 0) - (isConstructor(mh) ? 1 : 0); + } + + private static boolean isConstructor(final MethodHandle mh) { + return mh.type().parameterCount() >= 1 && mh.type().parameterType(0) == boolean.class; + } + +} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java new file mode 100644 index 00000000000..03f0ab5d906 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.runtime; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +import jdk.nashorn.internal.codegen.Compiler; +import jdk.nashorn.internal.codegen.CompilerConstants; +import jdk.nashorn.internal.codegen.FunctionSignature; +import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; +import jdk.nashorn.internal.parser.Token; +import jdk.nashorn.internal.parser.TokenType; + +import static jdk.nashorn.internal.lookup.Lookup.MH; + +/** + * This is a subclass that represents a script function that may be regenerated, + * for example with specialization based on call site types, or lazily generated. + * The common denominator is that it can get new invokers during its lifespan, + * unlike {@link FinalScriptFunctionData} + */ +public final class RecompilableScriptFunctionData extends ScriptFunctionData { + + private final FunctionNode functionNode; + private final PropertyMap allocatorMap; + private final CodeInstaller installer; + private final String allocatorClassName; + + /** lazily generated allocator */ + private MethodHandle allocator; + + private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); + + /** + * Constructor - public as scripts use it + * + * @param functionNode functionNode that represents this function code + * @param installer installer for code regeneration versions of this function + * @param allocatorClassName name of our allocator class, will be looked up dynamically if used as a constructor + * @param allocatorMap allocator map to seed instances with, when constructing + */ + public RecompilableScriptFunctionData(final FunctionNode functionNode, final CodeInstaller installer, final String allocatorClassName, final PropertyMap allocatorMap) { + super(functionNode.isAnonymous() ? + "" : + functionNode.getIdent().getName(), + functionNode.getParameters().size(), + functionNode.isStrictMode(), + false, + true); + + this.functionNode = functionNode; + this.installer = installer; + this.allocatorClassName = allocatorClassName; + this.allocatorMap = allocatorMap; + } + + @Override + String toSource() { + final Source source = functionNode.getSource(); + final long token = tokenFor(functionNode); + + if (source != null && token != 0) { + return source.getString(Token.descPosition(token), Token.descLength(token)); + } + + return "function " + (name == null ? "" : name) + "() { [native code] }"; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + final Source source = functionNode.getSource(); + final long token = tokenFor(functionNode); + + if (source != null) { + sb.append(source.getName()) + .append(':') + .append(source.getLine(Token.descPosition(token))) + .append(' '); + } + + return sb.toString() + super.toString(); + } + + private static long tokenFor(final FunctionNode fn) { + final int position = Token.descPosition(fn.getFirstToken()); + final int length = Token.descPosition(fn.getLastToken()) - position + Token.descLength(fn.getLastToken()); + + return Token.toDesc(TokenType.FUNCTION, position, length); + } + + @Override + ScriptObject allocate() { + try { + ensureHasAllocator(); //if allocatorClass name is set to null (e.g. for bound functions) we don't even try + return allocator == null ? null : (ScriptObject)allocator.invokeExact(allocatorMap); + } catch (final RuntimeException | Error e) { + throw e; + } catch (final Throwable t) { + throw new RuntimeException(t); + } + } + + private void ensureHasAllocator() throws ClassNotFoundException { + if (allocator == null && allocatorClassName != null) { + this.allocator = MH.findStatic(LOOKUP, Context.forStructureClass(allocatorClassName), CompilerConstants.ALLOCATE.tag(), MH.type(ScriptObject.class, PropertyMap.class)); + } + } + + @Override + protected void ensureCodeGenerated() { + if (!code.isEmpty()) { + return; // nothing to do, we have code, at least some. + } + + // check if function node is lazy, need to compile it. + // note that currently function cloning is not working completely, which + // means that the compiler will mutate the function node it has been given + // once it has been compiled, it cannot be recompiled. This means that + // lazy compilation works (not compiled yet) but e.g. specializations won't + // until the copy-on-write changes for IR are in, making cloning meaningless. + // therefore, currently method specialization is disabled. TODO + + if (functionNode.isLazy()) { + Compiler.LOG.info("Trampoline hit: need to do lazy compilation of '" + functionNode.getName() + "'"); + new Compiler(installer, functionNode).compile().install(); + + // we don't need to update any flags - varArgs and needsCallee are instrincic + // in the function world we need to get a destination node from the compile instead + // and replace it with our function node. TODO + } + + // we can't get here unless we have bytecode, either from eager compilation or from + // running a lazy compile on the lines above + + assert functionNode.hasState(CompilationState.INSTALLED); + + // code exists - look it up and add it into the automatically sorted invoker list + code.add( + new CompiledFunction( + MH.findStatic( + LOOKUP, + functionNode.getCompileUnit().getCode(), + functionNode.getName(), + new FunctionSignature(functionNode). + getMethodType()))); + } + + @Override + MethodHandle getBestInvoker(final MethodType callSiteType, final Object[] args) { + final MethodHandle mh = super.getBestInvoker(callSiteType, args); + if (code.isLessSpecificThan(callSiteType)) { + // opportunity for code specialization - we can regenerate a better version of this method + } + return mh; + } + +} + diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java index def0313f948..36a1d2ac4de 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java @@ -82,6 +82,9 @@ public final class ScriptEnvironment { /** Show full Nashorn version */ public final boolean _fullversion; + /** Should lazy compilation take place */ + public final boolean _lazy_compilation; + /** Create a new class loaded for each compilation */ public final boolean _loader_per_compile; @@ -155,6 +158,7 @@ public final class ScriptEnvironment { _early_lvalue_error = options.getBoolean("early.lvalue.error"); _empty_statements = options.getBoolean("empty.statements"); _fullversion = options.getBoolean("fullversion"); + _lazy_compilation = options.getBoolean("lazy.compilation"); _loader_per_compile = options.getBoolean("loader.per.compile"); _no_syntax_extensions = options.getBoolean("no.syntax.extensions"); _package = options.getString("package"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java index 2d28f91e1a4..512a0b16506 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java @@ -33,11 +33,11 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; + import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; import jdk.nashorn.internal.codegen.CompilerConstants.Call; -import jdk.nashorn.internal.objects.annotations.SpecializedFunction; import jdk.nashorn.internal.lookup.MethodHandleFactory; import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; import jdk.nashorn.internal.runtime.linker.NashornGuards; @@ -48,16 +48,16 @@ import jdk.nashorn.internal.runtime.linker.NashornGuards; public abstract class ScriptFunction extends ScriptObject { /** Method handle for prototype getter for this ScriptFunction */ - public static final MethodHandle G$PROTOTYPE = findOwnMH("G$prototype", Object.class, Object.class); + public static final MethodHandle G$PROTOTYPE = findOwnMH("G$prototype", Object.class, Object.class); /** Method handle for prototype setter for this ScriptFunction */ - public static final MethodHandle S$PROTOTYPE = findOwnMH("S$prototype", void.class, Object.class, Object.class); + public static final MethodHandle S$PROTOTYPE = findOwnMH("S$prototype", void.class, Object.class, Object.class); /** Method handle for length getter for this ScriptFunction */ - public static final MethodHandle G$LENGTH = findOwnMH("G$length", int.class, Object.class); + public static final MethodHandle G$LENGTH = findOwnMH("G$length", int.class, Object.class); /** Method handle for name getter for this ScriptFunction */ - public static final MethodHandle G$NAME = findOwnMH("G$name", Object.class, Object.class); + public static final MethodHandle G$NAME = findOwnMH("G$name", Object.class, Object.class); /** Method handle for allocate function for this ScriptFunction */ static final MethodHandle ALLOCATE = findOwnMH("allocate", Object.class); @@ -67,7 +67,9 @@ public abstract class ScriptFunction extends ScriptObject { /** method handle to scope getter for this ScriptFunction */ public static final Call GET_SCOPE = virtualCallNoLookup(ScriptFunction.class, "getScope", ScriptObject.class); - private final ScriptFunctionData data; + private static final MethodHandle IS_FUNCTION_MH = findOwnMH("isFunctionMH", boolean.class, Object.class, ScriptFunctionData.class); + + private static final MethodHandle IS_NONSTRICT_FUNCTION = findOwnMH("isNonStrictFunction", boolean.class, Object.class, Object.class, ScriptFunctionData.class); /** Reference to constructor prototype. */ protected Object prototype; @@ -75,6 +77,8 @@ public abstract class ScriptFunction extends ScriptObject { /** The parent scope. */ private final ScriptObject scope; + private final ScriptFunctionData data; + /** * Constructor * @@ -97,7 +101,7 @@ public abstract class ScriptFunction extends ScriptObject { final boolean builtin, final boolean isConstructor) { - this (new ScriptFunctionData(name, methodHandle, specs, strict, builtin, isConstructor), map, scope); + this(new FinalScriptFunctionData(name, methodHandle, specs, strict, builtin, isConstructor), map, scope); } /** @@ -118,8 +122,8 @@ public abstract class ScriptFunction extends ScriptObject { constructorCount++; } - this.data = data; - this.scope = scope; + this.data = data; + this.scope = scope; } @Override @@ -295,20 +299,20 @@ public abstract class ScriptFunction extends ScriptObject { /** * Return the most appropriate invoke handle if there are specializations * @param type most specific method type to look for invocation with + * @param callsite args for trampoline invocation * @return invoke method handle */ - private final MethodHandle getBestInvoker(final MethodType type) { - return data.getBestInvoker(type); + private MethodHandle getBestInvoker(final MethodType type, final Object[] args) { + return data.getBestInvoker(type, args); } /** - * Get the invoke handle - the most generic (and if no specializations are in place, only) invocation - * method handle for this ScriptFunction - * @see SpecializedFunction - * @return invokeHandle + * Return the most appropriate invoke handle if there are specializations + * @param type most specific method type to look for invocation with + * @return invoke method handle */ - public final MethodHandle getInvokeHandle() { - return data.getInvoker(); + public MethodHandle getBestInvoker(final MethodType type) { + return getBestInvoker(type, null); } /** @@ -319,7 +323,7 @@ public abstract class ScriptFunction extends ScriptObject { * @return bound invoke handle */ public final MethodHandle getBoundInvokeHandle(final ScriptObject self) { - return MH.bindTo(bindToCalleeIfNeeded(getInvokeHandle()), self); + return MH.bindTo(bindToCalleeIfNeeded(data.getGenericInvoker()), self); } /** @@ -329,7 +333,8 @@ public abstract class ScriptFunction extends ScriptObject { * @return the potentially bound method handle */ private MethodHandle bindToCalleeIfNeeded(final MethodHandle methodHandle) { - return data.needsCallee() ? MH.bindTo(methodHandle, this) : methodHandle; + return ScriptFunctionData.needsCallee(methodHandle) ? MH.bindTo(methodHandle, this) : methodHandle; + } /** @@ -340,15 +345,6 @@ public abstract class ScriptFunction extends ScriptObject { return data.getName(); } - /** - * Does this script function need to be compiled. This determined by - * null checking invokeHandle - * - * @return true if this needs compilation - */ - public final boolean needsCompilation() { - return data.getInvoker() == null; - } /** * Get the scope for this function @@ -358,15 +354,6 @@ public abstract class ScriptFunction extends ScriptObject { return scope; } - /** - * Reset the invoker handle. This is used by trampolines for - * lazy code generation - * @param invoker new invoker - */ - protected void resetInvoker(final MethodHandle invoker) { - data.resetInvoker(invoker); - } - /** * Prototype getter for this ScriptFunction - follows the naming convention * used by Nasgen and the code generator @@ -464,7 +451,7 @@ public abstract class ScriptFunction extends ScriptObject { @Override protected GuardedInvocation findNewMethod(final CallSiteDescriptor desc) { final MethodType type = desc.getMethodType(); - return new GuardedInvocation(pairArguments(data.getBestConstructor(type), type), null, NashornGuards.getFunctionGuard(this)); + return new GuardedInvocation(pairArguments(data.getBestConstructor(type.changeParameterType(0, ScriptFunction.class), null), type), null, getFunctionGuard(this)); } @SuppressWarnings("unused") @@ -472,7 +459,7 @@ public abstract class ScriptFunction extends ScriptObject { if (obj instanceof ScriptObject || !ScriptFunctionData.isPrimitiveThis(obj)) { return obj; } - return ((GlobalObject) Context.getGlobalTrusted()).wrapAsObject(obj); + return ((GlobalObject)Context.getGlobalTrusted()).wrapAsObject(obj); } /** @@ -506,8 +493,7 @@ public abstract class ScriptFunction extends ScriptObject { MethodHandle guard = null; if (data.needsCallee()) { - final MethodHandle callHandle = getBestInvoker(type); - + final MethodHandle callHandle = getBestInvoker(type, request.getArguments()); if (NashornCallSiteDescriptor.isScope(desc)) { // Make a handle that drops the passed "this" argument and substitutes either Global or Undefined // (callee, this, args...) => (callee, args...) @@ -525,13 +511,12 @@ public abstract class ScriptFunction extends ScriptObject { if (ScriptFunctionData.isPrimitiveThis(request.getArguments()[1])) { boundHandle = MH.filterArguments(boundHandle, 1, WRAPFILTER); } else { - guard = NashornGuards.getNonStrictFunctionGuard(this); + guard = getNonStrictFunctionGuard(this); } } } } else { - final MethodHandle callHandle = getBestInvoker(type.dropParameterTypes(0, 1)); - + final MethodHandle callHandle = getBestInvoker(type.dropParameterTypes(0, 1), request.getArguments()); if (NashornCallSiteDescriptor.isScope(desc)) { // Make a handle that drops the passed "this" argument and substitutes either Global or Undefined // (this, args...) => (args...) @@ -545,7 +530,8 @@ public abstract class ScriptFunction extends ScriptObject { } boundHandle = pairArguments(boundHandle, type); - return new GuardedInvocation(boundHandle, guard == null ? NashornGuards.getFunctionGuard(this) : guard); + + return new GuardedInvocation(boundHandle, guard == null ? getFunctionGuard(this) : guard); } /** @@ -554,13 +540,50 @@ public abstract class ScriptFunction extends ScriptObject { * These don't want a callee parameter, so bind that. Name binding is optional. */ MethodHandle getCallMethodHandle(final MethodType type, final String bindName) { - return pairArguments(bindToNameIfNeeded(bindToCalleeIfNeeded(getBestInvoker(type)), bindName), type); + return pairArguments(bindToNameIfNeeded(bindToCalleeIfNeeded(getBestInvoker(type, null)), bindName), type); } private static MethodHandle bindToNameIfNeeded(final MethodHandle methodHandle, final String bindName) { return bindName == null ? methodHandle : MH.insertArguments(methodHandle, 1, bindName); } + /** + * Get the guard that checks if a {@link ScriptFunction} is equal to + * a known ScriptFunction, using reference comparison + * + * @param function The ScriptFunction to check against. This will be bound to the guard method handle + * + * @return method handle for guard + */ + private static MethodHandle getFunctionGuard(final ScriptFunction function) { + assert function.data != null; + return MH.insertArguments(IS_FUNCTION_MH, 1, function.data); + } + + /** + * Get a guard that checks if a {@link ScriptFunction} is equal to + * a known ScriptFunction using reference comparison, and whether the type of + * the second argument (this-object) is not a JavaScript primitive type. + * + * @param function The ScriptFunction to check against. This will be bound to the guard method handle + * + * @return method handle for guard + */ + private static MethodHandle getNonStrictFunctionGuard(final ScriptFunction function) { + assert function.data != null; + return MH.insertArguments(IS_NONSTRICT_FUNCTION, 2, function.data); + } + + @SuppressWarnings("unused") + private static boolean isFunctionMH(final Object self, final ScriptFunctionData data) { + return self instanceof ScriptFunction && ((ScriptFunction)self).data == data; + } + + @SuppressWarnings("unused") + private static boolean isNonStrictFunction(final Object self, final Object arg, final ScriptFunctionData data) { + return self instanceof ScriptFunction && ((ScriptFunction)self).data == data && arg instanceof ScriptObject; + } + private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { final Class own = ScriptFunction.class; final MethodType mt = MH.type(rtype, types); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java index 8f8193e4786..f83cfa2c954 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java @@ -32,227 +32,94 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; -import jdk.nashorn.internal.ir.FunctionNode; -import jdk.nashorn.internal.parser.Token; -import jdk.nashorn.internal.parser.TokenType; + +import jdk.nashorn.internal.runtime.linker.JavaAdapterFactory; /** * A container for data needed to instantiate a specific {@link ScriptFunction} at runtime. * Instances of this class are created during codegen and stored in script classes' * constants array to reduce function instantiation overhead during runtime. */ -public final class ScriptFunctionData { - private static final MethodHandle BIND_VAR_ARGS = findOwnMH("bindVarArgs", Object[].class, Object[].class, Object[].class); +public abstract class ScriptFunctionData { + + /** Name of the function or "" for anonynous functions */ + protected final String name; + + /** All versions of this function that have been generated to code */ + protected final CompiledFunctions code; + + private int arity; + + private final boolean isStrict; + + private final boolean isBuiltin; + + private final boolean isConstructor; + private static final MethodHandle NEWFILTER = findOwnMH("newFilter", Object.class, Object.class, Object.class); - - // per-function object flags - private static final int IS_STRICT = 0b0000_0001; - private static final int IS_BUILTIN = 0b0000_0010; - private static final int HAS_CALLEE = 0b0000_0100; - private static final int IS_VARARGS = 0b0000_1000; - private static final int IS_CONSTRUCTOR = 0b0001_0000; - - /** Name of the function or "" */ - private final String name; - /** Source of this function, or null */ - private final Source source; - /** Map for new instance constructor */ - private PropertyMap allocatorMap; - /** Start position and length in source */ - private final long token; - /** Number of expected arguments, either taken from FunctionNode or calculated from method handle signature*/ - private int arity; - private final int flags; - - /** Reference to code for this method. */ - private MethodHandle invoker; - /** Reference to code for this method when called to create "new" object. This must always be populated with a - * result of calling {@link #composeConstructor(MethodHandle)} on the value of the {@link #invoker} field. */ - private MethodHandle constructor; - /** Constructor to create a new instance. */ - private MethodHandle allocator; - /** Generic invoker to used in {@link ScriptFunction#invoke(Object, Object...)}. */ - private MethodHandle genericInvoker; - /** Specializations - see @SpecializedFunction */ - private MethodHandle[] invokeSpecializations; - /** Specializations - see @SpecializedFunction. Same restrictions as for {@link #constructor} apply; only populate - * with method handles returned from {@link #composeConstructor(MethodHandle)}. */ - private MethodHandle[] constructSpecializations; - - /** - * Constructor - * @param fn the function node - * @param allocatorMap the allocator property map - */ - public ScriptFunctionData(final FunctionNode fn, final PropertyMap allocatorMap) { - - final long firstToken = fn.getFirstToken(); - final long lastToken = fn.getLastToken(); - final int position = Token.descPosition(firstToken); - final int length = Token.descPosition(lastToken) - position + Token.descLength(lastToken); - - this.name = fn.isAnonymous() ? "" : fn.getIdent().getName(); - this.source = fn.getSource(); - this.allocatorMap = allocatorMap; - this.token = Token.toDesc(TokenType.FUNCTION, position, length); - this.arity = fn.getParameters().size(); - this.flags = makeFlags(fn.needsCallee(), fn.isVarArg(), fn.isStrictMode(), false, true); - } + private static final MethodHandle BIND_VAR_ARGS = findOwnMH("bindVarArgs", Object[].class, Object[].class, Object[].class); /** * Constructor * - * @param name the function name - * @param methodHandle the method handle - * @param specs array of specialized method handles - * @param strict strict flag - * @param builtin builtin flag - * @param isConstructor constructor flags + * @param name script function name + * @param arity arity + * @param isStrict is the function strict + * @param isBuiltin is the function built in + * @param isConstructor is the function a constructor */ - public ScriptFunctionData(final String name, final MethodHandle methodHandle, final MethodHandle[] specs, final boolean strict, final boolean builtin, final boolean isConstructor) { - this(name, null, 0L, methodHandle, specs, strict, builtin, isConstructor); + protected ScriptFunctionData(final String name, final int arity, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) { + this.name = name; + this.arity = arity; + this.code = new CompiledFunctions(); + this.isStrict = isStrict; + this.isBuiltin = isBuiltin; + this.isConstructor = isConstructor; } - private ScriptFunctionData(final String name, final Source source, final long token, final MethodHandle methodHandle, final MethodHandle[] specs, final boolean strict, final boolean builtin, final boolean isConstructor) { - this.name = name; - this.source = source; - this.token = token; - - final boolean isVarArg = isVarArg(methodHandle); - final boolean needsCallee = needsCallee(methodHandle); - - this.flags = makeFlags(needsCallee, isVarArg, strict, builtin, isConstructor); - int lArity = isVarArg ? -1 : methodHandle.type().parameterCount() - 1; //drop the self param for arity - - if (needsCallee && !isVarArg) { - lArity--; - } - - if (isConstructor(methodHandle)) { - assert isConstructor; - if (!isVarArg) { - lArity--; // drop the boolean flag for arity - } - /* - * We insert a boolean argument to tell if the method was invoked as constructor or not if the method - * handle's first argument is boolean. - */ - this.invoker = MH.insertArguments(methodHandle, 0, false); - this.constructor = composeConstructor(MH.insertArguments(methodHandle, 0, true)); - - if (specs != null) { - this.invokeSpecializations = new MethodHandle[specs.length]; - this.constructSpecializations = new MethodHandle[specs.length]; - for (int i = 0; i < specs.length; i++) { - this.invokeSpecializations[i] = MH.insertArguments(specs[i], 0, false); - this.constructSpecializations[i] = composeConstructor(MH.insertArguments(specs[i], 0, true)); - } - } - } else { - this.invoker = methodHandle; - this.constructor = null; // delay composition of the constructor - this.invokeSpecializations = specs; - this.constructSpecializations = null; // delay composition of the constructors - } - this.arity = lArity; - } - - /** - * Get the arity of the function. - * @return the arity - */ - int getArity() { + final int getArity() { return arity; } /** - * Set the arity of the function. - * @param arity the arity + * Used from e.g. Native*$Constructors as an explicit call. TODO - make arity immutable and final + * @param arity new arity */ - void setArity(int arity) { + void setArity(final int arity) { this.arity = arity; } - /** - * Get the function name. - * @return function name - */ - String getName() { - return name; - } + CompiledFunction bind(final CompiledFunction originalInv, final ScriptFunction fn, final Object self, final Object[] args) { + final MethodHandle boundInvoker = bindInvokeHandle(originalInv.getInvoker(), fn, self, args); - /** - * Get this function as a String containing its source code. If no source code - * exists in this ScriptFunction, its contents will be displayed as {@code [native code]} - * @return string representation of this function's source - */ - String toSource() { - if (source != null && token != 0) { - return source.getString(Token.descPosition(token), Token.descLength(token)); + if (isConstructor()) { + ensureConstructor(originalInv); + return new CompiledFunction(boundInvoker, bindConstructHandle(originalInv.getConstructor(), fn, args)); } - return "function " + (name == null ? "" : name) + "() { [native code] }"; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - - sb.append(super.toString()) - .append(" [ ") - .append(invoker) - .append(", ") - .append((name == null || name.isEmpty()) ? "" : name); - - if (source != null) { - sb.append(" @ ") - .append(source.getName()) - .append(':') - .append(source.getLine(Token.descPosition(token))); - } - sb.append(" ]"); - - return sb.toString(); + return new CompiledFunction(boundInvoker); } /** - * Returns true if the function needs a callee argument. - * @return the needsCallee flag - */ - boolean needsCallee() { - return (flags & HAS_CALLEE) != 0; - } - - /** - * Returns true if this is a strict-mode function. - * @return the strict flag + * Is this a ScriptFunction generated with strict semantics? + * @return true if strict, false otherwise */ public boolean isStrict() { - return (flags & IS_STRICT) != 0; + return isStrict; } - /** - * Returns true if this is a built-in function. - * @return the built-in flag - */ - private boolean isBuiltin() { - return (flags & IS_BUILTIN) != 0; + boolean isBuiltin() { + return isBuiltin; } - /** - * Returns true if this function can be used as a constructor. - * @return the constructor flag - */ - private boolean isConstructor() { - return (flags & IS_CONSTRUCTOR) != 0; + boolean isConstructor() { + return isConstructor; } - /** - * Returns true if this is a var-arg function. - * @return the var-arg flag - */ - private boolean isVarArg() { - return (flags & IS_VARARGS) != 0; + boolean needsCallee() { + // we don't know if we need a callee or not unless we are generated + ensureCodeGenerated(); + return code.needsCallee(); } /** @@ -261,127 +128,408 @@ public final class ScriptFunctionData { * @return true if this argument must be an object */ boolean needsWrappedThis() { - return (flags & (IS_STRICT | IS_BUILTIN)) == 0; + return !isStrict && !isBuiltin; + } + + String toSource() { + return "function " + (name == null ? "" : name) + "() { [native code] }"; + } + + String getName() { + return name; } /** - * Get the method handle used to invoke this function. - * @return the invoke handle + * Get this function as a String containing its source code. If no source code + * exists in this ScriptFunction, its contents will be displayed as {@code [native code]} + * + * @return string representation of this function */ - MethodHandle getInvoker() { - return invoker; - } + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); - MethodHandle getBestInvoker(final MethodType type) { - return SpecializedMethodChooser.candidateWithLowestWeight(type, invoker, invokeSpecializations); + sb.append("name='"). + append(name.isEmpty() ? "" : name). + append("' "). + append(code.size()). + append(" invokers="). + append(code); + + return sb.toString(); } /** - * Get the method handle used to invoke this function as a constructor. - * @return the constructor handle + * Pick the best invoker, i.e. the one version of this method with as narrow and specific + * types as possible. If the call site arguments are objects, but boxed primitives we can + * also try to get a primitive version of the method and do an unboxing filter, but then + * we need to insert a guard that checks the argument is really always a boxed primitive + * and not suddenly a "real" object + * + * @param callSiteType callsite type + * @param args arguments at callsite on first trampoline invocation + * @return method handle to best invoker */ - private MethodHandle getConstructor() { - if (constructor == null) { - constructor = composeConstructor(invoker); - } - - return constructor; + MethodHandle getBestInvoker(final MethodType callSiteType, final Object[] args) { + return getBest(callSiteType).getInvoker(); } - MethodHandle getBestConstructor(MethodType descType) { + MethodHandle getBestInvoker(final MethodType callSiteType) { + return getBestInvoker(callSiteType, null); + } + + MethodHandle getBestConstructor(final MethodType callSiteType, final Object[] args) { if (!isConstructor()) { throw typeError("not.a.constructor", toSource()); } - return SpecializedMethodChooser.candidateWithLowestWeight(descType, getConstructor(), getConstructSpecializations()); + ensureCodeGenerated(); + + final CompiledFunction best = getBest(callSiteType); + ensureConstructor(best); + return best.getConstructor(); } - private MethodHandle composeConstructor(MethodHandle ctor) { + MethodHandle getBestConstructor(final MethodType callSiteType) { + return getBestConstructor(callSiteType, null); + } + + /** + * Subclass responsibility. If we can have lazy code generation, this is a hook to ensure that + * code exists before performing an operation. + */ + protected void ensureCodeGenerated() { + //empty + } + + /** + * Return a generic Object/Object invoker for this method. It will ensure code + * is generated, get the most generic of all versions of this function and adapt it + * to Objects. + * + * TODO this is only public because {@link JavaAdapterFactory} can't supply us with + * a MethodType that we can use for lookup due to boostrapping problems. Can be fixed + * + * @return generic invoker of this script function + */ + public final MethodHandle getGenericInvoker() { + ensureCodeGenerated(); + return composeGenericMethod(code.mostGeneric().getInvoker()); + } + + private CompiledFunction getBest(final MethodType callSiteType) { + ensureCodeGenerated(); + return code.best(callSiteType); + } + + /** + * Allocates an object using this function's allocator. + * @return the object allocated using this function's allocator, or null if the function doesn't have an allocator. + */ + ScriptObject allocate() { + return null; + } + + /** + * This method is used to create the immutable portion of a bound function. + * See {@link ScriptFunction#makeBoundFunction(Object, Object[])} + * + * @param fn the original function being bound + * @param self this reference to bind. Can be null. + * @param args additional arguments to bind. Can be null. + */ + ScriptFunctionData makeBoundFunctionData(final ScriptFunction fn, final Object self, final Object[] args) { + ensureCodeGenerated(); + + final Object[] allArgs = args == null ? ScriptRuntime.EMPTY_ARRAY : args; + final int length = args == null ? 0 : args.length; + + CompiledFunctions boundList = new CompiledFunctions(); + for (final CompiledFunction inv : code) { + boundList.add(bind(inv, fn, self, allArgs)); + } + ScriptFunctionData boundData = new FinalScriptFunctionData(name, arity == -1 ? -1 : Math.max(0, arity - length), boundList, isStrict(), isBuiltin(), isConstructor()); + return boundData; + } + + /** + * Compose a constructor given a primordial constructor handle + * + * @param ctor primordial constructor handle + * @param needsCallee do we need to pass a callee + * + * @return the composed constructor + */ + protected MethodHandle composeConstructor(final MethodHandle ctor, final boolean needsCallee) { // If it was (callee, this, args...), permute it to (this, callee, args...). We're doing this because having // "this" in the first argument position is what allows the elegant folded composition of // (newFilter x constructor x allocator) further down below in the code. Also, ensure the composite constructor // always returns Object. - MethodHandle composedCtor = changeReturnTypeToObject(swapCalleeAndThis(ctor)); + MethodHandle composedCtor = needsCallee ? swapCalleeAndThis(ctor) : ctor; + + composedCtor = changeReturnTypeToObject(composedCtor); final MethodType ctorType = composedCtor.type(); + // Construct a dropping type list for NEWFILTER, but don't include constructor "this" into it, so it's actually // captured as "allocation" parameter of NEWFILTER after we fold the constructor into it. // (this, [callee, ]args...) => ([callee, ]args...) final Class[] ctorArgs = ctorType.dropParameterTypes(0, 1).parameterArray(); + // Fold constructor into newFilter that replaces the return value from the constructor with the originally // allocated value when the originally allocated value is a primitive. // (result, this, [callee, ]args...) x (this, [callee, ]args...) => (this, [callee, ]args...) composedCtor = MH.foldArguments(MH.dropArguments(NEWFILTER, 2, ctorArgs), composedCtor); // allocate() takes a ScriptFunction and returns a newly allocated ScriptObject... - if (needsCallee()) { + if (needsCallee) { // ...we either fold it into the previous composition, if we need both the ScriptFunction callee object and // the newly allocated object in the arguments, so (this, callee, args...) x (callee) => (callee, args...), // or... return MH.foldArguments(composedCtor, ScriptFunction.ALLOCATE); } + // ...replace the ScriptFunction argument with the newly allocated object, if it doesn't need the callee // (this, args...) filter (callee) => (callee, args...) return MH.filterArguments(composedCtor, 0, ScriptFunction.ALLOCATE); } /** - * Get an adapted version of the invoker handle that only uses {@code Object} as parameter and return types. - * @return the generic invoke handle + * If this function's method handles need a callee parameter, swap the order of first two arguments for the passed + * method handle. If this function's method handles don't need a callee parameter, returns the original method + * handle unchanged. + * + * @param mh a method handle with order of arguments {@code (callee, this, args...)} + * + * @return a method handle with order of arguments {@code (this, callee, args...)} */ - private MethodHandle getGenericInvoker() { - if (genericInvoker == null) { - assert invoker != null : "invoker is null"; - genericInvoker = makeGenericMethod(invoker); + private static MethodHandle swapCalleeAndThis(final MethodHandle mh) { + final MethodType type = mh.type(); + assert type.parameterType(0) == ScriptFunction.class : type; + assert type.parameterType(1) == Object.class : type; + final MethodType newType = type.changeParameterType(0, Object.class).changeParameterType(1, ScriptFunction.class); + final int[] reorder = new int[type.parameterCount()]; + reorder[0] = 1; + assert reorder[1] == 0; + for (int i = 2; i < reorder.length; ++i) { + reorder[i] = i; } - return genericInvoker; + return MethodHandles.permuteArguments(mh, newType, reorder); + } + + /** + * Convert this argument for non-strict functions according to ES 10.4.3 + * + * @param thiz the this argument + * + * @return the converted this object + */ + private Object convertThisObject(final Object thiz) { + if (!(thiz instanceof ScriptObject) && needsWrappedThis()) { + if (JSType.nullOrUndefined(thiz)) { + return Context.getGlobalTrusted(); + } + + if (isPrimitiveThis(thiz)) { + return ((GlobalObject)Context.getGlobalTrusted()).wrapAsObject(thiz); + } + } + + return thiz; + } + + static boolean isPrimitiveThis(final Object obj) { + return obj instanceof String || obj instanceof ConsString || + obj instanceof Number || obj instanceof Boolean; + } + + /** + * Creates an invoker method handle for a bound function. + * + * @param targetFn the function being bound + * @param originalInvoker an original invoker method handle for the function. This can be its generic invoker or + * any of its specializations. + * @param self the "this" value being bound + * @param args additional arguments being bound + * + * @return a bound invoker method handle that will bind the self value and the specified arguments. The resulting + * invoker never needs a callee; if the original invoker needed it, it will be bound to {@code fn}. The resulting + * invoker still takes an initial {@code this} parameter, but it is always dropped and the bound {@code self} passed + * to the original invoker on invocation. + */ + private MethodHandle bindInvokeHandle(final MethodHandle originalInvoker, final ScriptFunction targetFn, final Object self, final Object[] args) { + // Is the target already bound? If it is, we won't bother binding either callee or self as they're already bound + // in the target and will be ignored anyway. + final boolean isTargetBound = targetFn.isBoundFunction(); + + final boolean needsCallee = needsCallee(originalInvoker); + assert needsCallee == needsCallee() : "callee contract violation 2"; + assert !(isTargetBound && needsCallee); // already bound functions don't need a callee + + final Object boundSelf = isTargetBound ? null : convertThisObject(self); + final MethodHandle boundInvoker; + + if (isVarArg(originalInvoker)) { + // First, bind callee and this without arguments + final MethodHandle noArgBoundInvoker; + + if (isTargetBound) { + // Don't bind either callee or this + noArgBoundInvoker = originalInvoker; + } else if (needsCallee) { + // Bind callee and this + noArgBoundInvoker = MH.insertArguments(originalInvoker, 0, targetFn, boundSelf); + } else { + // Only bind this + noArgBoundInvoker = MH.bindTo(originalInvoker, boundSelf); + } + // Now bind arguments + if (args.length > 0) { + boundInvoker = varArgBinder(noArgBoundInvoker, args); + } else { + boundInvoker = noArgBoundInvoker; + } + } else { + final Object[] boundArgs = new Object[Math.min(originalInvoker.type().parameterCount(), args.length + (isTargetBound ? 0 : (needsCallee ? 2 : 1)))]; + int next = 0; + if (!isTargetBound) { + if (needsCallee) { + boundArgs[next++] = targetFn; + } + boundArgs[next++] = boundSelf; + } + // If more bound args were specified than the function can take, we'll just drop those. + System.arraycopy(args, 0, boundArgs, next, boundArgs.length - next); + // If target is already bound, insert additional bound arguments after "this" argument, at position 1; + // "this" will get dropped anyway by the target invoker. We previously asserted that already bound functions + // don't take a callee parameter, so we can know that the signature is (this[, args...]) therefore args + // start at position 1. If the function is not bound, we start inserting arguments at position 0. + boundInvoker = MH.insertArguments(originalInvoker, isTargetBound ? 1 : 0, boundArgs); + } + + if (isTargetBound) { + return boundInvoker; + } + + // If the target is not already bound, add a dropArguments that'll throw away the passed this + return MH.dropArguments(boundInvoker, 0, Object.class); + } + + /** + * Creates a constructor method handle for a bound function using the passed constructor handle. + * + * @param originalConstructor the constructor handle to bind. It must be a composed constructor. + * @param fn the function being bound + * @param args arguments being bound + * + * @return a bound constructor method handle that will bind the specified arguments. The resulting constructor never + * needs a callee; if the original constructor needed it, it will be bound to {@code fn}. The resulting constructor + * still takes an initial {@code this} parameter and passes it to the underlying original constructor. Finally, if + * this script function data object has no constructor handle, null is returned. + */ + private static MethodHandle bindConstructHandle(final MethodHandle originalConstructor, final ScriptFunction fn, final Object[] args) { + assert originalConstructor != null; + + // If target function is already bound, don't bother binding the callee. + final MethodHandle calleeBoundConstructor = fn.isBoundFunction() ? originalConstructor : + MH.dropArguments(MH.bindTo(originalConstructor, fn), 0, ScriptFunction.class); + + if (args.length == 0) { + return calleeBoundConstructor; + } + + if (isVarArg(calleeBoundConstructor)) { + return varArgBinder(calleeBoundConstructor, args); + } + + final Object[] boundArgs; + + final int maxArgCount = calleeBoundConstructor.type().parameterCount() - 1; + if (args.length <= maxArgCount) { + boundArgs = args; + } else { + boundArgs = new Object[maxArgCount]; + System.arraycopy(args, 0, boundArgs, 0, maxArgCount); + } + + return MH.insertArguments(calleeBoundConstructor, 1, boundArgs); + } + + /** + * Takes a method handle, and returns a potentially different method handle that can be used in + * {@code ScriptFunction#invoke(Object, Object...)} or {code ScriptFunction#construct(Object, Object...)}. + * The returned method handle will be sure to return {@code Object}, and will have all its parameters turned into + * {@code Object} as well, except for the following ones: + *

    + *
  • a last parameter of type {@code Object[]} which is used for vararg functions,
  • + *
  • the first argument, which is forced to be {@link ScriptFunction}, in case the function receives itself + * (callee) as an argument.
  • + *
+ * + * @param mh the original method handle + * + * @return the new handle, conforming to the rules above. + */ + protected MethodHandle composeGenericMethod(final MethodHandle mh) { + final MethodType type = mh.type(); + MethodType newType = type.generic(); + if (isVarArg(mh)) { + newType = newType.changeParameterType(type.parameterCount() - 1, Object[].class); + } + if (needsCallee(mh)) { + newType = newType.changeParameterType(0, ScriptFunction.class); + } + return type.equals(newType) ? mh : mh.asType(newType); } /** * Execute this script function. + * * @param self Target object. * @param arguments Call arguments. * @return ScriptFunction result. + * * @throws Throwable if there is an exception/error with the invocation or thrown from it */ Object invoke(final ScriptFunction fn, final Object self, final Object... arguments) throws Throwable { - final MethodHandle genInvoker = getGenericInvoker(); - final Object selfObj = convertThisObject(self); - final Object[] args = arguments == null ? ScriptRuntime.EMPTY_ARRAY : arguments; + final MethodHandle mh = getGenericInvoker(); - if (isVarArg()) { - if (needsCallee()) { - return genInvoker.invokeExact(fn, selfObj, args); + final Object selfObj = convertThisObject(self); + final Object[] args = arguments == null ? ScriptRuntime.EMPTY_ARRAY : arguments; + + if (isVarArg(mh)) { + if (needsCallee(mh)) { + return mh.invokeExact(fn, selfObj, args); } - return genInvoker.invokeExact(selfObj, args); + return mh.invokeExact(selfObj, args); } - final int paramCount = genInvoker.type().parameterCount(); - if (needsCallee()) { + final int paramCount = mh.type().parameterCount(); + if (needsCallee(mh)) { switch (paramCount) { case 2: - return genInvoker.invokeExact(fn, selfObj); + return mh.invokeExact(fn, selfObj); case 3: - return genInvoker.invokeExact(fn, selfObj, getArg(args, 0)); + return mh.invokeExact(fn, selfObj, getArg(args, 0)); case 4: - return genInvoker.invokeExact(fn, selfObj, getArg(args, 0), getArg(args, 1)); + return mh.invokeExact(fn, selfObj, getArg(args, 0), getArg(args, 1)); case 5: - return genInvoker.invokeExact(fn, selfObj, getArg(args, 0), getArg(args, 1), getArg(args, 2)); + return mh.invokeExact(fn, selfObj, getArg(args, 0), getArg(args, 1), getArg(args, 2)); default: - return genInvoker.invokeWithArguments(withArguments(fn, selfObj, paramCount, args)); + return mh.invokeWithArguments(withArguments(fn, selfObj, paramCount, args)); } } switch (paramCount) { case 1: - return genInvoker.invokeExact(selfObj); + return mh.invokeExact(selfObj); case 2: - return genInvoker.invokeExact(selfObj, getArg(args, 0)); + return mh.invokeExact(selfObj, getArg(args, 0)); case 3: - return genInvoker.invokeExact(selfObj, getArg(args, 0), getArg(args, 1)); + return mh.invokeExact(selfObj, getArg(args, 0), getArg(args, 1)); case 4: - return genInvoker.invokeExact(selfObj, getArg(args, 0), getArg(args, 1), getArg(args, 2)); + return mh.invokeExact(selfObj, getArg(args, 0), getArg(args, 1), getArg(args, 2)); default: - return genInvoker.invokeWithArguments(withArguments(null, selfObj, paramCount, args)); + return mh.invokeWithArguments(withArguments(null, selfObj, paramCount, args)); } } @@ -389,15 +537,13 @@ public final class ScriptFunctionData { return i < args.length ? args[i] : UNDEFINED; } - private Object[] withArguments(final ScriptFunction fn, final Object self, final int argCount, final Object[] args) { + private static Object[] withArguments(final ScriptFunction fn, final Object self, final int argCount, final Object[] args) { final Object[] finalArgs = new Object[argCount]; int nextArg = 0; - if (needsCallee()) { - assert fn != null; + if (fn != null) { + //needs callee finalArgs[nextArg++] = fn; - } else { - assert fn == null; } finalArgs[nextArg++] = self; @@ -413,255 +559,14 @@ public final class ScriptFunctionData { return finalArgs; } - - /** - * Get the specialized construct handles for this function. - * @return array of specialized construct handles - */ - private MethodHandle[] getConstructSpecializations() { - if(constructSpecializations == null && invokeSpecializations != null) { - final MethodHandle[] ctors = new MethodHandle[invokeSpecializations.length]; - for(int i = 0; i < ctors.length; ++i) { - ctors[i] = composeConstructor(invokeSpecializations[i]); - } - constructSpecializations = ctors; - } - return constructSpecializations; - } - - /** - * Set the method handles for this function. - * @param invoker the invoker handle - * @param allocator the allocator handle - */ - public void setMethodHandles(final MethodHandle invoker, final MethodHandle allocator) { - // We can't make method handle fields final because they're not available during codegen - // and they're set when first called, so we enforce set-once here. - if (this.invoker == null) { - this.invoker = invoker; - this.constructor = null; // delay constructor composition - this.allocator = allocator; - } - } - - /** - * Used by the trampoline. Must not be any wider than package - * private - * @param invoker new invoker - */ - void resetInvoker(final MethodHandle invoker) { - this.invoker = invoker; - this.constructor = null; //delay constructor composition - } - - /** - * Allocates an object using this function's allocator. - * @return the object allocated using this function's allocator, or null if the function doesn't have an allocator. - */ - ScriptObject allocate() { - if (allocator == null) { - return null; - } - - try { - return (ScriptObject)allocator.invokeExact(allocatorMap); - } catch (final RuntimeException | Error e) { - throw e; - } catch (final Throwable t) { - throw new RuntimeException(t); - } - } - - /** - * This method is used to create the immutable portion of a bound function. - * See {@link ScriptFunction#makeBoundFunction(Object, Object[])} - * - * @param fn the original function being bound - * @param self this reference to bind. Can be null. - * @param args additional arguments to bind. Can be null. - */ - ScriptFunctionData makeBoundFunctionData(final ScriptFunction fn, final Object self, final Object[] args) { - final Object[] allArgs = args == null ? ScriptRuntime.EMPTY_ARRAY : args; - - final boolean isConstructor = isConstructor(); - // Note that the new ScriptFunctionData's method handle will not need a callee regardless of whether the - // original did. - final ScriptFunctionData boundData = new ScriptFunctionData(name, source, token, - bindInvokeHandle(invoker, fn, self, allArgs), bindInvokeSpecializations(fn, self, allArgs), isStrict(), isBuiltin(), isConstructor); - if(isConstructor) { - // Can't just rely on bound invoke as a basis for constructor, as it ignores the passed "this" in favor of the - // bound "this"; constructor on the other hand must see the actual "this" received from the allocator. - - // Binding a function will force constructor composition in getConstructor(); not really any way around that - // as it's the composed constructor that has to be bound to the function. - boundData.constructor = bindConstructHandle(getConstructor(), fn, allArgs); - boundData.constructSpecializations = bindConstructorSpecializations(fn, allArgs); - } - assert boundData.allocator == null; - final int thisArity = getArity(); - if(thisArity != -1) { - boundData.setArity(Math.max(0, thisArity - args.length)); - } else { - assert boundData.getArity() == -1; - } - return boundData; - } - - /** - * Convert this argument for non-strict functions according to ES 10.4.3 - * - * @param thiz the this argument - * - * @return the converted this object - */ - Object convertThisObject(final Object thiz) { - if (!(thiz instanceof ScriptObject) && needsWrappedThis()) { - if (JSType.nullOrUndefined(thiz)) { - return Context.getGlobalTrusted(); - } - - if (isPrimitiveThis(thiz)) { - return ((GlobalObject)Context.getGlobalTrusted()).wrapAsObject(thiz); - } - } - - return thiz; - } - - static boolean isPrimitiveThis(Object obj) { - return obj instanceof String || obj instanceof ConsString || - obj instanceof Number || obj instanceof Boolean; - } - - /** - * Creates an invoker method handle for a bound function. - * @param targetFn the function being bound - * @param originalInvoker an original invoker method handle for the function. This can be its generic invoker or - * any of its specializations. - * @param self the "this" value being bound - * @param args additional arguments being bound - * @return a bound invoker method handle that will bind the self value and the specified arguments. The resulting - * invoker never needs a callee; if the original invoker needed it, it will be bound to {@code fn}. The resulting - * invoker still takes an initial {@code this} parameter, but it is always dropped and the bound {@code self} passed - * to the original invoker on invocation. - */ - private MethodHandle bindInvokeHandle(final MethodHandle originalInvoker, final ScriptFunction targetFn, final Object self, final Object[] args) { - // Is the target already bound? If it is, we won't bother binding either callee or self as they're already bound - // in the target and will be ignored anyway. - final boolean isTargetBound = targetFn.isBoundFunction(); - assert !(isTargetBound && needsCallee()); // already bound functions don't need a callee - final Object boundSelf = isTargetBound ? null : convertThisObject(self); - final MethodHandle boundInvoker; - if(isVarArg(originalInvoker)) { - // First, bind callee and this without arguments - final MethodHandle noArgBoundInvoker; - if(isTargetBound) { - // Don't bind either callee or this - noArgBoundInvoker = originalInvoker; - } else if(needsCallee()) { - // Bind callee and this - noArgBoundInvoker = MH.insertArguments(originalInvoker, 0, targetFn, boundSelf); - } else { - // Only bind this - noArgBoundInvoker = MH.bindTo(originalInvoker, boundSelf); - } - // Now bind arguments - if(args.length > 0) { - boundInvoker = varArgBinder(noArgBoundInvoker, args); - } else { - boundInvoker = noArgBoundInvoker; - } - } else { - final Object[] boundArgs = new Object[Math.min(originalInvoker.type().parameterCount(), - args.length + (isTargetBound ? 0 : (needsCallee() ? 2 : 1)))]; - int next = 0; - if(!isTargetBound) { - if(needsCallee()) { - boundArgs[next++] = targetFn; - } - boundArgs[next++] = boundSelf; - } - // If more bound args were specified than the function can take, we'll just drop those. - System.arraycopy(args, 0, boundArgs, next, boundArgs.length - next); - // If target is already bound, insert additional bound arguments after "this" argument, at position 1; - // "this" will get dropped anyway by the target invoker. We previously asserted that already bound functions - // don't take a callee parameter, so we can know that the signature is (this[, args...]) therefore args - // start at position 1. If the function is not bound, we start inserting arguments at position 0. - boundInvoker = MH.insertArguments(originalInvoker, isTargetBound ? 1 : 0, boundArgs); - } - if(isTargetBound) { - return boundInvoker; - } - // If the target is not already bound, add a dropArguments that'll throw away the passed this - return MH.dropArguments(boundInvoker, 0, Object.class); - } - - private MethodHandle[] bindInvokeSpecializations(final ScriptFunction fn, final Object self, final Object[] args) { - if(invokeSpecializations == null) { - return null; - } - final MethodHandle[] boundSpecializations = new MethodHandle[invokeSpecializations.length]; - for(int i = 0; i < invokeSpecializations.length; ++i) { - boundSpecializations[i] = bindInvokeHandle(invokeSpecializations[i], fn, self, args); - } - return boundSpecializations; - } - - /** - * Creates a constructor method handle for a bound function using the passed constructor handle. - * @param originalConstructor the constructor handle to bind. It must be a composed constructor. - * @param fn the function being bound - * @param args arguments being bound - * @return a bound constructor method handle that will bind the specified arguments. The resulting constructor never - * needs a callee; if the original constructor needed it, it will be bound to {@code fn}. The resulting constructor - * still takes an initial {@code this} parameter and passes it to the underlying original constructor. Finally, if - * this script function data object has no constructor handle, null is returned. - */ - private static MethodHandle bindConstructHandle(final MethodHandle originalConstructor, final ScriptFunction fn, final Object[] args) { - if(originalConstructor == null) { - return null; - } - - // If target function is already bound, don't bother binding the callee. - final MethodHandle calleeBoundConstructor = fn.isBoundFunction() ? originalConstructor : - MH.dropArguments(MH.bindTo(originalConstructor, fn), 0, ScriptFunction.class); - if(args.length == 0) { - return calleeBoundConstructor; - } - - if(isVarArg(calleeBoundConstructor)) { - return varArgBinder(calleeBoundConstructor, args); - } - - final Object[] boundArgs; - final int maxArgCount = calleeBoundConstructor.type().parameterCount() - 1; - if (args.length <= maxArgCount) { - boundArgs = args; - } else { - boundArgs = new Object[maxArgCount]; - System.arraycopy(args, 0, boundArgs, 0, maxArgCount); - } - return MH.insertArguments(calleeBoundConstructor, 1, boundArgs); - } - - private MethodHandle[] bindConstructorSpecializations(final ScriptFunction fn, final Object[] args) { - final MethodHandle[] ctorSpecs = getConstructSpecializations(); - if(ctorSpecs == null) { - return null; - } - final MethodHandle[] boundSpecializations = new MethodHandle[ctorSpecs.length]; - for(int i = 0; i < ctorSpecs.length; ++i) { - boundSpecializations[i] = bindConstructHandle(ctorSpecs[i], fn, args); - } - return boundSpecializations; - } - /** * Takes a variable-arity method and binds a variable number of arguments in it. The returned method will filter the * vararg array and pass a different array that prepends the bound arguments in front of the arguments passed on * invocation + * * @param mh the handle * @param args the bound arguments + * * @return the bound method handle */ private static MethodHandle varArgBinder(final MethodHandle mh, final Object[] args) { @@ -670,99 +575,10 @@ public final class ScriptFunctionData { return MH.filterArguments(mh, mh.type().parameterCount() - 1, MH.bindTo(BIND_VAR_ARGS, args)); } - /** - * Convert boolean flags to int. - * @param needsCallee needs-callee flag - * @param isVarArg var-arg flag - * @param isStrict strict flag - * @param isBuiltin builtin flag - * @return int flags - */ - private static int makeFlags(final boolean needsCallee, final boolean isVarArg, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) { - int flags = 0; - if (needsCallee) { - flags |= HAS_CALLEE; - } - if (isVarArg) { - flags |= IS_VARARGS; - } - if (isStrict) { - flags |= IS_STRICT; - } - if (isBuiltin) { - flags |= IS_BUILTIN; - } - if (isConstructor) { - flags |= IS_CONSTRUCTOR; - } - - return flags; - } - - /** - * Test if a methodHandle refers to a constructor. - * @param methodHandle MethodHandle to test. - * @return True if method is a constructor. - */ - private static boolean isConstructor(final MethodHandle methodHandle) { - return methodHandle.type().parameterCount() >= 1 && methodHandle.type().parameterType(0) == boolean.class; - } - - /** - * Heuristic to figure out if the method handle has a callee argument. If it's type is either - * {@code (boolean, Object, ScriptFunction, ...)} or {@code (Object, ScriptFunction, ...)}, then we'll assume it has - * a callee argument. We need this as the constructor above is not passed this information, and can't just blindly - * assume it's false (notably, it's being invoked for creation of new scripts, and scripts have scopes, therefore - * they also always receive a callee. - * @param methodHandle the examined method handle - * @return true if the method handle expects a callee, false otherwise - */ - private static boolean needsCallee(MethodHandle methodHandle) { - final MethodType type = methodHandle.type(); - final int len = type.parameterCount(); - if(len == 0) { - return false; - } - if(type.parameterType(0) == boolean.class) { - return len > 1 && type.parameterType(1) == ScriptFunction.class; - } - return type.parameterType(0) == ScriptFunction.class; - } - - private static boolean isVarArg(MethodHandle methodHandle) { - final MethodType type = methodHandle.type(); - return type.parameterType(type.parameterCount() - 1).isArray(); - } - - /** - * Takes a method handle, and returns a potentially different method handle that can be used in - * {@link ScriptFunction#invoke(Object, Object...)} or {@link ScriptFunction#construct(Object, Object...)}. - * The returned method handle will be sure to return {@code Object}, and will have all its parameters turned into - * {@code Object} as well, except for the following ones: - *
    - *
  • a last parameter of type {@code Object[]} which is used for vararg functions,
  • - *
  • the first argument, which is forced to be {@link ScriptFunction}, in case the function receives itself - * (callee) as an argument.
  • - *
- * - * @param handle the original method handle - * @return the new handle, conforming to the rules above. - */ - private MethodHandle makeGenericMethod(final MethodHandle handle) { - final MethodType type = handle.type(); - MethodType newType = type.generic(); - if (isVarArg()) { - newType = newType.changeParameterType(type.parameterCount() - 1, Object[].class); - } - if (needsCallee()) { - newType = newType.changeParameterType(0, ScriptFunction.class); - } - return type.equals(newType) ? handle : handle.asType(newType); - } - /** * Adapts the method handle so its return type is {@code Object}. If the handle's return type is already * {@code Object}, the handle is returned unchanged. + * * @param mh the handle to adapt * @return the adapted handle */ @@ -770,45 +586,67 @@ public final class ScriptFunctionData { return MH.asType(mh, mh.type().changeReturnType(Object.class)); } + private void ensureConstructor(final CompiledFunction inv) { + if (!inv.hasConstructor()) { + inv.setConstructor(composeConstructor(inv.getInvoker(), needsCallee(inv.getInvoker()))); + } + } /** - * If this function's method handles need a callee parameter, swap the order of first two arguments for the passed - * method handle. If this function's method handles don't need a callee parameter, returns the original method - * handle unchanged. - * @param mh a method handle with order of arguments {@code (callee, this, args...)} - * @return a method handle with order of arguments {@code (this, callee, args...)} + * Heuristic to figure out if the method handle has a callee argument. If it's type is either + * {@code (boolean, Object, ScriptFunction, ...)} or {@code (Object, ScriptFunction, ...)}, then we'll assume it has + * a callee argument. We need this as the constructor above is not passed this information, and can't just blindly + * assume it's false (notably, it's being invoked for creation of new scripts, and scripts have scopes, therefore + * they also always receive a callee). + * + * @param mh the examined method handle + * + * @return true if the method handle expects a callee, false otherwise */ - private MethodHandle swapCalleeAndThis(final MethodHandle mh) { - if (!needsCallee()) { - return mh; + protected static boolean needsCallee(final MethodHandle mh) { + final MethodType type = mh.type(); + final int length = type.parameterCount(); + + if (length == 0) { + return false; } + + if (type.parameterType(0) == boolean.class) { + return length > 1 && type.parameterType(1) == ScriptFunction.class; + } + + return type.parameterType(0) == ScriptFunction.class; + } + + /** + * Check if a javascript function methodhandle is a vararg handle + * + * @param mh method handle to check + * + * @return true if vararg + */ + protected static boolean isVarArg(final MethodHandle mh) { final MethodType type = mh.type(); - assert type.parameterType(0) == ScriptFunction.class; - assert type.parameterType(1) == Object.class; - final MethodType newType = type.changeParameterType(0, Object.class).changeParameterType(1, ScriptFunction.class); - final int[] reorder = new int[type.parameterCount()]; - reorder[0] = 1; - assert reorder[1] == 0; - for (int i = 2; i < reorder.length; ++i) { - reorder[i] = i; - } - return MethodHandles.permuteArguments(mh, newType, reorder); + return type.parameterType(type.parameterCount() - 1).isArray(); } @SuppressWarnings("unused") private static Object[] bindVarArgs(final Object[] array1, final Object[] array2) { - if(array2 == null) { + if (array2 == null) { // Must clone it, as we can't allow the receiving method to alter the array return array1.clone(); } + final int l2 = array2.length; - if(l2 == 0) { + if (l2 == 0) { return array1.clone(); } + final int l1 = array1.length; final Object[] concat = new Object[l1 + l2]; System.arraycopy(array1, 0, concat, 0, l1); System.arraycopy(array2, 0, concat, l1, l2); + return concat; } @@ -820,5 +658,4 @@ public final class ScriptFunctionData { private static MethodHandle findOwnMH(final String name, final Class rtype, final Class... types) { return MH.findStatic(MethodHandles.lookup(), ScriptFunctionData.class, name, MH.type(rtype, types)); } - } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/SpecializedMethodChooser.java b/nashorn/src/jdk/nashorn/internal/runtime/SpecializedMethodChooser.java deleted file mode 100644 index 2853cdf2464..00000000000 --- a/nashorn/src/jdk/nashorn/internal/runtime/SpecializedMethodChooser.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.runtime; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; -import jdk.nashorn.internal.codegen.types.Type; -import jdk.nashorn.internal.runtime.options.Options; - -class SpecializedMethodChooser { - /** Should specialized function and specialized constructors for the builtin be used if available? */ - private static final boolean DISABLE_SPECIALIZATION = Options.getBooleanProperty("nashorn.scriptfunction.specialization.disable"); - - static MethodHandle candidateWithLowestWeight(final MethodType descType, final MethodHandle initialCandidate, final MethodHandle[] specs) { - if (DISABLE_SPECIALIZATION || specs == null) { - return initialCandidate; - } - - int minimumWeight = Integer.MAX_VALUE; - MethodHandle candidate = initialCandidate; - - for (final MethodHandle spec : specs) { - final MethodType specType = spec.type(); - - if (!typeCompatible(descType, specType)) { - continue; - } - - //return type is ok. we want a wider or equal one for our callsite. - final int specWeight = weigh(specType); - if (specWeight < minimumWeight) { - candidate = spec; - minimumWeight = specWeight; - } - } - - return candidate; - } - - private static boolean typeCompatible(final MethodType desc, final MethodType spec) { - //spec must fit in desc - final Class[] dparray = desc.parameterArray(); - final Class[] sparray = spec.parameterArray(); - - if (dparray.length != sparray.length) { - return false; - } - - for (int i = 0; i < dparray.length; i++) { - final Type dp = Type.typeFor(dparray[i]); - final Type sp = Type.typeFor(sparray[i]); - - if (dp.isBoolean()) { - return false; //don't specialize on booleans, we have the "true" vs int 1 ambiguity in resolution - } - - //specialization arguments must be at least as wide as dp, if not wider - if (Type.widest(dp, sp) != sp) { - //e.g. specialization takes double and callsite says "object". reject. - //but if specialization says double and callsite says "int" or "long" or "double", that's fine - return false; - } - } - - return true; // anything goes for return type, take the convenient one and it will be upcasted thru dynalink magic. - } - - private static int weigh(final MethodType t) { - int weight = Type.typeFor(t.returnType()).getWeight(); - for (final Class paramType : t.parameterArray()) { - final int pweight = Type.typeFor(paramType).getWeight(); - weight += pweight; - } - return weight; - } -} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java index 3d8363e10d9..834898afbf7 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaArgumentConverters.java @@ -39,7 +39,7 @@ import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptObject; /** - * Utility class shared by {@link NashornLinker} and {@code NashornPrimitiveLinker} for converting JS values to Java + * Utility class shared by {@code NashornLinker} and {@code NashornPrimitiveLinker} for converting JS values to Java * types. */ public class JavaArgumentConverters { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java index ed152485376..a8e79184d85 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java @@ -40,8 +40,6 @@ public final class NashornGuards { private static final MethodHandle IS_SCRIPTOBJECT = findOwnMH("isScriptObject", boolean.class, Object.class); private static final MethodHandle IS_SCRIPTFUNCTION = findOwnMH("isScriptFunction", boolean.class, Object.class); private static final MethodHandle IS_MAP = findOwnMH("isMap", boolean.class, Object.class, PropertyMap.class); - private static final MethodHandle IS_FUNCTION_MH = findOwnMH("isFunctionMH", boolean.class, Object.class, MethodHandle.class); - private static final MethodHandle IS_NONSTRICT_FUNCTION = findOwnMH("isNonStrictFunction", boolean.class, Object.class, Object.class, MethodHandle.class); private static final MethodHandle IS_INSTANCEOF_2 = findOwnMH("isInstanceOf2", boolean.class, Object.class, Class.class, Class.class); // don't create me! @@ -87,33 +85,6 @@ public final class NashornGuards { return MH.insertArguments(IS_INSTANCEOF_2, 1, class1, class2); } - /** - * Get the guard that checks if a {@link ScriptFunction} is equal to - * a known ScriptFunction, using reference comparison - * - * @param function The ScriptFunction to check against. This will be bound to the guard method handle - * - * @return method handle for guard - */ - public static MethodHandle getFunctionGuard(final ScriptFunction function) { - assert function.getInvokeHandle() != null; - return MH.insertArguments(IS_FUNCTION_MH, 1, function.getInvokeHandle()); - } - - /** - * Get a guard that checks if a {@link ScriptFunction} is equal to - * a known ScriptFunction using reference comparison, and whether the type of - * the second argument (this-object) is not a JavaScript primitive type. - * - * @param function The ScriptFunction to check against. This will be bound to the guard method handle - * - * @return method handle for guard - */ - public static MethodHandle getNonStrictFunctionGuard(final ScriptFunction function) { - assert function.getInvokeHandle() != null; - return MH.insertArguments(IS_NONSTRICT_FUNCTION, 2, function.getInvokeHandle()); - } - @SuppressWarnings("unused") private static boolean isScriptObject(final Object self) { return self instanceof ScriptObject; @@ -129,16 +100,6 @@ public final class NashornGuards { return self instanceof ScriptObject && ((ScriptObject)self).getMap() == map; } - @SuppressWarnings("unused") - private static boolean isFunctionMH(final Object self, final MethodHandle mh) { - return self instanceof ScriptFunction && ((ScriptFunction)self).getInvokeHandle() == mh; - } - - @SuppressWarnings("unused") - private static boolean isNonStrictFunction(final Object self, final Object arg, final MethodHandle mh) { - return self instanceof ScriptFunction && ((ScriptFunction)self).getInvokeHandle() == mh && arg instanceof ScriptObject; - } - @SuppressWarnings("unused") private static boolean isInstanceOf2(final Object self, final Class class1, final Class class2) { return class1.isInstance(self) || class2.isInstance(self); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java index 82b6edbc600..16ff04eaa41 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/OptionTemplate.java @@ -278,7 +278,7 @@ public class OptionTemplate implements Comparable { this.valueNextArg = Boolean.parseBoolean(arg); break; default: - throw new IllegalArgumentException(); + throw new IllegalArgumentException(keyToken); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties index 534eb1778e6..e63f7a3769d 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties @@ -165,6 +165,12 @@ nashorn.option.debug.locals = { \ desc="Generate local variable table in .class files." \ } +nashorn.option.lazy.compilation = { \ + name="--lazy-compilation", \ + is_undocumented=true, \ + desc="EXPERIMENTAL: Use lazy code generation strategies - do not compile the entire script at once." \ +} + nashorn.option.loader.per.compile = { \ name="--loader-per-compile", \ is_undocumented=true, \ diff --git a/nashorn/test/script/currently-failing/JDK-8006529.js b/nashorn/test/script/currently-failing/JDK-8006529.js index da08d2b516b..ca21f0b9c48 100644 --- a/nashorn/test/script/currently-failing/JDK-8006529.js +++ b/nashorn/test/script/currently-failing/JDK-8006529.js @@ -39,12 +39,13 @@ * and FunctionNode because of package-access check and so reflective calls. */ -var Parser = Java.type("jdk.nashorn.internal.parser.Parser") -var Compiler = Java.type("jdk.nashorn.internal.codegen.Compiler") -var Context = Java.type("jdk.nashorn.internal.runtime.Context") +var Parser = Java.type("jdk.nashorn.internal.parser.Parser") +var Compiler = Java.type("jdk.nashorn.internal.codegen.Compiler") +var Context = Java.type("jdk.nashorn.internal.runtime.Context") var ScriptEnvironment = Java.type("jdk.nashorn.internal.runtime.ScriptEnvironment") -var Source = Java.type("jdk.nashorn.internal.runtime.Source") -var FunctionNode = Java.type("jdk.nashorn.internal.ir.FunctionNode") +var Source = Java.type("jdk.nashorn.internal.runtime.Source") +var FunctionNode = Java.type("jdk.nashorn.internal.ir.FunctionNode") +var ThrowErrorManager = Java.type("jdk.nashorn.internal.runtime.Context$ThrowErrorManager"); // Compiler class methods and fields var parseMethod = Parser.class.getMethod("parse"); @@ -90,7 +91,7 @@ function getFirstFunction(functionNode) { // representing it. function compile(source) { var source = new Source("", source); - var parser = new Parser(Context.getContext().getEnv(), source, null); + var parser = new Parser(Context.getContext().getEnv(), source, new ThrowErrorManager()); var func = parseMethod.invoke(parser); var compiler = new Compiler(Context.getContext().getEnv(), func); diff --git a/nashorn/test/script/currently-failing/clone_ir.js b/nashorn/test/script/currently-failing/clone_ir.js new file mode 100644 index 00000000000..3c1eccf2bc3 --- /dev/null +++ b/nashorn/test/script/currently-failing/clone_ir.js @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * clone_ir : Check that functionNode.clone copies all nodes and that they + * are not the same references + * + * @test + * @run + */ + +var js1 = "var tuple = { func : function f(x) { if (x) { print('true'); { print('block_under-true'); } } else { print('false'); } } }"; + +var Parser = Java.type("jdk.nashorn.internal.parser.Parser"); +var ASTWriter = Java.type("jdk.nashorn.internal.ir.debug.ASTWriter"); +var Context = Java.type("jdk.nashorn.internal.runtime.Context"); +var ScriptEnvironment = Java.type("jdk.nashorn.internal.runtime.ScriptEnvironment"); +var Source = Java.type("jdk.nashorn.internal.runtime.Source"); +var FunctionNode = Java.type("jdk.nashorn.internal.ir.FunctionNode"); +var ThrowErrorManager = Java.type("jdk.nashorn.internal.runtime.Context$ThrowErrorManager"); +var System = Java.type("java.lang.System"); + +var toArrayMethod = ASTWriter.class.getMethod("toArray"); +var parseMethod = Parser.class.getMethod("parse"); + +function toString(obj) { + var output = "{ "; + for (property in obj) { + output += property + ': ' + obj[property]+'; '; + } + return output + '}' +} + +function flatten(func) { + var writer = new ASTWriter(func); + var funcList = toArrayMethod.invoke(writer); + + var res = []; + for each (x in funcList) { + res.push({ name: x.getClass().getName(), id: System.identityHashCode(x) }); + } + return res; +} + +function check(contents) { + return check_src(new Source("", contents)); +} + +function check_src(src) { + var parser = new Parser(Context.getContext().getEnv(), src, new ThrowErrorManager()); + + var func = parseMethod.invoke(parser); + print(func); + var func2 = func.clone(); + + var f1 = flatten(func); + var f2 = flatten(func2); + + print(f1.map(toString)); + print(f2.map(toString)); + + if (f1.length != f2.length) { + print("length difference between original and clone " + f1.length + " != " + f2.length); + return false; + } + + for (var i = 0; i < f1.length; i++) { + if (f1[i].name !== f2[i].name) { + print("name conflict at " + i + " " + f1[i].name + " != " + f2[i].name); + return false; + } else if (f1[i].id === f2[i].id) { + print("id problem at " + i + " " + toString(f1[i]) + " was not deep copied to " + toString(f2[i]) + " became " + f1[i].id + " != " + f2[i].id); + return false; + } + } + + return true; +} + +print(check(js1)); From d671cda73c206159122d02664cc301d32e0681d2 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 12 Mar 2013 21:17:47 +0530 Subject: [PATCH 003/155] 8009868: For loop with "true" as condition results in AssertionError in codegen Reviewed-by: jlaskey, hannesw, lagergren --- .../jdk/nashorn/internal/codegen/Lower.java | 1 + nashorn/test/script/basic/JDK-8009868.js | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 nashorn/test/script/basic/JDK-8009868.js diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 4be28193cc7..5baa7af535e 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -237,6 +237,7 @@ final class Lower extends NodeOperatorVisitor { if (!forNode.isForIn() && conservativeAlwaysTrue(test)) { forNode.setTest(null); + setHasGoto(forNode); setTerminal(forNode, !escapes); } diff --git a/nashorn/test/script/basic/JDK-8009868.js b/nashorn/test/script/basic/JDK-8009868.js new file mode 100644 index 00000000000..ffbc8c21871 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8009868.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + + +/** + * JDK-8009868: For loop with "true" as condition results in AssertionError in codegen + * + * @test + * @run + */ + +// This used to crash with AssertionError in codegen +for(; true;) { + break; +} From 09e3f06ae6048257a2e878e3efcf9fc94f46a987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Borggr=C3=A9n-Franck?= Date: Wed, 13 Mar 2013 22:03:09 +0100 Subject: [PATCH 004/155] 8006547: Repeating annotations: No Target on container annotation with all targets on base annotation gives compiler error Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Check.java | 66 ++++++++++++------- .../repeatingAnnotations/DefaultTarget.java | 47 +++++++++++++ .../DefaultTargetTypeParameter.java | 40 +++++++++++ .../DefaultTargetTypeParameter.out | 2 + .../DefaultTargetTypeUse.java | 40 +++++++++++ .../DefaultTargetTypeUse.out | 2 + .../NoTargetOnContainer.java | 49 ++++++++++++++ .../NoTargetOnContainer2.java | 50 ++++++++++++++ 8 files changed, 273 insertions(+), 23 deletions(-) create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java create mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 9ad5f55ca88..eb56d999459 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -2779,25 +2779,17 @@ public class Check { } private void validateTarget(Symbol container, Symbol contained, DiagnosticPosition pos) { - Attribute.Array containedTarget = getAttributeTargetAttribute(contained); + // The set of targets the container is applicable to must be a subset + // (with respect to annotation target semantics) of the set of targets + // the contained is applicable to. The target sets may be implicit or + // explicit. - // If contained has no Target, we are done - if (containedTarget == null) { - return; - } - - // If contained has Target m1, container must have a Target - // annotation, m2, and m2 must be a subset of m1. (This is - // trivially true if contained has no target as per above). - - // contained has target, but container has not, error + Set containerTargets; Attribute.Array containerTarget = getAttributeTargetAttribute(container); if (containerTarget == null) { - log.error(pos, "invalid.repeatable.annotation.incompatible.target", container, contained); - return; - } - - Set containerTargets = new HashSet(); + containerTargets = getDefaultTargetSet(); + } else { + containerTargets = new HashSet(); for (Attribute app : containerTarget.values) { if (!(app instanceof Attribute.Enum)) { continue; // recovery @@ -2805,8 +2797,14 @@ public class Check { Attribute.Enum e = (Attribute.Enum)app; containerTargets.add(e.value.name); } + } - Set containedTargets = new HashSet(); + Set containedTargets; + Attribute.Array containedTarget = getAttributeTargetAttribute(contained); + if (containedTarget == null) { + containedTargets = getDefaultTargetSet(); + } else { + containedTargets = new HashSet(); for (Attribute app : containedTarget.values) { if (!(app instanceof Attribute.Enum)) { continue; // recovery @@ -2814,20 +2812,42 @@ public class Check { Attribute.Enum e = (Attribute.Enum)app; containedTargets.add(e.value.name); } + } - if (!isTargetSubset(containedTargets, containerTargets)) { + if (!isTargetSubsetOf(containerTargets, containedTargets)) { log.error(pos, "invalid.repeatable.annotation.incompatible.target", container, contained); } } - /** Checks that t is a subset of s, with respect to ElementType + /* get a set of names for the default target */ + private Set getDefaultTargetSet() { + if (defaultTargets == null) { + Set targets = new HashSet(); + targets.add(names.ANNOTATION_TYPE); + targets.add(names.CONSTRUCTOR); + targets.add(names.FIELD); + targets.add(names.LOCAL_VARIABLE); + targets.add(names.METHOD); + targets.add(names.PACKAGE); + targets.add(names.PARAMETER); + targets.add(names.TYPE); + + defaultTargets = java.util.Collections.unmodifiableSet(targets); + } + + return defaultTargets; + } + private Set defaultTargets; + + + /** Checks that s is a subset of t, with respect to ElementType * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE} */ - private boolean isTargetSubset(Set s, Set t) { - // Check that all elements in t are present in s - for (Name n2 : t) { + private boolean isTargetSubsetOf(Set s, Set t) { + // Check that all elements in s are present in t + for (Name n2 : s) { boolean currentElementOk = false; - for (Name n1 : s) { + for (Name n1 : t) { if (n1 == n2) { currentElementOk = true; break; diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java new file mode 100644 index 00000000000..bffe1b50e65 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.lang.annotation.*; + +/** + * @test + * @bug 8006547 + * @compile DefaultTarget.java + */ + +@Target({ + ElementType.CONSTRUCTOR, + ElementType.PARAMETER, + ElementType.TYPE, + ElementType.METHOD, + ElementType.LOCAL_VARIABLE, + ElementType.PACKAGE, + ElementType.ANNOTATION_TYPE, + ElementType.FIELD, +}) +@interface Container { + DefaultTarget[] value(); +} + +@Repeatable(Container.class) +public @interface DefaultTarget {} diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java new file mode 100644 index 00000000000..2338329b321 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.lang.annotation.*; + +/** + * @test + * @bug 8006547 + * @compile/fail/ref=DefaultTargetTypeParameter.out -XDrawDiagnostics DefaultTargetTypeParameter.java + */ + +@Target({ + ElementType.TYPE_PARAMETER, +}) +@interface Container { + DefaultTargetTypeParameter[] value(); +} + +@Repeatable(Container.class) +public @interface DefaultTargetTypeParameter {} diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out new file mode 100644 index 00000000000..fc1f934ea34 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out @@ -0,0 +1,2 @@ +DefaultTargetTypeParameter.java:39:1: compiler.err.invalid.repeatable.annotation.incompatible.target: Container, DefaultTargetTypeParameter +1 error diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java new file mode 100644 index 00000000000..4c158434309 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.lang.annotation.*; + +/** + * @test + * @bug 8006547 + * @compile/fail/ref=DefaultTargetTypeUse.out -XDrawDiagnostics DefaultTargetTypeUse.java + */ + +@Target({ + ElementType.TYPE_USE, +}) +@interface Container { + DefaultTargetTypeUse[] value(); +} + +@Repeatable(Container.class) +public @interface DefaultTargetTypeUse {} diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out new file mode 100644 index 00000000000..1aba28b9e42 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out @@ -0,0 +1,2 @@ +DefaultTargetTypeUse.java:39:1: compiler.err.invalid.repeatable.annotation.incompatible.target: Container, DefaultTargetTypeUse +1 error diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java new file mode 100644 index 00000000000..eaa333e58e8 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.lang.annotation.*; + +/** + * @test + * @bug 8006547 + * @compile NoTargetOnContainer.java + */ + +@interface FooContainer { + Foo[] value(); +} + +@Target({ + ElementType.CONSTRUCTOR, + ElementType.PARAMETER, + ElementType.TYPE, + ElementType.METHOD, + ElementType.LOCAL_VARIABLE, + ElementType.PACKAGE, + ElementType.ANNOTATION_TYPE, + ElementType.FIELD, +}) +@Repeatable(FooContainer.class) +@interface Foo {} + +class NoTargetOnContainer {} diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java new file mode 100644 index 00000000000..539e299cdaf --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.lang.annotation.*; + +/** + * @test + * @bug 8006547 + * @compile NoTargetOnContainer2.java + */ + +@interface FooContainer { + Foo[] value(); +} + +@Target({ + ElementType.CONSTRUCTOR, + ElementType.PARAMETER, + ElementType.TYPE, + ElementType.METHOD, + ElementType.LOCAL_VARIABLE, + ElementType.PACKAGE, + ElementType.ANNOTATION_TYPE, + ElementType.FIELD, + ElementType.TYPE_USE, + ElementType.TYPE_PARAMETER}) +@Repeatable(FooContainer.class) +@interface Foo {} + +class NoTargetOnContainer2 {} From 82210b98a8ba90530bbdde1d1e5f66da6c38b334 Mon Sep 17 00:00:00 2001 From: Bhavesh Patel Date: Wed, 13 Mar 2013 14:47:15 -0700 Subject: [PATCH 005/155] 8009684: Default top left frame should be "All Packages" in the generated javadoc documentation Reviewed-by: jjg --- .../formats/html/FrameOutputWriter.java | 19 +------------- .../formats/html/PackageIndexFrameWriter.java | 2 +- .../formats/html/ProfileIndexFrameWriter.java | 4 +-- .../html/ProfilePackageIndexFrameWriter.java | 4 +-- .../javadoc/testProfiles/TestProfiles.java | 26 +++++++++++-------- 5 files changed, 21 insertions(+), 34 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java index acf39191670..b853cea635d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java @@ -135,13 +135,7 @@ public class FrameOutputWriter extends HtmlDocletWriter { protected Content getFrameDetails() { HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame", "top.loadFrames()"); - if (configuration.showProfiles) { - HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", - "top.loadFrames()"); - addAllProfilesFrameTag(leftFrameset); - addAllClassesFrameTag(leftFrameset); - frameset.addContent(leftFrameset); - } else if (noOfPackages <= 1) { + if (noOfPackages <= 1) { addAllClassesFrameTag(frameset); } else if (noOfPackages > 1) { HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames", @@ -155,17 +149,6 @@ public class FrameOutputWriter extends HtmlDocletWriter { return frameset; } - /** - * Add the FRAME tag for the frame that lists all profiles. - * - * @param contentTree the content tree to which the information will be added - */ - private void addAllProfilesFrameTag(Content contentTree) { - HtmlTree frame = HtmlTree.FRAME(DocPaths.PROFILE_OVERVIEW_FRAME.getPath(), - "profileListFrame", configuration.getText("doclet.All_Profiles")); - contentTree.addContent(frame); - } - /** * Add the FRAME tag for the frame that lists all packages. * diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java index 8d580f837a6..ef602999135 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java @@ -162,7 +162,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { */ protected void addAllProfilesLink(Content div) { Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME, - allprofilesLabel, "", "profileListFrame"); + allprofilesLabel, "", "packageListFrame"); Content span = HtmlTree.SPAN(linkContent); div.addContent(span); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java index 695745465ad..f336fe86f03 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java @@ -107,7 +107,7 @@ public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter { String profileName = (Profile.lookup(profile)).name; profileLabel = new StringContent(profileName); profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "", - "profileListFrame"); + "packageListFrame"); Content li = HtmlTree.LI(profileLinkContent); return li; } @@ -154,7 +154,7 @@ public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter { */ protected void addAllPackagesLink(Content div) { Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME, - allpackagesLabel, "", "profileListFrame"); + allpackagesLabel, "", "packageListFrame"); Content span = HtmlTree.SPAN(linkContent); div.addContent(span); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java index 193e5592281..3d5535d30f6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java @@ -172,7 +172,7 @@ public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter { */ protected void addAllPackagesLink(Content div) { Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME, - allpackagesLabel, "", "profileListFrame"); + allpackagesLabel, "", "packageListFrame"); Content span = HtmlTree.SPAN(linkContent); div.addContent(span); } @@ -185,7 +185,7 @@ public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter { */ protected void addAllProfilesLink(Content div) { Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME, - allprofilesLabel, "", "profileListFrame"); + allprofilesLabel, "", "packageListFrame"); Content span = HtmlTree.SPAN(linkContent); div.addContent(span); } diff --git a/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java b/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java index 93978fbe778..a52d3ccd5ac 100644 --- a/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java +++ b/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8006124 + * @bug 8006124 8009684 * @summary Test javadoc support for profiles. * @author Bhavesh Patel * @library ../lib/ @@ -33,7 +33,7 @@ public class TestProfiles extends JavadocTester { //Test information. - private static final String BUG_ID = "8006124"; + private static final String BUG_ID = "8006124-8009684"; private static final String PROFILE_BUG_ID = BUG_ID + "-1"; private static final String PACKAGE_BUG_ID = BUG_ID + "-2"; //Javadoc arguments. @@ -49,17 +49,17 @@ public class TestProfiles extends JavadocTester { // Tests for profile-overview-frame.html listing all profiles. {PROFILE_BUG_ID + FS + "profile-overview-frame.html", "All Packages" + + "target=\"packageListFrame\">All Packages" }, {PROFILE_BUG_ID + FS + "profile-overview-frame.html", - "
  • " + "
  • " + "compact1
  • " }, // Tests for profileName-frame.html listing all packages in a profile. {PROFILE_BUG_ID + FS + "compact2-frame.html", - "" + "" + "All PackagesAll Profiles" + + "target=\"packageListFrame\">All Profiles" }, {PROFILE_BUG_ID + FS + "compact2-frame.html", "
  • All Profiles" + + "target=\"packageListFrame\">All Profiles" }, //Test for "className.html" showing the profile information for the type. {PROFILE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html", "
    compact1, compact2, compact3
    " + }, + {PROFILE_BUG_ID + FS + "index.html", + "" } }; private static final String[][] PROFILES_NEGATED_TEST = { @@ -131,12 +135,12 @@ public class TestProfiles extends JavadocTester { private static final String[][] PACKAGES_NEGATED_TEST = { {PACKAGE_BUG_ID + FS + "profile-overview-frame.html", "All Packages" + + "target=\"packageListFrame\">All Packages" }, {PACKAGE_BUG_ID + FS + "compact2-frame.html", - "" + "" + "All PackagesAll Profiles" + + "target=\"packageListFrame\">All Profiles" }, {PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html", "" @@ -151,7 +155,7 @@ public class TestProfiles extends JavadocTester { }, {PACKAGE_BUG_ID + FS + "overview-frame.html", "All Profiles" + + "target=\"packageListFrame\">All Profiles" }, {PACKAGE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html", "
    compact1, compact2, compact3
    " From d1bf476e1d92f17f2622b2328dcbe2bb570e4246 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 14 Mar 2013 01:41:20 -0400 Subject: [PATCH 006/155] 8009428: Revert changes to $ substitution performed as part of nashorn integration Reviewed-by: alanb, erikj --- common/makefiles/MakeBase.gmk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/makefiles/MakeBase.gmk b/common/makefiles/MakeBase.gmk index 4c1ecc8c8b7..708cbada085 100644 --- a/common/makefiles/MakeBase.gmk +++ b/common/makefiles/MakeBase.gmk @@ -51,9 +51,8 @@ decompress_paths=$(SED) -f $(SRC_ROOT)/common/makefiles/support/ListPathsSafely- -e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \ -e 's|X00|X|g' | tr '\n' '$2' -# Subst in an extra $ to prevent it from disappearing. define ListPathsSafely_If - $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(subst $$,$$$$,$(wordlist $3,$4,$($1)))))) + $(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1))))) endef define ListPathsSafely_Printf From 52954e063d385088f3b41485db4dbf96dbb0e567 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 14 Mar 2013 01:45:44 -0400 Subject: [PATCH 007/155] 8009429: Miscellaneous profiles cleanup Reviewed-by: jjg, alanb --- .../classes/com/sun/tools/javac/sym/Profiles.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java b/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java index 53c709b2dc6..8cae1dd3696 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java +++ b/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java @@ -149,12 +149,13 @@ public abstract class Profiles { } final static Map packages = new TreeMap(); - int maxProfile; + + final int maxProfile = 4; // Three compact profiles plus full JRE MakefileProfiles(Properties p) { - int profile = 1; - while (true) { - String inclPackages = p.getProperty("PROFILE_" + profile + "_RTJAR_INCLUDE_PACKAGES"); + for (int profile = 1; profile <= maxProfile; profile++) { + String prefix = (profile < maxProfile ? "PROFILE_" + profile : "FULL_JRE"); + String inclPackages = p.getProperty(prefix + "_RTJAR_INCLUDE_PACKAGES"); if (inclPackages == null) break; for (String pkg: inclPackages.substring(1).trim().split("\\s+")) { @@ -162,22 +163,20 @@ public abstract class Profiles { pkg = pkg.substring(0, pkg.length() - 1); includePackage(profile, pkg); } - String inclTypes = p.getProperty("PROFILE_" + profile + "_RTJAR_INCLUDE_TYPES"); + String inclTypes = p.getProperty(prefix + "_RTJAR_INCLUDE_TYPES"); if (inclTypes != null) { for (String type: inclTypes.replace("$$", "$").split("\\s+")) { if (type.endsWith(".class")) includeType(profile, type.substring(0, type.length() - 6)); } } - String exclTypes = p.getProperty("PROFILE_" + profile + "_RTJAR_EXCLUDE_TYPES"); + String exclTypes = p.getProperty(prefix + "_RTJAR_EXCLUDE_TYPES"); if (exclTypes != null) { for (String type: exclTypes.replace("$$", "$").split("\\s+")) { if (type.endsWith(".class")) excludeType(profile, type.substring(0, type.length() - 6)); } } - maxProfile = profile; - profile++; } } From 4ef6ef5d0fb2d570d3712a131ac27cf9f8db781e Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 14 Mar 2013 08:30:16 +0000 Subject: [PATCH 008/155] 8008582: jtreg failures after conversion of shell tests to Java Reviewed-by: jjg --- .../com/sun/tools/javac/util/ArrayUtils.java | 13 -- .../javac/4846262/CheckEBCDICLocaleTest.java | 37 +++-- .../javac/ClassPathTest/ClassPathTest.java | 60 ++++++-- .../ProtectedInnerClassesTest.java | 11 +- langtools/test/tools/javac/lib/ToolBox.java | 140 +++++++++++++----- .../test/tools/javac/links/LinksTest.java | 17 ++- .../tools/javac/newlines/NewLineTest.java | 7 +- .../test/tools/javah/6257087/T6257087.java | 7 +- .../javah/constMacroTest/ConstMacroTest.java | 11 +- .../tools/javap/stackmap/StackmapTest.java | 9 +- 10 files changed, 199 insertions(+), 113 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java b/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java index e342711c12c..67a02369cf9 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java @@ -85,17 +85,4 @@ public class ArrayUtils { } } - public static T[] concat(T[] anArr, T[] anotherArr) { - int newLength = anArr.length + anotherArr.length; - @SuppressWarnings("unchecked") - T[] result = (T[]) Array.newInstance(anArr.getClass().getComponentType(), newLength); - System.arraycopy(anArr, 0, result, 0, anArr.length); - System.arraycopy(anotherArr, 0, result, anArr.length, anotherArr.length); - return result; - } - - @SuppressWarnings("unchecked") - public static T[] concatOpen(T[] anArr, T... anotherArr) { - return concat(anArr, anotherArr); - } } diff --git a/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java b/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java index cc48ba1a8d8..6dd2179f18e 100644 --- a/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java +++ b/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java @@ -34,9 +34,7 @@ import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; -import com.sun.tools.javac.util.ArrayUtils; -//original test: test/tools/javac/4846262/Test.sh public class CheckEBCDICLocaleTest { private static final String TestSrc = @@ -46,11 +44,11 @@ public class CheckEBCDICLocaleTest { " }\n" + "}"; - private static final String TestOut = - "output/Test.java:3: error: not a statement\n" + + private static final String TestOutTemplate = + "output%1$sTest.java:3: error: not a statement\n" + " abcdefg\n" + " ^\n" + - "output/Test.java:3: error: ';' expected\n" + + "output%1$sTest.java:3: error: ';' expected\n" + " abcdefg\n" + " ^\n" + "2 errors\n"; @@ -62,38 +60,37 @@ public class CheckEBCDICLocaleTest { public void test() throws Exception { String native2asciiBinary = Paths.get( System.getProperty("test.jdk"),"bin", "native2ascii").toString(); - String testVMOpts = System.getProperty("test.tool.vm.opts"); - String[] mainArgs = ToolBox.getJavacBin(); ToolBox.createJavaFileFromSource(TestSrc); Files.createDirectory(Paths.get("output")); -//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java ToolBox.AnyToolArgs nativeCmdParams = new ToolBox.AnyToolArgs() - .setAllArgs(native2asciiBinary, testVMOpts, - "-reverse", "-encoding", "IBM1047", - "Test.java", "output/Test.java"); + .appendArgs(native2asciiBinary) + .appendArgs(ToolBox.testToolVMOpts) + .appendArgs("-reverse", "-encoding", "IBM1047", "Test.java", + "output/Test.java"); ToolBox.executeCommand(nativeCmdParams); -//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp ToolBox.AnyToolArgs javacParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) - .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en", + .appendArgs(ToolBox.javacBinary) + .appendArgs(ToolBox.testToolVMOpts) + .appendArgs("-J-Duser.language=en", "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047", - "output/Test.java")) + "output/Test.java") .setErrOutput(new File("Test.tmp")); ToolBox.executeCommand(javacParams); -//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out - nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047", - "Test.tmp", "Test.out"); + nativeCmdParams = new ToolBox.AnyToolArgs() + .appendArgs(native2asciiBinary) + .appendArgs(ToolBox.testToolVMOpts) + .appendArgs("-encoding", "IBM1047", "Test.tmp", "Test.out"); ToolBox.executeCommand(nativeCmdParams); -//diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out + String goldenFile = String.format(TestOutTemplate, File.separator); ToolBox.compareLines(Paths.get("Test.out"), - Arrays.asList(TestOut.split("\n")), null); - + Arrays.asList(goldenFile.split("\n")), null, true); } } diff --git a/langtools/test/tools/javac/ClassPathTest/ClassPathTest.java b/langtools/test/tools/javac/ClassPathTest/ClassPathTest.java index 8dc75d428de..de4f73fd212 100644 --- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest.java +++ b/langtools/test/tools/javac/ClassPathTest/ClassPathTest.java @@ -31,9 +31,11 @@ */ import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.TreeMap; -import com.sun.tools.javac.util.ArrayUtils; //original test: test/tools/javac/ClassPathTest/ClassPathTest.sh public class ClassPathTest { @@ -92,24 +94,31 @@ public class ClassPathTest { } void checkCompileCommands() throws Exception { - String[] mainArgs = ToolBox.getJavacBin(); - // Without the -cp . parameter the command will fail seems like when called // from the command line, the current dir is added to the classpath // automatically but this is not happening when called using ProcessBuilder // testJavac success ClassPathTest3.java - String[] commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", "."); + List mainArgs = new ArrayList<>(); + mainArgs.add(ToolBox.javacBinary.toString()); + if (ToolBox.testToolVMOpts != null) { + mainArgs.addAll(ToolBox.testToolVMOpts); + } - ToolBox.AnyToolArgs successParams = - new ToolBox.AnyToolArgs() - .setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java")); + List commonArgs = new ArrayList<>(); + commonArgs.addAll(mainArgs); + commonArgs.addAll(Arrays.asList("-cp", ".")); + + ToolBox.AnyToolArgs successParams = new ToolBox.AnyToolArgs() + .appendArgs(commonArgs) + .appendArgs("ClassPathTest3.java"); ToolBox.executeCommand(successParams); // testJavac failure ClassPathTest1.java ToolBox.AnyToolArgs failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) - .setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java")); + .appendArgs(commonArgs) + .appendArgs("ClassPathTest1.java"); ToolBox.executeCommand(failParams); // This is done inside the executeCommand method @@ -119,29 +128,50 @@ public class ClassPathTest { extVars.put("CLASSPATH", "bar"); // testJavac success ClassPathTest2.java - successParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest2.java")).set(extVars); + successParams = new ToolBox.AnyToolArgs() + .appendArgs(mainArgs) + .appendArgs("ClassPathTest2.java") + .set(extVars); ToolBox.executeCommand(successParams); // testJavac failure ClassPathTest1.java - failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest1.java")).set(extVars); + failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) + .appendArgs(mainArgs) + .appendArgs("ClassPathTest1.java") + .set(extVars); ToolBox.executeCommand(failParams); // testJavac failure ClassPathTest3.java - failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest3.java")); + failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) + .appendArgs(mainArgs) + .appendArgs("ClassPathTest3.java") + .set(extVars); ToolBox.executeCommand(failParams); // testJavac success -classpath foo ClassPathTest1.java - commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", "foo"); - successParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java")); + commonArgs.clear(); + commonArgs.addAll(mainArgs); + commonArgs.addAll(Arrays.asList("-cp", "foo")); + + successParams = new ToolBox.AnyToolArgs() + .appendArgs(commonArgs) + .appendArgs("ClassPathTest1.java") + .set(extVars); ToolBox.executeCommand(successParams); // testJavac failure -classpath foo ClassPathTest2.java - failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest2.java")); + failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) + .appendArgs(commonArgs) + .appendArgs("ClassPathTest2.java") + .set(extVars); ToolBox.executeCommand(failParams); // testJavac failure -classpath foo ClassPathTest3.java - failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java")); + failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) + .appendArgs(commonArgs) + .appendArgs("ClassPathTest3.java") + .set(extVars); ToolBox.executeCommand(failParams); } diff --git a/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java b/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java index ba7b7a04f8a..cbe4c335306 100644 --- a/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java +++ b/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java @@ -91,7 +91,9 @@ public class ProtectedInnerClassesTest { //"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2 ToolBox.AnyToolArgs javaParams = new ToolBox.AnyToolArgs() - .setAllArgs(ToolBox.javaBinary, "-classpath", System.getProperty("user.dir"), + .appendArgs(ToolBox.javaBinary) + .appendArgs(ToolBox.testVMOpts) + .appendArgs("-classpath", System.getProperty("user.dir"), "p2.ProtectedInnerClass2"); ToolBox.executeCommand(javaParams); } @@ -101,14 +103,15 @@ public class ProtectedInnerClassesTest { //@run compile p1/ProtectedInnerClass1.java ToolBox.JavaToolArgs javacParams = new ToolBox.JavaToolArgs() - .setOptions("-d", ".") + .appendArgs("-d", ".") .setSources(protectedInnerClass1Src); ToolBox.javac(javacParams); //@run compile/fail p2/ProtectedInnerClass3.java - javacParams.setSources(protectedInnerClass3Src) - .set(ToolBox.Expect.FAIL); + javacParams = new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL) + .appendArgs("-d", ".") + .setSources(protectedInnerClass3Src); ToolBox.javac(javacParams); } diff --git a/langtools/test/tools/javac/lib/ToolBox.java b/langtools/test/tools/javac/lib/ToolBox.java index 9cc859730b7..49a65b480d1 100644 --- a/langtools/test/tools/javac/lib/ToolBox.java +++ b/langtools/test/tools/javac/lib/ToolBox.java @@ -38,6 +38,7 @@ import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Map; @@ -65,15 +66,32 @@ public class ToolBox { public static final String lineSeparator = System.getProperty("line.separator"); public static final String jdkUnderTest = System.getProperty("test.jdk"); - public static final String testVMOpts = System.getProperty("test.tool.vm.opts"); - public static final String javaBinary = Paths.get(jdkUnderTest, "bin", "java").toString(); - //why this one private. Because the function which provide also the test options should be used - private static final String javacBinary = Paths.get(jdkUnderTest, "bin", "javac").toString(); + public static final Path javaBinary = Paths.get(jdkUnderTest, "bin", "java"); + public static final Path javacBinary = Paths.get(jdkUnderTest, "bin", "javac"); + + public static final List testToolVMOpts; + public static final List testVMOpts; private static final Charset defaultCharset = Charset.defaultCharset(); static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + static { + String sysProp = System.getProperty("test.tool.vm.opts"); + if (sysProp != null && sysProp.length() > 0) { + testToolVMOpts = Arrays.asList(sysProp.split("\\s+")); + } else { + testToolVMOpts = Collections.emptyList(); + } + + sysProp = System.getProperty("test.vm.opts"); + if (sysProp != null && sysProp.length() > 0) { + testVMOpts = Arrays.asList(sysProp.split("\\s+")); + } else { + testVMOpts = Collections.emptyList(); + } + } + /** * The expected result of command-like method execution. */ @@ -199,8 +217,8 @@ public class ToolBox { protected Expect whatToExpect; protected WriterHelper stdOutput; protected WriterHelper errOutput; - protected List options; - protected String[] optionsArr; + protected List args = new ArrayList<>(); + protected String[] argsArr; protected GenericArgs() { set(Expect.SUCCESS); @@ -238,19 +256,50 @@ public class ToolBox { public T setAllArgs(String... args) { currentParams.add(AcceptedParams.OPTIONS); - this.optionsArr = args; + this.argsArr = args; + return (T) this; + } + + + public T appendArgs(String... args) { + appendArgs(Arrays.asList(args)); + return (T)this; + } + + public T appendArgs(Path... args) { + if (args != null) { + List list = new ArrayList<>(); + for (int i = 0; i < args.length; i++) { + if (args[i] != null) { + list.add(args[i].toString()); + } + } + appendArgs(list); + } + return (T)this; + } + + public T appendArgs(List args) { + if (args != null && args.size() > 0) { + currentParams.add(AcceptedParams.OPTIONS); + for (int i = 0; i < args.size(); i++) { + if (args.get(i) != null) { + this.args.add(args.get(i)); + } + } + } return (T)this; } public T setOptions(List options) { currentParams.add(AcceptedParams.OPTIONS); - this.options = options; + this.args = options; return (T)this; } public T setOptions(String... options) { currentParams.add(AcceptedParams.OPTIONS); - this.options = Arrays.asList(options); + this.args = Arrays.asList(options); return (T)this; } @@ -365,8 +414,12 @@ public class ToolBox { * Custom exception for not equal resources. */ public static class ResourcesNotEqualException extends Exception { - public ResourcesNotEqualException() { - super("The resources provided for comparison are different"); + public ResourcesNotEqualException(List res1, List res2) { + super(createMessage(res1, res2)); + } + + public ResourcesNotEqualException(String line1, String line2) { + super(createMessage(line1, line2)); } public ResourcesNotEqualException(Path path1, Path path2) { @@ -379,15 +432,20 @@ public class ToolBox { .append(path1.toString()).append(" and \n") .append(path2.toString()).append("are different").toString(); } - } - /** - * Method to get the a path to the javac command available at the jdk being - * tested along with the test vm options. - * @return a String[] with the two components mentioned. - */ - public static String[] getJavacBin() { - return new String[]{javacBinary, testVMOpts}; + private static String createMessage(String line1, String line2) { + return new StringBuilder() + .append("The resources provided for comparison are different at lines: \n") + .append(line1).append(" and \n") + .append(line2).toString(); + } + + private static String createMessage(List res1, List res2) { + return new StringBuilder() + .append("The resources provided for comparison are different: \n") + .append("Resource 1 is: ").append(res1).append("\n and \n") + .append("Resource 2 is: ").append(res2).append("\n").toString(); + } } /** @@ -396,7 +454,7 @@ public class ToolBox { public static int javac(JavaToolArgs params) throws CommandExecutionException, IOException { if (params.hasMinParams()) { - if (params.optionsArr != null) { + if (params.argsArr != null) { return genericJavaCMD(JavaCMD.JAVAC, params); } else { return genericJavaCMD(JavaCMD.JAVAC_API, params); @@ -437,14 +495,14 @@ public class ToolBox { JAVAC { @Override int run(JavaToolArgs params, PrintWriter pw) { - return com.sun.tools.javac.Main.compile(params.optionsArr, pw); + return com.sun.tools.javac.Main.compile(params.argsArr, pw); } }, JAVAC_API { @Override int run(JavaToolArgs params, PrintWriter pw) { JavacTask ct = (JavacTask)comp.getTask(pw, null, null, - params.options, null, params.sources); + params.args, null, params.sources); return ((JavacTaskImpl)ct).doCall().exitCode; } @@ -467,13 +525,13 @@ public class ToolBox { JAVAH { @Override int run(JavaToolArgs params, PrintWriter pw) { - return com.sun.tools.javah.Main.run(params.optionsArr, pw); + return com.sun.tools.javah.Main.run(params.argsArr, pw); } }, JAVAP { @Override int run(JavaToolArgs params, PrintWriter pw) { - return com.sun.tools.javap.Main.run(params.optionsArr, pw); + return com.sun.tools.javap.Main.run(params.argsArr, pw); } }; @@ -486,9 +544,9 @@ public class ToolBox { List getExceptionMsgContent(JavaToolArgs params) { List result = new ArrayList<>(); result.add(getName()); - result.addAll(params.optionsArr != null ? - Arrays.asList(params.optionsArr) : - params.options); + result.addAll(params.argsArr != null ? + Arrays.asList(params.argsArr) : + params.args); return result; } } @@ -509,7 +567,7 @@ public class ToolBox { String out = (sw == null) ? null : sw.toString(); if (params.errOutput != null && (out != null) && !out.isEmpty()) { - params.errOutput.addAll(splitLines(out)); + params.errOutput.addAll(splitLines(out, lineSeparator)); } if ( (rc == 0 && params.whatToExpect == Expect.SUCCESS) || @@ -542,9 +600,9 @@ public class ToolBox { public static int executeCommand(AnyToolArgs params) throws CommandExecutionException, IOException, InterruptedException { if (params.hasMinParams()) { - List cmd = (params.options != null) ? - params.options : - Arrays.asList(params.optionsArr); + List cmd = (params.args != null) ? + params.args : + Arrays.asList(params.argsArr); return executeCommand(cmd, params.extraEnv, params.stdOutput, params.errOutput, params.whatToExpect); } @@ -630,7 +688,7 @@ public class ToolBox { List list2, boolean trim) throws ResourcesNotEqualException { if ((list1 == list2) || (list1 == null && list2 == null)) return; if (list1.size() != list2.size()) - throw new ResourcesNotEqualException(); + throw new ResourcesNotEqualException(list1, list2); int i = 0; int j = 0; while (i < list1.size() && @@ -639,7 +697,7 @@ public class ToolBox { i++; j++; } if (!(i == list1.size() && j == list2.size())) - throw new ResourcesNotEqualException(); + throw new ResourcesNotEqualException(list1, list2); } private static boolean equals(String s1, String s2, boolean trim) { @@ -652,8 +710,8 @@ public class ToolBox { * and later the regExpr is seek in every split line. If a match is found, * the whole line is added to the result. */ - public static List grep(String regExpr, String text) { - return grep(regExpr, splitLines(text)); + public static List grep(String regExpr, String text, String sep) { + return grep(regExpr, splitLines(text, sep)); } public static List grep(String regExpr, List text) { @@ -865,8 +923,8 @@ public class ToolBox { /** * Splits a String using the System's line separator character as splitting point. */ - public static List splitLines(String lines) { - return Arrays.asList(lines.split(lineSeparator)); + public static List splitLines(String lines, String sep) { + return Arrays.asList(lines.split(sep)); } /** @@ -881,6 +939,14 @@ public class ToolBox { return sb.toString(); } + /** + * Returns true if the OS is a Windows version. + */ + public static boolean isWindows() { + String osName = System.getProperty("os.name"); + return osName.toUpperCase().startsWith("WINDOWS"); + } + /** * Class representing an in-memory java source file. It is able to extract * the file name from simple source codes using regular expressions. diff --git a/langtools/test/tools/javac/links/LinksTest.java b/langtools/test/tools/javac/links/LinksTest.java index f06e12c6bce..6cdebb0a37f 100644 --- a/langtools/test/tools/javac/links/LinksTest.java +++ b/langtools/test/tools/javac/links/LinksTest.java @@ -50,14 +50,17 @@ public class LinksTest { // cp ${TESTSRC}/b/B.java tmp ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc); + try { // ln -s `pwd`/tmp "${TESTCLASSES}/a" - Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp")); -// -////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1 - ToolBox.JavaToolArgs javacArgs = - new ToolBox.JavaToolArgs() - .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc); - ToolBox.javac(javacArgs); + Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp")); + ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1 + ToolBox.JavaToolArgs javacArgs = + new ToolBox.JavaToolArgs() + .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc); + ToolBox.javac(javacArgs); + } catch (UnsupportedOperationException e) { + System.err.println("Symbolic links not supported on this system. The test can't finish"); + } } } diff --git a/langtools/test/tools/javac/newlines/NewLineTest.java b/langtools/test/tools/javac/newlines/NewLineTest.java index a089581d745..27392f2666c 100644 --- a/langtools/test/tools/javac/newlines/NewLineTest.java +++ b/langtools/test/tools/javac/newlines/NewLineTest.java @@ -34,19 +34,18 @@ import java.io.File; import java.nio.charset.Charset; import java.nio.file.Files; import java.util.List; -import com.sun.tools.javac.util.ArrayUtils; //original test: test/tools/javac/newlines/Newlines.sh public class NewLineTest { public static void main(String args[]) throws Exception { - String[] mainArgs = ToolBox.getJavacBin(); - // "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1 File javacErrOutput = new File("output.txt"); ToolBox.AnyToolArgs cmdArgs = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) - .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Dline.separator='@'")) + .appendArgs(ToolBox.javacBinary) + .appendArgs(ToolBox.testToolVMOpts) + .appendArgs("-J-Dline.separator='@'") .setErrOutput(javacErrOutput); ToolBox.executeCommand(cmdArgs); diff --git a/langtools/test/tools/javah/6257087/T6257087.java b/langtools/test/tools/javah/6257087/T6257087.java index d296d1cd510..27b538f7f82 100644 --- a/langtools/test/tools/javah/6257087/T6257087.java +++ b/langtools/test/tools/javah/6257087/T6257087.java @@ -32,7 +32,6 @@ import java.nio.file.Paths; -//original test: test/tools/javah/6257087/foo.sh public class T6257087 { private static final String fooBarGoldenFile = @@ -59,17 +58,13 @@ public class T6257087 { "#endif"; public static void main(String[] args) throws Exception { -// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java" - -// "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo ToolBox.JavaToolArgs javahArgs = new ToolBox.JavaToolArgs() .setAllArgs("-cp", System.getProperty("test.classes"), "foo"); ToolBox.javah(javahArgs); -// diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h" ToolBox.compareLines(Paths.get("foo_bar.h"), - ToolBox.splitLines(fooBarGoldenFile), null); + ToolBox.splitLines(fooBarGoldenFile, "\n"), null, true); } } diff --git a/langtools/test/tools/javah/constMacroTest/ConstMacroTest.java b/langtools/test/tools/javah/constMacroTest/ConstMacroTest.java index ddf38bfca3a..88b31f6ebbd 100644 --- a/langtools/test/tools/javah/constMacroTest/ConstMacroTest.java +++ b/langtools/test/tools/javah/constMacroTest/ConstMacroTest.java @@ -38,7 +38,7 @@ import java.nio.file.Paths; //original test: test/tools/javah/ConstMacroTest.sh public class ConstMacroTest { - private static final String SubClassConstsGoldenFile = + private static final String subClassConstsGoldenFileTemplate = "/* DO NOT EDIT THIS FILE - it is machine generated */\n" + "#include \n" + "/* Header for class SubClassConsts */\n" + @@ -49,7 +49,7 @@ public class ConstMacroTest { "extern \"C\" {\n" + "#endif\n" + "#undef SubClassConsts_serialVersionUID\n" + - "#define SubClassConsts_serialVersionUID 6733861379283244755LL\n" + + "#define SubClassConsts_serialVersionUID 6733861379283244755%s\n" + "#undef SubClassConsts_SUPER_INT_CONSTANT\n" + "#define SubClassConsts_SUPER_INT_CONSTANT 3L\n" + "#undef SubClassConsts_SUPER_FLOAT_CONSTANT\n" + @@ -71,6 +71,9 @@ public class ConstMacroTest { "#endif\n" + "#endif"; + private static final String serialVersionUIDSuffix = + ToolBox.isWindows() ? "i64" : "LL"; ; + public static void main(String[] args) throws Exception { //first steps are now done by jtreg // cp "${TESTSRC}${FS}SuperClassConsts.java" . @@ -85,8 +88,10 @@ public class ConstMacroTest { ToolBox.javah(successParams); // diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}" + String subClassConstGoldenFile = String.format(subClassConstsGoldenFileTemplate, + serialVersionUIDSuffix); ToolBox.compareLines(Paths.get("SubClassConsts.h"), - ToolBox.splitLines(SubClassConstsGoldenFile), null); + ToolBox.splitLines(subClassConstGoldenFile, "\n"), null, true); } } diff --git a/langtools/test/tools/javap/stackmap/StackmapTest.java b/langtools/test/tools/javap/stackmap/StackmapTest.java index 11cd80352a7..81664be8bd9 100644 --- a/langtools/test/tools/javap/stackmap/StackmapTest.java +++ b/langtools/test/tools/javap/stackmap/StackmapTest.java @@ -84,10 +84,11 @@ public class StackmapTest { new ToolBox.JavaToolArgs() .setAllArgs("-v", "Test.class"); String out = ToolBox.javap(javapParams); - List grepResult = ToolBox.grep("frame_type", out); - grepResult.addAll(ToolBox.grep("offset_delta", out)); - grepResult.addAll(ToolBox.grep("stack = ", out)); - grepResult.addAll(ToolBox.grep("locals = ", out)); + List grepResult = ToolBox.grep("frame_type", out, + ToolBox.lineSeparator); + grepResult.addAll(ToolBox.grep("offset_delta", out, ToolBox.lineSeparator)); + grepResult.addAll(ToolBox.grep("stack = ", out, ToolBox.lineSeparator)); + grepResult.addAll(ToolBox.grep("locals = ", out, ToolBox.lineSeparator)); List goldenList = Arrays.asList(goldenOut.split("\n")); // diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out" From 2aeaf10fffd24b57bb3cef0feac6c9059d288a15 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Thu, 14 Mar 2013 14:49:55 +0100 Subject: [PATCH 009/155] 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings Reviewed-by: sundar, jlaskey --- .../scripting/NashornScriptEngineFactory.java | 2 +- .../internal/codegen/CodeGenerator.java | 5 ++- .../nashorn/internal/codegen/Compiler.java | 36 +++++++++++++++---- .../jdk/nashorn/internal/ir/FunctionNode.java | 12 +++---- .../jdk/nashorn/internal/objects/Global.java | 3 +- .../jdk/nashorn/internal/parser/Parser.java | 2 +- .../jdk/nashorn/internal/runtime/Context.java | 1 + .../internal/runtime/ScriptLoader.java | 3 +- .../runtime/linker/JavaAdapterFactory.java | 1 + .../runtime/regexp/DefaultRegExp.java | 10 +++--- .../internal/runtime/regexp/JoniRegExp.java | 10 +++--- .../internal/runtime/regexp/RegExp.java | 2 +- .../runtime/regexp/RegExpFactory.java | 9 +++-- .../internal/runtime/regexp/RegExpResult.java | 6 ++-- .../runtime/regexp/RegExpScanner.java | 2 -- .../script/basic/compile-octane.js.EXPECTED | 3 ++ nashorn/test/script/basic/run-octane.js | 23 +++++++++--- .../test/script/basic/runsunspider-eager.js | 33 +++++++++++++++++ .../test/script/basic/runsunspider-lazy.js | 34 ++++++++++++++++++ nashorn/test/script/basic/runsunspider.js | 30 +--------------- 20 files changed, 152 insertions(+), 75 deletions(-) create mode 100644 nashorn/test/script/basic/runsunspider-eager.js create mode 100644 nashorn/test/script/basic/runsunspider-lazy.js diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java index 4672f6a073e..e38284da99e 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java @@ -176,7 +176,7 @@ public final class NashornScriptEngineFactory implements ScriptEngineFactory { // -- Internals only below this point - private void checkConfigPermission() { + private static void checkConfigPermission() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("nashorn.setConfig")); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 71a2eb0fe1e..ce6a1fcdfdf 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -3230,8 +3230,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } private void newFunctionObject(final FunctionNode functionNode) { - final boolean isLazy = functionNode.isLazy(); - final Class[] cparams = new Class[] { RecompilableScriptFunctionData.class, ScriptObject.class }; + final boolean isLazy = functionNode.isLazy(); new ObjectCreator(this, new ArrayList(), new ArrayList(), false, false) { @Override @@ -3246,7 +3245,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } else { m.loadNull(); } - m.invoke(constructorNoLookup(className, cparams)); + m.invoke(constructorNoLookup(className, RecompilableScriptFunctionData.class, ScriptObject.class)); } }.makeObject(method); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index a799ee0506f..87d26c1aab5 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -217,8 +217,6 @@ public final class Compiler { append(safeSourceName(functionNode.getSource())); this.scriptName = sb.toString(); - - LOG.info("Initializing compiler for '" + functionNode.getName() + "' scriptName = " + scriptName + ", root function: '" + functionNode.getName() + "' lazy=" + functionNode.isLazy()); } /** @@ -361,7 +359,10 @@ public final class Compiler { final Map> installedClasses = new HashMap<>(); final String rootClassName = firstCompileUnitName(); - final Class rootClass = install(rootClassName, bytecode.get(rootClassName)); + final byte[] rootByteCode = bytecode.get(rootClassName); + final Class rootClass = install(rootClassName, rootByteCode); + + int length = rootByteCode.length; installedClasses.put(rootClassName, rootClass); @@ -370,7 +371,10 @@ public final class Compiler { if (className.equals(rootClassName)) { continue; } - installedClasses.put(className, install(className, entry.getValue())); + final byte[] code = entry.getValue(); + length += code.length; + + installedClasses.put(className, install(className, code)); } for (final CompileUnit unit : compileUnits) { @@ -388,12 +392,32 @@ public final class Compiler { } }); - LOG.info("Installed root class: " + rootClass + " and " + bytecode.size() + " compile unit classes"); + final StringBuilder sb; + if (LOG.isEnabled()) { + sb = new StringBuilder(); + sb.append("Installed class '"). + append(rootClass.getSimpleName()). + append('\''). + append(" bytes="). + append(length). + append('.'); + if (bytecode.size() > 1) { + sb.append(' ').append(bytecode.size()).append(" compile units."); + } + } else { + sb = null; + } if (Timing.isEnabled()) { final long duration = System.currentTimeMillis() - t0; Timing.accumulateTime("[Code Installation]", duration); - LOG.info("Installation time: " + duration + " ms"); + if (sb != null) { + sb.append(" Install time: ").append(duration).append(" ms"); + } + } + + if (sb != null) { + LOG.info(sb.toString()); } return rootClass; diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index 63590932d44..7fd77cd0471 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -218,8 +218,9 @@ public class FunctionNode extends Block { private static final int HAS_ALL_VARS_IN_SCOPE = HAS_DEEP_WITH_OR_EVAL | IS_SPLIT | HAS_LAZY_CHILDREN; /** Does this function potentially need "arguments"? Note that this is not a full test, as further negative check of REDEFINES_ARGS is needed. */ private static final int MAYBE_NEEDS_ARGUMENTS = USES_ARGUMENTS | HAS_EVAL; - /** Does this function need the parent scope? It needs it if either it or its descendants use variables from it, or have a deep with or eval. */ - private static final int NEEDS_PARENT_SCOPE = USES_ANCESTOR_SCOPE | HAS_DEEP_WITH_OR_EVAL; + /** Does this function need the parent scope? It needs it if either it or its descendants use variables from it, or have a deep with or eval. + * We also pessimistically need a parent scope if we have lazy children that have not yet been compiled */ + private static final int NEEDS_PARENT_SCOPE = USES_ANCESTOR_SCOPE | HAS_DEEP_WITH_OR_EVAL | HAS_LAZY_CHILDREN; /** What is the return type of this function? */ private Type returnType = Type.UNKNOWN; @@ -724,13 +725,10 @@ public class FunctionNode extends Block { * their parent scope, functions that reference themselves, and non-strict functions that need an Arguments object * (since it exposes {@code arguments.callee} property) will need to have a callee parameter. * - * We also conservatively need a callee if we have lazy children, i.e. nested function nodes that have not yet - * been evaluated. _They_ may need the callee and we don't know it - * * @return true if the function's generated Java method needs a {@code callee} parameter. */ public boolean needsCallee() { - return hasLazyChildren() || needsParentScope() || needsSelfSymbol() || (needsArguments() && !isStrictMode()); + return needsParentScope() || needsSelfSymbol() || (needsArguments() && !isStrictMode()); } /** @@ -1076,7 +1074,7 @@ public class FunctionNode extends Block { } else { this.flags |= USES_ANCESTOR_SCOPE; final FunctionNode parentFn = findParentFunction(); - if(parentFn != null) { + if (parentFn != null) { parentFn.setUsesScopeSymbol(symbol); } } diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index a9835f6fea9..e0bb9ecefd2 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -1528,8 +1528,9 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); } - private void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) { + private static void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Void run() { for (Field f : scriptEnv.getClass().getFields()) { try { diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index bfc96abf47c..166fed91f9e 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -126,7 +126,7 @@ public class Parser extends AbstractParser { /** Namespace for function names where not explicitly given */ private final Namespace namespace; - private static DebugLogger LOG = new DebugLogger("parser"); + private static final DebugLogger LOG = new DebugLogger("parser"); /** * Constructor diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 151615c07df..0ca2c47a9ec 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -744,6 +744,7 @@ public final class Context { global = (GlobalObject)Context.getGlobalTrusted(); script = global.findCachedClass(source); if (script != null) { + Compiler.LOG.fine("Code cache hit for " + source + " avoiding recompile."); return script; } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java index adecd8a3cbe..370faf312d0 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java @@ -60,8 +60,7 @@ final class ScriptLoader extends NashornLoader { synchronized Class installClass(final String name, final byte[] data, final CodeSource cs) { if (cs == null) { return defineClass(name, data, 0, data.length, new ProtectionDomain(null, getPermissions(null))); - } else { - return defineClass(name, data, 0, data.length, cs); } + return defineClass(name, data, 0, data.length, cs); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java index ba599da1a98..7b0d6d76190 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java @@ -412,6 +412,7 @@ public final class JavaAdapterFactory { public static MethodHandle getConstructor(final Class sourceType, final Class targetType) throws Exception { final StaticClass adapterClass = getAdapterClassFor(new Class[] { targetType }); return AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public MethodHandle run() throws Exception { return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get( "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java index 7c1dd8b448d..ecbc8bc9340 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/DefaultRegExp.java @@ -95,14 +95,14 @@ public class DefaultRegExp extends RegExp { return null; // never matches or similar, e.g. a[] } - RegExpMatcher matcher = this.matcher; + RegExpMatcher currentMatcher = this.matcher; - if (matcher == null || matcher.getInput() != str) { - matcher = new DefaultMatcher(str); - this.matcher = matcher; + if (currentMatcher == null || matcher.getInput() != str) { + currentMatcher = new DefaultMatcher(str); + this.matcher = currentMatcher; } - return matcher; + return currentMatcher; } class DefaultMatcher implements RegExpMatcher { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java index f8c35bfe99d..719f6c398ca 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java @@ -97,14 +97,14 @@ public class JoniRegExp extends RegExp { return null; } - RegExpMatcher matcher = this.matcher; + RegExpMatcher currentMatcher = this.matcher; - if (matcher == null || input != matcher.getInput()) { - matcher = new JoniMatcher(input); - this.matcher = matcher; + if (currentMatcher == null || input != currentMatcher.getInput()) { + currentMatcher = new JoniMatcher(input); + this.matcher = currentMatcher; } - return matcher; + return currentMatcher; } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java index a4274f6ae8b..ff694b90790 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java @@ -156,7 +156,7 @@ public abstract class RegExp { * * @param key the message key * @param str string argument - * @throws jdk.nashorn.internal.runtime.ParserException + * @throws jdk.nashorn.internal.runtime.ParserException unconditionally */ protected static void throwParserException(final String key, final String str) throws ParserException { throw new ParserException(ECMAErrors.getMessage("parser.error.regex." + key, str)); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java index 367cc85b28a..6ff66f21d05 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpFactory.java @@ -25,7 +25,6 @@ package jdk.nashorn.internal.runtime.regexp; -import jdk.nashorn.internal.parser.Lexer; import jdk.nashorn.internal.runtime.ParserException; import jdk.nashorn.internal.runtime.options.Options; @@ -35,7 +34,6 @@ import jdk.nashorn.internal.runtime.options.Options; */ public class RegExpFactory { - private final static RegExpFactory instance; private final static String JDK = "jdk"; @@ -60,7 +58,8 @@ public class RegExpFactory { * Creates a Regular expression from the given {@code pattern} and {@code flags} strings. * * @param pattern RegExp pattern string - * @param flags RegExp flags string + * @param flags RegExp flags string + * @return new RegExp * @throws ParserException if flags is invalid or pattern string has syntax error. */ protected RegExp compile(final String pattern, final String flags) throws ParserException { @@ -71,8 +70,8 @@ public class RegExpFactory { * Compile a regexp with the given {@code source} and {@code flags}. * * @param pattern RegExp pattern string - * @param flags flag string - * + * @param flags flag string + * @return new RegExp * @throws ParserException if invalid source or flags */ public static RegExp create(final String pattern, final String flags) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpResult.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpResult.java index ff838b6f346..cd81be3ccf8 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpResult.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpResult.java @@ -80,11 +80,11 @@ public final class RegExpResult { /** * Get the group with the given index or the empty string if group index is not valid. - * @param index the group index + * @param groupIndex the group index * @return the group or "" */ - public Object getGroup(int index) { - return index >= 0 && index < groups.length ? groups[index] : ""; + public Object getGroup(final int groupIndex) { + return groupIndex >= 0 && groupIndex < groups.length ? groups[groupIndex] : ""; } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java index b579865b693..e8c60c4a63e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java @@ -182,8 +182,6 @@ final class RegExpScanner extends Scanner { * @return Committed token */ private boolean commit(final int n) { - final int startIn = position; - switch (n) { case 1: sb.append(ch0); diff --git a/nashorn/test/script/basic/compile-octane.js.EXPECTED b/nashorn/test/script/basic/compile-octane.js.EXPECTED index dab419e6d46..39f866c2d17 100644 --- a/nashorn/test/script/basic/compile-octane.js.EXPECTED +++ b/nashorn/test/script/basic/compile-octane.js.EXPECTED @@ -16,6 +16,9 @@ Compiled OK: earley-boyer.js Compiling... gbemu.js Compiled OK: gbemu.js +Compiling... mandreel.js +Compiled OK: mandreel.js + Compiling... navier-stokes.js Compiled OK: navier-stokes.js diff --git a/nashorn/test/script/basic/run-octane.js b/nashorn/test/script/basic/run-octane.js index 42bf77fa9e6..315451cbee8 100644 --- a/nashorn/test/script/basic/run-octane.js +++ b/nashorn/test/script/basic/run-octane.js @@ -31,7 +31,8 @@ var tests = [ "crypto.js", "deltablue.js", "earley-boyer.js", - "gbemu.js", + "gbemu.js", + "mandreel.js", "navier-stokes.js", "pdfjs.js", "raytrace.js", @@ -49,6 +50,12 @@ var ignoreTeardown = [ { name: "gbemu.js" }, ]; + +//TODO mandreel can be compiled as a test, but not run multiple times unless modified to not have global state +var compileOnly = { + "mandreel.js" : true +}; + var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; // TODO: why is this path hard coded when it's defined in project properties? @@ -63,6 +70,10 @@ function endsWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } +function should_compile_only(name) { + return (typeof compile_only !== 'undefined') || compileOnly[name] === true; +} + function run_one_benchmark(arg, iters) { var file_name; @@ -77,14 +88,18 @@ function run_one_benchmark(arg, iters) { } file_name = file[file.length - 1]; - if (typeof compile_only !== 'undefined') { + var compile_and_return = should_compile_only(file_name); + if (compile_and_return) { + if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them + return; + } print("Compiling... " + file_name); } load(path + 'base.js'); load(arg); - if (typeof compile_only !== 'undefined') { + if (compile_and_return) { print("Compiled OK: " + file_name); print(""); return; @@ -164,7 +179,7 @@ function run_one_benchmark(arg, iters) { function run_suite(tests, iters) { for (var idx = 0; idx < tests.length; idx++) { - run_one_benchmark(tests[idx], iters, false); + run_one_benchmark(tests[idx], iters); } } diff --git a/nashorn/test/script/basic/runsunspider-eager.js b/nashorn/test/script/basic/runsunspider-eager.js new file mode 100644 index 00000000000..db358d28555 --- /dev/null +++ b/nashorn/test/script/basic/runsunspider-eager.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * runsunspider : runs the sunspider tests and checks for compliance + * + * @test + * @option -timezone=PST + * @runif external.sunspider + */ + +load(__DIR__ + "runsunspider.js"); + diff --git a/nashorn/test/script/basic/runsunspider-lazy.js b/nashorn/test/script/basic/runsunspider-lazy.js new file mode 100644 index 00000000000..6e24c0c5255 --- /dev/null +++ b/nashorn/test/script/basic/runsunspider-lazy.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * runsunspider : runs the sunspider tests and checks for compliance + * + * @test + * @option -timezone=PST + * @option --lazy-compilation + * @runif external.sunspider + */ + +load(__DIR__ + "runsunspider.js"); + diff --git a/nashorn/test/script/basic/runsunspider.js b/nashorn/test/script/basic/runsunspider.js index 7b0d732c7e8..7f787975888 100644 --- a/nashorn/test/script/basic/runsunspider.js +++ b/nashorn/test/script/basic/runsunspider.js @@ -24,39 +24,11 @@ /** * runsunspider : runs the sunspider tests and checks for compliance * - * @test - * @option -timezone=PST - * @runif external.sunspider - */ - -/* - * Copyright (c) 2010-2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. + * @subtest */ /** * This is not a test, but a test "framework" for running sunspider tests. - * */ function assertEq(a, b) { From 857b7efb962cbb1e348f5795f716b6cf8878b8ce Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Thu, 14 Mar 2013 10:33:31 -0700 Subject: [PATCH 010/155] 8005428: Update jdeps to read the same profile information as by javac Reviewed-by: alanb --- .../netbeans/langtools/nbproject/project.xml | 234 ++++++++++++++++- .../classes/com/sun/tools/jdeps/Analyzer.java | 55 ++-- .../com/sun/tools/jdeps/ClassFileReader.java | 12 +- .../com/sun/tools/jdeps/JdepsTask.java | 19 +- .../sun/tools/jdeps/PlatformClassPath.java | 61 ----- .../classes/com/sun/tools/jdeps/Profiles.java | 241 ++++++++++++++++++ .../tools/jdeps/resources/jdeps.properties | 2 + langtools/test/tools/jdeps/Basic.java | 120 ++++++--- langtools/test/tools/jdeps/p/Foo.java | 2 + .../tools/jdeps/profiles.properties} | 5 +- 10 files changed, 607 insertions(+), 144 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/jdeps/Profiles.java rename langtools/{src/share/classes/com/sun/tools/jdeps/resources/jdk.properties => test/tools/jdeps/profiles.properties} (97%) diff --git a/langtools/make/netbeans/langtools/nbproject/project.xml b/langtools/make/netbeans/langtools/nbproject/project.xml index 3e1c6316295..4aba328a0ac 100644 --- a/langtools/make/netbeans/langtools/nbproject/project.xml +++ b/langtools/make/netbeans/langtools/nbproject/project.xml @@ -29,15 +29,13 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> - - - -]> org.netbeans.modules.ant.freeform + langtools + + langtools @@ -48,11 +46,6 @@ ${root} - - - java - ${root}/src/share/classes - tests @@ -63,9 +56,169 @@ build ${root}/make + + + java + ${root}/src/share/classes + + + ${root}/build/classes + - &standard-ide-actions; + + + + build + + + clean + + + clean + build + + + compile-single + ${root}/src/share/classes + + includes + ${root}/src/share/classes + \.java$ + relative-path + + , + + + + + run + + + run-single + + run.classname + ${root}/src/share/classes + \.java$ + java-name + + + + + + + + jtreg + + jtreg.tests + ${root}/test + \.(java|sh)$ + relative-path + + , + + + + + jtreg + + + debug + + + debug-single + + debug.classname + ${root}/src/share/classes + \.java$ + java-name + + + + + + + + debug-jtreg + + jtreg.tests + ${root}/test + \.(java|sh)$ + relative-path + + + + + + + debug-fix + ${root}/src/share/classes + + class + ${root}/src/share/classes + \.java$ + relative-path-noext + + + + + + + javadoc + + + select-tool + + + test-select-tool-1 + + + test-select-tool-2 + folder @@ -86,13 +239,68 @@ ${root}/make + + + ${root}/src/share/classes + README - &standard-context-menu-items; + + + + + + + + + + + + + @@ -101,7 +309,7 @@ ${root}/src/share/classes ${root}/build/classes - 1.5 + 1.5 diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java index 4ec737c25b6..ca086e320b0 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java @@ -91,9 +91,11 @@ public class Analyzer { result.requiredArchives.add(source); } // either a profile name or the archive name - String tname = getProfile(target); - if (tname.isEmpty()){ - tname = source.toString(); + String tname = result.getTargetProfile(target); + if (tname.isEmpty()) { + tname = PlatformClassPath.contains(source) + ? "JDK internal API (" + source.getFileName() + ")" + : source.toString(); } if (!result.targetNames.contains(tname)) { result.targetNames.add(tname); @@ -110,7 +112,7 @@ public class Analyzer { * a fully-qualified classname, a package name, a profile or * archive name depending on the Analyzer's type. */ - void visit(String origin, String target); + void visit(String origin, String target, String profile); /** * Visits the source archive to its destination archive of * a recorded dependency. @@ -124,7 +126,7 @@ public class Analyzer { v.visit(r.archive, a); } for (String name : r.targetNames) { - v.visit(r.archive.getFileName(), name); + v.visit(r.archive.getFileName(), name, name); } } } @@ -138,7 +140,7 @@ public class Analyzer { for (String target : r.deps.get(origin)) { // filter intra-dependency unless in verbose mode if (type == Type.VERBOSE || getArchive(origin) != getArchive(target)) { - v.visit(origin, target); + v.visit(origin, target, r.getTargetProfile(target)); } } } @@ -149,21 +151,16 @@ public class Analyzer { return map.containsKey(name) ? map.get(name) : NOT_FOUND; } - public String getArchiveName(String name) { - return getArchive(name).getFileName(); - } - - public String getProfile(String name) { - String pn = type == Type.CLASS ? packageOf(name) : name; - Archive source = map.get(name); - if (source != null && PlatformClassPath.contains(source)) { - String profile = PlatformClassPath.getProfileName(pn); - if (profile.isEmpty()) { - return "JDK internal API (" + source.getFileName() + ")"; - } - return profile; - } - return ""; + /** + * Returns the file name of the archive for non-JRE class or + * internal JRE classes. It returns empty string for SE API. + */ + public String getArchiveName(String target, String profile) { + Archive source = getArchive(target); + String name = source.getFileName(); + if (PlatformClassPath.contains(source)) + return profile.isEmpty() ? "JDK internal API (" + name + ")" : ""; + return name; } private abstract class ArchiveDeps implements Archive.Visitor { @@ -200,6 +197,8 @@ public class Analyzer { } public abstract void visit(Location o, Location t); + public abstract String getTargetProfile(String target); + } private class ClassVisitor extends ArchiveDeps { @@ -212,6 +211,10 @@ public class Analyzer { public void visit(Location o, Location t) { add(o.getClassName(), t.getClassName()); } + public String getTargetProfile(String target) { + int i = target.lastIndexOf('.'); + return (i > 0) ? Profiles.getProfileName(target.substring(0, i)) : ""; + } } private class PackageVisitor extends ArchiveDeps { @@ -221,19 +224,15 @@ public class Analyzer { public void visit(Location o, Location t) { add(packageOf(o), packageOf(t)); } - public void visit(Location l) { add(packageOf(l)); } - private String packageOf(Location loc) { String pkg = loc.getPackageName(); return pkg.isEmpty() ? "" : pkg; } - } - - private static String packageOf(String cn) { - int i = cn.lastIndexOf('.'); - return (i > 0) ? cn.substring(0, i) : ""; + public String getTargetProfile(String target) { + return Profiles.getProfileName(target); + } } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java index deea6fe906e..8c947e3d6b1 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java @@ -59,6 +59,13 @@ public class ClassFileReader { } } + /** + * Returns a ClassFileReader instance of a given JarFile. + */ + public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException { + return new JarFileReader(path, jf); + } + protected final Path path; protected final String baseFileName; private ClassFileReader(Path path) { @@ -228,8 +235,11 @@ public class ClassFileReader { private static class JarFileReader extends ClassFileReader { final JarFile jarfile; JarFileReader(Path path) throws IOException { + this(path, new JarFile(path.toFile())); + } + JarFileReader(Path path, JarFile jf) throws IOException { super(path); - this.jarfile = new JarFile(path.toFile()); + this.jarfile = jf; } public ClassFile getClassFile(String name) throws IOException { diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java index 10de68eb36a..a7d0ecf9b6f 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -139,8 +139,11 @@ class JdepsTask { } }, new Option(false, "-P", "--profile") { - void process(JdepsTask task, String opt, String arg) { + void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.showProfile = true; + if (Profiles.getProfileCount() == 0) { + throw task.new BadArgs("err.option.unsupported", opt, getMessage("err.profiles.msg")); + } } }, new Option(false, "-R", "--recursive") { @@ -382,9 +385,9 @@ class JdepsTask { private void printSummary(final PrintWriter out, final Analyzer analyzer) { Analyzer.Visitor visitor = new Analyzer.Visitor() { - public void visit(String origin, String profile) { + public void visit(String origin, String target, String profile) { if (options.showProfile) { - out.format("%-30s -> %s%n", origin, profile); + out.format("%-30s -> %s%n", origin, target); } } public void visit(Archive origin, Archive target) { @@ -399,17 +402,15 @@ class JdepsTask { private void printDependencies(final PrintWriter out, final Analyzer analyzer) { Analyzer.Visitor visitor = new Analyzer.Visitor() { private String pkg = ""; - public void visit(String origin, String target) { + public void visit(String origin, String target, String profile) { if (!origin.equals(pkg)) { pkg = origin; - out.format(" %s (%s)%n", origin, analyzer.getArchiveName(origin)); + out.format(" %s (%s)%n", origin, analyzer.getArchive(origin).getFileName()); } - Archive source = analyzer.getArchive(target); - String profile = options.showProfile ? analyzer.getProfile(target) : ""; out.format(" -> %-50s %s%n", target, - PlatformClassPath.contains(source) + (options.showProfile && !profile.isEmpty()) ? profile - : analyzer.getArchiveName(target)); + : analyzer.getArchiveName(target, profile)); } public void visit(Archive origin, Archive target) { out.format("%s -> %s%n", origin, target); diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java b/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java index 2ae1b4637bc..75ac8932a9b 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java @@ -37,34 +37,6 @@ import java.util.*; * ClassPath for Java SE and JDK */ class PlatformClassPath { - /* - * Profiles for Java SE - * - * This is a temporary workaround until a common API is defined for langtools - * to determine which profile a given classname belongs to. The list of - * packages and profile names are hardcoded in jdk.properties and - * split packages are not supported. - */ - static class Profile { - final String name; - final Set packages; - - Profile(String name) { - this.name = name; - this.packages = new HashSet(); - } - } - - private final static String JAVAFX = "javafx"; - private final static Map map = getProfilePackages(); - static String getProfileName(String packageName) { - Profile profile = map.get(packageName); - if (packageName.startsWith(JAVAFX + ".")) { - profile = map.get(JAVAFX); - } - return profile != null ? profile.name : ""; - } - private final static List javaHomeArchives = init(); static List getArchives() { return javaHomeArchives; @@ -100,13 +72,6 @@ class PlatformClassPath { } catch (IOException e) { throw new RuntimeException(e); } - - // add a JavaFX profile if there is jfxrt.jar - for (Archive archive : result) { - if (archive.getFileName().equals("jfxrt.jar")) { - map.put(JAVAFX, new Profile("jfxrt.jar")); - } - } return result; } @@ -140,30 +105,4 @@ class PlatformClassPath { }); return result; } - - private static Map getProfilePackages() { - Map map = new HashMap(); - - // read the properties as a ResourceBundle as the build compiles - // the properties file into Java class. Another alternative is - // to load it as Properties and fix the build to exclude this file. - ResourceBundle profileBundle = - ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdk"); - - int i=1; - String key; - while (profileBundle.containsKey((key = "profile." + i + ".name"))) { - Profile profile = new Profile(profileBundle.getString(key)); - String n = profileBundle.getString("profile." + i + ".packages"); - String[] pkgs = n.split("\\s+"); - for (String p : pkgs) { - if (p.isEmpty()) continue; - assert(map.containsKey(p) == false); - profile.packages.add(p); - map.put(p, profile); - } - i++; - } - return map; - } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Profiles.java b/langtools/src/share/classes/com/sun/tools/jdeps/Profiles.java new file mode 100644 index 00000000000..0c7b4ccd027 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Profiles.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2013, 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 com.sun.tools.jdeps; + +import com.sun.tools.classfile.Annotation; +import com.sun.tools.classfile.Annotation.*; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPool; +import com.sun.tools.classfile.ConstantPool.*; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.RuntimeAnnotations_attribute; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.jar.JarFile; + +/** + * Build the profile information from ct.sym if exists. + */ +class Profiles { + private static final Map map = initProfiles(); + /** + * Returns the name of the profile for the given package name. + * It returns an empty string if the given package is not in any profile. + */ + public static String getProfileName(String pn) { + Profile profile = map.get(pn); + return (profile != null && profile.packages.contains(pn)) + ? profile.name : ""; + } + + public static int getProfileCount() { + return new HashSet(map.values()).size(); + } + + private static Map initProfiles() { + List profiles = new ArrayList(); + try { + String profilesProps = System.getProperty("jdeps.profiles"); + if (profilesProps != null) { + // for testing for JDK development build where ct.sym doesn't exist + initProfilesFromProperties(profiles, profilesProps); + } else { + Path home = Paths.get(System.getProperty("java.home")); + if (home.endsWith("jre")) { + home = home.getParent(); + } + Path ctsym = home.resolve("lib").resolve("ct.sym"); + if (ctsym.toFile().exists()) { + // add a default Full JRE + profiles.add(0, new Profile("Full JRE", 0)); + // parse ct.sym and load information about profiles + try (JarFile jf = new JarFile(ctsym.toFile())) { + ClassFileReader reader = ClassFileReader.newInstance(ctsym, jf); + for (ClassFile cf : reader.getClassFiles()) { + findProfile(profiles, cf); + } + } + + // merge the last Profile with the "Full JRE" + if (profiles.size() > 1) { + Profile fullJRE = profiles.get(0); + Profile p = profiles.remove(profiles.size() - 1); + for (String pn : fullJRE.packages) { + // The last profile contains the packages determined from ct.sym. + // Move classes annotated profile==0 or no attribute that are + // added in the fullJRE profile to either supported or proprietary + // packages appropriately + if (p.proprietaryPkgs.contains(pn)) { + p.proprietaryPkgs.add(pn); + } else { + p.packages.add(pn); + } + } + fullJRE.packages.clear(); + fullJRE.proprietaryPkgs.clear(); + fullJRE.packages.addAll(p.packages); + fullJRE.proprietaryPkgs.addAll(p.proprietaryPkgs); + } + } + } + } catch (IOException | ConstantPoolException e) { + throw new Error(e); + } + HashMap map = new HashMap(); + for (Profile profile : profiles) { + // Inner classes are not annotated with the profile annotation + // packages may be in one profile but also appear in the Full JRE + // Full JRE is always the first element in profiles list and + // so the map will contain the appropriate Profile + for (String pn : profile.packages) { + map.put(pn, profile); + } + for (String pn : profile.proprietaryPkgs) { + map.put(pn, profile); + } + } + return map; + } + + private static final String PROFILE_ANNOTATION = "Ljdk/Profile+Annotation;"; + private static final String PROPRIETARY_ANNOTATION = "Lsun/Proprietary+Annotation;"; + private static Profile findProfile(List profiles, ClassFile cf) + throws ConstantPoolException + { + RuntimeAnnotations_attribute attr = (RuntimeAnnotations_attribute) + cf.attributes.get(Attribute.RuntimeInvisibleAnnotations); + int index = 0; + boolean proprietary = false; + if (attr != null) { + for (int i = 0; i < attr.annotations.length; i++) { + Annotation ann = attr.annotations[i]; + String annType = cf.constant_pool.getUTF8Value(ann.type_index); + if (PROFILE_ANNOTATION.equals(annType)) { + for (int j = 0; j < ann.num_element_value_pairs; j++) { + Annotation.element_value_pair pair = ann.element_value_pairs[j]; + Primitive_element_value ev = (Primitive_element_value)pair.value; + CONSTANT_Integer_info info = (CONSTANT_Integer_info) + cf.constant_pool.get(ev.const_value_index); + index = info.value; + break; + } + } else if (PROPRIETARY_ANNOTATION.equals(annType)) { + proprietary = true; + } + } + if (index >= profiles.size()) { + Profile p = null; + for (int i = profiles.size(); i <= index; i++) { + p = new Profile(i); + profiles.add(p); + } + } + } + + Profile p = profiles.get(index); + String name = cf.getName(); + int i = name.lastIndexOf('/'); + name = (i > 0) ? name.substring(0, i).replace('/','.') : ""; + if (proprietary) { + p.proprietaryPkgs.add(name); + } else { + p.packages.add(name); + } + return p; + } + + private static void initProfilesFromProperties(List profiles, String path) + throws IOException + { + Properties props = new Properties(); + try (FileReader reader = new FileReader(path)) { + props.load(reader); + } + int i=1; + String key; + while (props.containsKey((key = "profile." + i + ".name"))) { + Profile profile = new Profile(props.getProperty(key), i); + profiles.add(profile); + String n = props.getProperty("profile." + i + ".packages"); + String[] pkgs = n.split("\\s+"); + for (String p : pkgs) { + if (p.isEmpty()) continue; + profile.packages.add(p); + } + i++; + } + } + + private static class Profile { + final String name; + final int profile; + final Set packages; + final Set proprietaryPkgs; + Profile(int profile) { + this("compact" + profile, profile); + } + Profile(String name, int profile) { + this.name = name; + this.profile = profile; + this.packages = new HashSet(); + this.proprietaryPkgs = new HashSet(); + } + public String toString() { + return name; + } + } + + // for debugging + public static void main(String[] args) { + if (args.length == 0) { + Profile[] profiles = new Profile[getProfileCount()]; + for (Profile p : map.values()) { + // move the zeroth profile to the last + int index = p.profile == 0 ? profiles.length-1 : p.profile-1; + profiles[index] = p; + } + for (Profile p : profiles) { + String profileName = p.name; + SortedSet set = new TreeSet(p.packages); + for (String s : set) { + // filter out the inner classes that are not annotated with + // the profile annotation + if (map.get(s) == p) { + System.out.format("%-10s %s%n", profileName, s); + profileName = ""; + } + } + } + } + for (String pn : args) { + System.out.format("%s in %s%n", pn, getProfileName(pn)); + } + } +} diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties index 5456fd1e287..7a01d8f2610 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties +++ b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties @@ -51,6 +51,8 @@ err.missing.arg=no value given for {0} err.internal.error=internal error: {0} {1} {2} err.invalid.arg.for.option=invalid argument for option: {0} err.option.after.class=option must be specified before classes: {0} +err.option.unsupported={0} not supported: {1} +err.profiles.msg=No profile information warn.invalid.arg=Invalid classname or pathname not exist: {0} warn.split.package=package {0} defined in {1} {2} diff --git a/langtools/test/tools/jdeps/Basic.java b/langtools/test/tools/jdeps/Basic.java index 421e11e38a6..e68875b5eae 100644 --- a/langtools/test/tools/jdeps/Basic.java +++ b/langtools/test/tools/jdeps/Basic.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8003562 + * @bug 8003562 8005428 * @summary Basic tests for jdeps tool * @build Test p.Foo * @run main Basic @@ -33,13 +33,35 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.*; import java.util.regex.*; public class Basic { + private static boolean symbolFileExist = initProfiles(); + private static boolean initProfiles() { + // check if ct.sym exists; if not use the profiles.properties file + Path home = Paths.get(System.getProperty("java.home")); + if (home.endsWith("jre")) { + home = home.getParent(); + } + Path ctsym = home.resolve("lib").resolve("ct.sym"); + boolean symbolExists = ctsym.toFile().exists(); + if (!symbolExists) { + Path testSrcProfiles = + Paths.get(System.getProperty("test.src", "."), "profiles.properties"); + if (!testSrcProfiles.toFile().exists()) + throw new Error(testSrcProfiles + " does not exist"); + System.out.format("%s doesn't exist.%nUse %s to initialize profiles info%n", + ctsym, testSrcProfiles); + System.setProperty("jdeps.profiles", testSrcProfiles.toString()); + } + return symbolExists; + } + public static void main(String... args) throws Exception { int errors = 0; - errors += new Basic().run(); if (errors > 0) throw new Exception(errors + " errors found"); @@ -49,54 +71,70 @@ public class Basic { File testDir = new File(System.getProperty("test.classes", ".")); // test a .class file test(new File(testDir, "Test.class"), - new String[] {"java.lang", "p"}); + new String[] {"java.lang", "p"}, + new String[] {"compact1", "not found"}); // test a directory test(new File(testDir, "p"), - new String[] {"java.lang", "java.util"}); + new String[] {"java.lang", "java.util", "java.lang.management"}, + new String[] {"compact1", "compact1", "compact3"}); // test class-level dependency output test(new File(testDir, "Test.class"), new String[] {"java.lang.Object", "p.Foo"}, + new String[] {"compact1", "not found"}, new String[] {"-V", "class"}); // test -p option test(new File(testDir, "Test.class"), new String[] {"p.Foo"}, + new String[] {"not found"}, new String[] {"--verbose-level=class", "-p", "p"}); // test -e option test(new File(testDir, "Test.class"), new String[] {"p.Foo"}, + new String[] {"not found"}, new String[] {"-V", "class", "-e", "p\\..*"}); test(new File(testDir, "Test.class"), new String[] {"java.lang"}, + new String[] {"compact1"}, new String[] {"-V", "package", "-e", "java\\.lang\\..*"}); // test -classpath and wildcard options test(null, new String[] {"com.sun.tools.jdeps", "java.lang", "java.util", - "java.util.regex", "java.io"}, + "java.util.regex", "java.io", "java.nio.file", + "java.lang.management"}, + new String[] {(symbolFileExist? "not found" : "JDK internal API (classes)"), + "compact1", "compact1", "compact1", + "compact1", "compact1", "compact3"}, new String[] {"--classpath", testDir.getPath(), "*"}); - // -v shows intra-dependency - test(new File(testDir, "Test.class"), - new String[] {"java.lang.Object", "p.Foo"}, - new String[] {"-v", "--classpath", testDir.getPath(), "Test.class"}); + /* Temporary disable this test case. Test.class has a dependency + * on java.lang.String on certain windows machine (8008479). + // -v shows intra-dependency + test(new File(testDir, "Test.class"), + new String[] {"java.lang.Object", "p.Foo"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-v", "--classpath", testDir.getPath(), "Test.class"}); + */ return errors; } - void test(File file, String[] expect) { - test(file, expect, new String[0]); + void test(File file, String[] expect, String[] profiles) { + test(file, expect, profiles, new String[0]); } - void test(File file, String[] expect, String[] options) { - String[] args; + void test(File file, String[] expect, String[] profiles, String[] options) { + List args = new ArrayList<>(Arrays.asList(options)); if (file != null) { - args = Arrays.copyOf(options, options.length+1); - args[options.length] = file.getPath(); - } else { - args = options; + args.add(file.getPath()); } - String[] deps = jdeps(args); - checkEqual("dependencies", expect, deps); + List argsWithDashP = new ArrayList<>(); + argsWithDashP.add("-P"); + argsWithDashP.addAll(args); + // test without -P + checkResult("dependencies", expect, jdeps(args.toArray(new String[0])).keySet()); + // test with -P + checkResult("profiles", expect, profiles, jdeps(argsWithDashP.toArray(new String[0]))); } - String[] jdeps(String... args) { + Map jdeps(String... args) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); System.err.println("jdeps " + Arrays.toString(args)); @@ -112,12 +150,12 @@ public class Basic { // Pattern used to parse lines private static Pattern linePattern = Pattern.compile(".*\r?\n"); - private static Pattern pattern = Pattern.compile("\\s+ -> (\\S+) +.*"); + private static Pattern pattern = Pattern.compile("\\s+ -> (\\S+) +(.*)"); // Use the linePattern to break the given String into lines, applying // the pattern to each line to see if we have a match - private static String[] findDeps(String out) { - List result = new ArrayList<>(); + private static Map findDeps(String out) { + Map result = new HashMap<>(); Matcher lm = linePattern.matcher(out); // Line matcher Matcher pm = null; // Pattern matcher int lines = 0; @@ -129,19 +167,41 @@ public class Basic { else pm.reset(cs); if (pm.find()) - result.add(pm.group(1)); + result.put(pm.group(1), pm.group(2).trim()); if (lm.end() == out.length()) break; } - return result.toArray(new String[0]); + return result; } - void checkEqual(String label, String[] expect, String[] found) { - Set s1 = new HashSet<>(Arrays.asList(expect)); - Set s2 = new HashSet<>(Arrays.asList(found)); + void checkResult(String label, String[] expect, Collection found) { + List list = Arrays.asList(expect); + if (!isEqual(list, found)) + error("Unexpected " + label + " found: '" + found + "', expected: '" + list + "'"); + } - if (!s1.equals(s2)) - error("Unexpected " + label + " found: '" + s2 + "', expected: '" + s1 + "'"); + void checkResult(String label, String[] expect, String[] profiles, Map result) { + if (expect.length != profiles.length) + error("Invalid expected names and profiles"); + + // check the dependencies + checkResult(label, expect, result.keySet()); + // check profile information + checkResult(label, profiles, result.values()); + for (int i=0; i < expect.length; i++) { + String profile = result.get(expect[i]); + if (!profile.equals(profiles[i])) + error("Unexpected profile: '" + profile + "', expected: '" + profiles[i] + "'"); + } + } + + boolean isEqual(List expected, Collection found) { + if (expected.size() != found.size()) + return false; + + List list = new ArrayList<>(found); + list.removeAll(expected); + return list.isEmpty(); } void error(String msg) { diff --git a/langtools/test/tools/jdeps/p/Foo.java b/langtools/test/tools/jdeps/p/Foo.java index 14febbff507..c9ec3cb1ee1 100644 --- a/langtools/test/tools/jdeps/p/Foo.java +++ b/langtools/test/tools/jdeps/p/Foo.java @@ -31,5 +31,7 @@ public class Foo { } public Foo() { + // compact3 + java.lang.management.ManagementFactory.getRuntimeMXBean(); } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdk.properties b/langtools/test/tools/jdeps/profiles.properties similarity index 97% rename from langtools/src/share/classes/com/sun/tools/jdeps/resources/jdk.properties rename to langtools/test/tools/jdeps/profiles.properties index 59ad26dc253..f00bb4a5e39 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdk.properties +++ b/langtools/test/tools/jdeps/profiles.properties @@ -1,5 +1,6 @@ -# This properties file does not need localization. - +# This properties file is used for testing a JDK development build. +# No need to keep this properties file up to date as long as it covers +# the APIs used by the jdeps regression test. profile.1.name = compact1 profile.1.packages = \ java.io \ From 46e9ef69a770952c7717f8049664ac2665cc36b5 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Thu, 14 Mar 2013 22:54:17 -0700 Subject: [PATCH 011/155] 8010010: NPE generating serializedLambdaName for nested lambda Reviewed-by: mcimadamore --- .../sun/tools/javac/comp/LambdaToMethod.java | 20 ++++- .../javac/lambda/LambdaLambdaSerialized.java | 79 +++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/LambdaLambdaSerialized.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 1b767a40dc4..fad0a51512e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1293,9 +1293,16 @@ public class LambdaToMethod extends TreeTranslator { return names.lambda.append(names.fromString("" + lambdaCount++)); } + /** + * For a serializable lambda, generate a name which maximizes name + * stability across deserialization. + * @param owner + * @return Name to use for the synthetic lambda method name + */ private Name serializedLambdaName(Symbol owner) { StringBuilder buf = new StringBuilder(); buf.append(names.lambda); + // Append the name of the method enclosing the lambda. String methodName = owner.name.toString(); if (methodName.equals("")) methodName = "static"; @@ -1303,9 +1310,18 @@ public class LambdaToMethod extends TreeTranslator { methodName = "new"; buf.append(methodName); buf.append('$'); - int methTypeHash = methodSig(owner.type).hashCode(); - buf.append(Integer.toHexString(methTypeHash)); + // Append a hash of the enclosing method signature to differentiate + // overloaded enclosing methods. For lambdas enclosed in lambdas, + // the generated lambda method will not have type yet, but the + // enclosing method's name will have been generated with this same + // method, so it will be unique and never be overloaded. + if (owner.type != null) { + int methTypeHash = methodSig(owner.type).hashCode(); + buf.append(Integer.toHexString(methTypeHash)); + } buf.append('$'); + // The above appended name components may not be unique, append a + // count based on the above name components. String temp = buf.toString(); Integer count = serializableLambdaCounts.get(temp); if (count == null) { diff --git a/langtools/test/tools/javac/lambda/LambdaLambdaSerialized.java b/langtools/test/tools/javac/lambda/LambdaLambdaSerialized.java new file mode 100644 index 00000000000..f788e8a16c7 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaLambdaSerialized.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2013, 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 8010010 +@summary NPE generating serializedLambdaName for nested lambda +*/ + +import java.io.*; +import java.util.Map; +import java.util.HashMap; + +public class LambdaLambdaSerialized { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) + throw new AssertionError(); + } + + public static void main(String[] args) throws Exception { + try { + // Write lambdas out + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutput out = new ObjectOutputStream(baos); + LSI> ssi = () -> (() -> new HashMap()); + write(out, ssi ); + out.flush(); + out.close(); + + // Read them back + ByteArrayInputStream bais = + new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream in = new ObjectInputStream(bais); + readAssert(in, "[X]"); + in.close(); + } catch (IOException e) { + e.printStackTrace(); + throw e; + } + } + + static void write(ObjectOutput out, LSI> lamb) throws IOException { + out.writeObject(lamb); + } + + static void readAssert(ObjectInputStream in, String expected) throws IOException, ClassNotFoundException { + LSI> ls = (LSI>) in.readObject(); + Map result = ls.get().get(); + System.out.printf("Result: %s\n", result); + } +} + +interface LSI extends Serializable { + T get(); +} From a7e53ae56d9fbd56327256bd8cf7a160539fb39e Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 15 Mar 2013 09:02:26 +0000 Subject: [PATCH 012/155] 5053846: javac: MethodRef entries are duplicated in the constant pool Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Lower.java | 10 +- .../MethodRefDupInConstantPoolTest.java | 91 +++++++++++++++++++ 2 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 langtools/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 5fd5753ae5a..3d49bbeaff4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -3434,14 +3434,16 @@ public class Lower extends TreeTranslator { tree.expr = make.TypeCast(types.erasure(iterableType), tree.expr); Symbol iterator = lookupMethod(tree.expr.pos(), names.iterator, - types.erasure(syms.iterableType), + eType, List.nil()); VarSymbol itvar = new VarSymbol(0, names.fromString("i" + target.syntheticNameChar()), types.erasure(iterator.type.getReturnType()), currentMethodSym); - JCStatement init = make. - VarDef(itvar, - make.App(make.Select(tree.expr, iterator))); + + JCStatement init = make. + VarDef(itvar, make.App(make.Select(tree.expr, iterator) + .setType(types.erasure(iterator.type)))); + Symbol hasNext = lookupMethod(tree.expr.pos(), names.hasNext, itvar.type, diff --git a/langtools/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java b/langtools/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java new file mode 100644 index 00000000000..60a0f3a0d48 --- /dev/null +++ b/langtools/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2013, 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 5053846 + * @summary javac: MethodRef entries are duplicated in the constant pool + */ + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.Paths; +import java.util.*; + +public class MethodRefDupInConstantPoolTest { + + private static final String methodToLookFor = + "java/util/Vector.iterator:()Ljava/util/Iterator;"; + + public static void main(String[] args) { + new MethodRefDupInConstantPoolTest().run(); + } + + void run() { + check("-v", Paths.get(System.getProperty("test.classes"), + "TestHelper1.class").toString()); + check("-v", Paths.get(System.getProperty("test.classes"), + "TestHelper2.class").toString()); + } + + void check(String... params) { + StringWriter s; + String out; + try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { + com.sun.tools.javap.Main.run(params, pw); + out = s.toString(); + } + String constantPool = getConstantPool(out); + if (constantPool.indexOf(methodToLookFor) != + constantPool.lastIndexOf(methodToLookFor)) { + throw new AssertionError("There is more than one entry for the method seek " + + methodToLookFor); + } + } + + String getConstantPool(String out) { + int start = out.indexOf("Constant pool:"); + int end = out.indexOf("{"); + return out.substring(start, end); + } +} + +class TestHelper1 { + void m() { + Vector v = new Vector(); + Iterator iter = v.iterator(); + while (iter.hasNext()) { + Object o = iter.next(); + Object o2 = o; + } + for (Object o: v) { + Object o2 = o; + } + } +} + +class TestHelper2> { + void test(X x) { + for (String s : x) { } + } +} From cd78ad2c8a1cdf45a9cd744e0516856520ed4c21 Mon Sep 17 00:00:00 2001 From: Matherey Nunez Date: Fri, 15 Mar 2013 13:39:04 +0100 Subject: [PATCH 013/155] 8007767: TargetAnnoCombo.java need to be updated to add a new test mode Reviewed-by: jjg, strarup --- .../repeatingAnnotations/combo/Helper.java | 1 + .../combo/TargetAnnoCombo.java | 742 +++++++++--------- .../combo/TestCaseGenerator.java | 191 ----- 3 files changed, 391 insertions(+), 543 deletions(-) delete mode 100644 langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TestCaseGenerator.java diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java index 9171e5176cb..0aee99c4010 100644 --- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java @@ -146,6 +146,7 @@ public class Helper { public static final String template = "/*PACKAGE*/\n" + "//pkg test;\n\n" + + "/*ANNODATA*/\n" // import statements, declaration of Foo/FooContainer + "/*TYPE*/ //class\n" + "class #ClassName {\n" + " /*FIELD*/ //instance var\n" diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java index ff1b4cc1b04..058b48910cd 100644 --- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java @@ -21,245 +21,404 @@ * questions. */ -/** +/* * @test - * @bug 7195131 - * @author sogoel - * @summary Combo test for all possible combinations for Target values - * @ignore 8008339 Test TargetAnnoCombo.java is broken + * @bug 7151010 8006547 8007766 + * @summary Default test cases for running combinations for Target values * @build Helper - * @compile TargetAnnoCombo.java TestCaseGenerator.java * @run main TargetAnnoCombo */ +import java.util.Set; +import java.util.List; import java.io.IOException; +import java.lang.annotation.ElementType; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; +import java.util.EnumSet; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaFileObject; -/* - * TargetAnnoCombo gets a list of test case numbers using TestCaseGenerator. - * For each of the test case number, @Target sets for base and container annotations - * are determined, source files are generated, compiled, and the result is verified - * based on if the @Target set for base and container is a positive or negative combination. - * - * @Target sets for base and container annotations are determined using a bit mapping of - * 10 ElementType enum constants defined in JDK8. - * - * Bit Target value - * 0 "ElementType.ANNOTATION_TYPE" - * 1 "ElementType.CONSTRUCTOR" - * 2 "ElementType.FIELD" - * 3 "ElementType.LOCAL_VARIABLE" - * 4 "ElementType.METHOD" - * 5 "ElementType.TYPE" - * 6 "ElementType.PARAMETER" - * 7 "ElementType.PACKAGE" - * 8 "ElementType.TYPE_USE" - * 9 "ElementType.TYPE_PARAMETER" - * - * Group 1: - * 20 bits mapping, representing a test case number, is used for all target set - * combinations ( 0 to 1048575 ) including empty @Target sets => @Target({}). - * From this 20 bits, 10 bits are for base followed by 10 bits for container - * where each bit maps to an ElementType enum constant defined in JDK8. - * - * Examples: - * Test case number: 4, binary: 100 => container=100, base=[], container=["ElementType.FIELD"] - * Test case number: 1003575, binary: 11110101000000110111 => base=1111010100, container=0000110111; - * base=["ElementType.PARAMETER", "ElementType.TYPE_USE", "ElementType.METHOD", "ElementType.FIELD", "ElementType.PACKAGE", "ElementType.TYPE_PARAMETER"], - * container=["ElementType.TYPE", "ElementType.METHOD", "ElementType.ANNOTATION_TYPE", "ElementType.CONSTRUCTOR", "ElementType.FIELD"] - * - * In the following groups, no @Target set is represented by null. - * Group 2: - * @Target is not defined on base. - * Target sets for container are determined using the 10-bit binary number - * resulting in 1024 test cases, mapping them to test case numbers from - * 1048576 to (1048576 + 1023) => 1048576 to 1049599. - * - * Example: - * Test case number: 1048587 => 1048587 - 1048576 = test case 11 in Group 2, binary: 1011 => - * base = null, - * container = ["ElementType.ANNOTATION_TYPE","ElementType.CONSTRUCTOR","ElementType.LOCAL_VARIABLE"] - * - * Group 3: - * @Target is not defined on container - * Target sets for base are determined using the 10-bit binary number - * resulting in 1024 test cases, mapping them to test case numbers from - * 1049600 to (1049600 + 1023) => 1049600 to 1050623. - * - * Example: - * Test case number: 1049708 => 1049708 - 1049600 = test case 108 in Group 3, binary: 1101100 => - * base = ["ElementType.FIELD", "ElementType.LOCAL_VARIABLE", "ElementType.TYPE", "ElementType.PARAMETER"], - * container = null - * - * For the above group, test case number: 1049855 gives compiler error, JDK-8006547 filed - * - * Group 4: - * @Target not defined for both base and container annotations. - * - * This is the last test and corresponds to test case number 1050624. base=null, container=null - * - * Examples to run this test: - * 1. Run a specific test case number: - * ${JTREG} -DTestCaseNum=10782 -samevm -jdk:${JAVA_TEST} -reportDir ${REPORT} -workDir ${WORK} TargetAnnoCombo.java - * 2. Run specific number of tests: - * ${JTREG} -DNumberOfTests=4 -samevm -jdk:${JAVA_TEST} -reportDir ${REPORT} -workDir ${WORK} TargetAnnoCombo.java - * 3. Run specific number of tests with a seed: - * ${JTREG} -DNumberOfTests=4 -DTestSeed=-972894659 -samevm -jdk:${JAVA_TEST} -reportDir ${REPORT} -workDir ${WORK} TargetAnnoCombo.java - * 4. Run tests in default mode (number of tests = 1000): - * ${JTREG} -DTestMode=DEFAULT -samevm -jdk:${JAVA_TEST} -reportDir ${REPORT} -workDir ${WORK} TargetAnnoCombo.java - * 5. Run all tests (FULL mode): - * ${JTREG} -DTestMode=FULL -samevm -jdk:${JAVA_TEST} -reportDir ${REPORT} -workDir ${WORK} TargetAnnoCombo.java - * - */ +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.LOCAL_VARIABLE; +import static java.lang.annotation.ElementType.TYPE_USE; +import static java.lang.annotation.ElementType.TYPE_PARAMETER; public class TargetAnnoCombo { - int errors = 0; + static final String TESTPKG = "testpkg"; - /* - * Set it to true to get more debug information including base and - * container target sets for a given test case number - */ + + // Set it to true to get more debug information including base and container + // target sets for a given test case. static final boolean DEBUG = false; - // JDK 5/6/7/8 Targets - static final String[] targetVals = {"ElementType.ANNOTATION_TYPE", - "ElementType.CONSTRUCTOR", "ElementType.FIELD", - "ElementType.LOCAL_VARIABLE", "ElementType.METHOD", - "ElementType.TYPE", "ElementType.PARAMETER", - "ElementType.PACKAGE", "ElementType.TYPE_USE", - "ElementType.TYPE_PARAMETER"}; + // Define constant target sets to be used for the combination of the target values. + final static Set noSet = null; + final static Set empty = EnumSet.noneOf(ElementType.class); - // TYPE_USE and TYPE_PARAMETER (added in JDK8) are not part of default Target set - static final int DEFAULT_TARGET_CNT = 8; + // [TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, + // PACKAGE, TYPE_PARAMETER, TYPE_USE] + final static Set allTargets = EnumSet.allOf(ElementType.class); - public static void main(String args[]) throws Exception { + // [TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, + // PACKAGE] + final static Set jdk7 = EnumSet.range(TYPE, PACKAGE); - /* maxTestNum = (base and container combinations of targetVals elems [0 - 1048575 combos]) - * + (combinations where base or container has no Target [1024 combos]) - * + (no -1 even though 1st test is number 0 as last test is where both - * base and container have no target) - */ + // [TYPE_USE, TYPE_PARAMETER] + final static Set jdk8 = EnumSet.range(TYPE_PARAMETER, TYPE_USE); - int maxTestNum = (int)Math.pow(2, 2*targetVals.length) + 2*(int)Math.pow(2, targetVals.length); - TestCaseGenerator tcg = new TestCaseGenerator(maxTestNum); - TargetAnnoCombo tac = new TargetAnnoCombo(); + // List of test cases to run. This list is created in generate(). + // To run a specific test cases add case number in @run main line. + List testCases = new ArrayList(); - int testCtr = 0; - int testCase = -1; - while ( (testCase=tcg.getNextTestCase()) != -1 ) { - tac.executeTestCase(testCase, maxTestNum); - testCtr++; + int errors = 0; + + // Identify test cases that fail. + enum IgnoreKind { + RUN, + IGNORE + }; + + private class TestCase { + + private Set baseAnnotations; + private Set containerAnnotations; + private IgnoreKind ignore; + + public TestCase(Set baseAnnotations, Set containerAnnotations) { + this(baseAnnotations, containerAnnotations, IgnoreKind.RUN); } - System.out.println("Total tests run: " + testCtr); - if (tac.errors > 0) - throw new Exception(tac.errors + " errors found"); + public TestCase(Set baseAnnotations, Set containerAnnotations, + IgnoreKind ignoreKind) { + this.baseAnnotations = baseAnnotations; + this.containerAnnotations = containerAnnotations; + this.ignore = ignoreKind; + } + + public Set getBaseAnnotations() { + return baseAnnotations; + } + + public Set getContainerAnnotations() { + return containerAnnotations; + } + + public boolean isIgnored() { + return ignore == IgnoreKind.IGNORE; + } + + // Determine if a testCase should compile or not. + private boolean isValidSubSet() { + /* + * RULE 1: conAnnoTarget should be a subset of baseAnnoTarget + * RULE 2: For empty @Target ({}) - annotation cannot be applied anywhere + * - Empty sets for both is valid + * - Empty baseTarget set is invalid with non-empty conTarget set + * - Non-empty baseTarget set is valid with empty conTarget set + * RULE 3: For no @Target specified - annotation can be applied to any JDK 7 targets + * - No @Target for both is valid + * - No @Target for baseTarget set with @Target conTarget set is valid + * - @Target for baseTarget set with no @Target for conTarget is invalid + */ + + + /* If baseAnno has no @Target, Foo can be either applied to @Target specified + * for container annotation else will be applicable for all default targets + * if no @Target is present for container annotation. + * In both cases, the set will be a valid set with no @Target for base annotation + */ + if (baseAnnotations == null) { + if (containerAnnotations == null) { + return true; + } + return !(containerAnnotations.contains(TYPE_USE) || + containerAnnotations.contains(TYPE_PARAMETER)); + } + + Set tempBaseSet = EnumSet.noneOf(ElementType.class); + tempBaseSet.addAll(baseAnnotations); + // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default. + if (baseAnnotations.contains(TYPE)) { + tempBaseSet.add(ANNOTATION_TYPE); + } + + // If containerAnno has no @Target, only valid case if baseAnnoTarget has + // all targets defined else invalid set. + if (containerAnnotations == null) { + return tempBaseSet.containsAll(jdk7); + } + + // At this point, neither conAnnoTarget or baseAnnoTarget are null. + if (containerAnnotations.isEmpty()) { + return true; + } + + // At this point, conAnnoTarget is non-empty. + if (baseAnnotations.isEmpty()) { + return false; + } + + // At this point, neither conAnnoTarget or baseAnnoTarget are empty. + return tempBaseSet.containsAll(containerAnnotations); + } } - /* - * For given testCase, determine the base and container annotation Target sets, - * get if testCase should compile, get test source file(s), get compilation result and verify. - * - */ - private void executeTestCase(int testCase, int maxTestNum) { - - // Determine base and container annotation Target sets for the testCase - Set baseAnnoTarget = null; - Set conAnnoTarget = null; - - //Number of base and container combinations [0 - 1048575 combos] - int baseContCombos = (int)Math.pow(2, 2*targetVals.length); - //Number of either base or container combinations when one of them has no @Target [1024 combos] - int targetValsCombos = (int)Math.pow(2, targetVals.length); - - if (testCase >= baseContCombos) { - //Base annotation do not have @Target - if (testCase < baseContCombos + targetValsCombos) { - baseAnnoTarget = null; - conAnnoTarget = getSetFromBitVec(Integer.toBinaryString(testCase - baseContCombos)); - } else if (testCase < baseContCombos + 2*targetValsCombos) { - //Container annotation do not have @Target - baseAnnoTarget = getSetFromBitVec(Integer.toBinaryString(testCase - baseContCombos - targetValsCombos)); - conAnnoTarget = null; - } else { - //Both Base and Container annotation do not have @Target - baseAnnoTarget = null; - conAnnoTarget = null; - } - } else { - //TestCase number is represented as 10-bits for base followed by container bits - String bin = Integer.toBinaryString(testCase); - String base="", cont=bin; - if (bin.length() > targetVals.length){ - base = bin.substring(0, bin.length() - targetVals.length); - cont = bin.substring(bin.length() - targetVals.length,bin.length()); - } - baseAnnoTarget = getSetFromBitVec(base); - conAnnoTarget = getSetFromBitVec(cont); + public static void main(String args[]) throws Exception { + TargetAnnoCombo tac = new TargetAnnoCombo(); + // Generates all test cases to be run. + tac.generate(); + List cases = new ArrayList(); + for (int i = 0; i < args.length; i++) { + cases.add(Integer.parseInt(args[i])); } + if (cases.isEmpty()) { + tac.run(); + } else { + for (int index : cases) { + tac.executeTestCase(tac.testCases.get(index), index); + } + } + } - debugPrint("Test case number = " + testCase + " => binary = " + Integer.toBinaryString(testCase)); - debugPrint(" => baseAnnoTarget = " + baseAnnoTarget); - debugPrint(" => containerAnnoTarget = " + conAnnoTarget); + private void generate() { + // Adding test cases to run. + testCases.addAll(Arrays.asList( + // No base target against no container target. + new TestCase(noSet, noSet), + // No base target against empty container target. + new TestCase(noSet, empty), + // No base target against TYPE_USE only container target. + new TestCase(noSet, less(jdk8, TYPE_PARAMETER)), + // No base target against TYPE_PARAMETER only container target. + new TestCase(noSet, less(jdk8, TYPE_USE)), + // No base target against TYPE_USE + TYPE_PARAMETER only container target. + new TestCase(noSet, jdk8), + // No base target against TYPE_USE + some selection of jdk7 targets. + new TestCase(noSet, + plus(EnumSet.range(TYPE, LOCAL_VARIABLE), TYPE_USE)), + // No base target against TYPE_PARAMETER + some selection of jdk7 targets. + new TestCase(noSet, + plus(EnumSet.range(TYPE, LOCAL_VARIABLE), TYPE_PARAMETER)), + // No base target against each jdk7 target alone as container target. + new TestCase(noSet, plus(empty, TYPE)), + new TestCase(noSet, plus(empty, PARAMETER)), + new TestCase(noSet, plus(empty, PACKAGE)), + new TestCase(noSet, plus(empty, METHOD)), + new TestCase(noSet, plus(empty, LOCAL_VARIABLE)), + new TestCase(noSet, plus(empty, FIELD)), + new TestCase(noSet, plus(empty, CONSTRUCTOR)), + new TestCase(noSet, plus(empty, ANNOTATION_TYPE)), + // Empty base target against no container target. + new TestCase(empty, noSet), + // Empty base target against empty container target. + new TestCase(empty, empty), + // Empty base target against any lone container target. + new TestCase(empty, plus(empty, TYPE)), + new TestCase(empty, plus(empty, PARAMETER)), + new TestCase(empty, plus(empty, PACKAGE)), + new TestCase(empty, plus(empty, METHOD)), + new TestCase(empty, plus(empty, LOCAL_VARIABLE)), + new TestCase(empty, plus(empty, FIELD)), + new TestCase(empty, plus(empty, CONSTRUCTOR)), + new TestCase(empty, plus(empty, ANNOTATION_TYPE)), + new TestCase(empty, less(jdk8, TYPE_USE)), + new TestCase(empty, less(jdk8, TYPE_PARAMETER)), + // No container target against all all-but one jdk7 targets. + new TestCase(less(jdk7, TYPE), noSet), + new TestCase(less(jdk7, PARAMETER), noSet), + new TestCase(less(jdk7, PACKAGE), noSet), + new TestCase(less(jdk7, METHOD), noSet), + new TestCase(less(jdk7, LOCAL_VARIABLE), noSet), + new TestCase(less(jdk7, FIELD), noSet), + new TestCase(less(jdk7, CONSTRUCTOR), noSet), + new TestCase(less(jdk7, ANNOTATION_TYPE), noSet), + // No container against all but TYPE and ANNOTATION_TYPE + new TestCase(less(jdk7, TYPE, ANNOTATION_TYPE), noSet), + // No container against jdk7 targets. + new TestCase(jdk7, noSet), + // No container against jdk7 targets plus one or both of TYPE_USE, TYPE_PARAMETER + new TestCase(plus(jdk7, TYPE_USE), noSet), + new TestCase(plus(jdk7, TYPE_PARAMETER), noSet), + new TestCase(allTargets, noSet), + // Empty container target against any lone target. + new TestCase(plus(empty, TYPE), empty), + new TestCase(plus(empty, PARAMETER), empty), + new TestCase(plus(empty, PACKAGE), empty), + new TestCase(plus(empty, METHOD), empty), + new TestCase(plus(empty, LOCAL_VARIABLE), empty), + new TestCase(plus(empty, FIELD), empty), + new TestCase(plus(empty, CONSTRUCTOR), empty), + new TestCase(plus(empty, ANNOTATION_TYPE), empty), + new TestCase(plus(empty, TYPE_USE), empty), + new TestCase(plus(empty, TYPE_PARAMETER), empty), + // All base targets against all container targets. + new TestCase(allTargets, allTargets), + // All base targets against all but one container targets. + new TestCase(allTargets, less(allTargets, TYPE)), + new TestCase(allTargets, less(allTargets, PARAMETER)), + new TestCase(allTargets, less(allTargets, PACKAGE)), + new TestCase(allTargets, less(allTargets, METHOD)), + new TestCase(allTargets, less(allTargets, LOCAL_VARIABLE)), + new TestCase(allTargets, less(allTargets, FIELD)), + new TestCase(allTargets, less(allTargets, CONSTRUCTOR)), + new TestCase(allTargets, less(allTargets, ANNOTATION_TYPE)), + new TestCase(allTargets, less(allTargets, TYPE_USE)), + new TestCase(allTargets, less(allTargets, TYPE_PARAMETER)), + // All container targets against all but one base targets. + new TestCase(less(allTargets, TYPE), allTargets), + new TestCase(less(allTargets, PARAMETER), allTargets), + new TestCase(less(allTargets, PACKAGE), allTargets), + new TestCase(less(allTargets, METHOD), allTargets), + new TestCase(less(allTargets, LOCAL_VARIABLE), allTargets), + new TestCase(less(allTargets, FIELD), allTargets), + new TestCase(less(allTargets, CONSTRUCTOR), allTargets), + new TestCase(less(allTargets, ANNOTATION_TYPE), allTargets), + new TestCase(less(allTargets, TYPE_USE), allTargets), + new TestCase(less(allTargets, TYPE_PARAMETER), allTargets))); + // Generates 100 test cases for any lone base target contained in Set + // allTargets against any lone container target. + for (ElementType b : allTargets) { + for (ElementType c : allTargets) { + testCases.add(new TestCase(plus(empty, b), plus(empty, c))); + } + } + } - // Determine if a testCase should compile or not - String className = "TC" + testCase; - boolean shouldCompile = isValidSubSet(baseAnnoTarget, conAnnoTarget); + void run() throws Exception { + int testCtr = 0; + for (TestCase tc : testCases) { + if (!tc.isIgnored()) { + executeTestCase(tc, testCases.indexOf(tc)); + testCtr++; + } + } + System.out.println("Total tests run: " + testCtr); + if (errors > 0) { + throw new Exception(errors + " errors found"); + } + } - // Get test source file(s) - Iterable files = getFileList(className, baseAnnoTarget, - conAnnoTarget, shouldCompile); + private void executeTestCase(TestCase testCase, int index) { + debugPrint("Test case number = " + index); + debugPrint(" => baseAnnoTarget = " + testCase.getBaseAnnotations()); + debugPrint(" => containerAnnoTarget = " + testCase.getContainerAnnotations()); - // Get result of compiling test src file(s) + String className = "TC" + index; + boolean shouldCompile = testCase.isValidSubSet(); + Iterable files = getFileList(className, testCase, shouldCompile); + // Get result of compiling test src file(s). boolean result = getCompileResult(className, shouldCompile, files); - - // List test src code if test fails - if(!result) { - System.out.println("FAIL: Test " + testCase); + // List test src code if test fails. + if (!result) { + System.out.println("FAIL: Test " + index); try { - for (JavaFileObject f: files) { + for (JavaFileObject f : files) { System.out.println("File: " + f.getName() + "\n" + f.getCharContent(true)); } } catch (IOException ioe) { System.out.println("Exception: " + ioe); } } else { - debugPrint("PASS: Test " + testCase); + debugPrint("PASS: Test " + index); } + } - // Get a Set based on bits that are set to 1 - public Set getSetFromBitVec(String bitVec) { - Set ret = new HashSet<>(); - char[] bit = bitVec.toCharArray(); - for (int i=bit.length-1, j=0; i>=0; i--, j++){ - if (bit[i] == '1') { - ret.add(targetVals[j]); + // Create src code and corresponding JavaFileObjects. + private Iterable getFileList(String className, + TestCase testCase, boolean shouldCompile) { + Set baseAnnoTarget = testCase.getBaseAnnotations(); + Set conAnnoTarget = testCase.getContainerAnnotations(); + String srcContent = ""; + String pkgInfoContent = ""; + String template = Helper.template; + String baseTarget = "", conTarget = ""; + + String target = Helper.ContentVars.TARGET.getVal(); + if (baseAnnoTarget != null) { + String tmp = target.replace("#VAL", convertToString(baseAnnoTarget).toString()); + baseTarget = tmp.replace("[", "{").replace("]", "}"); + } + if (conAnnoTarget != null) { + String tmp = target.replace("#VAL", convertToString(conAnnoTarget).toString()); + conTarget = tmp.replace("[", "{").replace("]", "}"); + } + + String annoData = Helper.ContentVars.IMPORTSTMTS.getVal() + + conTarget + + Helper.ContentVars.CONTAINER.getVal() + + baseTarget + + Helper.ContentVars.REPEATABLE.getVal() + + Helper.ContentVars.BASE.getVal(); + + JavaFileObject pkgInfoFile = null; + + // If shouldCompile = true and no @Target is specified for container annotation, + // then all 8 ElementType enum constants are applicable as targets for + // container annotation. + if (shouldCompile && conAnnoTarget == null) { + Set copySet = EnumSet.noneOf(ElementType.class); + copySet.addAll(jdk7); + conAnnoTarget = copySet; + } + + if (shouldCompile) { + boolean isPkgCasePresent = conAnnoTarget.contains(PACKAGE); + String repeatableAnno = Helper.ContentVars.BASEANNO.getVal() + + " " + Helper.ContentVars.BASEANNO.getVal(); + for (ElementType s : conAnnoTarget) { + String replaceStr = "/*" + s.name() + "*/"; + if (s.name().equalsIgnoreCase("PACKAGE")) { + //Create packageInfo file. + String pkgInfoName = TESTPKG + "." + "package-info"; + pkgInfoContent = repeatableAnno + "\npackage " + TESTPKG + ";" + annoData; + pkgInfoFile = Helper.getFile(pkgInfoName, pkgInfoContent); + } else { + template = template.replace(replaceStr, repeatableAnno); + if (!isPkgCasePresent) { + srcContent = template.replace( + "/*ANNODATA*/", annoData).replace("#ClassName", className); + } else { + replaceStr = "/*PACKAGE*/"; + String tmp = template.replace(replaceStr, "package " + TESTPKG + ";"); + srcContent = tmp.replace("#ClassName", className); + } + } } + } else { + // For invalid cases, compilation should fail at declaration site. + template = "class #ClassName {}"; + srcContent = annoData + template.replace("#ClassName", className); } - return ret; + JavaFileObject srcFile = Helper.getFile(className, srcContent); + Iterable files = null; + if (pkgInfoFile != null) { + files = Arrays.asList(pkgInfoFile, srcFile); + } else { + files = Arrays.asList(srcFile); + } + return files; } - // Compile the test source file(s) and return test result + // Compile the test source file(s) and return test result. private boolean getCompileResult(String className, boolean shouldCompile, Iterable files) { DiagnosticCollector diagnostics = new DiagnosticCollector(); Helper.compileCode(diagnostics, files); - - // Test case pass or fail + // Test case pass or fail. boolean ok = false; - String errMesg = ""; int numDiags = diagnostics.getDiagnostics().size(); - if (numDiags == 0) { if (shouldCompile) { debugPrint("Test passed, compiled as expected."); @@ -270,201 +429,80 @@ public class TargetAnnoCombo { } } else { if (shouldCompile) { - // did not compile + // did not compile. errMesg = "Test failed, did not compile."; ok = false; } else { - // Error in compilation as expected - String expectedErrKey = "compiler.err.invalid.repeatable." + - "annotation.incompatible.target"; + // Error in compilation as expected. + String expectedErrKey = "compiler.err.invalid.repeatable." + + "annotation.incompatible.target"; for (Diagnostic d : diagnostics.getDiagnostics()) { - if((d.getKind() == Diagnostic.Kind.ERROR) && - d.getCode().contains(expectedErrKey)) { - // Error message as expected + if ((d.getKind() == Diagnostic.Kind.ERROR) + && d.getCode().contains(expectedErrKey)) { + // Error message as expected. debugPrint("Error message as expected."); ok = true; break; } else { - // error message is incorrect + // error message is incorrect. ok = false; } } if (!ok) { - errMesg = "Incorrect error received when compiling " + - className + ", expected: " + expectedErrKey; + errMesg = "Incorrect error received when compiling " + + className + ", expected: " + expectedErrKey; } } } - if(!ok) { + if (!ok) { error(errMesg); - for (Diagnostic d : diagnostics.getDiagnostics()) + for (Diagnostic d : diagnostics.getDiagnostics()) { System.out.println(" Diags: " + d); + } } return ok; } + private Set less(Set base, ElementType... sub) { + Set res = EnumSet.noneOf(ElementType.class); + res.addAll(base); + for (ElementType t : sub) { + res.remove(t); + } + return res; + } + + private Set plus(Set base, ElementType... add) { + Set res = EnumSet.noneOf(ElementType.class); + res.addAll(base); + for (ElementType t : add) { + res.add(t); + } + return res; + } + + // Iterate target set and add "ElementType." in front of every target type. + private List convertToString(Set annoTarget) { + if (annoTarget == null) { + return null; + } + List annoTargets = new ArrayList(); + for (ElementType e : annoTarget) { + annoTargets.add("ElementType." + e.name()); + } + return annoTargets; + } + private void debugPrint(String string) { - if(DEBUG) + if (DEBUG) { System.out.println(string); + } } - // Create src code and corresponding JavaFileObjects - private Iterable getFileList(String className, - Set baseAnnoTarget, Set conAnnoTarget, - boolean shouldCompile) { - - String srcContent = ""; - String pkgInfoContent = ""; - String template = Helper.template; - String baseTarget = "", conTarget = ""; - - String target = Helper.ContentVars.TARGET.getVal(); - if(baseAnnoTarget != null) { - baseTarget = target.replace("#VAL", baseAnnoTarget.toString()) - .replace("[", "{").replace("]", "}"); - } - if(conAnnoTarget != null) { - conTarget = target.replace("#VAL", conAnnoTarget.toString()) - .replace("[", "{").replace("]", "}"); - } - - String annoData = Helper.ContentVars.IMPORTSTMTS.getVal() + - conTarget + - Helper.ContentVars.CONTAINER.getVal() + - baseTarget + - Helper.ContentVars.REPEATABLE.getVal() + - Helper.ContentVars.BASE.getVal(); - - JavaFileObject pkgInfoFile = null; - - /* - * If shouldCompile = true and no @Target is specified for container annotation, - * then all 8 ElementType enum constants are applicable as targets for - * container annotation. - */ - if(shouldCompile && conAnnoTarget == null) { - //conAnnoTarget = new HashSet(Arrays.asList(targetVals)); - conAnnoTarget = getDefaultTargetSet(); - } - - if(shouldCompile) { - boolean isPkgCasePresent = new ArrayList(conAnnoTarget).contains("ElementType.PACKAGE"); - String repeatableAnno = Helper.ContentVars.BASEANNO.getVal() + " " + Helper.ContentVars.BASEANNO.getVal(); - for(String s: conAnnoTarget) { - s = s.replace("ElementType.",""); - String replaceStr = "/*"+s+"*/"; - if(s.equalsIgnoreCase("PACKAGE")) { - //Create packageInfo file - String pkgInfoName = TESTPKG + "." + "package-info"; - pkgInfoContent = repeatableAnno + "\npackage " + TESTPKG + ";" + annoData; - pkgInfoFile = Helper.getFile(pkgInfoName, pkgInfoContent); - } else { - template = template.replace(replaceStr, repeatableAnno); - //srcContent = template.replace("#ClassName",className); - if(!isPkgCasePresent) { - srcContent = template.replace("/*ANNODATA*/", annoData).replace("#ClassName",className); - } else { - replaceStr = "/*PACKAGE*/"; - srcContent = template.replace(replaceStr, "package " + TESTPKG + ";") - .replace("#ClassName", className); - } - } - } - } else { - // For invalid cases, compilation should fail at declaration site - template = "class #ClassName {}"; - srcContent = annoData + template.replace("#ClassName",className); - } - JavaFileObject srcFile = Helper.getFile(className, srcContent); - Iterable files = null; - if(pkgInfoFile != null) - files = Arrays.asList(pkgInfoFile,srcFile); - else - files = Arrays.asList(srcFile); - return files; - } - - private Set getDefaultTargetSet() { - Set defaultSet = new HashSet<>(); - int ctr = 0; - for(String s : targetVals) { - if(ctr++ < DEFAULT_TARGET_CNT) { - defaultSet.add(s); - } - } - return defaultSet; - } - - private boolean isValidSubSet(Set baseAnnoTarget, Set conAnnoTarget) { - /* - * RULE 1: conAnnoTarget should be a subset of baseAnnoTarget - * RULE 2: For empty @Target ({}) - annotation cannot be applied anywhere - * - Empty sets for both is valid - * - Empty baseTarget set is invalid with non-empty conTarget set - * - Non-empty baseTarget set is valid with empty conTarget set - * RULE 3: For no @Target specified - annotation can be applied to any JDK 7 targets - * - No @Target for both is valid - * - No @Target for baseTarget set with @Target conTarget set is valid - * - @Target for baseTarget set with no @Target for conTarget is invalid - */ - - - /* If baseAnno has no @Target, Foo can be either applied to @Target specified for container annotation - * else will be applicable for all default targets if no @Target is present for container annotation. - * In both cases, the set will be a valid set with no @Target for base annotation - */ - if(baseAnnoTarget == null) { - if(conAnnoTarget == null) return true; - return !(conAnnoTarget.contains("ElementType.TYPE_USE") || conAnnoTarget.contains("ElementType.TYPE_PARAMETER")); - } - - Set tempBaseSet = new HashSet<>(baseAnnoTarget); - // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default - if(baseAnnoTarget.contains("ElementType.TYPE")) { - tempBaseSet.add("ElementType.ANNOTATION_TYPE"); - } - - /* - * If containerAnno has no @Target, only valid case if baseAnnoTarget has all targets defined - * else invalid set - */ - if(conAnnoTarget == null) { - return (tempBaseSet.containsAll(getDefaultTargetSet())); - } - - // At this point, neither conAnnoTarget or baseAnnoTarget are null - if(conAnnoTarget.size() == 0) return true; - - // At this point, conAnnoTarget is non-empty - if (baseAnnoTarget.size() == 0) return false; - - // At this point, neither conAnnoTarget or baseAnnoTarget are empty - return tempBaseSet.containsAll(conAnnoTarget); - } - - void error(String msg) { + private void error(String msg) { System.out.println("ERROR: " + msg); errors++; } - - // Lists the start and end range for the given set of target vals - void showGroups() { - //Group 1: All target set combinations ( 0 to 1048575 ) including empty @Target sets => @Target({}) - int grpEnd1 = (int)Math.pow(2, 2*targetVals.length) - 1; - System.out.println("[Group 1]: 0 - " + grpEnd1); - - //Group 2: @Target not defined for base annotation ( 1048576 - 1049599 ). - System.out.print("[Group 2]: " + (grpEnd1 + 1) + " - "); - int grpEnd2 = grpEnd1 + 1 + (int)Math.pow(2, targetVals.length) - 1; - System.out.println(grpEnd2); - - //Group 3: @Target not defined for container annotation ( 1049600 - 1050623 ). - System.out.print("[Group 3]: " + (grpEnd2 + 1) + " - "); - int grpEnd3 = grpEnd2 + 1 + (int)Math.pow(2, targetVals.length) - 1; - System.out.println(grpEnd3); - - //Group 4: @Target not defined for both base and container annotations ( 1050624 ). - System.out.println("[Group 4]: " + (grpEnd3 + 1)); - } } + diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TestCaseGenerator.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TestCaseGenerator.java deleted file mode 100644 index fe2eaf231b4..00000000000 --- a/langtools/test/tools/javac/annotations/repeatingAnnotations/combo/TestCaseGenerator.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2013, 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. - */ - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Random; - -/* System properties: - * NumberOfTests, TestMode, and TestCaseNum are mutually exclusive - * TestSeed will be used only with NumberOfTests or TestMode, otherwise it will be ignored - * -DNumberOfTests=[0 to 2^20+2^11+1] - * -DTestMode=[FULL|DEFAULT] - * -DTestSeed=[seedNumber] - * -DTestCaseNum=[0 to 2^20+2^11+1] - */ -public class TestCaseGenerator { - // Total number of tests to be run - int numberOfTests = -1; - //Single test case - int testCaseNum = -1; - //Seed used to generate test cases - int testSeed; - - int maxTestNum; - Random randNum; - - // used in getNextTestCase - int curTestNum; - int testCompletedCount; - HashSet uniqueTestSet; - - static final int DEFAULT_TEST_COUNT = 250; - - /* - * Get parameter values from command line to set numberOfTests, testCaseNum, - * and testSeed - */ - public TestCaseGenerator(int maxTestNum) { - this.maxTestNum = maxTestNum; - - // Set values for variables based on input from command line - - // TestMode system property - String testModeVal = System.getProperty("TestMode"); - if(testModeVal != null && !testModeVal.isEmpty()) { - switch (testModeVal.toUpperCase()) { - case "FULL": - numberOfTests = maxTestNum; - break; - case "DEFAULT": - numberOfTests = DEFAULT_TEST_COUNT; - break; - default: - System.out.println("Invalid property value " + testModeVal + - " for numberOfTests. Possible range: 0 to " + - maxTestNum + ". Ignoring property"); - numberOfTests = -1; - } - } - - // NumberOfTests system property - String numTestsStr = System.getProperty("NumberOfTests"); - if(numTestsStr != null && !numTestsStr.isEmpty()) { - int numTests = -1; - try { - numTests = Integer.parseInt(numTestsStr); - if (numTests < 0 || numTests > maxTestNum) { - throw new NumberFormatException(); - } - } catch(NumberFormatException nfe) { - System.out.println("Invalid NumberOfTests property value " + - numTestsStr + ". Possible range: 0 to " + maxTestNum + - "Reset to default: " + DEFAULT_TEST_COUNT); - numTests = DEFAULT_TEST_COUNT; - } - - if (numberOfTests != -1 && numTests != -1) { - System.out.println("TestMode and NumberOfTests cannot be set together. Ignoring TestMode."); - } - numberOfTests = numTests; - } - - // TestSeed system property - String seedVal = System.getProperty("TestSeed"); - if(seedVal != null && !seedVal.isEmpty()) { - try { - testSeed = Integer.parseInt(seedVal); - } catch(NumberFormatException nfe) { - Random srand = new Random(); - testSeed = srand.nextInt(); - } - } else { - Random srand = new Random(); - testSeed = srand.nextInt(); - } - - // TestCaseNum system property - String testNumStr = System.getProperty("TestCaseNum"); - if(testNumStr != null && !testNumStr.isEmpty()) { - try { - testCaseNum = Integer.parseInt(testNumStr); - if (testCaseNum < 0 || testCaseNum > maxTestNum) { - throw new NumberFormatException(); - } - } catch(NumberFormatException nfe) { - System.out.println("Invalid TestCaseNumber property value " + - testNumStr + ". Possible value in range: 0 to " + - maxTestNum + ". Defaulting to last test case."); - testCaseNum = maxTestNum; - } - - if ( numberOfTests != -1) { - System.out.println("TestMode or NumberOfTests cannot be set along with TestCaseNum. Ignoring TestCaseNumber."); - testCaseNum = -1; - } - } - - if (numberOfTests == -1 && testCaseNum == -1) { - numberOfTests = DEFAULT_TEST_COUNT; - System.out.println("Setting TestMode to default, will run " + numberOfTests + "tests."); - } - - /* - * By this point in code, we will have: - * - testSeed: as per TestSeed or a Random one - * - numberOfTests to run or -1 to denote not set - * - testCaseNum to run or -1 to denote not set - */ - - /* - * If numberOfTests = maxTestNum, all tests are to be run, - * so no randNum will be required - */ - if (numberOfTests != -1 && numberOfTests < maxTestNum) { - System.out.println("Seed = " + testSeed); - randNum = new Random(testSeed); - uniqueTestSet = new HashSet<>(); - } - - testCompletedCount = 0; - // to be used to keep sequential count when running all tests - curTestNum = 0; - } - - /* - * returns next test case number to run - * returns -1 when there are no more tests to run - */ - public int getNextTestCase() { - if (testCaseNum != -1) { - int nextTC = testCaseNum; - testCaseNum = -1; - return nextTC; - } - if (++testCompletedCount <= numberOfTests) { - if (numberOfTests == maxTestNum) { - //all the tests need to be run, so just return - //next test case sequentially - return curTestNum++; - } else { - int nextTC = -1; - // Ensuring unique test are run - while(!uniqueTestSet.add(nextTC = randNum.nextInt(maxTestNum))) { - } - return nextTC; - } - } - return -1; - } -} From e05970ca52edee6f3dfcb61f82754c2d5523328c Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Fri, 15 Mar 2013 16:07:13 +0100 Subject: [PATCH 014/155] 8010147: Forgot to add EXPECTED files for lazy and eager sunspider test Reviewed-by: sundar, jlaskey --- .../{runsunspider.js.EXPECTED => runsunspider-eager.js.EXPECTED} | 0 nashorn/test/script/basic/runsunspider-lazy.js.EXPECTED | 1 + 2 files changed, 1 insertion(+) rename nashorn/test/script/basic/{runsunspider.js.EXPECTED => runsunspider-eager.js.EXPECTED} (100%) create mode 100644 nashorn/test/script/basic/runsunspider-lazy.js.EXPECTED diff --git a/nashorn/test/script/basic/runsunspider.js.EXPECTED b/nashorn/test/script/basic/runsunspider-eager.js.EXPECTED similarity index 100% rename from nashorn/test/script/basic/runsunspider.js.EXPECTED rename to nashorn/test/script/basic/runsunspider-eager.js.EXPECTED diff --git a/nashorn/test/script/basic/runsunspider-lazy.js.EXPECTED b/nashorn/test/script/basic/runsunspider-lazy.js.EXPECTED new file mode 100644 index 00000000000..dd360839514 --- /dev/null +++ b/nashorn/test/script/basic/runsunspider-lazy.js.EXPECTED @@ -0,0 +1 @@ +Sunspider finished! From 5aea724d29eb99d92d46cb28be8aebeafb91d7f3 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 15 Mar 2013 21:52:40 +0530 Subject: [PATCH 015/155] 8010145: removed workaround "init.js" in nashorn repo Reviewed-by: jlaskey, lagergren --- .../jdk/nashorn/api/scripting/Formatter.java | 10 +- .../api/scripting/NashornScriptEngine.java | 8 - .../nashorn/api/scripting/ScriptUtils.java | 12 + .../nashorn/api/scripting/resources/engine.js | 46 + .../nashorn/api/scripting/resources/init.js | 939 ------------------ 5 files changed, 63 insertions(+), 952 deletions(-) delete mode 100644 nashorn/src/jdk/nashorn/api/scripting/resources/init.js diff --git a/nashorn/src/jdk/nashorn/api/scripting/Formatter.java b/nashorn/src/jdk/nashorn/api/scripting/Formatter.java index 3b47d3479e4..5cb19ed47af 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/Formatter.java +++ b/nashorn/src/jdk/nashorn/api/scripting/Formatter.java @@ -46,7 +46,7 @@ import java.util.regex.Pattern; *

    Pattern and the logic for parameter position: java.util.Formatter * */ -public final class Formatter { +final class Formatter { private Formatter() { } @@ -59,8 +59,8 @@ public final class Formatter { * @param args arguments referenced by the format specifiers in format * @return a formatted string */ - public static String format(final String format, final Object[] args) { - Matcher m = FS_PATTERN.matcher(format); + static String format(final String format, final Object[] args) { + final Matcher m = FS_PATTERN.matcher(format); int positionalParameter = 1; while (m.find()) { @@ -143,7 +143,7 @@ public final class Formatter { /** * Method to parse the integer of the argument index. * - * @param s + * @param s string to parse * @return -1 if parsing failed, 0 if string is null, > 0 integer */ private static int index(final String s) { @@ -166,7 +166,7 @@ public final class Formatter { * Method to check if a string contains '<'. This is used to find out if * previous parameter is used. * - * @param s + * @param s string to check * @return true if '<' is in the string, else false */ private static boolean isPreviousArgument(final String s) { diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index ce16a7e82d0..4fa6033c11f 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -394,14 +394,6 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C setContextVariables(ctxt); final Object val = ctxt.getAttribute(ScriptEngine.FILENAME); final String fileName = (val != null) ? val.toString() : ""; - - // NOTE: FIXME: If this is jrunscript's init.js, we want to run the replacement. - // This should go away once we fix jrunscript's copy of init.js. - if ("".equals(fileName)) { - evalSupportScript("resources/init.js", "nashorn:engine/resources/init.js"); - return null; - } - Object res = ScriptRuntime.apply(script, ctxtGlobal); return ScriptObjectMirror.translateUndefined(ScriptObjectMirror.wrap(res, ctxtGlobal)); } catch (final Exception e) { diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java index 63358bd7db9..ccd5879b3f9 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java @@ -45,4 +45,16 @@ public final class ScriptUtils { public static String parse(final String code, final String name, final boolean includeLoc) { return ScriptRuntime.parse(code, name, includeLoc); } + + /** + * Method which converts javascript types to java types for the + * String.format method (jrunscript function sprintf). + * + * @param format a format string + * @param args arguments referenced by the format specifiers in format + * @return a formatted string + */ + public static String format(final String format, final Object[] args) { + return Formatter.format(format, args); + } } diff --git a/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js b/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js index 65b82dfe797..e95607287d4 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js +++ b/nashorn/src/jdk/nashorn/api/scripting/resources/engine.js @@ -46,3 +46,49 @@ function print(str) { } writer.println(String(str)); } + +/** + * This is C-like printf + * + * @param format string to format the rest of the print items + * @param args variadic argument list + */ +Object.defineProperty(this, "printf", { + configurable: true, + enumerable: false, + writable: true, + value: function (format, args/*, more args*/) { + print(sprintf.apply(this, arguments)); + } +}); + +/** + * This is C-like sprintf + * + * @param format string to format the rest of the print items + * @param args variadic argument list + */ +Object.defineProperty(this, "sprintf", { + configurable: true, + enumerable: false, + writable: true, + value: function (format, args/*, more args*/) { + var len = arguments.length - 1; + var array = []; + + if (len < 0) { + return ""; + } + + for (var i = 0; i < len; i++) { + if (arguments[i+1] instanceof Date) { + array[i] = arguments[i+1].getTime(); + } else { + array[i] = arguments[i+1]; + } + } + + array = Java.toJavaArray(array); + return Packages.jdk.nashorn.api.scripting.ScriptUtils.format(format, array); + } +}); diff --git a/nashorn/src/jdk/nashorn/api/scripting/resources/init.js b/nashorn/src/jdk/nashorn/api/scripting/resources/init.js deleted file mode 100644 index 18cde929451..00000000000 --- a/nashorn/src/jdk/nashorn/api/scripting/resources/init.js +++ /dev/null @@ -1,939 +0,0 @@ -/* - * Copyright (c) 2005, 2013, 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. - */ - -/** - * jrunscript JavaScript built-in functions and objects. - */ - -/** - * Creates an object that delegates all method calls on - * it to the 'invoke' method on the given delegate object.
    - * - * Example: - *

    - * 
    - *     var x  = { invoke: function(name, args) { //code...}
    - *     var y = new JSInvoker(x);
    - *     y.func(3, 3); // calls x.invoke('func', args); where args is array of arguments
    - * 
    - * 
    - * @param obj object to be wrapped by JSInvoker - * @constructor - */ -function JSInvoker(obj) { - return new JSAdapter({ - __get__ : function(name) { - return function() { - return obj.invoke(name, arguments); - } - } - }); -} - -/** - * This variable represents OS environment. Environment - * variables can be accessed as fields of this object. For - * example, env.PATH will return PATH value configured. - */ -var env = new JSAdapter({ - __get__ : function (name) { - return java.lang.System.getenv(name); - }, - __has__ : function (name) { - return java.lang.System.getenv().containsKey(name); - }, - __getIds__ : function() { - return java.lang.System.getenv().keySet().toArray(); - }, - __delete__ : function(name) { - println("can't delete env item"); - }, - __put__ : function (name, value) { - println("can't change env item"); - }, - toString: function() { - return java.lang.System.getenv().toString(); - } -}); - -/** - * Creates a convenient script object to deal with java.util.Map instances. - * The result script object's field names are keys of the Map. For example, - * scriptObj.keyName can be used to access value associated with given key.
    - * Example: - *
    - * 
    - *     var x = java.lang.SystemProperties();
    - *     var y = jmap(x);
    - *     println(y['java.class.path']); // prints java.class.path System property
    - *     delete y['java.class.path']; // remove java.class.path System property
    - * 
    - * 
    - * - * @param map java.util.Map instance that will be wrapped - * @constructor - */ -function jmap(map) { - return new JSAdapter({ - __get__ : function(name) { - if (map.containsKey(name)) { - return map.get(name); - } else { - return undefined; - } - }, - __has__ : function(name) { - return map.containsKey(name); - }, - - __delete__ : function (name) { - return map.remove(name); - }, - __put__ : function(name, value) { - map.put(name, value); - }, - __getIds__ : function() { - return map.keySet().toArray(); - }, - toString: function() { - return map.toString(); - } - }); -} - -/** - * Creates a convenient script object to deal with java.util.List instances. - * The result script object behaves like an array. For example, - * scriptObj[index] syntax can be used to access values in the List instance. - * 'length' field gives size of the List.
    - * - * Example: - *
    - * 
    - *    var x = new java.util.ArrayList(4);
    - *    x.add('Java');
    - *    x.add('JavaScript');
    - *    x.add('SQL');
    - *    x.add('XML');
    - *
    - *    var y = jlist(x);
    - *    println(y[2]); // prints third element of list
    - *    println(y.length); // prints size of the list
    - *
    - * @param map java.util.List instance that will be wrapped
    - * @constructor
    - */
    -function jlist(list) {
    -    function isValid(index) {
    -        return typeof(index) == 'number' &&
    -            index > -1 && index < list.size();
    -    }
    -    return new JSAdapter({
    -        __get__ :  function(name) {
    -            if (isValid(name)) {
    -                return list.get(name);
    -            } else if (name == 'length') {
    -                return list.size();
    -            } else {
    -                return undefined;
    -            }
    -        },
    -        __has__ : function (name) {
    -            return isValid(name) || name == 'length';
    -        },
    -        __delete__ : function(name) {
    -            if (isValid(name)) {
    -                list.remove(name);
    -            }
    -        },
    -        __put__ : function(name, value) {
    -            if (isValid(name)) {
    -                list.set(name, value);
    -            }
    -        },
    -        __getIds__: function() {
    -            var res = new Array(list.size());
    -            for (var i = 0; i < res.length; i++) {
    -                res[i] = i;
    -            }
    -            return res;
    -        },
    -        toString: function() {
    -            return list.toString();
    -        }
    -    });
    -}
    -
    -/**
    - * This is java.lang.System properties wrapped by JSAdapter.
    - * For eg. to access java.class.path property, you can use
    - * the syntax sysProps["java.class.path"]
    - */
    -var sysProps = new JSAdapter({
    -    __get__ : function (name) {
    -        return java.lang.System.getProperty(name);
    -    },
    -    __has__ : function (name) {
    -        return java.lang.System.getProperty(name) != null;
    -    },
    -    __getIds__ : function() {
    -        return java.lang.System.getProperties().keySet().toArray();
    -    },
    -    __delete__ : function(name) {
    -        java.lang.System.clearProperty(name);
    -        return true;
    -    },
    -    __put__ : function (name, value) {
    -        java.lang.System.setProperty(name, value);
    -    },
    -    toString: function() {
    -        return "";
    -    }
    -});
    -
    -// stdout, stderr & stdin
    -var out = java.lang.System.out;
    -var err = java.lang.System.err;
    -// can't use 'in' because it is a JavaScript keyword :-(
    -var inp = java.lang.System["in"];
    -
    -var BufferedInputStream = java.io.BufferedInputStream;
    -var BufferedOutputStream = java.io.BufferedOutputStream;
    -var BufferedReader = java.io.BufferedReader;
    -var DataInputStream = java.io.DataInputStream;
    -var File = java.io.File;
    -var FileInputStream = java.io.FileInputStream;
    -var FileOutputStream = java.io.FileOutputStream;
    -var InputStream = java.io.InputStream;
    -var InputStreamReader = java.io.InputStreamReader;
    -var OutputStream = java.io.OutputStream;
    -var Reader = java.io.Reader;
    -var URL = java.net.URL;
    -
    -/**
    - * Generic any object to input stream mapper
    - * @param str input file name, URL or InputStream
    - * @return InputStream object
    - * @private
    - */
    -function inStream(str) {
    -    if (typeof(str) == "string") {
    -        // '-' means standard input
    -        if (str == '-') {
    -            return java.lang.System["in"];
    -        }
    -        // try file first
    -        var file = null;
    -        try {
    -            file = pathToFile(str);
    -        } catch (e) {
    -        }
    -        if (file && file.exists()) {
    -            return new FileInputStream(file);
    -        } else {
    -            try {
    -                // treat the string as URL
    -                return new URL(str).openStream();
    -            } catch (e) {
    -                throw 'file or URL ' + str + ' not found';
    -            }
    -        }
    -    } else {
    -        if (str instanceof InputStream) {
    -            return str;
    -        } else if (str instanceof URL) {
    -            return str.openStream();
    -        } else if (str instanceof File) {
    -            return new FileInputStream(str);
    -        }
    -    }
    -    // everything failed, just give input stream
    -    return java.lang.System["in"];
    -}
    -
    -/**
    - * Generic any object to output stream mapper
    - *
    - * @param out output file name or stream
    - * @return OutputStream object
    - * @private
    - */
    -function outStream(out) {
    -    if (typeof(out) == "string") {
    -        if (out == '>') {
    -            return java.lang.System.out;
    -        } else {
    -            // treat it as file
    -            return new FileOutputStream(pathToFile(out));
    -        }
    -    } else {
    -        if (out instanceof OutputStream) {
    -            return out;
    -        } else if (out instanceof File) {
    -            return new FileOutputStream(out);
    -        }
    -    }
    -
    -    // everything failed, just return System.out
    -    return java.lang.System.out;
    -}
    -
    -/**
    - * stream close takes care not to close stdin, out & err.
    - * @private
    - */
    -function streamClose(stream) {
    -    if (stream) {
    -        if (stream != java.lang.System["in"] &&
    -            stream != java.lang.System.out &&
    -            stream != java.lang.System.err) {
    -            try {
    -                stream.close();
    -            } catch (e) {
    -                println(e);
    -            }
    -        }
    -    }
    -}
    -
    -/**
    - * Loads and evaluates JavaScript code from a stream or file or URL
    - * - * Examples: - *
    - * 
    - *    load('test.js'); // load script file 'test.js'
    - *    load('http://java.sun.com/foo.js'); // load from a URL
    - * 
    - * 
    - * - * @param str input from which script is loaded and evaluated - */ -if (typeof(load) == 'undefined') { - var load = function(str) { - var stream = inStream(str); - var bstream = new BufferedInputStream(stream); - var reader = new BufferedReader(new InputStreamReader(bstream)); - var oldFilename = engine.get(engine.FILENAME); - engine.put(engine.FILENAME, str); - try { - engine.eval(reader); - } finally { - engine.put(engine.FILENAME, oldFilename); - streamClose(stream); - } - } -} - -// file system utilities - -/** - * Creates a Java byte[] of given length - * @param len size of the array to create - * @private - */ -function javaByteArray(len) { - return java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, len); -} - -var curDir = new File('.'); - -/** - * Print present working directory - */ -function pwd() { - println(curDir.getAbsolutePath()); -} - -/** - * Changes present working directory to given directory - * @param target directory to change to. optional, defaults to user's HOME - */ -function cd(target) { - if (target == undefined) { - target = sysProps["user.home"]; - } - if (!(target instanceof File)) { - target = pathToFile(target); - } - if (target.exists() && target.isDirectory()) { - curDir = target; - } else { - println(target + " is not a directory"); - } -} - -/** - * Converts path to java.io.File taking care of shell present working dir - * - * @param pathname file path to be converted - * @private - */ -function pathToFile(pathname) { - var tmp = pathname; - if (!(tmp instanceof File)) { - tmp = new File(tmp); - } - if (!tmp.isAbsolute()) { - return new File(curDir, pathname); - } else { - return tmp; - } -} - -/** - * Copies a file or URL or stream to another file or stream - * - * @param from input file or URL or stream - * @param to output stream or file - */ -function cp(from, to) { - if (from == to) { - println("file " + from + " cannot be copied onto itself!"); - return; - } - var inp = inStream(from); - var out = outStream(to); - var binp = new BufferedInputStream(inp); - var bout = new BufferedOutputStream(out); - var buff = javaByteArray(1024); - var len; - while ((len = binp.read(buff)) > 0 ) - bout.write(buff, 0, len); - - bout.flush(); - streamClose(inp); - streamClose(out); -} - -/** - * Shows the content of a file or URL or any InputStream
    - * Examples: - *
    - * 
    - *    cat('test.txt'); // show test.txt file contents
    - *    cat('http://java.net'); // show the contents from the URL http://java.net
    - * 
    - * 
    - * @param obj input to show - * @param pattern optional. show only the lines matching the pattern - */ -function cat(obj, pattern) { - if (obj instanceof File && obj.isDirectory()) { - ls(obj); - return; - } - - var inp = null; - if (!(obj instanceof Reader)) { - inp = inStream(obj); - obj = new BufferedReader(new InputStreamReader(inp)); - } - var line; - if (pattern) { - var count = 1; - while ((line=obj.readLine()) != null) { - if (line.match(pattern)) { - println(count + "\t: " + line); - } - count++; - } - } else { - while ((line=obj.readLine()) != null) { - println(line); - } - } -} - -/** - * Returns directory part of a filename - * - * @param pathname input path name - * @return directory part of the given file name - */ -function dirname(pathname) { - var dirName = "."; - // Normalize '/' to local file separator before work. - var i = pathname.replace('/', File.separatorChar ).lastIndexOf( - File.separator ); - if ( i != -1 ) - dirName = pathname.substring(0, i); - return dirName; -} - -/** - * Creates a new dir of given name - * - * @param dir name of the new directory - */ -function mkdir(dir) { - dir = pathToFile(dir); - println(dir.mkdir()? "created" : "can not create dir"); -} - -/** - * Creates the directory named by given pathname, including - * any necessary but nonexistent parent directories. - * - * @param dir input path name - */ -function mkdirs(dir) { - dir = pathToFile(dir); - println(dir.mkdirs()? "created" : "can not create dirs"); -} - -/** - * Removes a given file - * - * @param pathname name of the file - */ -function rm(pathname) { - var file = pathToFile(pathname); - if (!file.exists()) { - println("file not found: " + pathname); - return false; - } - // note that delete is a keyword in JavaScript! - println(file["delete"]()? "deleted" : "can not delete"); -} - -/** - * Removes a given directory - * - * @param pathname name of the directory - */ -function rmdir(pathname) { - rm(pathname); -} - -/** - * Synonym for 'rm' - */ -function del(pathname) { - rm(pathname); -} - -/** - * Moves a file to another - * - * @param from original name of the file - * @param to new name for the file - */ -function mv(from, to) { - println(pathToFile(from).renameTo(pathToFile(to))? - "moved" : "can not move"); -} - -/** - * Synonym for 'mv'. - */ -function ren(from, to) { - mv(from, to); -} - -var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; - -/** - * Helper function called by ls - * @private - */ -function printFile(f) { - var sb = new java.lang.StringBuffer(); - sb.append(f.isDirectory()? "d" : "-"); - sb.append(f.canRead() ? "r": "-" ); - sb.append(f.canWrite() ? "w": "-" ); - sb.append(" "); - - var d = new java.util.Date(f.lastModified()); - var c = new java.util.GregorianCalendar(); - c.setTime(d); - var day = c.get(java.util.Calendar.DAY_OF_MONTH); - sb.append(months[c.get(java.util.Calendar.MONTH)] - + " " + day ); - if (day < 10) { - sb.append(" "); - } - - // to get fixed length 'length' field - var fieldlen = 8; - var len = new java.lang.StringBuffer(); - for(var j=0; j - * - * Examples: - *
    - * 
    - *    find('.')
    - *    find('.', '.*\.class', rm);  // remove all .class files
    - *    find('.', '.*\.java');       // print fullpath of each .java file
    - *    find('.', '.*\.java', cat);  // print all .java files
    - * 
    - * 
    - * - * @param dir directory to search files - * @param pattern to search in the files - * @param callback function to call for matching files - */ -function find(dir, pattern, callback) { - dir = pathToFile(dir); - if (!callback) callback = print; - var files = dir.listFiles(); - for (var f in files) { - var file = files[f]; - if (file.isDirectory()) { - find(file, pattern, callback); - } else { - if (pattern) { - if (file.getName().match(pattern)) { - callback(file); - } - } else { - callback(file); - } - } - } -} - -// process utilities - -/** - * Exec's a child process, waits for completion & returns exit code - * - * @param cmd command to execute in child process - */ -function exec(cmd) { - var process = java.lang.Runtime.getRuntime().exec(cmd); - var inp = new DataInputStream(process.getInputStream()); - var line = null; - while ((line = inp.readLine()) != null) { - println(line); - } - process.waitFor(); - $exit = process.exitValue(); -} - -// XML utilities - -/** - * Converts input to DOM Document object - * - * @param inp file or reader. optional, without this param, - * this function returns a new DOM Document. - * @return returns a DOM Document object - */ -function XMLDocument(inp) { - var factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); - var builder = factory.newDocumentBuilder(); - if (inp) { - if (typeof(inp) == "string") { - return builder.parse(pathToFile(inp)); - } else { - return builder.parse(inp); - } - } else { - return builder.newDocument(); - } -} - -/** - * Converts arbitrary stream, file, URL to XMLSource - * - * @param inp input stream or file or URL - * @return XMLSource object - */ -function XMLSource(inp) { - if (inp instanceof javax.xml.transform.Source) { - return inp; - } else if (inp instanceof Packages.org.w3c.dom.Document) { - return new javax.xml.transform.dom.DOMSource(inp); - } else { - inp = new BufferedInputStream(inStream(inp)); - return new javax.xml.transform.stream.StreamSource(inp); - } -} - -/** - * Converts arbitrary stream, file to XMLResult - * - * @param inp output stream or file - * @return XMLResult object - */ -function XMLResult(out) { - if (out instanceof javax.xml.transform.Result) { - return out; - } else if (out instanceof Packages.org.w3c.dom.Document) { - return new javax.xml.transform.dom.DOMResult(out); - } else { - out = new BufferedOutputStream(outStream(out)); - return new javax.xml.transform.stream.StreamResult(out); - } -} - -/** - * Perform XSLT transform - * - * @param inp Input XML to transform (URL, File or InputStream) - * @param style XSL Stylesheet to be used (URL, File or InputStream). optional. - * @param out Output XML (File or OutputStream - */ -function XSLTransform(inp, style, out) { - switch (arguments.length) { - case 2: - inp = arguments[0]; - out = arguments[1]; - break; - case 3: - inp = arguments[0]; - style = arguments[1]; - out = arguments[2]; - break; - default: - println("XSL tranform requires 2 or 3 arguments"); - return; - } - - var factory = javax.xml.transform.TransformerFactory.newInstance(); - var transformer; - if (style) { - transformer = factory.newTransformer(XMLSource(style)); - } else { - transformer = factory.newTransformer(); - } - var source = XMLSource(inp); - var result = XMLResult(out); - transformer.transform(source, result); - if (source.getInputStream) { - streamClose(source.getInputStream()); - } - if (result.getOutputStream) { - streamClose(result.getOutputStream()); - } -} - -// miscellaneous utilities - -/** - * Prints which command is selected from PATH - * - * @param cmd name of the command searched from PATH - */ -function which(cmd) { - var st = new java.util.StringTokenizer(env.PATH, File.pathSeparator); - while (st.hasMoreTokens()) { - var file = new File(st.nextToken(), cmd); - if (file.exists()) { - println(file.getAbsolutePath()); - return; - } - } -} - -/** - * Prints IP addresses of given domain name - * - * @param name domain name - */ -function ip(name) { - var addrs = InetAddress.getAllByName(name); - for (var i in addrs) { - println(addrs[i]); - } -} - -/** - * Prints current date in current locale - */ -function date() { - println(new Date().toLocaleString()); -} - -/** - * Echoes the given string arguments - */ -function echo(x) { - for (var i = 0; i < arguments.length; i++) { - println(arguments[i]); - } -} - -/** - * Reads one or more lines from stdin after printing prompt - * - * @param prompt optional, default is '>' - * @param multiline to tell whether to read single line or multiple lines - */ -function read(prompt, multiline) { - if (!prompt) { - prompt = '>'; - } - var inp = java.lang.System["in"]; - var reader = new BufferedReader(new InputStreamReader(inp)); - if (multiline) { - var line = ''; - while (true) { - java.lang.System.err.print(prompt); - java.lang.System.err.flush(); - var tmp = reader.readLine(); - if (tmp == '' || tmp == null) break; - line += tmp + '\n'; - } - return line; - } else { - java.lang.System.err.print(prompt); - java.lang.System.err.flush(); - return reader.readLine(); - } -} - -if (typeof(println) == 'undefined') { - var print = function(str, newline) { - if (typeof(str) == 'undefined') { - str = 'undefined'; - } else if (str == null) { - str = 'null'; - } - - if (!(out instanceof java.io.PrintWriter)) { - out = new java.io.PrintWriter(out); - } - - out.print(String(str)); - if (newline) { - out.print('\n'); - } - out.flush(); - } - - var println = function(str) { - print(str, true); - }; -} - -/** - * This is C-like printf - * - * @param format string to format the rest of the print items - * @param args variadic argument list - */ -function printf(format, args/*, more args*/) { - print(sprintf.apply(this, arguments)); -} - -/** - * This is C-like sprintf - * - * @param format string to format the rest of the print items - * @param args variadic argument list - */ -function sprintf(format, args/*, more args*/) { - var len = arguments.length - 1; - var array = []; - - if (len < 0) { - return ""; - } - - for (var i = 0; i < len; i++) { - if (arguments[i+1] instanceof Date) { - array[i] = arguments[i+1].getTime(); - } else { - array[i] = arguments[i+1]; - } - } - - array = Java.toJavaArray(array); - return Packages.jdk.nashorn.api.scripting.Formatter.format(format, array); -} From c846064c8fb08c9623703205e31d990c4a84087c Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 18 Mar 2013 21:03:11 +0530 Subject: [PATCH 016/155] 8010199: javax.script.Invocable implementation for nashorn does not return null when matching functions are missing Reviewed-by: lagergren, jlaskey --- nashorn/bin/jjs | 2 +- nashorn/bin/jjssecure | 2 +- nashorn/bin/nashorn | 2 +- nashorn/bin/nashornsecure | 2 +- .../api/scripting/NashornScriptEngine.java | 26 +++++++- nashorn/test/script/basic/JDK-8010199.js | 51 +++++++++++++++ .../api/scripting/ScriptEngineTest.java | 62 +++++++++++++++++++ 7 files changed, 140 insertions(+), 7 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8010199.js diff --git a/nashorn/bin/jjs b/nashorn/bin/jjs index ca531f4dd02..fe6665c3c3d 100644 --- a/nashorn/bin/jjs +++ b/nashorn/bin/jjs @@ -26,4 +26,4 @@ [ -z "$JAVA_HOME" ] && echo "Please set JAVA_HOME" && exit 1; -$JAVA_HOME/bin/java -server -XX:-TieredCompilation -Xms2G -Xmx2G -esa -ea -Djava.ext.dirs=$JAVA_HOME/jre/lib/ext:`dirname $0`/../dist -XX:+HeapDumpOnOutOfMemoryError -Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -Dnashorn.debug=true jdk.nashorn.tools.Shell $* +$JAVA_HOME/bin/java -server -XX:-TieredCompilation -Xms2G -Xmx2G -esa -ea -Djava.ext.dirs=`dirname $0`/../dist:$JAVA_HOME/jre/lib/ext -XX:+HeapDumpOnOutOfMemoryError -Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -Dnashorn.debug=true jdk.nashorn.tools.Shell $* diff --git a/nashorn/bin/jjssecure b/nashorn/bin/jjssecure index 614ffd36213..db6bdfc4178 100644 --- a/nashorn/bin/jjssecure +++ b/nashorn/bin/jjssecure @@ -26,4 +26,4 @@ [ -z "$JAVA_HOME" ] && echo "Please set JAVA_HOME" && exit 1; -$JAVA_HOME/bin/java -Xms2G -Xmx2G -XX:-TieredCompilation -server -esa -ea -Djava.security.properties=`dirname $0`/../make/java.security.override -Djava.ext.dirs=$JAVA_HOME/jre/lib/ext:`dirname $0`/../dist -XX:+HeapDumpOnOutOfMemoryError -Dnashorn.debug=true -Djava.lang.invoke.MethodHandle.DEBUG_NAMES=true -Dnashorn.home=`dirname $0`/.. -Djava.security.manager jdk.nashorn.tools.Shell $* +$JAVA_HOME/bin/java -Xms2G -Xmx2G -XX:-TieredCompilation -server -esa -ea -Djava.security.properties=`dirname $0`/../make/java.security.override -Djava.ext.dirs=`dirname $0`/../dist:$JAVA_HOME/jre/lib/ext -XX:+HeapDumpOnOutOfMemoryError -Dnashorn.debug=true -Djava.lang.invoke.MethodHandle.DEBUG_NAMES=true -Dnashorn.home=`dirname $0`/.. -Djava.security.manager jdk.nashorn.tools.Shell $* diff --git a/nashorn/bin/nashorn b/nashorn/bin/nashorn index 3fccdd04c72..da22be1fb01 100644 --- a/nashorn/bin/nashorn +++ b/nashorn/bin/nashorn @@ -26,4 +26,4 @@ [ -z "$JAVA_HOME" ] && echo "Please set JAVA_HOME" && exit 1; -$JAVA_HOME/bin/jrunscript -J-Xms2G -J-Xmx2G -J-XX:-TieredCompilation -J-server -J-esa -J-ea -J-Djava.ext.dirs=$JAVA_HOME/jre/lib/ext:`dirname $0`/../dist -J-XX:+HeapDumpOnOutOfMemoryError -J-Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -J-Dnashorn.debug=true -l nashorn $* +$JAVA_HOME/bin/jrunscript -J-Xms2G -J-Xmx2G -J-XX:-TieredCompilation -J-server -J-esa -J-ea -J-Djava.ext.dirs=`dirname $0`/../dist:$JAVA_HOME/jre/lib/ext -J-XX:+HeapDumpOnOutOfMemoryError -J-Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -J-Dnashorn.debug=true -l nashorn $* diff --git a/nashorn/bin/nashornsecure b/nashorn/bin/nashornsecure index 3d02c5293e5..77c7c52933a 100644 --- a/nashorn/bin/nashornsecure +++ b/nashorn/bin/nashornsecure @@ -26,4 +26,4 @@ [ -z "$JAVA_HOME" ] && echo "Please set JAVA_HOME" && exit 1; -$JAVA_HOME/bin/jrunscript -J-Djava.security.properties=`dirname $0`/../make/java.security.override -J-Djava.security.manager -J-Xms2G -J-Xmx2G -J-XX:-TieredCompilation -J-server -J-esa -J-ea -J-Djava.ext.dirs=$JAVA_HOME/jre/lib/ext:`dirname $0`/../dist -J-XX:+HeapDumpOnOutOfMemoryError -J-Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -J-Dnashorn.debug=true -l nashorn $* +$JAVA_HOME/bin/jrunscript -J-Djava.security.properties=`dirname $0`/../make/java.security.override -J-Djava.security.manager -J-Xms2G -J-Xmx2G -J-XX:-TieredCompilation -J-server -J-esa -J-ea -J-Djava.ext.dirs=`dirname $0`/../dist:$JAVA_HOME/jre/lib/ext -J-XX:+HeapDumpOnOutOfMemoryError -J-Djava.lang.invoke.MethodHandle.DEBUG_NAMES=false -J-Dnashorn.debug=true -l nashorn $* diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index 4fa6033c11f..55967bb04d4 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.lang.reflect.Method; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; @@ -179,14 +180,14 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } private T getInterfaceInner(final Object self, final Class clazz) { - final Object realSelf; + final ScriptObject realSelf; final ScriptObject ctxtGlobal = getNashornGlobalFrom(context); if(self == null) { realSelf = ctxtGlobal; } else if (!(self instanceof ScriptObject)) { - realSelf = ScriptObjectMirror.unwrap(self, ctxtGlobal); + realSelf = (ScriptObject)ScriptObjectMirror.unwrap(self, ctxtGlobal); } else { - realSelf = self; + realSelf = (ScriptObject)self; } try { final ScriptObject oldGlobal = getNashornGlobal(); @@ -194,6 +195,10 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C if(oldGlobal != ctxtGlobal) { setNashornGlobal(ctxtGlobal); } + + if (! isInterfaceImplemented(clazz, realSelf)) { + return null; + } return clazz.cast(JavaAdapterFactory.getConstructor(realSelf.getClass(), clazz).invoke(realSelf)); } finally { if(oldGlobal != ctxtGlobal) { @@ -463,6 +468,21 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } } + private static boolean isInterfaceImplemented(final Class iface, final ScriptObject sobj) { + for (final Method method : iface.getMethods()) { + // ignore methods of java.lang.Object class + if (method.getDeclaringClass() == Object.class) { + continue; + } + + Object obj = sobj.get(method.getName()); + if (! (obj instanceof ScriptFunction)) { + return false; + } + } + return true; + } + // don't make this public!! static ScriptObject getNashornGlobal() { return Context.getGlobal(); diff --git a/nashorn/test/script/basic/JDK-8010199.js b/nashorn/test/script/basic/JDK-8010199.js new file mode 100644 index 00000000000..ddd3ba0ff25 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8010199.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * JDK-8010199: javax.script.Invocable implementation for nashorn does not return null when matching functions are missing + * + * @test + * @run + */ + +var m = new javax.script.ScriptEngineManager(); +var e = m.getEngineByName("nashorn"); + +var iface = e.getInterface(java.lang.Runnable.class); + +if (iface != null) { + fail("Expected interface object to be null"); +} + +e.eval("var runcalled = false; function run() { runcalled = true }"); + +iface = e.getInterface(java.lang.Runnable.class); +if (iface == null) { + fail("Expected interface object to be non-null"); +} + +iface.run(); + +if (e.get("runcalled") != true) { + fail("runcalled is not true"); +} diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index 0994b0d26ca..48277aa8ab1 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -283,6 +283,68 @@ public class ScriptEngineTest { } } + public interface Foo { + public void bar(); + } + + public interface Foo2 extends Foo { + public void bar2(); + } + + @Test + public void getInterfaceMissingTest() { + final ScriptEngineManager manager = new ScriptEngineManager(); + final ScriptEngine engine = manager.getEngineByName("nashorn"); + + // don't define any function. + try { + engine.eval(""); + } catch (final Exception exp) { + exp.printStackTrace(); + fail(exp.getMessage()); + } + + Runnable runnable = ((Invocable)engine).getInterface(Runnable.class); + if (runnable != null) { + fail("runnable is not null!"); + } + + // now define "run" + try { + engine.eval("function run() { print('this is run function'); }"); + } catch (final Exception exp) { + exp.printStackTrace(); + fail(exp.getMessage()); + } + runnable = ((Invocable)engine).getInterface(Runnable.class); + // should not return null now! + runnable.run(); + + // define only one method of "Foo2" + try { + engine.eval("function bar() { print('bar function'); }"); + } catch (final Exception exp) { + exp.printStackTrace(); + fail(exp.getMessage()); + } + + Foo2 foo2 = ((Invocable)engine).getInterface(Foo2.class); + if (foo2 != null) { + throw new RuntimeException("foo2 is not null!"); + } + + // now define other method of "Foo2" + try { + engine.eval("function bar2() { print('bar2 function'); }"); + } catch (final Exception exp) { + exp.printStackTrace(); + fail(exp.getMessage()); + } + foo2 = ((Invocable)engine).getInterface(Foo2.class); + foo2.bar(); + foo2.bar2(); + } + @Test public void accessGlobalTest() { final ScriptEngineManager m = new ScriptEngineManager(); From 1e9182453523e3f06de11864dfc0aa75a0270ffb Mon Sep 17 00:00:00 2001 From: Peter Jensen Date: Mon, 18 Mar 2013 08:46:09 -0700 Subject: [PATCH 017/155] 8005220: RFE to write javap tests for repeating annotations Reviewed-by: jjg --- .../output/RepeatingTypeAnnotations.java | 400 ++++++++++++++++++ langtools/test/tools/javap/output/Tester.java | 389 +++++++++++++++++ 2 files changed, 789 insertions(+) create mode 100644 langtools/test/tools/javap/output/RepeatingTypeAnnotations.java create mode 100644 langtools/test/tools/javap/output/Tester.java diff --git a/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java b/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java new file mode 100644 index 00000000000..706f9d9b105 --- /dev/null +++ b/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2013, 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 8005220 + * @summary javap must display repeating annotations + */ +import java.io.*; +import java.util.*; + +/** + * This class extends the abstract {@link Tester} test-driver, and + * encapusulates a number of test-case classes (i.e. classes extending + * this class and annotated with {@code TestCase}). + *

    + * By default (no argument), this test runs all test-cases, except + * if annotated with {@code ignore}. + *

    + * Individual test cases can be executed using a run action. + *

    + * Example: @run main RepeatingTypeAnnotations RepeatingTypeAnnotations$TC4 + *

    + * Note: when specific test-cases are run, additional debug output is + * produced to help debugging. Test annotated with {@code ignore} + * can be executed explicitly. + */ +public class RepeatingTypeAnnotations extends Tester { + + /** + * Main method instantiates test and run test-cases. + */ + public static void main(String... args) throws Exception { + Tester tester = new RepeatingTypeAnnotations(); + tester.run(args); + } + + /** + * Testcases are classes extending {@code RepeatingTypeAnnotations}, + * and calling {@link setSrc}, followed by one or more invocations + * of {@link verify} in the body of the constructor. + */ + public RepeatingTypeAnnotations() { + setSrc(new TestSource(template)); + } + + /** + * Common template for test cases. The line TESTCASE is + * replaced with the specific lines of individual tests. + */ + private static final String[] template = { + "import java.lang.annotation.*;", + "class Test {", + " @Repeatable(As.class)", + " @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})", + " @Retention(RetentionPolicy.CLASS)", + " @interface A {", + " Class f() default int.class;", + " }", + + " @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})", + " @Retention(RetentionPolicy.CLASS)", + " @interface As { A[] value(); }", + + " @Repeatable(Bs.class)", + " @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})", + " @Retention(RetentionPolicy.CLASS)", + " @interface B {", + " Class f() default int.class;", + " }", + + " @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})", + " @Retention(RetentionPolicy.CLASS)", + " @interface Bs { B[] value(); }", + + " @Repeatable(Cs.class)", + " @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})", + " @Retention(RetentionPolicy.RUNTIME)", + " @interface C {", + " Class f() default int.class;", + " }", + + " @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})", + " @Retention(RetentionPolicy.RUNTIME)", + " @interface Cs { C[] value(); }", + "TESTCASE", + "}" + }; + + /* + * The test cases covers annotation in the following locations: + * - static and non-static fields + * - local variables + * - constructor and method return type and parameter types + * - casts in class and method contexts. + * For the above locations the test-cases covers: + * - single annotation type + * - two annotation types with same retention + * - two annotation types with different retention + * - three annotation types, two of same retention, one different. + */ + + @TestCase + @ignore // 8008082:missing type annotation for cast + public static class TC1 extends RepeatingTypeAnnotations { + public TC1() { + setSrc(" static String so = \"hello world\";", + " public @A @A @A Object o = (@A @A @A String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #25(#26=[@#27(),@#27(),@#27()]): FIELD", + "1: #25(#26=[@#27(),@#27(),@#27()]): CAST, offset=5"); + } + } + + @TestCase + public static class TC2 extends RepeatingTypeAnnotations { + public TC2() { + setSrc(" static String so = \"hello world\";", + " public @A @B @A Object o = (@B @A @B String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #25(#26=[@#27(),@#27()]): FIELD", + "1: #28(): FIELD", + "2: #29(#26=[@#28(),@#28()]): CAST, offset=5", + "3: #27(): CAST, offset=5"); + } + } + + @TestCase + public static class TC3 extends RepeatingTypeAnnotations { + public TC3() { + setSrc(" static String so = \"hello world\";", + " public @A @A @C Object o = (@B @C @B String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #25(): FIELD", + "1: #25(): CAST, offset=5", + "RuntimeVisibleTypeAnnotations", + "0: #27(#28=[@#29(),@#29()]): FIELD", + "1: #30(#28=[@#31(),@#31()]): CAST, offset=5"); + } + } + + @TestCase + public static class TC4 extends RepeatingTypeAnnotations { + public TC4() { + setSrc(" static String so = \"hello world\";", + " public @A @B @C Object o = (@C @B @A String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #25(): FIELD", + "1: #25(): CAST, offset=5", + "0: #27(): FIELD", + "1: #28(): FIELD", + "2: #28(): CAST, offset=5", + "3: #27(): CAST, offset=5"); + } + } + + @TestCase + @ignore // 8008082:missing type annotation for cast + public static class TC5 extends RepeatingTypeAnnotations { + public TC5() { + setSrc(" static String so = \"hello world\";", + " public static @A @A @A Object o = (@B @B @B String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #25(#26=[@#27(),@#27(),@#27()]): FIELD", + "1: #28(#26=[@#29(),@#29(),@#29()]): CAST, offset=5, type_index=0"); + } + } + + @TestCase + public static class TC6 extends RepeatingTypeAnnotations { + public TC6() { + setSrc(" static String so = \"hello world\";", + " public static @A @B @A Object o = (@B @A @B String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #25(#26=[@#27(),@#27()]): FIELD", + "1: #28(): FIELD", + "2: #29(#26=[@#28(),@#28()]): CAST, offset=5", + "3: #27(): CAST, offset=5"); + } + } + + @TestCase + public static class TC7 extends RepeatingTypeAnnotations { + public TC7() { + setSrc(" static String so = \"hello world\";", + " public static @A @A @C Object o = (@B @C @B String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #25(): FIELD", + "1: #25(): CAST, offset=5", + "0: #27(#28=[@#29(),@#29()]): FIELD", + "1: #30(#28=[@#31(),@#31()]): CAST, offset=5"); + } + } + + @TestCase + public static class TC8 extends RepeatingTypeAnnotations { + public TC8() { + setSrc(" static String so = \"hello world\";", + " public static @A @B @C Object o = (@C @B @A String) Test.so;"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #25(): FIELD", + "1: #25(): CAST, offset=5", + "0: #27(): FIELD", + "1: #28(): FIELD", + "2: #28(): CAST, offset=5", + "3: #27(): CAST, offset=5"); + } + } + + @TestCase + @ignore // 8008082:missing type annotation for cast + public static class TC9 extends RepeatingTypeAnnotations { + public TC9() { + setSrc(" public Test(@A @A @A Object o, @A int i, long l) {", + " @A @A @A String ls = (@B @B @B String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #34(#35=[@#36(),@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0", + "1: #36(): METHOD_FORMAL_PARAMETER, param_index=1", + "2: #37(#35=[@#38(),@#38(),@#38()]): CAST, offset=4, type_index=0", + "3: #34(#35=[@#36(),@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}"); + } + } + + @TestCase + public static class TC10 extends RepeatingTypeAnnotations { + public TC10() { + setSrc(" public Test(@A @A @B Object o, @A @B int i, long l) {", + " @A @A @B String ls = (@B @A @B String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations:", + "0: #34(#35=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0", + "1: #37(): METHOD_FORMAL_PARAMETER, param_index=0", + "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1", + "3: #37(): METHOD_FORMAL_PARAMETER, param_index=1", + "4: #38(#35=[@#37(),@#37()]): CAST, offset=4, type_index=0", + "5: #36(): CAST, offset=4, type_index=0", + "6: #34(#35=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}", + "7: #37(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}"); + } + } + + @TestCase + public static class TC11 extends RepeatingTypeAnnotations { + public TC11() { + setSrc(" public Test(@C @C @A Object o, @A @B int i, long l) {", + " @C @C @A String ls = (@A @A @C String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #34(#35=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0", + "1: #36(): CAST, offset=4", + "2: #34(#35=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}", + "0: #38(): METHOD_FORMAL_PARAMETER, param_index=0", + "1: #38(): METHOD_FORMAL_PARAMETER, param_index=1", + "2: #39(): METHOD_FORMAL_PARAMETER, param_index=1", + "3: #40(#35=[@#38(),@#38()]): CAST, offset=4", + "4: #38(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}"); + } + } + + @TestCase + public static class TC12 extends RepeatingTypeAnnotations { + public TC12() { + setSrc(" public Test(@A @B @C Object o, @A @C int i, long l) {", + " @A @B @C String ls = (@C @A @B String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #34(): METHOD_FORMAL_PARAMETER, param_index=0", + "1: #34(): METHOD_FORMAL_PARAMETER, param_index=1", + "2: #34(): CAST, offset=4", + "3: #34(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}", + "0: #36(): METHOD_FORMAL_PARAMETER, param_index=0", + "1: #37(): METHOD_FORMAL_PARAMETER, param_index=0", + "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1", + "3: #36(): CAST, offset=4", + "4: #37(): CAST, offset=4", + "5: #36(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}", + "6: #37(): LOCAL_VARIABLE, {start_pc=10, length=1, index=5}"); + } + } + + @TestCase + @ignore // 8008082:missing type annotation for cast + public static class TC13 extends RepeatingTypeAnnotations { + public TC13() { + setSrc(" public @A @A @A String foo(@A @A @A Object o, @A int i, long l) {", + " @A @A @A String ls = (@B @B @B String) o;", + " return (@A @A @A String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #36(#37=[@#38(),@#38(),@#38()]): METHOD_RETURN", + "1: #36(#37=[@#38(),@#38(),@#38()]): METHOD_FORMAL_PARAMETER, param_index=0", + "2: #38(): METHOD_FORMAL_PARAMETER, param_index=1", + "3: #39(#37=[@#40(),@#40(),@#40()]): CAST, offset=0, type_index=0", + "4: #36(#37=[@#38(),@#38(),@#38()]): CAST, offset=6, type_index=0", + "5: #36(#37=[@#38(),@#38(),@#38()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}"); + } + } + + @TestCase + public static class TC14 extends RepeatingTypeAnnotations { + public TC14() { + setSrc(" public @A @B @B String foo(@A @A @B Object o, @A @B int i, long l) {", + " @A @A @B String ls = (@B @A @B String) o;", + " return (@A @B @B String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "0: #36(): METHOD_RETURN", + "1: #37(#38=[@#39(),@#39()]): METHOD_RETURN", + "2: #40(#38=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0", + "3: #39(): METHOD_FORMAL_PARAMETER, param_index=0", + "4: #36(): METHOD_FORMAL_PARAMETER, param_index=1", + "5: #39(): METHOD_FORMAL_PARAMETER, param_index=1", + "6: #37(#38=[@#39(),@#39()]): CAST, offset=0", + "7: #36(): CAST, offset=0", + "8: #36(): CAST, offset=6", + "9: #37(#38=[@#39(),@#39()]): CAST, offset=6", + "10: #40(#38=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}", + "11: #39(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}"); + } + } + + @TestCase + public static class TC15 extends RepeatingTypeAnnotations { + public TC15() { + setSrc(" public @A @A @C String foo(@C @C @A Object o, @A @B int i, long l) {", + " @C @C @A String ls = (@A @A @C String) o;", + " return (@C @B @B String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #36(): METHOD_RETURN", + "1: #37(#38=[@#36(),@#36()]): METHOD_FORMAL_PARAMETER, param_index=0", + "2: #36(): CAST, offset=0", + "3: #36(): CAST, offset=6", + "4: #37(#38=[@#36(),@#36()]): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}", + "0: #40(#38=[@#41(),@#41()]): METHOD_RETURN", + "1: #41(): METHOD_FORMAL_PARAMETER, param_index=0", + "2: #41(): METHOD_FORMAL_PARAMETER, param_index=1", + "3: #42(): METHOD_FORMAL_PARAMETER, param_index=1", + "4: #40(#38=[@#41(),@#41()]): CAST, offset=0", + "5: #43(#38=[@#42(),@#42()]): CAST, offset=6", + "6: #41(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}"); + } + } + + @TestCase + public static class TC16 extends RepeatingTypeAnnotations { + public TC16() { + setSrc(" public @A @B @C String foo(@A @B @C Object o, @A @C int i, long l) {", + " @A @B @C String ls = (@C @A @B String) o;", + " return (@B @A @C String) o;", + " }"); + verify("RuntimeInvisibleTypeAnnotations", + "RuntimeVisibleTypeAnnotations", + "0: #36(): METHOD_RETURN", + "1: #36(): METHOD_FORMAL_PARAMETER, param_index=0", + "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1", + "3: #36(): CAST, offset=0", + "4: #36(): CAST, offset=6", + "5: #36(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}", + "0: #38(): METHOD_RETURN", + "1: #39(): METHOD_RETURN", + "2: #38(): METHOD_FORMAL_PARAMETER, param_index=0", + "3: #39(): METHOD_FORMAL_PARAMETER, param_index=0", + "4: #38(): METHOD_FORMAL_PARAMETER, param_index=1", + "5: #38(): CAST, offset=0", + "6: #39(): CAST, offset=0", + "7: #39(): CAST, offset=6", + "8: #38(): CAST, offset=6", + "9: #38(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}", + "10: #39(): LOCAL_VARIABLE, {start_pc=6, length=5, index=5}"); + } + } +} diff --git a/langtools/test/tools/javap/output/Tester.java b/langtools/test/tools/javap/output/Tester.java new file mode 100644 index 00000000000..e0d4cb5820c --- /dev/null +++ b/langtools/test/tools/javap/output/Tester.java @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.io.*; +import java.util.*; +import java.lang.annotation.*; +import java.lang.reflect.InvocationTargetException; + +/** + * {@code Tester} is an abstract test-driver that provides the logic + * to execute test-cases, grouped by test classes. + * A test class is a main class extending this class, that instantiate + * itself, and calls the {@link run} method, passing any command line + * arguments. + *

    + * The {@code run} method, expects arguments to identify test-case classes. + * A test-case class is a class extending the test class, and annotated + * with {@code TestCase}. + *

    + * If no test-cases are specified, the test class directory is searched for + * co-located test-case classes (i.e. any class extending the test class, + * annotated with {@code TestCase}). + *

    + * Besides serving to group test-cases, extending the driver allow + * setting up a test-case template, and possibly overwrite default + * test-driver behaviour. + */ +public abstract class Tester { + + private static boolean debug = false; + private static final PrintStream out = System.err; + private static final PrintStream err = System.err; + + + protected void run(String... args) throws Exception { + + final File classesdir = new File(System.getProperty("test.classes", ".")); + + String[] classNames = args; + + // If no test-cases are specified, we regard all co-located classes + // as potential test-cases. + if (args.length == 0) { + final String pattern = ".*\\.class"; + final File classFiles[] = classesdir.listFiles(new FileFilter() { + public boolean accept(File f) { + return f.getName().matches(pattern); + } + }); + ArrayList names = new ArrayList(classFiles.length); + for (File f : classFiles) { + String fname = f.getName(); + names.add(fname.substring(0, fname.length() -6)); + } + classNames = names.toArray(new String[names.size()]); + } else { + debug = true; + } + // Test-cases must extend the driver type, and be marked + // @TestCase. Other arguments (classes) are ignored. + // Test-cases are instantiated, and thereby executed. + for (String clname : classNames) { + try { + final Class tclass = Class.forName(clname); + if (!getClass().isAssignableFrom(tclass)) continue; + TestCase anno = (TestCase) tclass.getAnnotation(TestCase.class); + if (anno == null) continue; + if (!debug) { + ignore i = (ignore) tclass.getAnnotation(ignore.class); + if (i != null) { + out.println("Ignore: " + clname); + ignored++; + continue; + } + } + out.println("TestCase: " + clname); + cases++; + Tester tc = (Tester) tclass.getConstructor().newInstance(); + if (tc.errors > 0) { + error("" + tc.errors + " test points failed in " + clname); + errors += tc.errors - 1; + fcases++; + } + } catch(ReflectiveOperationException roe) { + error("Warning: " + clname + " - ReflectiveOperationException"); + roe.printStackTrace(err); + } catch(Exception unknown) { + error("Warning: " + clname + " - uncaught exception"); + unknown.printStackTrace(err); + } + } + + String imsg = ignored > 0 ? " (" + ignored + " ignored)" : ""; + if (errors > 0) + throw new Error(errors + " error, in " + fcases + " of " + cases + " test-cases" + imsg); + else + err.println("" + cases + " test-cases executed" + imsg + ", no errors"); + } + + + /** + * Test-cases must be marked with the {@code TestCase} annotation, + * as well as extend {@code Tester} (or an driver extension + * specified as the first argument to the {@code main()} method. + */ + @Retention(RetentionPolicy.RUNTIME) + @interface TestCase { } + + /** + * Individual test-cases failing due to product bugs, may temporarily + * be excluded by marking them like this: + * @ignore // 1234567:bug synopsis + */ + @Retention(RetentionPolicy.RUNTIME) + @interface ignore { } + + /** + * Test-cases are classes extending {@code Tester}, and + * calling {@link setSrc}, followed by one or more invocations + * of {@link verify} in the body of the constructor. + *

    + * Sets a default test-case template, which is empty except + * for a key of {@code "TESTCASE"}. + * Subclasses will typically call {@code setSrc(TestSource)} + * to setup a useful test-case template. + */ + public Tester() { + this.testCase = this.getClass().getName(); + src = new TestSource("TESTCASE"); + } + + /** + * Set the top-level source template. + */ + protected Tester setSrc(TestSource src) { + this.src = src; + return this; + } + + /** + * Convenience method for calling {@code innerSrc("TESTCASE", ...)}. + */ + protected Tester setSrc(String... lines) { + return innerSrc("TESTCASE", lines); + } + + /** + * Convenience method for calling {@code innerSrc(key, new TestSource(...))}. + */ + protected Tester innerSrc(String key, String... lines) { + return innerSrc(key, new TestSource(lines)); + } + + /** + * Specialize the testcase template, setting replacement content + * for the specified key. + */ + protected Tester innerSrc(String key, TestSource content) { + if (src == null) { + src = new TestSource(key); + } + src.setInner(key, content); + return this; + } + + /** + * On the first invocation, call {@code execute()} to compile + * the test-case source and process the resulting class(se) + * into verifiable output. + *

    + * Verify that the output matches each of the regular expressions + * given as argument. + *

    + * Any failure to match constitutes a test failure, but doesn't + * abort the test-case. + *

    + * Any exception (e.g. bad regular expression syntax) results in + * a test failure, and aborts the test-case. + */ + protected void verify(String... expect) { + if (!didExecute) { + try { + execute(); + } catch(Exception ue) { + throw new Error(ue); + } finally { + didExecute = true; + } + } + if (output == null) { + error("output is null"); + return; + } + for (String e: expect) { + // Escape regular expressions (to allow input to be literals). + // Notice, characters to be escaped are themselves identified + // using regular expressions + String rc[] = { "(", ")", "[", "]", "{", "}", "$" }; + for (String c : rc) { + e = e.replace(c, "\\" + c); + } + // DEBUG: Uncomment this to test modulo constant pool index. + // e = e.replaceAll("#[0-9]{2}", "#[0-9]{2}"); + if (!output.matches("(?s).*" + e + ".*")) { + if (!didPrint) { + out.println(output); + didPrint = true; + } + error("not matched: '" + e + "'"); + } else if(debug) { + out.println("matched: '" + e + "'"); + } + } + } + + /** + * Calls {@code writeTestFile()} to write out the test-case source + * content to a file, then call {@code compileTestFile()} to + * compile it, and finally run the {@link process} method to produce + * verifiable output. The default {@code process} method runs javap. + *

    + * If an exception occurs, it results in a test failure, and + * aborts the test-case. + */ + protected void execute() throws IOException { + err.println("TestCase: " + testCase); + writeTestFile(); + compileTestFile(); + process(); + } + + /** + * Generate java source from test-case. + * TBD: change to use javaFileObject, possibly make + * this class extend JavaFileObject. + */ + protected void writeTestFile() throws IOException { + javaFile = new File("Test.java"); + FileWriter fw = new FileWriter(javaFile); + BufferedWriter bw = new BufferedWriter(fw); + PrintWriter pw = new PrintWriter(bw); + for (String line : src) { + pw.println(line); + if (debug) out.println(line); + } + pw.close(); + } + + /** + * Compile the Java source code. + */ + protected void compileTestFile() { + String path = javaFile.getPath(); + String params[] = { "-source", "1.8", "-g", path }; + int rc = com.sun.tools.javac.Main.compile(params); + if (rc != 0) + throw new Error("compilation failed. rc=" + rc); + classFile = new File(path.substring(0, path.length() - 5) + ".class"); + } + + + /** + * Process class file to generate output for verification. + * The default implementation simply runs javap. This might be + * overwritten to generate output in a different manner. + */ + protected void process() { + String testClasses = "."; //System.getProperty("test.classes", "."); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = { "-v", "-classpath", testClasses, "Test" }; + int rc = com.sun.tools.javap.Main.run(args, pw); + if (rc != 0) + throw new Error("javap failed. rc=" + rc); + pw.close(); + output = sw.toString(); + if (debug) { + out.println(output); + didPrint = true; + } + + } + + + private String testCase; + private TestSource src; + private File javaFile = null; + private File classFile = null; + private String output = null; + private boolean didExecute = false; + private boolean didPrint = false; + + + protected void error(String msg) { + err.println("Error: " + msg); + errors++; + } + + private int cases; + private int fcases; + private int errors; + private int ignored; + + /** + * The TestSource class provides a simple container for + * test cases. It contains an array of source code lines, + * where zero or more lines may be markers for nested lines. + * This allows representing templates, with specialization. + *

    + * This may be generalized to support more advance combo + * tests, but presently it's only used with a static template, + * and one level of specialization. + */ + public class TestSource implements Iterable { + + private String[] lines; + private Hashtable innerSrc; + + public TestSource(String... lines) { + this.lines = lines; + innerSrc = new Hashtable(); + } + + public void setInner(String key, TestSource inner) { + innerSrc.put(key, inner); + } + + public void setInner(String key, String... lines) { + innerSrc.put(key, new TestSource(lines)); + } + + public Iterator iterator() { + return new LineIterator(); + } + + private class LineIterator implements Iterator { + + int nextLine = 0; + Iterator innerIt = null; + + public boolean hasNext() { + return nextLine < lines.length; + } + + public String next() { + if (!hasNext()) throw new NoSuchElementException(); + String str = lines[nextLine]; + TestSource inner = innerSrc.get(str); + if (inner == null) { + nextLine++; + return str; + } + if (innerIt == null) { + innerIt = inner.iterator(); + } + if (innerIt.hasNext()) { + return innerIt.next(); + } + innerIt = null; + nextLine++; + return next(); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + } + } +} From 0e8a3df6c7b5f06cca8dfcdc6c8be6ac90b169cd Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 18 Mar 2013 14:40:32 -0700 Subject: [PATCH 018/155] 8008425: Remove interim new javax.lang.model API for type-annotations Reviewed-by: darcy --- .../com/sun/tools/javac/code/Type.java | 29 +++-- .../sun/tools/javac/code/TypeAnnotations.java | 4 +- .../com/sun/tools/javac/code/Types.java | 2 +- .../com/sun/tools/javac/comp/Attr.java | 2 +- .../com/sun/tools/javac/model/JavacTypes.java | 24 ---- .../javadoc/ExecutableMemberDocImpl.java | 2 +- .../com/sun/tools/javadoc/TypeMaker.java | 6 +- .../sun/tools/javadoc/TypeVariableImpl.java | 4 +- .../javax/lang/model/type/AnnotatedType.java | 48 -------- .../javax/lang/model/type/ExecutableType.java | 8 -- .../javax/lang/model/type/TypeKind.java | 9 +- .../javax/lang/model/type/TypeVisitor.java | 10 -- .../lang/model/util/AbstractTypeVisitor6.java | 17 --- .../classes/javax/lang/model/util/Types.java | 112 ------------------ 14 files changed, 30 insertions(+), 247 deletions(-) delete mode 100644 langtools/src/share/classes/javax/lang/model/type/AnnotatedType.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java index 3da9564dcd6..23e99329ba7 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java @@ -246,6 +246,10 @@ public class Type implements PrimitiveType { return this; } + public boolean isAnnotated() { + return false; + } + /** * If this is an annotated type, return the underlying type. * Otherwise, return the type itself. @@ -1539,7 +1543,12 @@ public class Type implements PrimitiveType { } public static class AnnotatedType extends Type - implements javax.lang.model.type.AnnotatedType { + implements + javax.lang.model.type.ArrayType, + javax.lang.model.type.DeclaredType, + javax.lang.model.type.PrimitiveType, + javax.lang.model.type.TypeVariable, + javax.lang.model.type.WildcardType { /** The type annotations on this type. */ public List typeAnnotations; @@ -1552,7 +1561,7 @@ public class Type implements PrimitiveType { super(underlyingType.tag, underlyingType.tsym); this.typeAnnotations = List.nil(); this.underlyingType = underlyingType; - Assert.check(underlyingType.getKind() != TypeKind.ANNOTATED, + Assert.check(!underlyingType.isAnnotated(), "Can't annotate already annotated type: " + underlyingType); } @@ -1561,14 +1570,19 @@ public class Type implements PrimitiveType { super(underlyingType.tag, underlyingType.tsym); this.typeAnnotations = typeAnnotations; this.underlyingType = underlyingType; - Assert.check(underlyingType.getKind() != TypeKind.ANNOTATED, + Assert.check(!underlyingType.isAnnotated(), "Can't annotate already annotated type: " + underlyingType + "; adding: " + typeAnnotations); } + @Override + public boolean isAnnotated() { + return true; + } + @Override public TypeKind getKind() { - return TypeKind.ANNOTATED; + return underlyingType.getKind(); } @Override @@ -1576,11 +1590,6 @@ public class Type implements PrimitiveType { return typeAnnotations; } - @Override - public TypeMirror getUnderlyingType() { - return underlyingType; - } - @Override public Type unannotatedType() { return underlyingType; @@ -1593,7 +1602,7 @@ public class Type implements PrimitiveType { @Override public R accept(TypeVisitor v, P p) { - return v.visitAnnotated(this, p); + return underlyingType.accept(v, p); } @Override diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index a7ce49e470f..460f7e339af 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -233,7 +233,7 @@ public class TypeAnnotations { Type.ArrayType arType; { Type touse = type; - if (type.getKind() == TypeKind.ANNOTATED) { + if (type.isAnnotated()) { Type.AnnotatedType atype = (Type.AnnotatedType)type; toreturn = new Type.AnnotatedType(atype.underlyingType); ((Type.AnnotatedType)toreturn).typeAnnotations = atype.typeAnnotations; @@ -252,7 +252,7 @@ public class TypeAnnotations { ListBuffer depth = ListBuffer.lb(); depth = depth.append(TypePathEntry.ARRAY); while (arType.elemtype.hasTag(TypeTag.ARRAY)) { - if (arType.elemtype.getKind() == TypeKind.ANNOTATED) { + if (arType.elemtype.isAnnotated()) { Type.AnnotatedType aelemtype = (Type.AnnotatedType) arType.elemtype; Type.AnnotatedType newAT = new Type.AnnotatedType(aelemtype.underlyingType); tomodify.elemtype = newAT; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index 88f40e3b048..df1e4042143 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2091,7 +2091,7 @@ public class Types { @Override public Type visitAnnotatedType(AnnotatedType t, Boolean recurse) { Type erased = erasure(t.underlyingType, recurse); - if (erased.getKind() == TypeKind.ANNOTATED) { + if (erased.isAnnotated()) { // This can only happen when the underlying type is a // type variable and the upper bound of it is annotated. // The annotation on the type variable overrides the one diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index e6f9e8e0e9f..912f1bd261a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -3362,7 +3362,7 @@ public class Attr extends JCTree.Visitor { Type normOuter = site; if (normOuter.hasTag(CLASS)) { normOuter = types.asEnclosingSuper(site, ownOuter.tsym); - if (site.getKind() == TypeKind.ANNOTATED) { + if (site.isAnnotated()) { // Propagate any type annotations. // TODO: should asEnclosingSuper do this? // Note that the type annotations in site will be updated diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java index 9d8933daa5c..6b3bf941bcb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -333,28 +333,4 @@ public class JavacTypes implements javax.lang.model.util.Types { return results; } - - public List typeAnnotationsOf(TypeMirror type) { - // TODO: these methods can be removed. - return null; // ((Type)type).typeAnnotations; - } - - public A typeAnnotationOf(TypeMirror type, - Class annotationType) { - // TODO: these methods can be removed. - return null; // JavacElements.getAnnotation(((Type)type).typeAnnotations, annotationType); - } - - public TypeMirror receiverTypeOf(ExecutableType type) { - return ((Type)type).asMethodType().recvtype; - } - - /* - public A receiverTypeAnnotationOf( - ExecutableType type, Class annotationType) { - return JavacElements.getAnnotation( - ((Type)type).asMethodType().receiverTypeAnnotations, - annotationType); - }*/ - } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java index a1a741d10ff..2182a832725 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java @@ -205,7 +205,7 @@ public abstract class ExecutableMemberDocImpl if (recvtype == null) { return new AnnotationDesc[0]; } - if (recvtype.getKind() != TypeKind.ANNOTATED) { + if (!recvtype.isAnnotated()) { return new AnnotationDesc[0]; } List typeAnnos = ((com.sun.tools.javac.code.Type.AnnotatedType)recvtype).typeAnnotations; diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java index 4a24e9406a5..098a175878c 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java @@ -65,11 +65,11 @@ public class TypeMaker { t = env.types.erasure(t); } if (considerAnnotations - && t.getKind() == TypeKind.ANNOTATED) { + && t.isAnnotated()) { return new AnnotatedTypeImpl(env, (com.sun.tools.javac.code.Type.AnnotatedType) t); } - if (t.getKind() == TypeKind.ANNOTATED) { + if (t.isAnnotated()) { Type.AnnotatedType at = (Type.AnnotatedType) t; return new AnnotatedTypeImpl(env, at); } @@ -147,7 +147,7 @@ public class TypeMaker { */ static String getTypeString(DocEnv env, Type t, boolean full) { // TODO: should annotations be included here? - if (t.getKind() == TypeKind.ANNOTATED) { + if (t.isAnnotated()) { Type.AnnotatedType at = (Type.AnnotatedType)t; t = at.underlyingType; } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java index 19a5bb9fab4..b6f540f2373 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java @@ -127,7 +127,7 @@ public class TypeVariableImpl extends AbstractTypeImpl implements TypeVariable { final Type upperBound = v.getUpperBound(); Name boundname = upperBound.tsym.getQualifiedName(); if (boundname == boundname.table.names.java_lang_Object - && upperBound.getKind() != TypeKind.ANNOTATED) { + && !upperBound.isAnnotated()) { return List.nil(); } else { return env.types.getBounds(v); @@ -139,7 +139,7 @@ public class TypeVariableImpl extends AbstractTypeImpl implements TypeVariable { * Return an empty array if there are none. */ public AnnotationDesc[] annotations() { - if (type.getKind() != TypeKind.ANNOTATED) { + if (!type.isAnnotated()) { return new AnnotationDesc[0]; } List tas = ((com.sun.tools.javac.code.Type.AnnotatedType) type).typeAnnotations; diff --git a/langtools/src/share/classes/javax/lang/model/type/AnnotatedType.java b/langtools/src/share/classes/javax/lang/model/type/AnnotatedType.java deleted file mode 100644 index c2a27dc6e1a..00000000000 --- a/langtools/src/share/classes/javax/lang/model/type/AnnotatedType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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 javax.lang.model.type; - -import java.util.List; - -import javax.lang.model.element.AnnotationMirror; - -/** - * Represents an annotated type. - * - * As of the {@link javax.lang.model.SourceVersion#RELEASE_8 - * RELEASE_8} source version, annotated types can appear for all - * type uses. - * - * @author Werner Dietl - * @since 1.8 - */ -public interface AnnotatedType extends TypeMirror, - DeclaredType, TypeVariable, WildcardType, - PrimitiveType, ArrayType { - - List getAnnotations(); - TypeMirror getUnderlyingType(); -} diff --git a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java index 9bdccaaefb3..c25ffd0e19e 100644 --- a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java +++ b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java @@ -77,14 +77,6 @@ public interface ExecutableType extends TypeMirror { */ List getParameterTypes(); - /** - * Returns the type of this executable's receiver parameter. - * - * @return the type of this executable's receiver parameter - * TODO: null if none specified or always a valid value? - */ - TypeMirror getReceiverType(); - /** * Returns the exceptions and other throwables listed in this * executable's {@code throws} clause. diff --git a/langtools/src/share/classes/javax/lang/model/type/TypeKind.java b/langtools/src/share/classes/javax/lang/model/type/TypeKind.java index 1a9f11d895e..cd974ceed12 100644 --- a/langtools/src/share/classes/javax/lang/model/type/TypeKind.java +++ b/langtools/src/share/classes/javax/lang/model/type/TypeKind.java @@ -151,14 +151,7 @@ public enum TypeKind { * * @since 1.8 */ - INTERSECTION, - - /** - * An annotated type. - * - * @since 1.8 - */ - ANNOTATED; + INTERSECTION; /** * Returns {@code true} if this kind corresponds to a primitive diff --git a/langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java b/langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java index 2d8674d6512..f51d843d60e 100644 --- a/langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java +++ b/langtools/src/share/classes/javax/lang/model/type/TypeVisitor.java @@ -194,14 +194,4 @@ public interface TypeVisitor { * @since 1.8 */ R visitIntersection(IntersectionType t, P p); - - /** - * Visits an annotated type. - * - * @param t the type to visit - * @param p a visitor-specified parameter - * @return a visitor-specified result - * @since 1.8 - */ - R visitAnnotated(AnnotatedType t, P p); } diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java index 0ae91ef0977..148cc83065a 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java @@ -133,23 +133,6 @@ public abstract class AbstractTypeVisitor6 implements TypeVisitor { return visitUnknown(t, p); } - /** - * Visits an {@code AnnotatedType} element by calling {@code - * visit} on the underlying type. - - * @param t {@inheritDoc} - * @param p {@inheritDoc} - * @return the result of calling {@code visit} on the underlying type - * - * @since 1.8 - * - * TODO: should xxxVisitor8 subclasses override this and call - * the defaultAction? - */ - public R visitAnnotated(AnnotatedType t, P p) { - return visit(t.getUnderlyingType(), p); - } - /** * {@inheritDoc} * diff --git a/langtools/src/share/classes/javax/lang/model/util/Types.java b/langtools/src/share/classes/javax/lang/model/util/Types.java index 7e41ddf70cd..89f197b98ea 100644 --- a/langtools/src/share/classes/javax/lang/model/util/Types.java +++ b/langtools/src/share/classes/javax/lang/model/util/Types.java @@ -301,116 +301,4 @@ public interface Types { * for the given type */ TypeMirror asMemberOf(DeclaredType containing, Element element); - - /** - * Returns the annotations targeting the type. - * - * @param type the targeted type - * @return the type annotations targeting the type - */ - List typeAnnotationsOf(TypeMirror type); - - /** - * Returns the type's annotation for the specified type if - * such an annotation is present, else {@code null}. The - * annotation has to be directly present on this - * element. - * - *

    The annotation returned by this method could contain an element - * whose value is of type {@code Class}. - * This value cannot be returned directly: information necessary to - * locate and load a class (such as the class loader to use) is - * not available, and the class might not be loadable at all. - * Attempting to read a {@code Class} object by invoking the relevant - * method on the returned annotation - * will result in a {@link MirroredTypeException}, - * from which the corresponding {@link TypeMirror} may be extracted. - * Similarly, attempting to read a {@code Class[]}-valued element - * will result in a {@link MirroredTypesException}. - * - *

    - * Note: This method is unlike others in this and related - * interfaces. It operates on runtime reflective information — - * representations of annotation types currently loaded into the - * VM — rather than on the representations defined by and used - * throughout these interfaces. Consequently, calling methods on - * the returned annotation object can throw many of the exceptions - * that can be thrown when calling methods on an annotation object - * returned by core reflection. This method is intended for - * callers that are written to operate on a known, fixed set of - * annotation types. - *
    - * - * @param the annotation type - * @param type the targeted type - * @param annotationType the {@code Class} object corresponding to - * the annotation type - * @return the type's annotation for the specified annotation - * type if present on the type, else {@code null} - * - * @see Element#getAnnotationMirrors() - * @see EnumConstantNotPresentException - * @see AnnotationTypeMismatchException - * @see IncompleteAnnotationException - * @see MirroredTypeException - * @see MirroredTypesException - */ - A typeAnnotationOf(TypeMirror type, Class annotationType); - - /** - * Returns the annotations targeting the method receiver type. - * - * @param type the targeted type - * @return the receiver type of the executable type - */ - TypeMirror receiverTypeOf(ExecutableType type); - - /** - * Returns the type's annotation for the specified executable type - * receiver if such an annotation is present, else {@code null}. The - * annotation has to be directly present on this - * element. - * - *

    The annotation returned by this method could contain an element - * whose value is of type {@code Class}. - * This value cannot be returned directly: information necessary to - * locate and load a class (such as the class loader to use) is - * not available, and the class might not be loadable at all. - * Attempting to read a {@code Class} object by invoking the relevant - * method on the returned annotation - * will result in a {@link MirroredTypeException}, - * from which the corresponding {@link TypeMirror} may be extracted. - * Similarly, attempting to read a {@code Class[]}-valued element - * will result in a {@link MirroredTypesException}. - * - *

    - * Note: This method is unlike others in this and related - * interfaces. It operates on runtime reflective information — - * representations of annotation types currently loaded into the - * VM — rather than on the representations defined by and used - * throughout these interfaces. Consequently, calling methods on - * the returned annotation object can throw many of the exceptions - * that can be thrown when calling methods on an annotation object - * returned by core reflection. This method is intended for - * callers that are written to operate on a known, fixed set of - * annotation types. - *
    - * - * @param
    the annotation type - * @param type the method type - * @param annotationType the {@code Class} object corresponding to - * the annotation type - * @return the type's annotation for the specified annotation - * type if present on the type, else {@code null} - * - * @see Element#getAnnotationMirrors() - * @see EnumConstantNotPresentException - * @see AnnotationTypeMismatchException - * @see IncompleteAnnotationException - * @see MirroredTypeException - * @see MirroredTypesException - */ - // TODO: no longer needed? - // A receiverTypeAnnotationOf(ExecutableType type, Class annotationType); - } From 49d55f9300f027cb1657db262c9eab1ed9f977ba Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 18 Mar 2013 18:33:13 -0700 Subject: [PATCH 019/155] 8007803: Implement javax.lang.model API for Type Annotations Reviewed-by: darcy --- .../com/sun/tools/javac/code/Printer.java | 4 +- .../com/sun/tools/javac/code/Symbol.java | 15 +- .../com/sun/tools/javac/code/Type.java | 43 +- .../com/sun/tools/javac/comp/Attr.java | 2 +- .../javac/model/AnnotationProxyMaker.java | 4 +- .../javac/model/JavacAnnoConstructs.java | 412 ++++++++++++++++++ .../sun/tools/javac/model/JavacElements.java | 236 ---------- .../com/sun/tools/javac/model/JavacTypes.java | 1 - .../javax/lang/model/AnnotatedConstruct.java | 151 +++++++ .../javax/lang/model/element/Element.java | 129 +----- .../lang/model/element/ExecutableElement.java | 21 +- .../javax/lang/model/type/ExecutableType.java | 19 + .../javax/lang/model/type/TypeMirror.java | 6 +- .../classes/javax/lang/model/util/Types.java | 7 + 14 files changed, 678 insertions(+), 372 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java create mode 100644 langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java index af6207f04ef..3a8982f42cc 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java @@ -311,9 +311,9 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi } if (args.head.unannotatedType().getKind() == TypeKind.ARRAY) { buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale)); - if (args.head.getAnnotations().nonEmpty()) { + if (args.head.getAnnotationMirrors().nonEmpty()) { buf.append(' '); - buf.append(args.head.getAnnotations()); + buf.append(args.head.getAnnotationMirrors()); buf.append(' '); } buf.append("..."); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index 3d5b0d03914..97af4174e31 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -483,12 +483,12 @@ public abstract class Symbol implements Element { */ @Deprecated public A getAnnotation(Class annoType) { - return JavacElements.getAnnotation(this, annoType); + return JavacAnnoConstructs.getAnnotation(this, annoType); } // This method is part of the javax.lang.model API, do not use this in javac code. public A[] getAnnotationsByType(Class annoType) { - return JavacElements.getAnnotations(this, annoType); + return JavacAnnoConstructs.getAnnotations(this, annoType); } // TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList @@ -935,11 +935,12 @@ public abstract class Symbol implements Element { } /** - * @deprecated this method should never be used by javac internally. + * Since this method works in terms of the runtime representation + * of annotations, it should never be used by javac internally. */ - @Override @Deprecated + @Override public A getAnnotation(Class annoType) { - return JavacElements.getAnnotation(this, annoType); + return JavacAnnoConstructs.getAnnotation(this, annoType); } public R accept(ElementVisitor v, P p) { @@ -1444,6 +1445,10 @@ public abstract class Symbol implements Element { return v.visitMethodSymbol(this, p); } + public Type getReceiverType() { + return asType().getReceiverType(); + } + public Type getReturnType() { return asType().getReturnType(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java index 23e99329ba7..fb5c433fb90 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java @@ -25,6 +25,9 @@ package com.sun.tools.javac.code; +import com.sun.tools.javac.model.JavacAnnoConstructs; +import com.sun.tools.javac.model.JavacTypes; +import java.lang.annotation.Annotation; import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; @@ -258,6 +261,23 @@ public class Type implements PrimitiveType { return this; } + @Override + public List getAnnotationMirrors() { + return List.nil(); + } + + @Override + public A getAnnotation(Class annotationType) { + return null; + } + + @Override + public A[] getAnnotationsByType(Class annotationType) { + @SuppressWarnings("unchecked") + A[] tmp = (A[]) java.lang.reflect.Array.newInstance(annotationType, 0); + return tmp; + } + /** Return the base types of a list of types. */ public static List baseTypes(List ts) { @@ -354,8 +374,8 @@ public class Type implements PrimitiveType { } if (args.head.unannotatedType().tag == ARRAY) { buf.append(((ArrayType)args.head.unannotatedType()).elemtype); - if (args.head.getAnnotations().nonEmpty()) { - buf.append(args.head.getAnnotations()); + if (args.head.getAnnotationMirrors().nonEmpty()) { + buf.append(args.head.getAnnotationMirrors()); } buf.append("..."); } else { @@ -366,7 +386,6 @@ public class Type implements PrimitiveType { /** Access methods. */ - public List getAnnotations() { return List.nil(); } public List getTypeArguments() { return List.nil(); } public Type getEnclosingType() { return null; } public List getParameterTypes() { return List.nil(); } @@ -1581,13 +1600,23 @@ public class Type implements PrimitiveType { } @Override - public TypeKind getKind() { - return underlyingType.getKind(); + public List getAnnotationMirrors() { + return typeAnnotations; } @Override - public List getAnnotations() { - return typeAnnotations; + public A getAnnotation(Class annotationType) { + return JavacAnnoConstructs.getAnnotation(this, annotationType); + } + + @Override + public A[] getAnnotationsByType(Class annotationType) { + return JavacAnnoConstructs.getAnnotationsByType(this, annotationType); + } + + @Override + public TypeKind getKind() { + return underlyingType.getKind(); } @Override diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 912f1bd261a..e693efe64e5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -4279,7 +4279,7 @@ public class Attr extends JCTree.Visitor { validateAnnotatedType(errtree, type); if (type.tsym != null && type.tsym.isStatic() && - type.getAnnotations().nonEmpty()) { + type.getAnnotationMirrors().nonEmpty()) { // Enclosing static classes cannot have type annotations. log.error(errtree.pos(), "cant.annotate.static.class"); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java b/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java index dd86ec20978..e44f6734b28 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 @@ -273,7 +273,7 @@ public class AnnotationProxyMaker { /** * ExceptionProxy for MirroredTypeException. - * The toString, hashCode, and equals methods foward to the underlying + * The toString, hashCode, and equals methods forward to the underlying * type. */ private static final class MirroredTypeExceptionProxy extends ExceptionProxy { diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java new file mode 100644 index 00000000000..7b9be8ddc99 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java @@ -0,0 +1,412 @@ +/* + * Copyright (c) 2005, 2013, 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 com.sun.tools.javac.model; + +import java.lang.annotation.Annotation; +import java.lang.annotation.Inherited; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import com.sun.tools.javac.code.Attribute; +import com.sun.tools.javac.code.Kinds; +import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Type.AnnotatedType; +import com.sun.tools.javac.util.ListBuffer; +import static com.sun.tools.javac.code.TypeTag.CLASS; + +/** + * Utility methods for operating on annotated constructs. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own + * risk. This code and its internal interfaces are subject to change + * or deletion without notice.

    + */ +public class JavacAnnoConstructs { + + // + + /** + * An internal-use utility that creates a runtime view of an + * annotation. This is the implementation of + * Element.getAnnotation(Class). + */ + public static
    A getAnnotation(Symbol annotated, + Class annoType) { + if (!annoType.isAnnotation()) + throw new IllegalArgumentException("Not an annotation type: " + + annoType); + Attribute.Compound c; + if (annotated.kind == Kinds.TYP && annotated instanceof ClassSymbol) { + c = getAttributeOnClass((ClassSymbol)annotated, annoType); + } else { + c = getAttribute(annotated, annoType); + } + return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType); + } + + // Helper to getAnnotation[s] + private static Attribute.Compound getAttribute(Symbol annotated, + Class annoType) { + String name = annoType.getName(); + + for (Attribute.Compound anno : annotated.getRawAttributes()) { + if (name.equals(anno.type.tsym.flatName().toString())) + return anno; + } + + return null; + } + + // Helper to getAnnotation[s] + private static Attribute.Compound getAttributeOnClass(ClassSymbol annotated, + Class annoType) { + boolean inherited = annoType.isAnnotationPresent(Inherited.class); + Attribute.Compound result = null; + while (annotated.name != annotated.name.table.names.java_lang_Object) { + result = getAttribute(annotated, annoType); + if (result != null || !inherited) + break; + Type sup = annotated.getSuperclass(); + if (!sup.hasTag(CLASS) || sup.isErroneous()) + break; + annotated = (ClassSymbol) sup.tsym; + } + return result; + } + + /** + * An internal-use utility that creates a runtime view of + * annotations. This is the implementation of + * Element.getAnnotations(Class). + */ + public static A[] getAnnotations(Symbol annotated, + Class annoType) { + if (!annoType.isAnnotation()) + throw new IllegalArgumentException("Not an annotation type: " + + annoType); + // If annoType does not declare a container this is equivalent to wrapping + // getAnnotation(...) in an array. + Class containerType = getContainer(annoType); + if (containerType == null) { + A res = getAnnotation(annotated, annoType); + int size; + if (res == null) { + size = 0; + } else { + size = 1; + } + @SuppressWarnings("unchecked") // annoType is the Class for A + A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size); + if (res != null) + arr[0] = res; + return arr; + } + + // So we have a containing type + String name = annoType.getName(); + String annoTypeName = annoType.getSimpleName(); + String containerTypeName = containerType.getSimpleName(); + int directIndex = -1, containerIndex = -1; + Attribute.Compound direct = null, container = null; + Attribute.Compound[] rawAttributes = annotated.getRawAttributes().toArray(new Attribute.Compound[0]); + + // Find directly present annotations + for (int i = 0; i < rawAttributes.length; i++) { + if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) { + directIndex = i; + direct = rawAttributes[i]; + } else if(containerTypeName != null && + containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) { + containerIndex = i; + container = rawAttributes[i]; + } + } + + // Deal with inherited annotations + if (annotated.kind == Kinds.TYP && + (annotated instanceof ClassSymbol)) { + ClassSymbol s = (ClassSymbol)annotated; + if (direct == null && container == null) { + direct = getAttributeOnClass(s, annoType); + container = getAttributeOnClass(s, containerType); + + // both are inherited and found, put container last + if (direct != null && container != null) { + directIndex = 0; + containerIndex = 1; + } else if (direct != null) { + directIndex = 0; + } else { + containerIndex = 0; + } + } else if (direct == null) { + direct = getAttributeOnClass(s, annoType); + if (direct != null) + directIndex = containerIndex + 1; + } else if (container == null) { + container = getAttributeOnClass(s, containerType); + if (container != null) + containerIndex = directIndex + 1; + } + } + + // Pack them in an array + Attribute[] contained0 = new Attribute[0]; + if (container != null) + contained0 = unpackAttributes(container); + ListBuffer compounds = ListBuffer.lb(); + for (Attribute a : contained0) + if (a instanceof Attribute.Compound) + compounds = compounds.append((Attribute.Compound)a); + Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]); + + int size = (direct == null ? 0 : 1) + contained.length; + @SuppressWarnings("unchecked") // annoType is the Class for A + A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size); + + // if direct && container, which is first? + int insert = -1; + int length = arr.length; + if (directIndex >= 0 && containerIndex >= 0) { + if (directIndex < containerIndex) { + arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType); + insert = 1; + } else { + arr[arr.length - 1] = AnnotationProxyMaker.generateAnnotation(direct, annoType); + insert = 0; + length--; + } + } else if (directIndex >= 0) { + arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType); + return arr; + } else { + // Only container + insert = 0; + } + + for (int i = 0; i + insert < length; i++) + arr[insert + i] = AnnotationProxyMaker.generateAnnotation(contained[i], annoType); + + return arr; + } + + // + + // + + /** + * An internal-use utility that creates a runtime view of an + * annotation. This is the implementation of + * TypeMirror.getAnnotation(Class). + */ + public static A getAnnotation(AnnotatedType annotated, Class annoType) { + if (!annoType.isAnnotation()) + throw new IllegalArgumentException("Not an annotation type: " + + annoType); + Attribute.Compound c = getAttribute(annotated, annoType); + return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType); + } + + // Helper to getAnnotation[s] + private static Attribute.Compound getAttribute(Type annotated, + Class annoType) { + String name = annoType.getName(); + + for (Attribute.Compound anno : annotated.getAnnotationMirrors()) { + if (name.equals(anno.type.tsym.flatName().toString())) + return anno; + } + + return null; + } + + /** + * An internal-use utility that creates a runtime view of + * annotations. This is the implementation of + * TypeMirror.getAnnotationsByType(Class). + */ + public static A[] getAnnotationsByType(AnnotatedType annotated, Class annoType) { + if (!annoType.isAnnotation()) + throw new IllegalArgumentException("Not an annotation type: " + + annoType); + // If annoType does not declare a container this is equivalent to wrapping + // getAnnotation(...) in an array. + Class containerType = getContainer(annoType); + if (containerType == null) { + A res = getAnnotation(annotated, annoType); + int size; + if (res == null) { + size = 0; + } else { + size = 1; + } + @SuppressWarnings("unchecked") // annoType is the Class for A + A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size); + if (res != null) + arr[0] = res; + return arr; + } + + // So we have a containing type + String name = annoType.getName(); + String annoTypeName = annoType.getSimpleName(); + String containerTypeName = containerType.getSimpleName(); + int directIndex = -1, containerIndex = -1; + Attribute.Compound direct = null, container = null; + Attribute.Compound[] rawAttributes = annotated.getAnnotationMirrors().toArray(new Attribute.Compound[0]); + + // Find directly present annotations + for (int i = 0; i < rawAttributes.length; i++) { + if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) { + directIndex = i; + direct = rawAttributes[i]; + } else if(containerTypeName != null && + containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) { + containerIndex = i; + container = rawAttributes[i]; + } + } + + // Pack them in an array + Attribute[] contained0 = new Attribute[0]; + if (container != null) + contained0 = unpackAttributes(container); + ListBuffer compounds = ListBuffer.lb(); + for (Attribute a : contained0) { + if (a instanceof Attribute.Compound) + compounds = compounds.append((Attribute.Compound)a); + } + Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]); + + int size = (direct == null ? 0 : 1) + contained.length; + @SuppressWarnings("unchecked") // annoType is the Class for A + A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size); + + // if direct && container, which is first? + int insert = -1; + int length = arr.length; + if (directIndex >= 0 && containerIndex >= 0) { + if (directIndex < containerIndex) { + arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType); + insert = 1; + } else { + arr[arr.length - 1] = AnnotationProxyMaker.generateAnnotation(direct, annoType); + insert = 0; + length--; + } + } else if (directIndex >= 0) { + arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType); + return arr; + } else { + // Only container + insert = 0; + } + + for (int i = 0; i + insert < length; i++) + arr[insert + i] = AnnotationProxyMaker.generateAnnotation(contained[i], annoType); + + return arr; + } + + // + + // + + // Needed to unpack the runtime view of containing annotations + private static final Class REPEATABLE_CLASS = initRepeatable(); + private static final Method VALUE_ELEMENT_METHOD = initValueElementMethod(); + + private static Class initRepeatable() { + try { + // Repeatable will not be available when bootstrapping on + // JDK 7 so use a reflective lookup instead of a class + // literal for Repeatable.class. + return Class.forName("java.lang.annotation.Repeatable").asSubclass(Annotation.class); + } catch (ClassNotFoundException e) { + return null; + } catch (SecurityException e) { + return null; + } + } + + private static Method initValueElementMethod() { + if (REPEATABLE_CLASS == null) + return null; + + Method m = null; + try { + m = REPEATABLE_CLASS.getMethod("value"); + if (m != null) + m.setAccessible(true); + return m; + } catch (NoSuchMethodException e) { + return null; + } + } + + // Helper to getAnnotations + private static Class getContainer(Class annoType) { + // Since we can not refer to java.lang.annotation.Repeatable until we are + // bootstrapping with java 8 we need to get the Repeatable annotation using + // reflective invocations instead of just using its type and element method. + if (REPEATABLE_CLASS != null && + VALUE_ELEMENT_METHOD != null) { + // Get the Repeatable instance on the annotations declaration + Annotation repeatable = (Annotation)annoType.getAnnotation(REPEATABLE_CLASS); + if (repeatable != null) { + try { + // Get the value element, it should be a class + // indicating the containing annotation type + @SuppressWarnings("unchecked") + Class containerType = (Class)VALUE_ELEMENT_METHOD.invoke(repeatable); + if (containerType == null) + return null; + + return containerType; + } catch (ClassCastException e) { + return null; + } catch (IllegalAccessException e) { + return null; + } catch (InvocationTargetException e ) { + return null; + } + } + } + return null; + } + + // Helper to getAnnotations + private static Attribute[] unpackAttributes(Attribute.Compound container) { + // We now have an instance of the container, + // unpack it returning an instance of the + // contained type or null + return ((Attribute.Array)container.member(container.type.tsym.name.table.names.value)).values; + } + + // +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java index 23416a0efe6..f6d98790a68 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java @@ -25,10 +25,6 @@ package com.sun.tools.javac.model; -import java.lang.annotation.Annotation; -import java.lang.annotation.Inherited; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.Map; import javax.lang.model.SourceVersion; @@ -40,7 +36,6 @@ import static javax.lang.model.util.ElementFilter.methodsIn; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.code.TypeTag; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Enter; import com.sun.tools.javac.comp.Env; @@ -98,237 +93,6 @@ public class JavacElements implements Elements { enter = Enter.instance(context); } - /** - * An internal-use utility that creates a runtime view of an - * annotation. This is the implementation of - * Element.getAnnotation(Class). - */ - public static A getAnnotation(Symbol annotated, - Class annoType) { - if (!annoType.isAnnotation()) - throw new IllegalArgumentException("Not an annotation type: " - + annoType); - Attribute.Compound c; - if (annotated.kind == Kinds.TYP && annotated instanceof ClassSymbol) { - c = getAttributeOnClass((ClassSymbol)annotated, annoType); - } else { - c = getAttribute(annotated, annoType); - } - return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType); - } - - // Helper to getAnnotation[s] - private static Attribute.Compound getAttribute(Symbol annotated, - Class annoType) { - String name = annoType.getName(); - - for (Attribute.Compound anno : annotated.getRawAttributes()) - if (name.equals(anno.type.tsym.flatName().toString())) - return anno; - - return null; - } - // Helper to getAnnotation[s] - private static Attribute.Compound getAttributeOnClass(ClassSymbol annotated, - Class annoType) { - boolean inherited = annoType.isAnnotationPresent(Inherited.class); - Attribute.Compound result = null; - while (annotated.name != annotated.name.table.names.java_lang_Object) { - result = getAttribute(annotated, annoType); - if (result != null || !inherited) - break; - Type sup = annotated.getSuperclass(); - if (!sup.hasTag(CLASS) || sup.isErroneous()) - break; - annotated = (ClassSymbol) sup.tsym; - } - return result; - } - - /** - * An internal-use utility that creates a runtime view of - * annotations. This is the implementation of - * Element.getAnnotations(Class). - */ - public static A[] getAnnotations(Symbol annotated, - Class annoType) { - if (!annoType.isAnnotation()) - throw new IllegalArgumentException("Not an annotation type: " - + annoType); - // If annoType does not declare a container this is equivalent to wrapping - // getAnnotation(...) in an array. - Class containerType = getContainer(annoType); - if (containerType == null) { - A res = getAnnotation(annotated, annoType); - int size; - if (res == null) { - size = 0; - } else { - size = 1; - } - @SuppressWarnings("unchecked") // annoType is the Class for A - A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size); - if (res != null) - arr[0] = res; - return arr; - } - - // So we have a containing type - String name = annoType.getName(); - String annoTypeName = annoType.getSimpleName(); - String containerTypeName = containerType.getSimpleName(); - int directIndex = -1, containerIndex = -1; - Attribute.Compound direct = null, container = null; - Attribute.Compound[] rawAttributes = annotated.getRawAttributes().toArray(new Attribute.Compound[0]); - - // Find directly present annotations - for (int i = 0; i < rawAttributes.length; i++) { - if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) { - directIndex = i; - direct = rawAttributes[i]; - } else if(containerTypeName != null && - containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) { - containerIndex = i; - container = rawAttributes[i]; - } - } - // Deal with inherited annotations - if (annotated.kind == Kinds.TYP && - (annotated instanceof ClassSymbol)) { - ClassSymbol s = (ClassSymbol)annotated; - if (direct == null && container == null) { - direct = getAttributeOnClass(s, annoType); - container = getAttributeOnClass(s, containerType); - - // both are inherited and found, put container last - if (direct != null && container != null) { - directIndex = 0; - containerIndex = 1; - } else if (direct != null) { - directIndex = 0; - } else { - containerIndex = 0; - } - } else if (direct == null) { - direct = getAttributeOnClass(s, annoType); - if (direct != null) - directIndex = containerIndex + 1; - } else if (container == null) { - container = getAttributeOnClass(s, containerType); - if (container != null) - containerIndex = directIndex + 1; - } - } - - // Pack them in an array - Attribute[] contained0 = new Attribute[0]; - if (container != null) - contained0 = unpackAttributes(container); - ListBuffer compounds = ListBuffer.lb(); - for (Attribute a : contained0) - if (a instanceof Attribute.Compound) - compounds = compounds.append((Attribute.Compound)a); - Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]); - - int size = (direct == null ? 0 : 1) + contained.length; - @SuppressWarnings("unchecked") // annoType is the Class for A - A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size); - - // if direct && container, which is first? - int insert = -1; - int length = arr.length; - if (directIndex >= 0 && containerIndex >= 0) { - if (directIndex < containerIndex) { - arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType); - insert = 1; - } else { - arr[arr.length - 1] = AnnotationProxyMaker.generateAnnotation(direct, annoType); - insert = 0; - length--; - } - } else if (directIndex >= 0) { - arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType); - return arr; - } else { - // Only container - insert = 0; - } - - for (int i = 0; i + insert < length; i++) - arr[insert + i] = AnnotationProxyMaker.generateAnnotation(contained[i], annoType); - - return arr; - } - - // Needed to unpack the runtime view of containing annotations - private static final Class REPEATABLE_CLASS = initRepeatable(); - private static final Method VALUE_ELEMENT_METHOD = initValueElementMethod(); - - private static Class initRepeatable() { - try { - // Repeatable will not be available when bootstrapping on - // JDK 7 so use a reflective lookup instead of a class - // literal for Repeatable.class. - return Class.forName("java.lang.annotation.Repeatable").asSubclass(Annotation.class); - } catch (ClassNotFoundException e) { - return null; - } catch (SecurityException e) { - return null; - } - } - private static Method initValueElementMethod() { - if (REPEATABLE_CLASS == null) - return null; - - Method m = null; - try { - m = REPEATABLE_CLASS.getMethod("value"); - if (m != null) - m.setAccessible(true); - return m; - } catch (NoSuchMethodException e) { - return null; - } - } - - // Helper to getAnnotations - private static Class getContainer(Class annoType) { - // Since we can not refer to java.lang.annotation.Repeatable until we are - // bootstrapping with java 8 we need to get the Repeatable annotation using - // reflective invocations instead of just using its type and element method. - if (REPEATABLE_CLASS != null && - VALUE_ELEMENT_METHOD != null) { - // Get the Repeatable instance on the annotations declaration - Annotation repeatable = (Annotation)annoType.getAnnotation(REPEATABLE_CLASS); - if (repeatable != null) { - try { - // Get the value element, it should be a class - // indicating the containing annotation type - @SuppressWarnings("unchecked") - Class containerType = (Class)VALUE_ELEMENT_METHOD.invoke(repeatable); - if (containerType == null) - return null; - - return containerType; - } catch (ClassCastException e) { - return null; - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e ) { - return null; - } - } - } - return null; - } - // Helper to getAnnotations - private static Attribute[] unpackAttributes(Attribute.Compound container) { - // We now have an instance of the container, - // unpack it returning an instance of the - // contained type or null - return ((Attribute.Array)container.member(container.type.tsym.name.table.names.value)).values; - } - public PackageSymbol getPackageElement(CharSequence name) { String strName = name.toString(); if (strName.equals("")) diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java index 6b3bf941bcb..76d29eb7531 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -25,7 +25,6 @@ package com.sun.tools.javac.model; -import java.lang.annotation.Annotation; import java.util.Collections; import java.util.EnumSet; import java.util.LinkedHashSet; diff --git a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java new file mode 100644 index 00000000000..7e2d66687b3 --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2013, 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 javax.lang.model; + +import java.lang.annotation.Annotation; +import java.util.List; +import javax.lang.model.element.*; + +/** + * Represent a construct that can have annotations. + * + * When annotations are on an {@linkplain element.Element element}, + * the are on a declaration. When annotations are on a {@linkplain + * type.TypeMirror type}, they are on a use of a type. + * + * @since 1.8 + */ +public interface AnnotatedConstruct { + /** + * Returns the annotations that are directly present on this + * element or type use. + * + * @return the annotations directly present on this element or type use; + * an empty list if there are none + */ + List getAnnotationMirrors(); + + /** + * Returns this element's or type use's annotation for the + * specified type if such an annotation is present, else {@code + * null}. The annotation may be either inherited or directly + * present on this element. + * + *

    The annotation returned by this method could contain an element + * whose value is of type {@code Class}. + * This value cannot be returned directly: information necessary to + * locate and load a class (such as the class loader to use) is + * not available, and the class might not be loadable at all. + * Attempting to read a {@code Class} object by invoking the relevant + * method on the returned annotation + * will result in a {@link MirroredTypeException}, + * from which the corresponding {@link TypeMirror} may be extracted. + * Similarly, attempting to read a {@code Class[]}-valued element + * will result in a {@link MirroredTypesException}. + * + *

    + * Note: This method is unlike others in this and related + * interfaces. It operates on runtime reflective information — + * representations of annotation types currently loaded into the + * VM — rather than on the representations defined by and used + * throughout these interfaces. Consequently, calling methods on + * the returned annotation object can throw many of the exceptions + * that can be thrown when calling methods on an annotation object + * returned by core reflection. This method is intended for + * callers that are written to operate on a known, fixed set of + * annotation types. + *
    + * + * @param
    the annotation type + * @param annotationType the {@code Class} object corresponding to + * the annotation type + * @return this element's or type use's annotation for the + * specified annotation type if present on this element, else + * {@code null} + * + * @see #getAnnotationMirrors() + * @see java.lang.reflect.AnnotatedElement#getAnnotation + * @see EnumConstantNotPresentException + * @see AnnotationTypeMismatchException + * @see IncompleteAnnotationException + * @see MirroredTypeException + * @see MirroredTypesException + */ + A getAnnotation(Class annotationType); + + /** + * Returns annotations that are present on this element or type use. + * + * If there are no annotations present on this element or type use, + * the return value is an array of length 0. + * + * The difference between this method and {@link #getAnnotation(Class)} + * is that this method detects if its argument is a repeatable + * annotation type (JLS 9.6), and if so, attempts to find one or more + * annotations of that type by "looking through" a container annotation. + * + *

    The annotations returned by this method could contain an element + * whose value is of type {@code Class}. + * This value cannot be returned directly: information necessary to + * locate and load a class (such as the class loader to use) is + * not available, and the class might not be loadable at all. + * Attempting to read a {@code Class} object by invoking the relevant + * method on the returned annotation + * will result in a {@link MirroredTypeException}, + * from which the corresponding {@link TypeMirror} may be extracted. + * Similarly, attempting to read a {@code Class[]}-valued element + * will result in a {@link MirroredTypesException}. + * + *

    + * Note: This method is unlike others in this and related + * interfaces. It operates on runtime reflective information — + * representations of annotation types currently loaded into the + * VM — rather than on the representations defined by and used + * throughout these interfaces. Consequently, calling methods on + * the returned annotation object can throw many of the exceptions + * that can be thrown when calling methods on an annotation object + * returned by core reflection. This method is intended for + * callers that are written to operate on a known, fixed set of + * annotation types. + *
    + * + * @param
    the annotation type + * @param annotationType the {@code Class} object corresponding to + * the annotation type + * @return this element's annotations for the specified annotation + * type if present on this element, else an empty array + * + * @see #getAnnotationMirrors() + * @see #getAnnotation(java.lang.Class) + * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType + * @see EnumConstantNotPresentException + * @see AnnotationTypeMismatchException + * @see IncompleteAnnotationException + * @see MirroredTypeException + * @see MirroredTypesException + */ + A[] getAnnotationsByType(Class annotationType); +} diff --git a/langtools/src/share/classes/javax/lang/model/element/Element.java b/langtools/src/share/classes/javax/lang/model/element/Element.java index ab2bcb54eaf..bc007cf10fd 100644 --- a/langtools/src/share/classes/javax/lang/model/element/Element.java +++ b/langtools/src/share/classes/javax/lang/model/element/Element.java @@ -60,8 +60,7 @@ import javax.lang.model.util.*; * @see TypeMirror * @since 1.6 */ -public interface Element { - +public interface Element extends javax.lang.model.AnnotatedConstruct { /** * Returns the type defined by this element. * @@ -88,119 +87,6 @@ public interface Element { */ ElementKind getKind(); - /** - * Returns the annotations that are directly present on this element. - * - *

    To get inherited annotations as well, use - * {@link Elements#getAllAnnotationMirrors(Element) getAllAnnotationMirrors}. - * - * @see ElementFilter - * - * @return the annotations directly present on this element; - * an empty list if there are none - */ - List getAnnotationMirrors(); - - /** - * Returns this element's annotation for the specified type if - * such an annotation is present, else {@code null}. The - * annotation may be either inherited or directly present on this - * element. - * - *

    The annotation returned by this method could contain an element - * whose value is of type {@code Class}. - * This value cannot be returned directly: information necessary to - * locate and load a class (such as the class loader to use) is - * not available, and the class might not be loadable at all. - * Attempting to read a {@code Class} object by invoking the relevant - * method on the returned annotation - * will result in a {@link MirroredTypeException}, - * from which the corresponding {@link TypeMirror} may be extracted. - * Similarly, attempting to read a {@code Class[]}-valued element - * will result in a {@link MirroredTypesException}. - * - *

    - * Note: This method is unlike others in this and related - * interfaces. It operates on runtime reflective information — - * representations of annotation types currently loaded into the - * VM — rather than on the representations defined by and used - * throughout these interfaces. Consequently, calling methods on - * the returned annotation object can throw many of the exceptions - * that can be thrown when calling methods on an annotation object - * returned by core reflection. This method is intended for - * callers that are written to operate on a known, fixed set of - * annotation types. - *
    - * - * @param
    the annotation type - * @param annotationType the {@code Class} object corresponding to - * the annotation type - * @return this element's annotation for the specified annotation - * type if present on this element, else {@code null} - * - * @see #getAnnotationMirrors() - * @see java.lang.reflect.AnnotatedElement#getAnnotation - * @see EnumConstantNotPresentException - * @see AnnotationTypeMismatchException - * @see IncompleteAnnotationException - * @see MirroredTypeException - * @see MirroredTypesException - */ - A getAnnotation(Class annotationType); - - /** - * Returns annotations that are present on this element. - * - * If there are no annotations present on this element, the return - * value is an array of length 0. - * - * The difference between this method and {@link #getAnnotation(Class)} - * is that this method detects if its argument is a repeatable - * annotation type (JLS 9.6), and if so, attempts to find one or more - * annotations of that type by "looking through" a container annotation. - * - *

    The annotations returned by this method could contain an element - * whose value is of type {@code Class}. - * This value cannot be returned directly: information necessary to - * locate and load a class (such as the class loader to use) is - * not available, and the class might not be loadable at all. - * Attempting to read a {@code Class} object by invoking the relevant - * method on the returned annotation - * will result in a {@link MirroredTypeException}, - * from which the corresponding {@link TypeMirror} may be extracted. - * Similarly, attempting to read a {@code Class[]}-valued element - * will result in a {@link MirroredTypesException}. - * - *

    - * Note: This method is unlike others in this and related - * interfaces. It operates on runtime reflective information — - * representations of annotation types currently loaded into the - * VM — rather than on the representations defined by and used - * throughout these interfaces. Consequently, calling methods on - * the returned annotation object can throw many of the exceptions - * that can be thrown when calling methods on an annotation object - * returned by core reflection. This method is intended for - * callers that are written to operate on a known, fixed set of - * annotation types. - *
    - * - * @param
    the annotation type - * @param annotationType the {@code Class} object corresponding to - * the annotation type - * @return this element's annotations for the specified annotation - * type if present on this element, else an empty array - * - * @see #getAnnotationMirrors() - * @see #getAnnotation(java.lang.Class) - * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType - * @see EnumConstantNotPresentException - * @see AnnotationTypeMismatchException - * @see IncompleteAnnotationException - * @see MirroredTypeException - * @see MirroredTypesException - */ - A[] getAnnotationsByType(Class annotationType); - /** * Returns the modifiers of this element, excluding annotations. * Implicit modifiers, such as the {@code public} and {@code static} @@ -325,6 +211,19 @@ public interface Element { */ int hashCode(); + + /** + * {@inheritDoc} + * + *

    To get inherited annotations as well, use {@link + * Elements#getAllAnnotationMirrors(Element) + * getAllAnnotationMirrors}. + * + * @see ElementFilter + * @since 1.6 + */ + @Override + List getAnnotationMirrors(); /** * Applies a visitor to this element. * diff --git a/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java b/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java index b36cd356892..ec72899f565 100644 --- a/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java +++ b/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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 @@ -68,6 +68,25 @@ public interface ExecutableElement extends Element, Parameterizable { */ List getParameters(); + /** + * Returns the receiver type of this executable, + * or {@link javax.lang.model.type.NoType NoType} with + * kind {@link javax.lang.model.type.TypeKind#NONE NONE} + * if the executable has no receiver type. + * + * An executable which is an instance method, or a constructor of an + * inner class, has a receiver type derived from the {@linkplain + * #getEnclosingElement declaring type}. + * + * An executable which is a static method, or a constructor of a + * non-inner class, or an initializer (static or instance), has no + * receiver type. + * + * @return the receiver type of this executable + * @since 1.8 + */ + TypeMirror getReceiverType(); + /** * Returns {@code true} if this method or constructor accepts a variable * number of arguments and returns {@code false} otherwise. diff --git a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java index c25ffd0e19e..0531e2233f6 100644 --- a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java +++ b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java @@ -77,6 +77,25 @@ public interface ExecutableType extends TypeMirror { */ List getParameterTypes(); + /** + * Returns the receiver type of this executable, + * or {@link javax.lang.model.type.NoType NoType} with + * kind {@link javax.lang.model.type.TypeKind#NONE NONE} + * if the executable has no receiver type. + * + * An executable which is an instance method, or a constructor of an + * inner class, has a receiver type derived from the {@linkplain + * #getEnclosingElement declaring type}. + * + * An executable which is a static method, or a constructor of a + * non-inner class, or an initializer (static or instance), has no + * receiver type. + * + * @return the receiver type of this executable + * @since 1.8 + */ + TypeMirror getReceiverType(); + /** * Returns the exceptions and other throwables listed in this * executable's {@code throws} clause. diff --git a/langtools/src/share/classes/javax/lang/model/type/TypeMirror.java b/langtools/src/share/classes/javax/lang/model/type/TypeMirror.java index 49495f26adc..5e5358b9ed0 100644 --- a/langtools/src/share/classes/javax/lang/model/type/TypeMirror.java +++ b/langtools/src/share/classes/javax/lang/model/type/TypeMirror.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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,6 +25,8 @@ package javax.lang.model.type; +import java.lang.annotation.Annotation; +import java.util.List; import javax.lang.model.element.*; import javax.lang.model.util.Types; @@ -55,7 +57,7 @@ import javax.lang.model.util.Types; * @see Types * @since 1.6 */ -public interface TypeMirror { +public interface TypeMirror extends javax.lang.model.AnnotatedConstruct { /** * Returns the {@code kind} of this type. diff --git a/langtools/src/share/classes/javax/lang/model/util/Types.java b/langtools/src/share/classes/javax/lang/model/util/Types.java index 89f197b98ea..560e8e57715 100644 --- a/langtools/src/share/classes/javax/lang/model/util/Types.java +++ b/langtools/src/share/classes/javax/lang/model/util/Types.java @@ -59,6 +59,13 @@ public interface Types { /** * Tests whether two {@code TypeMirror} objects represent the same type. * + *

    Since annotations are only meta-data associated with a type, + * the set of annotations on either argument is not taken + * into account when computing whether or not two {@code + * TypeMirror} objects are the same type. In particular, two + * {@code TypeMirror} objects can have different annotations and + * still be considered the same. + * *

    Caveat: if either of the arguments to this method represents a * wildcard, this method will return false. As a consequence, a wildcard * is not the same type as itself. This might be surprising at first, From 2b3155346ca5efb646354373c871ec964dcaddd7 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 18 Mar 2013 18:34:44 -0700 Subject: [PATCH 020/155] 8007803: Implement javax.lang.model API for Type Annotations Reviewed-by: darcy --- .../internal/jxc/model/nav/ApNavigator.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java index ff450c9a0e7..da1cf800e89 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -31,7 +31,9 @@ import com.sun.source.util.Trees; import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.runtime.Location; +import java.lang.annotation.Annotation; import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -372,6 +374,21 @@ public class ApNavigator implements Navigator getAnnotationMirrors() { + throw new IllegalStateException(); + } + + @Override + public A getAnnotation(Class annotationType) { + throw new IllegalStateException(); + } + + @Override + public A[] getAnnotationsByType(Class annotationType) { + throw new IllegalStateException(); + } }; public Location getClassLocation(TypeElement typeElement) { From e4b8273cc6a18cb960999dce8d1d3e4e91e71da2 Mon Sep 17 00:00:00 2001 From: Pavel Stepanov Date: Tue, 19 Mar 2013 11:03:24 -0300 Subject: [PATCH 021/155] 8009969: CodeCoverage should use template Reviewed-by: jlaskey, sundar --- nashorn/make/build.xml | 2 +- nashorn/make/code_coverage.xml | 60 +++++++++++++++++++++++++++++---- nashorn/make/project.properties | 4 ++- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index e2d8f0ccb31..945ccaa27f1 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -124,7 +124,7 @@ - + diff --git a/nashorn/make/code_coverage.xml b/nashorn/make/code_coverage.xml index 41d85ff3ef1..33980bdfdf6 100644 --- a/nashorn/make/code_coverage.xml +++ b/nashorn/make/code_coverage.xml @@ -36,7 +36,12 @@ + + + + + @@ -51,25 +56,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - + + + + - + @@ -81,12 +127,12 @@ - + - + diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index c4d0b943cd7..60444de766b 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -235,10 +235,12 @@ jcov=dynamic #naming of CC results #NB directory specified in the cc.dir will be cleaned up!!! cc.dir=${basedir}/../Codecoverage_Nashorn -cc.result.file.name=cc_nashorn.xml +cc.result.file.name=CC_${jcov}_nashorn.xml #dynamic CC parameters; please redefine in the ${user.home}/.nashorn.project.local.properties jcov2.lib.dir=${basedir}/../jcov2/lib jcov.jar=${jcov2.lib.dir}/jcov.jar cc.include=jdk\.nashorn\.* cc.exclude=jdk\.nashorn\.internal\.scripts\.* +cc.dynamic.genereate.template=true +cc.template=${cc.dir}/CC_template.xml cc.dynamic.args=-javaagent:${jcov.jar}=include=${cc.include},exclude=${cc.exclude},type=all,verbose=0,file=${cc.dir}/${cc.result.file.name} From f4bcfd04cae624d5f47425e4ae47763305ae0bf5 Mon Sep 17 00:00:00 2001 From: Ron Durbin Date: Tue, 19 Mar 2013 11:33:11 -0700 Subject: [PATCH 022/155] 7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test 7123945: runtime/6878713/Test6878713.sh require about 2G of native memory, swaps and times out Add new diagnostic option -XX:MallocMaxTestWords=NNN and fix Test6878713.sh. Reviewed-by: dcubed, coleenp, dholmes, iklam --- hotspot/src/share/vm/runtime/globals.hpp | 4 + hotspot/src/share/vm/runtime/os.cpp | 39 +++++- hotspot/test/runtime/6878713/Test6878713.sh | 131 +++++++++++++++++--- 3 files changed, 157 insertions(+), 17 deletions(-) diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9645f625a85..489999f6c4a 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2905,6 +2905,10 @@ class CommandLineFlags { "if non-zero, start verifying C heap after Nth call to " \ "malloc/realloc/free") \ \ + diagnostic(uintx, MallocMaxTestWords, 0, \ + "if non-zero, max # of Words that malloc/realloc can allocate " \ + "(for testing only)") \ + \ product(intx, TypeProfileWidth, 2, \ "number of receiver types to record in call/cast profile") \ \ diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index b4090680395..05fa2d07e73 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -80,6 +80,8 @@ julong os::num_frees = 0; // # of calls to free julong os::free_bytes = 0; // # of bytes freed #endif +static juint cur_malloc_words = 0; // current size for MallocMaxTestWords + void os_init_globals() { // Called from init_globals(). // See Threads::create_vm() in thread.cpp, and init.cpp. @@ -570,6 +572,26 @@ void verify_block(void* memblock) { } #endif +// +// This function supports testing of the malloc out of memory +// condition without really running the system out of memory. +// +static u_char* testMalloc(size_t alloc_size) { + + if (MallocMaxTestWords > 0 && + (cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) { + return NULL; + } + + u_char* ptr = (u_char*)::malloc(alloc_size); + + if (MallocMaxTestWords > 0 && (ptr != NULL)) { + Atomic::add(((jint) (alloc_size / BytesPerWord)), + (volatile jint *) &cur_malloc_words); + } + return ptr; +} + void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); @@ -579,11 +601,22 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { // if NULL is returned the calling functions assume out of memory. size = 1; } - if (size > size + space_before + space_after) { // Check for rollover. + + const size_t alloc_size = size + space_before + space_after; + + if (size > alloc_size) { // Check for rollover. return NULL; } + NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); - u_char* ptr = (u_char*)::malloc(size + space_before + space_after); + + u_char* ptr; + + if (MallocMaxTestWords > 0) { + ptr = testMalloc(alloc_size); + } else { + ptr = (u_char*)::malloc(alloc_size); + } #ifdef ASSERT if (ptr == NULL) return NULL; diff --git a/hotspot/test/runtime/6878713/Test6878713.sh b/hotspot/test/runtime/6878713/Test6878713.sh index a452ad58fcd..c66c95b0ec8 100644 --- a/hotspot/test/runtime/6878713/Test6878713.sh +++ b/hotspot/test/runtime/6878713/Test6878713.sh @@ -1,10 +1,38 @@ #!/bin/sh +# +# Copyright (c) 2011, 2013, 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 6878713 +## @bug 7030610 +## @bug 7037122 +## @bug 7123945 ## @summary Verifier heap corruption, relating to backward jsrs -## @run shell/timeout=120 Test6878713.sh +## @run shell Test6878713.sh ## if [ "${TESTSRC}" = "" ] @@ -49,23 +77,98 @@ case "$OS" in ;; esac -JEMMYPATH=${CPAPPEND} -CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH - -THIS_DIR=`pwd` +CLASSPATH=.${PS}${TESTCLASSES} ; export CLASSPATH ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version -${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar +TARGET_CLASS=OOMCrashClass1960_2 -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass1960_2 > test.out 2>&1 +echo "INFO: extracting the target class." +${TESTJAVA}${FS}bin${FS}jar xvf \ + ${TESTSRC}${FS}testcase.jar ${TARGET_CLASS}.class -if [ -s core -o -s "hs_*.log" ] -then - cat hs*.log - echo "Test Failed" - exit 1 +# remove any hs_err_pid that might exist here +rm -f hs_err_pid*.log + +echo "INFO: checking for 32-bit versus 64-bit VM." +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version 2>&1 \ + | grep "64-Bit [^ ][^ ]* VM" > /dev/null 2>&1 +status="$?" +if [ "$status" = 0 ]; then + echo "INFO: testing a 64-bit VM." + is_64_bit=true else - echo "Test Passed" - exit 0 + echo "INFO: testing a 32-bit VM." fi + +if [ "$is_64_bit" = true ]; then + # limit is 768MB in 8-byte words (1024 * 1024 * 768 / 8) == 100663296 + MALLOC_MAX=100663296 +else + # limit is 768MB in 4-byte words (1024 * 1024 * 768 / 4) == 201326592 + MALLOC_MAX=201326592 +fi +echo "INFO: MALLOC_MAX=$MALLOC_MAX" + +echo "INFO: executing the target class." +# -XX:+PrintCommandLineFlags for debugging purposes +# -XX:+IgnoreUnrecognizedVMOptions so test will run on a VM without +# the new -XX:MallocMaxTestWords option +# -XX:+UnlockDiagnosticVMOptions so we can use -XX:MallocMaxTestWords +# -XX:MallocMaxTestWords limits malloc to $MALLOC_MAX +${TESTJAVA}${FS}bin${FS}java \ + -XX:+PrintCommandLineFlags \ + -XX:+IgnoreUnrecognizedVMOptions \ + -XX:+UnlockDiagnosticVMOptions \ + -XX:MallocMaxTestWords=$MALLOC_MAX \ + ${TESTVMOPTS} ${TARGET_CLASS} > test.out 2>&1 + +echo "INFO: begin contents of test.out:" +cat test.out +echo "INFO: end contents of test.out." + +echo "INFO: checking for memory allocation error message." +# We are looking for this specific memory allocation failure mesg so +# we know we exercised the right allocation path with the test class: +MESG1="Native memory allocation (malloc) failed to allocate 25696531[0-9][0-9] bytes" +grep "$MESG1" test.out +status="$?" +if [ "$status" = 0 ]; then + echo "INFO: found expected memory allocation error message." +else + echo "INFO: did not find expected memory allocation error message." + + # If we didn't find MESG1 above, then there are several scenarios: + # 1) -XX:MallocMaxTestWords is not supported by the current VM and we + # didn't fail TARGET_CLASS's memory allocation attempt; instead + # we failed to find TARGET_CLASS's main() method. The TARGET_CLASS + # is designed to provoke a memory allocation failure during class + # loading; we actually don't care about running the class which is + # why it doesn't have a main() method. + # 2) we failed a memory allocation, but not the one we were looking + # so it might be that TARGET_CLASS no longer tickles the same + # memory allocation code path + # 3) TARGET_CLASS reproduces the failure mode (SIGSEGV) fixed by + # 6878713 because the test is running on a pre-fix VM. + echo "INFO: checking for no main() method message." + MESG2="Error: Main method not found in class" + grep "$MESG2" test.out + status="$?" + if [ "$status" = 0 ]; then + echo "INFO: found no main() method message." + else + echo "FAIL: did not find no main() method message." + # status is non-zero for exit below + + if [ -s hs_err_pid*.log ]; then + echo "INFO: begin contents of hs_err_pid file:" + cat hs_err_pid*.log + echo "INFO: end contents of hs_err_pid file." + fi + fi +fi + +if [ "$status" = 0 ]; then + echo "PASS: test found one of the expected messages." +fi +exit "$status" From 479d5c83b0860e7d7ae77c931d5684bcc1489347 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 19 Mar 2013 13:10:40 -0700 Subject: [PATCH 023/155] 8010179: Remove transitional target values from javac Reviewed-by: jjg, mcimadamore --- .../com/sun/tools/javac/comp/Attr.java | 3 +- .../com/sun/tools/javac/comp/Lower.java | 193 ------------------ .../com/sun/tools/javac/comp/MemberEnter.java | 53 +---- .../com/sun/tools/javac/jvm/Target.java | 37 +--- .../ClassFileModifiers/MemberModifiers.java | 4 +- .../javac/profiles/ProfileOptionTest.java | 3 +- 6 files changed, 13 insertions(+), 280 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index e693efe64e5..6297a72823e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -4009,8 +4009,7 @@ public class Attr extends JCTree.Visitor { // Enums may not be extended by source-level classes if (st.tsym != null && ((st.tsym.flags_field & Flags.ENUM) != 0) && - ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0) && - !target.compilerBootstrap(c)) { + ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0)) { log.error(env.tree.pos(), "enum.types.not.extensible"); } attribClassBody(env, c); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 3d49bbeaff4..388c7a52fba 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2604,11 +2604,6 @@ public class Lower extends TreeTranslator { enumDefs.appendList(otherDefs.toList()); tree.defs = enumDefs.toList(); - - // Add the necessary members for the EnumCompatibleMode - if (target.compilerBootstrap(tree.sym)) { - addEnumCompatibleMembers(tree); - } } // where private MethodSymbol systemArraycopyMethod; @@ -2657,30 +2652,6 @@ public class Lower extends TreeTranslator { olderasure.getReturnType(), olderasure.getThrownTypes(), syms.methodClass); - - if (target.compilerBootstrap(m.owner)) { - // Initialize synthetic name field - Symbol nameVarSym = lookupSynthetic(names.fromString("$name"), - tree.sym.owner.members()); - JCIdent nameIdent = make.Ident(nameParam.sym); - JCIdent id1 = make.Ident(nameVarSym); - JCAssign newAssign = make.Assign(id1, nameIdent); - newAssign.type = id1.type; - JCExpressionStatement nameAssign = make.Exec(newAssign); - nameAssign.type = id1.type; - tree.body.stats = tree.body.stats.prepend(nameAssign); - - // Initialize synthetic ordinal field - Symbol ordinalVarSym = lookupSynthetic(names.fromString("$ordinal"), - tree.sym.owner.members()); - JCIdent ordIdent = make.Ident(ordParam.sym); - id1 = make.Ident(ordinalVarSym); - newAssign = make.Assign(id1, ordIdent); - newAssign.type = id1.type; - JCExpressionStatement ordinalAssign = make.Exec(newAssign); - ordinalAssign.type = id1.type; - tree.body.stats = tree.body.stats.prepend(ordinalAssign); - } } JCMethodDecl prevMethodDef = currentMethodDef; @@ -3888,168 +3859,4 @@ public class Lower extends TreeTranslator { } return translated.toList(); } - - ////////////////////////////////////////////////////////////// - // The following contributed by Borland for bootstrapping purposes - ////////////////////////////////////////////////////////////// - private void addEnumCompatibleMembers(JCClassDecl cdef) { - make_at(null); - - // Add the special enum fields - VarSymbol ordinalFieldSym = addEnumOrdinalField(cdef); - VarSymbol nameFieldSym = addEnumNameField(cdef); - - // Add the accessor methods for name and ordinal - MethodSymbol ordinalMethodSym = addEnumFieldOrdinalMethod(cdef, ordinalFieldSym); - MethodSymbol nameMethodSym = addEnumFieldNameMethod(cdef, nameFieldSym); - - // Add the toString method - addEnumToString(cdef, nameFieldSym); - - // Add the compareTo method - addEnumCompareTo(cdef, ordinalFieldSym); - } - - private VarSymbol addEnumOrdinalField(JCClassDecl cdef) { - VarSymbol ordinal = new VarSymbol(PRIVATE|FINAL|SYNTHETIC, - names.fromString("$ordinal"), - syms.intType, - cdef.sym); - cdef.sym.members().enter(ordinal); - cdef.defs = cdef.defs.prepend(make.VarDef(ordinal, null)); - return ordinal; - } - - private VarSymbol addEnumNameField(JCClassDecl cdef) { - VarSymbol name = new VarSymbol(PRIVATE|FINAL|SYNTHETIC, - names.fromString("$name"), - syms.stringType, - cdef.sym); - cdef.sym.members().enter(name); - cdef.defs = cdef.defs.prepend(make.VarDef(name, null)); - return name; - } - - private MethodSymbol addEnumFieldOrdinalMethod(JCClassDecl cdef, VarSymbol ordinalSymbol) { - // Add the accessor methods for ordinal - Symbol ordinalSym = lookupMethod(cdef.pos(), - names.ordinal, - cdef.type, - List.nil()); - - Assert.check(ordinalSym instanceof MethodSymbol); - - JCStatement ret = make.Return(make.Ident(ordinalSymbol)); - cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)ordinalSym, - make.Block(0L, List.of(ret)))); - - return (MethodSymbol)ordinalSym; - } - - private MethodSymbol addEnumFieldNameMethod(JCClassDecl cdef, VarSymbol nameSymbol) { - // Add the accessor methods for name - Symbol nameSym = lookupMethod(cdef.pos(), - names._name, - cdef.type, - List.nil()); - - Assert.check(nameSym instanceof MethodSymbol); - - JCStatement ret = make.Return(make.Ident(nameSymbol)); - - cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)nameSym, - make.Block(0L, List.of(ret)))); - - return (MethodSymbol)nameSym; - } - - private MethodSymbol addEnumToString(JCClassDecl cdef, - VarSymbol nameSymbol) { - Symbol toStringSym = lookupMethod(cdef.pos(), - names.toString, - cdef.type, - List.nil()); - - JCTree toStringDecl = null; - if (toStringSym != null) - toStringDecl = TreeInfo.declarationFor(toStringSym, cdef); - - if (toStringDecl != null) - return (MethodSymbol)toStringSym; - - JCStatement ret = make.Return(make.Ident(nameSymbol)); - - JCTree resTypeTree = make.Type(syms.stringType); - - MethodType toStringType = new MethodType(List.nil(), - syms.stringType, - List.nil(), - cdef.sym); - toStringSym = new MethodSymbol(PUBLIC, - names.toString, - toStringType, - cdef.type.tsym); - toStringDecl = make.MethodDef((MethodSymbol)toStringSym, - make.Block(0L, List.of(ret))); - - cdef.defs = cdef.defs.prepend(toStringDecl); - cdef.sym.members().enter(toStringSym); - - return (MethodSymbol)toStringSym; - } - - private MethodSymbol addEnumCompareTo(JCClassDecl cdef, VarSymbol ordinalSymbol) { - Symbol compareToSym = lookupMethod(cdef.pos(), - names.compareTo, - cdef.type, - List.of(cdef.sym.type)); - - Assert.check(compareToSym instanceof MethodSymbol); - - JCMethodDecl compareToDecl = (JCMethodDecl) TreeInfo.declarationFor(compareToSym, cdef); - - ListBuffer blockStatements = new ListBuffer(); - - JCModifiers mod1 = make.Modifiers(0L); - Name oName = names.fromString("o"); - JCVariableDecl par1 = make.Param(oName, cdef.type, compareToSym); - - JCIdent paramId1 = make.Ident(names.java_lang_Object); - paramId1.type = cdef.type; - paramId1.sym = par1.sym; - - ((MethodSymbol)compareToSym).params = List.of(par1.sym); - - JCIdent par1UsageId = make.Ident(par1.sym); - JCIdent castTargetIdent = make.Ident(cdef.sym); - JCTypeCast cast = make.TypeCast(castTargetIdent, par1UsageId); - cast.setType(castTargetIdent.type); - - Name otherName = names.fromString("other"); - - VarSymbol otherVarSym = new VarSymbol(mod1.flags, - otherName, - cdef.type, - compareToSym); - JCVariableDecl otherVar = make.VarDef(otherVarSym, cast); - blockStatements.append(otherVar); - - JCIdent id1 = make.Ident(ordinalSymbol); - - JCIdent fLocUsageId = make.Ident(otherVarSym); - JCExpression sel = make.Select(fLocUsageId, ordinalSymbol); - JCBinary bin = makeBinary(MINUS, id1, sel); - JCReturn ret = make.Return(bin); - blockStatements.append(ret); - JCMethodDecl compareToMethod = make.MethodDef((MethodSymbol)compareToSym, - make.Block(0L, - blockStatements.toList())); - compareToMethod.params = List.of(par1); - cdef.defs = cdef.defs.append(compareToMethod); - - return (MethodSymbol)compareToSym; - } - ////////////////////////////////////////////////////////////// - // The above contributed by Borland for bootstrapping purposes - ////////////////////////////////////////////////////////////// } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 907f06882c8..1e2d1e1e0a4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -473,44 +473,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer { null, //make.Block(0, Tree.emptyList.prepend(make.Return(make.Ident(names._null)))), null); memberEnter(valueOf, env); - - // the remaining members are for bootstrapping only - if (!target.compilerBootstrap(tree.sym)) return; - - // public final int ordinal() { return ???; } - JCMethodDecl ordinal = make.at(tree.pos). - MethodDef(make.Modifiers(Flags.PUBLIC|Flags.FINAL), - names.ordinal, - make.Type(syms.intType), - List.nil(), - List.nil(), - List.nil(), - null, - null); - memberEnter(ordinal, env); - - // public final String name() { return ???; } - JCMethodDecl name = make. - MethodDef(make.Modifiers(Flags.PUBLIC|Flags.FINAL), - names._name, - make.Type(syms.stringType), - List.nil(), - List.nil(), - List.nil(), - null, - null); - memberEnter(name, env); - - // public int compareTo(E other) { return ???; } - MethodSymbol compareTo = new - MethodSymbol(Flags.PUBLIC, - names.compareTo, - new MethodType(List.of(tree.sym.type), - syms.intType, - List.nil(), - syms.methodClass), - tree.sym); - memberEnter(make.MethodDef(compareTo, null), env); } public void visitTopLevel(JCCompilationUnit tree) { @@ -936,7 +898,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { Type supertype = (tree.extending != null) ? attr.attribBase(tree.extending, baseEnv, true, false, true) - : ((tree.mods.flags & Flags.ENUM) != 0 && !target.compilerBootstrap(c)) + : ((tree.mods.flags & Flags.ENUM) != 0) ? attr.attribBase(enumBase(tree.pos, c), baseEnv, true, false, false) : (c.fullname == names.java_lang_Object) @@ -949,16 +911,6 @@ public class MemberEnter extends JCTree.Visitor implements Completer { ListBuffer all_interfaces = null; // lazy init Set interfaceSet = new HashSet(); List interfaceTrees = tree.implementing; - if ((tree.mods.flags & Flags.ENUM) != 0 && target.compilerBootstrap(c)) { - // add interface Comparable - interfaceTrees = - interfaceTrees.prepend(make.Type(new ClassType(syms.comparableType.getEnclosingType(), - List.of(c.type), - syms.comparableType.tsym))); - // add interface Serializable - interfaceTrees = - interfaceTrees.prepend(make.Type(syms.serializableType)); - } for (JCExpression iface : interfaceTrees) { Type i = attr.attribBase(iface, baseEnv, false, true, true); if (i.hasTag(CLASS)) { @@ -1401,8 +1353,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { if (c.type != syms.objectType) stats = stats.prepend(SuperCall(make, typarams, params, based)); if ((c.flags() & ENUM) != 0 && - (types.supertype(c.type).tsym == syms.enumSym || - target.compilerBootstrap(c))) { + (types.supertype(c.type).tsym == syms.enumSym)) { // constructors of true enums are private flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR; } else diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java index 3c22d211104..54eee749b58 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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 @@ -48,17 +48,6 @@ public enum Target { /** J2SE1.4 = Merlin. */ JDK1_4("1.4", 48, 0), - /** Support for the JSR14 prototype compiler (targeting 1.4 VMs - * augmented with a few support classes). This is a transitional - * option that will not be supported in the product. */ - JSR14("jsr14", 48, 0), - - /** The following are undocumented transitional targets that we - * had used to test VM fixes in update releases. We do not - * promise to retain support for them. */ - JDK1_4_1("1.4.1", 48, 0), - JDK1_4_2("1.4.2", 48, 0), - /** Tiger. */ JDK1_5("1.5", 49, 0), @@ -175,23 +164,23 @@ public enum Target { return compareTo(JDK1_5) >= 0; } - /** Beginning in -target 1.4.2, we make synthetic variables + /** Beginning in -target 1.5, we make synthetic variables * package-private instead of private. This is to prevent the * necessity of access methods, which effectively relax the * protection of the field but bloat the class files and affect * execution. */ public boolean usePrivateSyntheticFields() { - return compareTo(JDK1_4_2) < 0; + return compareTo(JDK1_5) < 0; } /** Sometimes we need to create a field to cache a value like a - * class literal of the assertions flag. In -target 1.4.2 and + * class literal of the assertions flag. In -target 1.5 and * later we create a new synthetic class for this instead of * using the outermost class. See 4401576. */ public boolean useInnerCacheClass() { - return compareTo(JDK1_4_2) >= 0; + return compareTo(JDK1_5) >= 0; } /** Return true if cldc-style stack maps need to be generated. */ @@ -276,7 +265,7 @@ public enum Target { * See 4468823 */ public boolean classLiteralsNoInit() { - return compareTo(JDK1_4_2) >= 0; + return compareTo(JDK1_5) >= 0; } /** Although we may not have support for class literals, when we @@ -300,22 +289,10 @@ public enum Target { return compareTo(JDK1_5) >= 0; } - /** For bootstrapping javac only, we do without java.lang.Enum if - * necessary. - */ - public boolean compilerBootstrap(Symbol c) { - return - this == JSR14 && - (c.flags() & Flags.ENUM) != 0 && - c.flatName().toString().startsWith("com.sun.tools.") - // && !Target.class.getSuperclass().getName().equals("java.lang.Enum") - ; - } - /** In J2SE1.5.0, we introduced the "EnclosingMethod" attribute * for improved reflection support. */ public boolean hasEnclosingMethodAttribute() { - return compareTo(JDK1_5) >= 0 || this == JSR14; + return compareTo(JDK1_5) >= 0; } } diff --git a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java index f66376d5802..dc70ff16cba 100644 --- a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java +++ b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 4249112 4785453 * @summary Verify that implicit member modifiers are set correctly. * - * @compile/ref=MemberModifiers.out -source 1.4 -target 1.4.2 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java + * @compile/ref=MemberModifiers.out -source 1.4 -target 1.5 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java */ // Currently, we check only that members of final classes are not final. diff --git a/langtools/test/tools/javac/profiles/ProfileOptionTest.java b/langtools/test/tools/javac/profiles/ProfileOptionTest.java index 648cef39f1b..2fc55b24d55 100644 --- a/langtools/test/tools/javac/profiles/ProfileOptionTest.java +++ b/langtools/test/tools/javac/profiles/ProfileOptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -106,7 +106,6 @@ public class ProfileOptionTest { for (Target t: Target.values()) { switch (t) { case JDK1_1: case JDK1_2: // no equivalent -source - case JDK1_4_1: case JDK1_4_2: case JSR14: // transitional values continue; } From a52c1dd51a43acbd90ba4868739ce85c3d9aebca Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 19 Mar 2013 15:13:44 -0700 Subject: [PATCH 024/155] 8010315: doclint errors in javac public API Reviewed-by: darcy --- langtools/make/build.xml | 29 +++++++++++++++++-- .../com/sun/source/util/DocTreeScanner.java | 2 +- .../com/sun/source/util/JavacTask.java | 2 +- .../classes/com/sun/source/util/Plugin.java | 2 +- .../javax/lang/model/AnnotatedConstruct.java | 9 +++--- .../javax/lang/model/type/ExecutableType.java | 2 +- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/langtools/make/build.xml b/langtools/make/build.xml index 9292ee3f392..2d3da00b0f4 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -1,6 +1,6 @@ @@ -678,7 +703,7 @@ jarclasspath="sjavac.jar"/> - + diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java index eba4730f585..4121f29d385 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java @@ -53,7 +53,7 @@ import com.sun.source.doctree.*; * *

    Here is an example to count the number of erroneous nodes in a tree: *

    - *   class CountErrors extends DocTreeScanner {
    + *   class CountErrors extends DocTreeScanner<Integer,Void> {
      *      {@literal @}Override
      *      public Integer visitErroneous(ErroneousTree node, Void p) {
      *          return 1;
    diff --git a/langtools/src/share/classes/com/sun/source/util/JavacTask.java b/langtools/src/share/classes/com/sun/source/util/JavacTask.java
    index e760f5c3526..e65e8d6c6b5 100644
    --- a/langtools/src/share/classes/com/sun/source/util/JavacTask.java
    +++ b/langtools/src/share/classes/com/sun/source/util/JavacTask.java
    @@ -56,7 +56,7 @@ public abstract class JavacTask implements CompilationTask {
          * If the compiler is being invoked using a
          * {@link javax.tools.JavaCompiler.CompilationTask CompilationTask},
          * then that task will be returned.
    -     * @param processingEnvironment
    +     * @param processingEnvironment the processing environment
          * @return the {@code JavacTask} for a {@code ProcessingEnvironment}
          * @since 1.8
          */
    diff --git a/langtools/src/share/classes/com/sun/source/util/Plugin.java b/langtools/src/share/classes/com/sun/source/util/Plugin.java
    index 726115535f1..06f7418f0aa 100644
    --- a/langtools/src/share/classes/com/sun/source/util/Plugin.java
    +++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java
    @@ -38,7 +38,7 @@ import javax.tools.StandardLocation;
      *
      * 

    Plug-ins are located via a {@link ServiceLoader}, * using the same class path as annotation processors (i.e. - * {@link StandardLocation#PROCESSOR_PATH PROCESSOR_PATH} or + * {@link StandardLocation#ANNOTATION_PROCESSOR_PATH ANNOTATION_PROCESSOR_PATH} or * {@code -processorpath}). * *

    It is expected that a typical plug-in will simply register a diff --git a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java index 7e2d66687b3..a7d1a84c1fe 100644 --- a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java +++ b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java @@ -25,16 +25,17 @@ package javax.lang.model; -import java.lang.annotation.Annotation; +import java.lang.annotation.*; import java.util.List; import javax.lang.model.element.*; +import javax.lang.model.type.*; /** * Represent a construct that can have annotations. * - * When annotations are on an {@linkplain element.Element element}, - * the are on a declaration. When annotations are on a {@linkplain - * type.TypeMirror type}, they are on a use of a type. + * When annotations are on an {@linkplain Element element}, + * they are on a declaration. When annotations are on a {@linkplain + * TypeMirror type}, they are on a use of a type. * * @since 1.8 */ diff --git a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java index 0531e2233f6..3e8e53cbdaf 100644 --- a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java +++ b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java @@ -85,7 +85,7 @@ public interface ExecutableType extends TypeMirror { * * An executable which is an instance method, or a constructor of an * inner class, has a receiver type derived from the {@linkplain - * #getEnclosingElement declaring type}. + * ExecutableElement#getEnclosingElement declaring type}. * * An executable which is a static method, or a constructor of a * non-inner class, or an initializer (static or instance), has no From ab8f7a37628258f785397aab71bb4303a981909e Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 19 Mar 2013 17:04:03 -0700 Subject: [PATCH 025/155] 8010361: fix some langtools findbugs issues Reviewed-by: darcy --- .../sun/tools/classfile/Code_attribute.java | 6 ++--- .../com/sun/tools/classfile/Descriptor.java | 4 +-- .../internal/toolkit/Configuration.java | 2 +- .../builders/AnnotationTypeBuilder.java | 6 ++--- .../classes/com/sun/tools/javah/Util.java | 6 +---- .../com/sun/tools/javap/StackMapWriter.java | 6 ++--- .../com/sun/tools/jdeps/JdepsTask.java | 11 ++++---- .../sun/tools/jdeps/PlatformClassPath.java | 3 +-- .../classes/com/sun/tools/sjavac/Main.java | 27 ++++++++----------- .../sun/tools/sjavac/comp/Dependencies.java | 2 +- 10 files changed, 31 insertions(+), 42 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java b/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java index af34c2a463c..5d7c81474f2 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -38,7 +38,7 @@ import java.util.NoSuchElementException; * deletion without notice. */ public class Code_attribute extends Attribute { - public class InvalidIndex extends AttributeException { + public static class InvalidIndex extends AttributeException { private static final long serialVersionUID = -8904527774589382802L; InvalidIndex(int index) { this.index = index; @@ -143,7 +143,7 @@ public class Code_attribute extends Attribute { public final Exception_data[] exception_table; public final Attributes attributes; - public class Exception_data { + public static class Exception_data { Exception_data(ClassReader cr) throws IOException { start_pc = cr.readUnsignedShort(); end_pc = cr.readUnsignedShort(); diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java b/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java index 7cbc3481264..0e340e06ad9 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +37,7 @@ import java.io.IOException; * deletion without notice. */ public class Descriptor { - public class InvalidDescriptor extends DescriptorException { + public static class InvalidDescriptor extends DescriptorException { private static final long serialVersionUID = 1L; InvalidDescriptor(String desc) { this.desc = desc; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index c34e1dface9..493d0e9a970 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -56,7 +56,7 @@ public abstract class Configuration { /** * Exception used to report a problem during setOptions. */ - public class Fault extends Exception { + public static class Fault extends Exception { private static final long serialVersionUID = 0; Fault(String msg) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java index 1a9dec1f757..4de54026794 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -116,9 +116,9 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * @param contentTree the content tree to which the documentation will be added */ public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception { - contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") + + contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") + " " + annotationTypeDoc.name()); - Content annotationContentTree = writer.getAnnotationContentHeader(); + Content annotationContentTree = writer.getAnnotationContentHeader(); buildChildren(node, annotationContentTree); contentTree.addContent(annotationContentTree); writer.addFooter(contentTree); diff --git a/langtools/src/share/classes/com/sun/tools/javah/Util.java b/langtools/src/share/classes/com/sun/tools/javah/Util.java index 36dcf22a6c2..20736e6595b 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/Util.java +++ b/langtools/src/share/classes/com/sun/tools/javah/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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,10 +144,6 @@ public class Util { throw new Exit(15); } - private void fatal(String msg) throws Exit { - fatal(msg, null); - } - private void fatal(String msg, Exception e) throws Exit { dl.report(createDiagnostic(Diagnostic.Kind.ERROR, "", msg)); throw new Exit(10, e); diff --git a/langtools/src/share/classes/com/sun/tools/javap/StackMapWriter.java b/langtools/src/share/classes/com/sun/tools/javap/StackMapWriter.java index 084c536f51d..bed0485cb68 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/StackMapWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javap/StackMapWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, 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 @@ -269,7 +269,7 @@ public class StackMapWriter extends InstructionDetailWriter { } - class StackMap { + static class StackMap { StackMap(verification_type_info[] locals, verification_type_info[] stack) { this.locals = locals; this.stack = stack; @@ -279,7 +279,7 @@ public class StackMapWriter extends InstructionDetailWriter { private final verification_type_info[] stack; } - class CustomVerificationTypeInfo extends verification_type_info { + static class CustomVerificationTypeInfo extends verification_type_info { public CustomVerificationTypeInfo(String text) { super(-1); this.text = text; diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java index a7d0ecf9b6f..c606d963679 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -38,7 +38,7 @@ import java.util.regex.Pattern; * Implementation for the jdeps tool for static class dependency analysis. */ class JdepsTask { - class BadArgs extends Exception { + static class BadArgs extends Exception { static final long serialVersionUID = 8765093759964640721L; BadArgs(String key, Object... args) { super(JdepsTask.getMessage(key, args)); @@ -119,7 +119,7 @@ class JdepsTask { } else if ("class".equals(arg)) { task.options.verbose = Analyzer.Type.CLASS; } else { - throw task.new BadArgs("err.invalid.arg.for.option", opt); + throw new BadArgs("err.invalid.arg.for.option", opt); } } }, @@ -142,7 +142,7 @@ class JdepsTask { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.showProfile = true; if (Profiles.getProfileCount() == 0) { - throw task.new BadArgs("err.option.unsupported", opt, getMessage("err.profiles.msg")); + throw new BadArgs("err.option.unsupported", opt, getMessage("err.profiles.msg")); } } }, @@ -156,7 +156,7 @@ class JdepsTask { try { task.options.depth = Integer.parseInt(arg); } catch (NumberFormatException e) { - throw task.new BadArgs("err.invalid.arg.for.option", opt); + throw new BadArgs("err.invalid.arg.for.option", opt); } } }, @@ -515,7 +515,6 @@ class JdepsTask { boolean help; boolean version; boolean fullVersion; - boolean showFlags; boolean showProfile; boolean showSummary; boolean wildcard; diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java b/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java index 75ac8932a9b..14e25830af9 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -49,7 +49,6 @@ class PlatformClassPath { private static List init() { List result = new ArrayList(); String javaHome = System.getProperty("java.home"); - List files = new ArrayList(); File jre = new File(javaHome, "jre"); File lib = new File(javaHome, "lib"); diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java index 0deb39cb70f..14c65f376ae 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,18 +26,13 @@ package com.sun.tools.sjavac; import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import com.sun.tools.sjavac.server.JavacServer; import java.io.IOException; import java.io.PrintStream; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.sun.tools.sjavac.server.JavacServer; /** * The main class of the smart javac wrapper tool. @@ -268,12 +263,12 @@ public class Main { // Find all class files allowable for linking. // And pickup knowledge of all modules found here. // This cannot currently filter classes inside jar files. - Map classes_to_link_to = new HashMap(); +// Map classes_to_link_to = new HashMap(); // findFiles(args, "-classpath", Util.set(".class"), classes_to_link_to, modules, current_module, true); // Find all module sources allowable for linking. - Map modules_to_link_to = new HashMap(); - // findFiles(args, "-modulepath", Util.set(".class"), modules_to_link_to, modules, current_module, true); +// Map modules_to_link_to = new HashMap(); +// findFiles(args, "-modulepath", Util.set(".class"), modules_to_link_to, modules, current_module, true); // Add the set of sources to the build database. javac_state.now().collectPackagesSourcesAndArtifacts(modules); @@ -935,13 +930,13 @@ public class Main { if (roots.contains(root)) { throw new ProblemException("\""+r+"\" has already been used for "+option); } - if (roots.equals(bin_dir)) { + if (root.equals(bin_dir)) { throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -d"); } - if (roots.equals(gensrc_dir)) { + if (root.equals(gensrc_dir)) { throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -s"); } - if (roots.equals(header_dir)) { + if (root.equals(header_dir)) { throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -h"); } roots.add(root); diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java index 4c3dab29f5e..1fc81464918 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java @@ -108,7 +108,7 @@ public class Dependencies { return new_deps; } - class CompareNames implements Comparator { + static class CompareNames implements Comparator { public int compare(Name a, Name b) { return a.toString().compareTo(b.toString()); } From 622349cdb1a8180f3244931d5e89170d0aaf63be Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 19 Mar 2013 17:05:57 -0700 Subject: [PATCH 026/155] 8010333: Remove com.sun.tools.javac.Server Reviewed-by: darcy --- .../classes/com/sun/tools/javac/Server.java | 197 ------------------ 1 file changed, 197 deletions(-) delete mode 100644 langtools/src/share/classes/com/sun/tools/javac/Server.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/Server.java b/langtools/src/share/classes/com/sun/tools/javac/Server.java deleted file mode 100644 index 6a175d19cc4..00000000000 --- a/langtools/src/share/classes/com/sun/tools/javac/Server.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javac; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.logging.Logger; -import javax.tools.*; - -/** - * Java Compiler Server. Can be used to speed up a set of (small) - * compilation tasks by caching jar files between compilations. - * - *

    This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice.

    - * - * @author Peter von der Ahé - * @since 1.6 - */ -@jdk.Supported(false) -class Server implements Runnable { - private final BufferedReader in; - private final OutputStream out; - private final boolean isSocket; - private static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); - private static final Logger logger = Logger.getLogger("com.sun.tools.javac"); - static class CwdFileManager extends ForwardingJavaFileManager { - String cwd; - CwdFileManager(JavaFileManager fileManager) { - super(fileManager); - } - String getAbsoluteName(String name) { - if (new File(name).isAbsolute()) { - return name; - } else { - return new File(cwd,name).getPath(); - } - } -// public JavaFileObject getFileForInput(String name) -// throws IOException -// { -// return super.getFileForInput(getAbsoluteName(name)); -// } - } - // static CwdFileManager fm = new CwdFileManager(tool.getStandardFileManager()); - static final StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); - static { - // Use the same file manager for all compilations. This will - // cache jar files in the standard file manager. Use - // tool.getStandardFileManager().close() to release. - // FIXME tool.setFileManager(fm); - logger.setLevel(java.util.logging.Level.SEVERE); - } - private Server(BufferedReader in, OutputStream out, boolean isSocket) { - this.in = in; - this.out = out; - this.isSocket = isSocket; - } - private Server(BufferedReader in, OutputStream out) { - this(in, out, false); - } - private Server(Socket socket) throws IOException, UnsupportedEncodingException { - this(new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8")), - socket.getOutputStream(), - true); - } - public void run() { - List args = new ArrayList(); - int res = -1; - try { - String line = null; - try { - line = in.readLine(); - } catch (IOException e) { - System.err.println(e.getLocalizedMessage()); - System.exit(0); - line = null; - } - // fm.cwd=null; - String cwd = null; - while (line != null) { - if (line.startsWith("PWD:")) { - cwd = line.substring(4); - } else if (line.equals("END")) { - break; - } else if (!"-XDstdout".equals(line)) { - args.add(line); - } - try { - line = in.readLine(); - } catch (IOException e) { - System.err.println(e.getLocalizedMessage()); - System.exit(0); - line = null; - } - } - Iterable path = cwd == null ? null : Arrays.asList(new File(cwd)); - // try { in.close(); } catch (IOException e) {} - long msec = System.currentTimeMillis(); - try { - synchronized (tool) { - for (StandardLocation location : StandardLocation.values()) - fm.setLocation(location, path); - res = compile(out, fm, args); - // FIXME res = tool.run((InputStream)null, null, out, args.toArray(new String[args.size()])); - } - } catch (Throwable ex) { - logger.log(java.util.logging.Level.SEVERE, args.toString(), ex); - PrintWriter p = new PrintWriter(out, true); - ex.printStackTrace(p); - p.flush(); - } - if (res >= 3) { - logger.severe(String.format("problem: %s", args)); - } else { - logger.info(String.format("success: %s", args)); - } - // res = compile(args.toArray(new String[args.size()]), out); - msec -= System.currentTimeMillis(); - logger.info(String.format("Real time: %sms", -msec)); - } finally { - if (!isSocket) { - try { in.close(); } catch (IOException e) {} - } - try { - out.write(String.format("EXIT: %s%n", res).getBytes()); - } catch (IOException ex) { - logger.log(java.util.logging.Level.SEVERE, args.toString(), ex); - } - try { - out.flush(); - out.close(); - } catch (IOException ex) { - logger.log(java.util.logging.Level.SEVERE, args.toString(), ex); - } - logger.info(String.format("EXIT: %s", res)); - } - } - public static void main(String... args) throws FileNotFoundException { - if (args.length == 2) { - for (;;) { - throw new UnsupportedOperationException("TODO"); -// BufferedReader in = new BufferedReader(new FileReader(args[0])); -// PrintWriter out = new PrintWriter(args[1]); -// new Server(in, out).run(); -// System.out.flush(); -// System.err.flush(); - } - } else { - ExecutorService pool = Executors.newCachedThreadPool(); - try - { - ServerSocket socket = new ServerSocket(0xcafe, -1, null); - for (;;) { - pool.execute(new Server(socket.accept())); - } - } - catch (IOException e) { - System.err.format("Error: %s%n", e.getLocalizedMessage()); - pool.shutdown(); - } - } - } - - private int compile(OutputStream out, StandardJavaFileManager fm, List args) { - // FIXME parse args and use getTask - // System.err.println("Running " + args); - return tool.run(null, null, out, args.toArray(new String[args.size()])); - } -} From d4e9a74af5202648f7a7e0798b49dc0419809ac0 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 19 Mar 2013 19:16:59 -0700 Subject: [PATCH 027/155] 8010317: DocLint incorrectly reports some
     tags
     as empty
    
    Reviewed-by: darcy
    ---
     .../com/sun/tools/doclint/Checker.java        | 35 +++++++++++----
     .../test/tools/doclint/EmptyPreTest.java      | 44 +++++++++++++++++++
     2 files changed, 71 insertions(+), 8 deletions(-)
     create mode 100644 langtools/test/tools/doclint/EmptyPreTest.java
    
    diff --git a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java
    index 5969a10a307..716845d1333 100644
    --- a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java
    +++ b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java
    @@ -25,20 +25,18 @@
     
     package com.sun.tools.doclint;
     
    -import com.sun.source.doctree.LiteralTree;
    -import java.util.regex.Matcher;
    -import com.sun.source.doctree.LinkTree;
    -import java.net.URI;
    -import java.util.regex.Pattern;
     import java.io.IOException;
    -import com.sun.tools.javac.tree.DocPretty;
     import java.io.StringWriter;
    +import java.net.URI;
    +import java.net.URISyntaxException;
     import java.util.Deque;
     import java.util.EnumSet;
     import java.util.HashSet;
     import java.util.LinkedList;
     import java.util.List;
     import java.util.Set;
    +import java.util.regex.Matcher;
    +import java.util.regex.Pattern;
     
     import javax.lang.model.element.Element;
     import javax.lang.model.element.ElementKind;
    @@ -52,12 +50,15 @@ import javax.tools.Diagnostic.Kind;
     import com.sun.source.doctree.AttributeTree;
     import com.sun.source.doctree.AuthorTree;
     import com.sun.source.doctree.DocCommentTree;
    +import com.sun.source.doctree.DocRootTree;
     import com.sun.source.doctree.DocTree;
     import com.sun.source.doctree.EndElementTree;
     import com.sun.source.doctree.EntityTree;
     import com.sun.source.doctree.ErroneousTree;
     import com.sun.source.doctree.IdentifierTree;
     import com.sun.source.doctree.InheritDocTree;
    +import com.sun.source.doctree.LinkTree;
    +import com.sun.source.doctree.LiteralTree;
     import com.sun.source.doctree.ParamTree;
     import com.sun.source.doctree.ReferenceTree;
     import com.sun.source.doctree.ReturnTree;
    @@ -67,11 +68,12 @@ import com.sun.source.doctree.SinceTree;
     import com.sun.source.doctree.StartElementTree;
     import com.sun.source.doctree.TextTree;
     import com.sun.source.doctree.ThrowsTree;
    +import com.sun.source.doctree.ValueTree;
     import com.sun.source.doctree.VersionTree;
     import com.sun.source.util.DocTreeScanner;
     import com.sun.source.util.TreePath;
     import com.sun.tools.doclint.HtmlTag.AttrKind;
    -import java.net.URISyntaxException;
    +import com.sun.tools.javac.tree.DocPretty;
     import static com.sun.tools.doclint.Messages.Group.*;
     
     
    @@ -95,6 +97,7 @@ public class Checker extends DocTreeScanner {
         public enum Flag {
             TABLE_HAS_CAPTION,
             HAS_ELEMENT,
    +        HAS_INLINE_TAG,
             HAS_TEXT,
             REPORTED_BAD_INLINE
         }
    @@ -418,7 +421,8 @@ public class Checker extends DocTreeScanner {
                         }
                         if (t.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
                                 && !top.flags.contains(Flag.HAS_TEXT)
    -                            && !top.flags.contains(Flag.HAS_ELEMENT)) {
    +                            && !top.flags.contains(Flag.HAS_ELEMENT)
    +                            && !top.flags.contains(Flag.HAS_INLINE_TAG)) {
                             env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
                         }
                         tagStack.pop();
    @@ -570,8 +574,15 @@ public class Checker extends DocTreeScanner {
             return super.visitAuthor(tree, ignore);
         }
     
    +    @Override
    +    public Void visitDocRoot(DocRootTree tree, Void ignore) {
    +        markEnclosingTag(Flag.HAS_INLINE_TAG);
    +        return super.visitDocRoot(tree, ignore);
    +    }
    +
         @Override
         public Void visitInheritDoc(InheritDocTree tree, Void ignore) {
    +        markEnclosingTag(Flag.HAS_INLINE_TAG);
             // TODO: verify on overridden method
             foundInheritDoc = true;
             return super.visitInheritDoc(tree, ignore);
    @@ -579,6 +590,7 @@ public class Checker extends DocTreeScanner {
     
         @Override
         public Void visitLink(LinkTree tree, Void ignore) {
    +        markEnclosingTag(Flag.HAS_INLINE_TAG);
             // simulate inline context on tag stack
             HtmlTag t = (tree.getKind() == DocTree.Kind.LINK)
                     ? HtmlTag.CODE : HtmlTag.SPAN;
    @@ -592,6 +604,7 @@ public class Checker extends DocTreeScanner {
     
         @Override
         public Void visitLiteral(LiteralTree tree, Void ignore) {
    +        markEnclosingTag(Flag.HAS_INLINE_TAG);
             if (tree.getKind() == DocTree.Kind.CODE) {
                 for (TagStackItem tsi: tagStack) {
                     if (tsi.tag == HtmlTag.CODE) {
    @@ -745,6 +758,12 @@ public class Checker extends DocTreeScanner {
             }
         }
     
    +    @Override
    +    public Void visitValue(ValueTree tree, Void ignore) {
    +        markEnclosingTag(Flag.HAS_INLINE_TAG);
    +        return super.visitValue(tree, ignore);
    +    }
    +
         @Override
         public Void visitVersion(VersionTree tree, Void ignore) {
             warnIfEmpty(tree, tree.getBody());
    diff --git a/langtools/test/tools/doclint/EmptyPreTest.java b/langtools/test/tools/doclint/EmptyPreTest.java
    new file mode 100644
    index 00000000000..ada4995f41c
    --- /dev/null
    +++ b/langtools/test/tools/doclint/EmptyPreTest.java
    @@ -0,0 +1,44 @@
    +/*
    + * Copyright (c) 2012, 2013, 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 8010317
    + * @summary DocLint incorrectly reports some 
     tags as empty
    + * @build DocLintTester
    + * @run main DocLintTester -Xmsgs:html EmptyPreTest.java
    + */
    +
    +public class EmptyPreTest {
    +    /** 
     {@code xyzzy} 
    */ + public void m1() { } + + /**
     {@docRoot} 
    */ + public void m2() { } + + /**
     {@link java.lang.String} 
    */ + public void m3() { } + + /**
     {@value} 
    */ + public static final int v1 = 1; +} From 3277de9dad1b2565f3242516552073afec749ee9 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Wed, 20 Mar 2013 08:17:55 +0100 Subject: [PATCH 028/155] 8010084: Race in runtime/NMT/BaselineWithParameter.java Added a waitFor() on the process Reviewed-by: mgerdin, sla, zgu --- hotspot/test/runtime/NMT/BaselineWithParameter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/runtime/NMT/BaselineWithParameter.java b/hotspot/test/runtime/NMT/BaselineWithParameter.java index 594bd7165ed..ff10b28a060 100644 --- a/hotspot/test/runtime/NMT/BaselineWithParameter.java +++ b/hotspot/test/runtime/NMT/BaselineWithParameter.java @@ -43,7 +43,7 @@ public class BaselineWithParameter { // Run 'jcmd VM.native_memory baseline=false' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline=false"}); - pb.start(); + pb.start().waitFor(); // Run 'jcmd VM.native_memory summary=false' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary=false"}); From e21f2d67e197983e6b35652b206dbbd068a26a31 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 20 Mar 2013 08:04:54 -0400 Subject: [PATCH 029/155] 8008217: CDS: Class data sharing limits the malloc heap on Solaris In 64bit VM move CDS archive address to 32G on all platforms using new flag SharedBaseAddress. In 32bit VM set CDS archive address to 3Gb on Linux and let other OSs pick the address. Reviewed-by: kvn, dcubed, zgu, hseigel --- .../src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp | 2 +- .../os_cpu/bsd_zero/vm/globals_bsd_zero.hpp | 2 +- .../linux_sparc/vm/globals_linux_sparc.hpp | 2 +- .../os_cpu/linux_x86/vm/globals_linux_x86.hpp | 2 +- .../linux_zero/vm/globals_linux_zero.hpp | 2 +- .../vm/globals_solaris_sparc.hpp | 2 +- .../solaris_x86/vm/globals_solaris_x86.hpp | 2 +- .../windows_x86/vm/globals_windows_x86.hpp | 2 +- hotspot/src/share/vm/memory/filemap.cpp | 2 +- hotspot/src/share/vm/memory/metaspace.cpp | 23 +++++-------------- hotspot/src/share/vm/runtime/globals.hpp | 5 ++-- 11 files changed, 18 insertions(+), 28 deletions(-) diff --git a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp index 1144115bc5e..0da430230a8 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp @@ -46,7 +46,7 @@ define_pd_global(uintx, SurvivorRatio, 8); define_pd_global(uintx, JVMInvokeMethodSlack, 8192); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx, HeapBaseMinAddress, 2*G); #endif // OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP diff --git a/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp b/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp index 9c988eb743b..44f72df22cf 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp @@ -41,7 +41,7 @@ define_pd_global(intx, VMThreadStackSize, 512); define_pd_global(intx, CompilerThreadStackSize, 0); define_pd_global(uintx, JVMInvokeMethodSlack, 8192); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx, HeapBaseMinAddress, 2*G); #endif // OS_CPU_BSD_ZERO_VM_GLOBALS_BSD_ZERO_HPP diff --git a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp index 4ac5ead1946..844279e41e0 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp @@ -33,7 +33,7 @@ define_pd_global(uintx, JVMInvokeMethodSlack, 12288); define_pd_global(intx, CompilerThreadStackSize, 0); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx, HeapBaseMinAddress, CONST64(4)*G); #endif // OS_CPU_LINUX_SPARC_VM_GLOBALS_LINUX_SPARC_HPP diff --git a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp index b11a6f3aa27..622928aa17b 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp +++ b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp @@ -44,7 +44,7 @@ define_pd_global(intx, CompilerThreadStackSize, 0); define_pd_global(uintx,JVMInvokeMethodSlack, 8192); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx,HeapBaseMinAddress, 2*G); #endif // OS_CPU_LINUX_X86_VM_GLOBALS_LINUX_X86_HPP diff --git a/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp index 56495d176d1..4e0be5c79f3 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp +++ b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp @@ -41,7 +41,7 @@ define_pd_global(intx, VMThreadStackSize, 512); define_pd_global(intx, CompilerThreadStackSize, 0); define_pd_global(uintx, JVMInvokeMethodSlack, 8192); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx, HeapBaseMinAddress, 2*G); #endif // OS_CPU_LINUX_ZERO_VM_GLOBALS_LINUX_ZERO_HPP diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp index e6cb0dddb01..595cd781447 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp @@ -33,7 +33,7 @@ define_pd_global(uintx, JVMInvokeMethodSlack, 12288); define_pd_global(intx, CompilerThreadStackSize, 0); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address #ifdef _LP64 define_pd_global(uintx, HeapBaseMinAddress, CONST64(4)*G); #else diff --git a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp index 5d99a09c447..91a4336d903 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp @@ -43,7 +43,7 @@ define_pd_global(uintx,JVMInvokeMethodSlack, 10*K); define_pd_global(intx, CompilerThreadStackSize, 0); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx,HeapBaseMinAddress, 256*M); #endif // OS_CPU_SOLARIS_X86_VM_GLOBALS_SOLARIS_X86_HPP diff --git a/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp b/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp index f4167f5eb5c..10e0aaff747 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp +++ b/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp @@ -45,7 +45,7 @@ define_pd_global(intx, CompilerThreadStackSize, 0); define_pd_global(uintx, JVMInvokeMethodSlack, 8192); -// Used on 64 bit platforms for UseCompressedOops base address or CDS +// Used on 64 bit platforms for UseCompressedOops base address define_pd_global(uintx, HeapBaseMinAddress, 2*G); #endif // OS_CPU_WINDOWS_X86_VM_GLOBALS_WINDOWS_X86_HPP diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp index fec0957f145..133685932fd 100644 --- a/hotspot/src/share/vm/memory/filemap.cpp +++ b/hotspot/src/share/vm/memory/filemap.cpp @@ -372,7 +372,7 @@ ReservedSpace FileMapInfo::reserve_shared_memory() { // other reserved memory (like the code cache). ReservedSpace rs(size, alignment, false, requested_addr); if (!rs.is_reserved()) { - fail_continue(err_msg("Unable to reserved shared space at required address " INTPTR_FORMAT, requested_addr)); + fail_continue(err_msg("Unable to reserve shared space at required address " INTPTR_FORMAT, requested_addr)); return rs; } // the reserved virtual memory is for mapping class data sharing archive diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index 6e3145dfac5..47cbeaa19ed 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -337,27 +337,16 @@ VirtualSpaceNode::VirtualSpaceNode(size_t byte_size) : _top(NULL), _next(NULL), // align up to vm allocation granularity byte_size = align_size_up(byte_size, os::vm_allocation_granularity()); - // This allocates memory with mmap. For DumpSharedspaces, allocate the - // space at low memory so that other shared images don't conflict. - // This is the same address as memory needed for UseCompressedOops but - // compressed oops don't work with CDS (offsets in metadata are wrong), so - // borrow the same address. + // This allocates memory with mmap. For DumpSharedspaces, try to reserve + // configurable address, generally at the top of the Java heap so other + // memory addresses don't conflict. if (DumpSharedSpaces) { - char* shared_base = (char*)HeapBaseMinAddress; + char* shared_base = (char*)SharedBaseAddress; _rs = ReservedSpace(byte_size, 0, false, shared_base, 0); if (_rs.is_reserved()) { - assert(_rs.base() == shared_base, "should match"); + assert(shared_base == 0 || _rs.base() == shared_base, "should match"); } else { - // If we are dumping the heap, then allocate a wasted block of address - // space in order to push the heap to a lower address. This extra - // address range allows for other (or larger) libraries to be loaded - // without them occupying the space required for the shared spaces. - uintx reserved = 0; - uintx block_size = 64*1024*1024; - while (reserved < SharedDummyBlockSize) { - char* dummy = os::reserve_memory(block_size); - reserved += block_size; - } + // Get a mmap region anywhere if the SharedBaseAddress fails. _rs = ReservedSpace(byte_size); } MetaspaceShared::set_shared_rs(&_rs); diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 489999f6c4a..7a8dd4a436e 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3573,8 +3573,9 @@ class CommandLineFlags { product(uintx, SharedMiscCodeSize, 120*K, \ "Size of the shared miscellaneous code area (in bytes)") \ \ - product(uintx, SharedDummyBlockSize, 0, \ - "Size of dummy block used to shift heap addresses (in bytes)") \ + product(uintx, SharedBaseAddress, LP64_ONLY(32*G) \ + NOT_LP64(LINUX_ONLY(2*G) NOT_LINUX(0)), \ + "Address to allocate shared memory region for class data") \ \ diagnostic(bool, EnableInvokeDynamic, true, \ "support JSR 292 (method handles, invokedynamic, " \ From b799726f352399bf9c5d0397f176fe5648f81049 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 20 Mar 2013 09:42:48 -0400 Subject: [PATCH 030/155] 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT 8009777: NMT: add new NMT dcmd to control auto shutdown option Added diagnostic VM option and DCmd command to allow NMT stay alive under stress situation Reviewed-by: dcubed, coleenp --- hotspot/src/share/vm/runtime/globals.hpp | 5 ++++ hotspot/src/share/vm/services/memTracker.cpp | 15 ++++++++++++ hotspot/src/share/vm/services/memTracker.hpp | 15 ++++++++++++ hotspot/src/share/vm/services/nmtDCmd.cpp | 24 +++++++++++++------- hotspot/src/share/vm/services/nmtDCmd.hpp | 1 + 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 489999f6c4a..8b1db90bdee 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -869,6 +869,11 @@ class CommandLineFlags { diagnostic(bool, PrintNMTStatistics, false, \ "Print native memory tracking summary data if it is on") \ \ + diagnostic(bool, AutoShutdownNMT, true, \ + "Automatically shutdown native memory tracking under stress " \ + "situation. When set to false, native memory tracking tries to " \ + "stay alive at the expense of JVM performance") \ + \ diagnostic(bool, LogCompilation, false, \ "Log compilation activity in detail to hotspot.log or LogFile") \ \ diff --git a/hotspot/src/share/vm/services/memTracker.cpp b/hotspot/src/share/vm/services/memTracker.cpp index 4c110d584ac..8172f67ad4a 100644 --- a/hotspot/src/share/vm/services/memTracker.cpp +++ b/hotspot/src/share/vm/services/memTracker.cpp @@ -68,6 +68,7 @@ int MemTracker::_thread_count = 255; volatile jint MemTracker::_pooled_recorder_count = 0; volatile unsigned long MemTracker::_processing_generation = 0; volatile bool MemTracker::_worker_thread_idle = false; +volatile bool MemTracker::_slowdown_calling_thread = false; debug_only(intx MemTracker::_main_thread_tid = 0;) NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;) @@ -364,6 +365,12 @@ void MemTracker::create_memory_record(address addr, MEMFLAGS flags, } if (thread != NULL) { + // slow down all calling threads except NMT worker thread, so it + // can catch up. + if (_slowdown_calling_thread && thread != _worker_thread) { + os::yield_all(); + } + if (thread->is_Java_thread() && ((JavaThread*)thread)->is_safepoint_visible()) { JavaThread* java_thread = (JavaThread*)thread; JavaThreadState state = java_thread->thread_state(); @@ -442,6 +449,7 @@ void MemTracker::enqueue_pending_recorder(MemRecorder* rec) { #define MAX_SAFEPOINTS_TO_SKIP 128 #define SAFE_SEQUENCE_THRESHOLD 30 #define HIGH_GENERATION_THRESHOLD 60 +#define MAX_RECORDER_THREAD_RATIO 30 void MemTracker::sync() { assert(_tracking_level > NMT_off, "NMT is not enabled"); @@ -487,6 +495,13 @@ void MemTracker::sync() { pending_recorders = _global_recorder; _global_recorder = NULL; } + + // see if NMT has too many outstanding recorder instances, it usually + // means that worker thread is lagging behind in processing them. + if (!AutoShutdownNMT) { + _slowdown_calling_thread = (MemRecorder::_instance_count > MAX_RECORDER_THREAD_RATIO * _thread_count); + } + // check _worker_thread with lock to avoid racing condition if (_worker_thread != NULL) { _worker_thread->at_sync_point(pending_recorders, InstanceKlass::number_of_instance_classes()); diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 764b2950543..934daf06ab9 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -84,6 +84,7 @@ class MemTracker : AllStatic { static inline bool baseline() { return false; } static inline bool has_baseline() { return false; } + static inline void set_autoShutdown(bool value) { } static void shutdown(ShutdownReason reason) { } static inline bool shutdown_in_progress() { } static bool print_memory_usage(BaselineOutputer& out, size_t unit, @@ -238,6 +239,16 @@ class MemTracker : AllStatic { // if native memory tracking tracks callsite static inline bool track_callsite() { return _tracking_level == NMT_detail; } + // NMT automatically shuts itself down under extreme situation by default. + // When the value is set to false, NMT will try its best to stay alive, + // even it has to slow down VM. + static inline void set_autoShutdown(bool value) { + AutoShutdownNMT = value; + if (AutoShutdownNMT && _slowdown_calling_thread) { + _slowdown_calling_thread = false; + } + } + // shutdown native memory tracking capability. Native memory tracking // can be shutdown by VM when it encounters low memory scenarios. // Memory tracker should gracefully shutdown itself, and preserve the @@ -507,6 +518,10 @@ class MemTracker : AllStatic { // although NMT is still procesing current generation, but // there is not more recorder to process, set idle state static volatile bool _worker_thread_idle; + + // if NMT should slow down calling thread to allow + // worker thread to catch up + static volatile bool _slowdown_calling_thread; }; #endif // !INCLUDE_NMT diff --git a/hotspot/src/share/vm/services/nmtDCmd.cpp b/hotspot/src/share/vm/services/nmtDCmd.cpp index 83b7d7e4b8a..62bd72b8158 100644 --- a/hotspot/src/share/vm/services/nmtDCmd.cpp +++ b/hotspot/src/share/vm/services/nmtDCmd.cpp @@ -49,6 +49,9 @@ NMTDCmd::NMTDCmd(outputStream* output, _shutdown("shutdown", "request runtime to shutdown itself and free the " \ "memory used by runtime.", "BOOLEAN", false, "false"), + _auto_shutdown("autoShutdown", "automatically shutdown itself under " \ + "stress situation", + "BOOLEAN", true, "true"), #ifndef PRODUCT _debug("debug", "print tracker statistics. Debug only, not thread safe", \ "BOOLEAN", false, "false"), @@ -61,6 +64,7 @@ NMTDCmd::NMTDCmd(outputStream* output, _dcmdparser.add_dcmd_option(&_summary_diff); _dcmdparser.add_dcmd_option(&_detail_diff); _dcmdparser.add_dcmd_option(&_shutdown); + _dcmdparser.add_dcmd_option(&_auto_shutdown); #ifndef PRODUCT _dcmdparser.add_dcmd_option(&_debug); #endif @@ -84,17 +88,19 @@ void NMTDCmd::execute(TRAPS) { } int nopt = 0; - if(_summary.is_set() && _summary.value()) { ++nopt; } - if(_detail.is_set() && _detail.value()) { ++nopt; } - if(_baseline.is_set() && _baseline.value()) { ++nopt; } - if(_summary_diff.is_set() && _summary_diff.value()) { ++nopt; } - if(_detail_diff.is_set() && _detail_diff.value()) { ++nopt; } - if(_shutdown.is_set() && _shutdown.value()) { ++nopt; } + if (_summary.is_set() && _summary.value()) { ++nopt; } + if (_detail.is_set() && _detail.value()) { ++nopt; } + if (_baseline.is_set() && _baseline.value()) { ++nopt; } + if (_summary_diff.is_set() && _summary_diff.value()) { ++nopt; } + if (_detail_diff.is_set() && _detail_diff.value()) { ++nopt; } + if (_shutdown.is_set() && _shutdown.value()) { ++nopt; } + if (_auto_shutdown.is_set()) { ++nopt; } + #ifndef PRODUCT - if(_debug.is_set() && _debug.value()) { ++nopt; } + if (_debug.is_set() && _debug.value()) { ++nopt; } #endif - if(nopt > 1) { + if (nopt > 1) { output()->print_cr("At most one of the following option can be specified: " \ "summary, detail, baseline, summary.diff, detail.diff, shutdown" #ifndef PRODUCT @@ -156,6 +162,8 @@ void NMTDCmd::execute(TRAPS) { MemTracker::shutdown(MemTracker::NMT_shutdown_user); output()->print_cr("Shutdown is in progress, it will take a few moments to " \ "completely shutdown"); + } else if (_auto_shutdown.is_set()) { + MemTracker::set_autoShutdown(_auto_shutdown.value()); } else { ShouldNotReachHere(); output()->print_cr("Unknown command"); diff --git a/hotspot/src/share/vm/services/nmtDCmd.hpp b/hotspot/src/share/vm/services/nmtDCmd.hpp index 0c8c8657a72..4f6dd83f03d 100644 --- a/hotspot/src/share/vm/services/nmtDCmd.hpp +++ b/hotspot/src/share/vm/services/nmtDCmd.hpp @@ -39,6 +39,7 @@ class NMTDCmd: public DCmdWithParser { DCmdArgument _summary_diff; DCmdArgument _detail_diff; DCmdArgument _shutdown; + DCmdArgument _auto_shutdown; #ifndef PRODUCT DCmdArgument _debug; #endif From cfb7431cca4ce9ff8bb679b82b9c84188d574811 Mon Sep 17 00:00:00 2001 From: Karen Kinnear Date: Wed, 20 Mar 2013 11:43:56 -0400 Subject: [PATCH 031/155] 8010017: lambda: reflection get(Declared)Methods support for default methods Don't expose vm generated overpass (bridges to default methods). Reviewed-by: dholmes, fparain --- hotspot/src/share/vm/prims/jvm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 1c277b76ccc..ce66961269f 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -1722,7 +1722,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, int i; for (i = 0; i < methods_length; i++) { methodHandle method(THREAD, methods->at(i)); - if (!method->is_initializer()) { + if (!method->is_initializer() && !method->is_overpass()) { if (!publicOnly || method->is_public()) { ++num_methods; } @@ -1736,7 +1736,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, int out_idx = 0; for (i = 0; i < methods_length; i++) { methodHandle method(THREAD, methods->at(i)); - if (!method->is_initializer()) { + if (!method->is_initializer() && !method->is_overpass()) { if (!publicOnly || method->is_public()) { oop m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL); result->obj_at_put(out_idx, m); From 0268771fc45a2c9a4ec0d6cc421f3b87421538b2 Mon Sep 17 00:00:00 2001 From: Tao Mao Date: Wed, 20 Mar 2013 12:27:03 -0700 Subject: [PATCH 032/155] 7196080: assert(max_heap >= InitialHeapSize) in arguments.cpp Remove the related assertions becasue they do not hold here. Reviewed-by: jmasa, tschatzl --- hotspot/src/share/vm/runtime/arguments.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index a2bcb956249..7fccf4be754 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1169,7 +1169,6 @@ void Arguments::set_cms_and_parnew_gc_flags() { set_parnew_gc_flags(); } - // MaxHeapSize is aligned down in collectorPolicy size_t max_heap = align_size_down(MaxHeapSize, CardTableRS::ct_max_alignment_constraint()); @@ -1207,10 +1206,6 @@ void Arguments::set_cms_and_parnew_gc_flags() { } // Code along this path potentially sets NewSize and OldSize - - assert(max_heap >= InitialHeapSize, "Error"); - assert(max_heap >= NewSize, "Error"); - if (PrintGCDetails && Verbose) { // Too early to use gclog_or_tty tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT From b7d738913e361409d5d443fa2456aa1ca3a8642f Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Wed, 20 Mar 2013 20:40:57 +0100 Subject: [PATCH 033/155] 8007982: some runtime/CommandLine/ tests fail on 32-bit platforms Changed tests to use platform independent flags Reviewed-by: collins, hseigel, zgu --- .../runtime/CommandLine/BooleanFlagWithInvalidValue.java | 8 ++++---- .../test/runtime/CommandLine/FlagWithInvalidValue.java | 4 ++-- .../NonBooleanFlagWithInvalidBooleanPrefix.java | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hotspot/test/runtime/CommandLine/BooleanFlagWithInvalidValue.java b/hotspot/test/runtime/CommandLine/BooleanFlagWithInvalidValue.java index 85f533a88e3..be035e2ca43 100644 --- a/hotspot/test/runtime/CommandLine/BooleanFlagWithInvalidValue.java +++ b/hotspot/test/runtime/CommandLine/BooleanFlagWithInvalidValue.java @@ -33,17 +33,17 @@ import com.oracle.java.testlibrary.*; public class BooleanFlagWithInvalidValue { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UseLargePages=8", "-version"); + "-XX:+PrintWarnings=8", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Improperly specified VM option 'UseLargePages=8'"); + output.shouldContain("Improperly specified VM option 'PrintWarnings=8'"); output.shouldHaveExitValue(1); pb = ProcessTools.createJavaProcessBuilder( - "-XX:-UseLargePages=8", "-version"); + "-XX:-PrintWarnings=8", "-version"); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Improperly specified VM option 'UseLargePages=8'"); + output.shouldContain("Improperly specified VM option 'PrintWarnings=8'"); output.shouldHaveExitValue(1); } } diff --git a/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java b/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java index 9d475c21951..22abc53c50d 100644 --- a/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java +++ b/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java @@ -33,10 +33,10 @@ import com.oracle.java.testlibrary.*; public class FlagWithInvalidValue { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:ObjectAlignmentInBytes=v", "-version"); + "-XX:MaxRAMFraction=v", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Improperly specified VM option 'ObjectAlignmentInBytes=v'"); + output.shouldContain("Improperly specified VM option 'MaxRAMFraction=v'"); output.shouldHaveExitValue(1); } } diff --git a/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java b/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java index d84570eb734..7933aef1a0a 100644 --- a/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java +++ b/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java @@ -33,17 +33,17 @@ import com.oracle.java.testlibrary.*; public class NonBooleanFlagWithInvalidBooleanPrefix { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:-ObjectAlignmentInBytes=16", "-version"); + "-XX:-MaxRAMFraction=16", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Unexpected +/- setting in VM option 'ObjectAlignmentInBytes=16'"); + output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMFraction=16'"); output.shouldHaveExitValue(1); pb = ProcessTools.createJavaProcessBuilder( - "-XX:+ObjectAlignmentInBytes=16", "-version"); + "-XX:+MaxRAMFraction=16", "-version"); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Unexpected +/- setting in VM option 'ObjectAlignmentInBytes=16'"); + output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMFraction=16'"); output.shouldHaveExitValue(1); } From 08c578cdcf82321c6576049181e9089d46c8baa3 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 20 Mar 2013 17:41:40 -0700 Subject: [PATCH 034/155] 8010364: Clarify javax.lang.model API for Type Annotations Reviewed-by: jjg, abuckley --- .../javax/lang/model/AnnotatedConstruct.java | 68 +++++++++++++++---- .../javax/lang/model/type/ExecutableType.java | 1 - 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java index a7d1a84c1fe..99bbe35cfae 100644 --- a/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java +++ b/langtools/src/share/classes/javax/lang/model/AnnotatedConstruct.java @@ -31,29 +31,64 @@ import javax.lang.model.element.*; import javax.lang.model.type.*; /** - * Represent a construct that can have annotations. + * Represents a construct that can be annotated. * - * When annotations are on an {@linkplain Element element}, - * they are on a declaration. When annotations are on a {@linkplain - * TypeMirror type}, they are on a use of a type. + * A construct is either an {@linkplain + * javax.lang.model.element.Element element} or a {@linkplain + * javax.lang.model.type.TypeMirror type}. Annotations on an element + * are on a declaration, whereas annotations on a type are on + * a specific use of a type name. + * + * The terms directly present and present are used + * throughout this interface to describe precisely which annotations + * are returned by methods: + * + *

    An annotation A is directly present on a + * construct E if E is annotated, and: + * + *

      + * + *
    • for an invocation of {@code getAnnotation(Class)} or + * {@code getAnnotationMirrors()}, E's annotations contain A. + * + *
    • for an invocation of getAnnotationsByType(Class), + * E's annotations either contain A or, if the type of + * A is repeatable, contain exactly one annotation whose value + * element contains A and whose type is the containing + * annotation type of A's type. + * + *
    + * + *

    An annotation A is present on a construct E if either: + * + *

      + *
    • A is directly present on E; or + * + *
    • A is not directly present on E, and + * E is an element representing a class, and A's type + * is inheritable, and A is present on the element + * representing the superclass of E. + * + *
    * * @since 1.8 + * @jls 9.6 Annotation Types + * @jls 9.6.3.3 @Inherited */ public interface AnnotatedConstruct { /** - * Returns the annotations that are directly present on this - * element or type use. + * Returns the annotations that are directly present on + * this construct. * - * @return the annotations directly present on this element or type use; - * an empty list if there are none + * @return the annotations directly present on this + * construct; an empty list if there are none */ List getAnnotationMirrors(); /** - * Returns this element's or type use's annotation for the - * specified type if such an annotation is present, else {@code - * null}. The annotation may be either inherited or directly - * present on this element. + * Returns this construct's annotation of the + * specified type if such an annotation is present, else {@code + * null}. * *

    The annotation returned by this method could contain an element * whose value is of type {@code Class}. @@ -94,18 +129,19 @@ public interface AnnotatedConstruct { * @see IncompleteAnnotationException * @see MirroredTypeException * @see MirroredTypesException + * @jls 9.6.1 Annotation Type Elements */ A getAnnotation(Class annotationType); /** - * Returns annotations that are present on this element or type use. + * Returns annotations that are present on this construct. * - * If there are no annotations present on this element or type use, + * If there are no annotations present on this construct, * the return value is an array of length 0. * * The difference between this method and {@link #getAnnotation(Class)} * is that this method detects if its argument is a repeatable - * annotation type (JLS 9.6), and if so, attempts to find one or more + * annotation type, and if so, attempts to find one or more * annotations of that type by "looking through" a container annotation. * *

    The annotations returned by this method could contain an element @@ -147,6 +183,8 @@ public interface AnnotatedConstruct { * @see IncompleteAnnotationException * @see MirroredTypeException * @see MirroredTypesException + * @jls 9.6 Annotation Types + * @jls 9.6.1 Annotation Type Elements */ A[] getAnnotationsByType(Class annotationType); } diff --git a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java index 3e8e53cbdaf..41132dcf2e0 100644 --- a/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java +++ b/langtools/src/share/classes/javax/lang/model/type/ExecutableType.java @@ -30,7 +30,6 @@ import java.util.List; import javax.lang.model.element.ExecutableElement; - /** * Represents the type of an executable. An executable * is a method, constructor, or initializer. From a003234ac85dcd5a99d7fa17f564c4e864c4f2f2 Mon Sep 17 00:00:00 2001 From: Ron Durbin Date: Wed, 20 Mar 2013 20:44:54 -0700 Subject: [PATCH 035/155] 8010396: checking MallocMaxTestWords in testMalloc() function is redundant Remove redundant checks in testMalloc and add assert. Reviewed-by: dcubed, coleenp, dholmes --- hotspot/src/share/vm/runtime/os.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 05fa2d07e73..aff49e80615 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -577,15 +577,15 @@ void verify_block(void* memblock) { // condition without really running the system out of memory. // static u_char* testMalloc(size_t alloc_size) { + assert(MallocMaxTestWords > 0, "sanity check"); - if (MallocMaxTestWords > 0 && - (cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) { + if ((cur_malloc_words + (alloc_size / BytesPerWord)) > MallocMaxTestWords) { return NULL; } u_char* ptr = (u_char*)::malloc(alloc_size); - if (MallocMaxTestWords > 0 && (ptr != NULL)) { + if (ptr != NULL) { Atomic::add(((jint) (alloc_size / BytesPerWord)), (volatile jint *) &cur_malloc_words); } From 06ef4cddf78c79c010cf32f358fa7b2cc91a84ae Mon Sep 17 00:00:00 2001 From: Thomas Wuerthinger Date: Thu, 21 Mar 2013 09:27:54 +0100 Subject: [PATCH 036/155] 7153771: array bound check elimination for c1 When possible optimize out array bound checks, inserting predicates when needed. Reviewed-by: never, kvn, twisti --- .../src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp | 38 +- .../cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 39 + .../cpu/sparc/vm/c1_LIRGenerator_sparc.cpp | 11 +- .../src/cpu/sparc/vm/c1_Runtime1_sparc.cpp | 19 + hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp | 33 +- .../src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 38 + .../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 12 +- hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp | 3 +- hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp | 18 + hotspot/src/share/vm/c1/c1_Canonicalizer.cpp | 2 + hotspot/src/share/vm/c1/c1_Canonicalizer.hpp | 2 + hotspot/src/share/vm/c1/c1_CodeStubs.hpp | 16 + hotspot/src/share/vm/c1/c1_Compilation.cpp | 54 +- hotspot/src/share/vm/c1/c1_Compilation.hpp | 13 + hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 28 +- hotspot/src/share/vm/c1/c1_GraphBuilder.hpp | 2 + hotspot/src/share/vm/c1/c1_IR.cpp | 94 +- hotspot/src/share/vm/c1/c1_IR.hpp | 7 +- hotspot/src/share/vm/c1/c1_Instruction.cpp | 96 +- hotspot/src/share/vm/c1/c1_Instruction.hpp | 145 +- .../src/share/vm/c1/c1_InstructionPrinter.cpp | 34 + .../src/share/vm/c1/c1_InstructionPrinter.hpp | 2 + hotspot/src/share/vm/c1/c1_LIR.cpp | 15 + hotspot/src/share/vm/c1/c1_LIR.hpp | 36 +- hotspot/src/share/vm/c1/c1_LIRAssembler.hpp | 3 + hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 137 +- hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 4 + hotspot/src/share/vm/c1/c1_LinearScan.cpp | 35 +- hotspot/src/share/vm/c1/c1_Optimizer.cpp | 11 +- .../share/vm/c1/c1_RangeCheckElimination.cpp | 1517 +++++++++++++++++ .../share/vm/c1/c1_RangeCheckElimination.hpp | 241 +++ hotspot/src/share/vm/c1/c1_Runtime1.cpp | 44 + hotspot/src/share/vm/c1/c1_Runtime1.hpp | 3 + hotspot/src/share/vm/c1/c1_ValueMap.cpp | 210 ++- hotspot/src/share/vm/c1/c1_ValueMap.hpp | 10 + hotspot/src/share/vm/c1/c1_globals.hpp | 18 + .../src/share/vm/compiler/compileBroker.cpp | 3 + hotspot/src/share/vm/oops/instanceKlass.cpp | 11 - hotspot/src/share/vm/oops/methodData.cpp | 8 + hotspot/src/share/vm/runtime/globals.hpp | 2 +- 40 files changed, 2861 insertions(+), 153 deletions(-) create mode 100644 hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp create mode 100644 hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp diff --git a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp index 6d936b376e0..113665220ae 100644 --- a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp @@ -51,6 +51,16 @@ RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); + if (_info->deoptimize_on_exception()) { + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(a, relocInfo::runtime_call_type); + __ delayed()->nop(); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); + return; + } + if (_index->is_register()) { __ mov(_index->as_register(), G4); } else { @@ -64,11 +74,22 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ delayed()->nop(); ce->add_call_info_here(_info); ce->verify_oop_map(_info); -#ifdef ASSERT - __ should_not_reach_here(); -#endif + debug_only(__ should_not_reach_here()); } +PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { + _info = new CodeEmitInfo(info); +} + +void PredicateFailedStub::emit_code(LIR_Assembler* ce) { + __ bind(_entry); + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(a, relocInfo::runtime_call_type); + __ delayed()->nop(); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); +} void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); @@ -99,10 +120,17 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { + address a; + if (_info->deoptimize_on_exception()) { + // Deoptimize, do not throw the exception, because it is probably wrong to do it here. + a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + } else { + a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + } + ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); __ bind(_entry); - __ call(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id), - relocInfo::runtime_call_type); + __ call(a, relocInfo::runtime_call_type); __ delayed()->nop(); ce->add_call_info_here(_info); ce->verify_oop_map(_info); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 27bf44244b5..7c4c54ea37f 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -3361,6 +3361,45 @@ void LIR_Assembler::get_thread(LIR_Opr result_reg) { __ mov(G2_thread, result_reg->as_register()); } +#ifdef ASSERT +// emit run-time assertion +void LIR_Assembler::emit_assert(LIR_OpAssert* op) { + assert(op->code() == lir_assert, "must be"); + + if (op->in_opr1()->is_valid()) { + assert(op->in_opr2()->is_valid(), "both operands must be valid"); + comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); + } else { + assert(op->in_opr2()->is_illegal(), "both operands must be illegal"); + assert(op->condition() == lir_cond_always, "no other conditions allowed"); + } + + Label ok; + if (op->condition() != lir_cond_always) { + Assembler::Condition acond; + switch (op->condition()) { + case lir_cond_equal: acond = Assembler::equal; break; + case lir_cond_notEqual: acond = Assembler::notEqual; break; + case lir_cond_less: acond = Assembler::less; break; + case lir_cond_lessEqual: acond = Assembler::lessEqual; break; + case lir_cond_greaterEqual: acond = Assembler::greaterEqual; break; + case lir_cond_greater: acond = Assembler::greater; break; + case lir_cond_aboveEqual: acond = Assembler::greaterEqualUnsigned; break; + case lir_cond_belowEqual: acond = Assembler::lessEqualUnsigned; break; + default: ShouldNotReachHere(); + }; + __ br(acond, false, Assembler::pt, ok); + __ delayed()->nop(); + } + if (op->halt()) { + const char* str = __ code_string(op->msg()); + __ stop(str); + } else { + breakpoint(); + } + __ bind(ok); +} +#endif void LIR_Assembler::peephole(LIR_List* lir) { LIR_OpList* inst = lir->instructions_list(); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index 2d4b3a2f1d1..82cc696e8b7 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -324,7 +324,7 @@ void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { assert(x->is_pinned(),""); - bool needs_range_check = true; + bool needs_range_check = x->compute_needs_range_check(); bool use_length = x->length() != NULL; bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT; bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL || @@ -339,12 +339,9 @@ void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { array.load_item(); index.load_nonconstant(); - if (use_length) { - needs_range_check = x->compute_needs_range_check(); - if (needs_range_check) { - length.set_instruction(x->length()); - length.load_item(); - } + if (use_length && needs_range_check) { + length.set_instruction(x->length()); + length.load_item(); } if (needs_store_check) { value.load_item(); diff --git a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp index b8c838b1620..6723ef2c352 100644 --- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp @@ -987,6 +987,25 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; #endif // INCLUDE_ALL_GCS + case predicate_failed_trap_id: + { + __ set_info("predicate_failed_trap", dont_gc_arguments); + OopMap* oop_map = save_live_registers(sasm); + + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); + + oop_maps = new OopMapSet(); + oop_maps->add_gc_map(call_offset, oop_map); + + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); + assert(deopt_blob != NULL, "deoptimization blob must have been created"); + restore_live_registers(sasm); + __ restore(); + __ br(Assembler::always, false, Assembler::pt, deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type); + __ delayed()->nop(); + } + break; + default: { __ set_info("unimplemented entry", dont_gc_arguments); __ save_frame(0); diff --git a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp index 806bce01bfa..cef3cdbbeaa 100644 --- a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp @@ -101,6 +101,15 @@ RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); + if (_info->deoptimize_on_exception()) { + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(RuntimeAddress(a)); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); + return; + } + // pass the array index on stack because all registers must be preserved if (_index->is_cpu_register()) { ce->store_parameter(_index->as_register(), 0); @@ -115,9 +124,22 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { } __ call(RuntimeAddress(Runtime1::entry_for(stub_id))); ce->add_call_info_here(_info); + ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); } +PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { + _info = new CodeEmitInfo(info); +} + +void PredicateFailedStub::emit_code(LIR_Assembler* ce) { + __ bind(_entry); + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(RuntimeAddress(a)); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); +} void DivByZeroStub::emit_code(LIR_Assembler* ce) { if (_offset != -1) { @@ -414,10 +436,19 @@ void DeoptimizeStub::emit_code(LIR_Assembler* ce) { void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { + address a; + if (_info->deoptimize_on_exception()) { + // Deoptimize, do not throw the exception, because it is probably wrong to do it here. + a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + } else { + a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + } + ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); __ bind(_entry); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id))); + __ call(RuntimeAddress(a)); ce->add_call_info_here(_info); + ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); } diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index 83146761cd2..a99d7939373 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -3755,6 +3755,44 @@ void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, } } +#ifdef ASSERT +// emit run-time assertion +void LIR_Assembler::emit_assert(LIR_OpAssert* op) { + assert(op->code() == lir_assert, "must be"); + + if (op->in_opr1()->is_valid()) { + assert(op->in_opr2()->is_valid(), "both operands must be valid"); + comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); + } else { + assert(op->in_opr2()->is_illegal(), "both operands must be illegal"); + assert(op->condition() == lir_cond_always, "no other conditions allowed"); + } + + Label ok; + if (op->condition() != lir_cond_always) { + Assembler::Condition acond = Assembler::zero; + switch (op->condition()) { + case lir_cond_equal: acond = Assembler::equal; break; + case lir_cond_notEqual: acond = Assembler::notEqual; break; + case lir_cond_less: acond = Assembler::less; break; + case lir_cond_lessEqual: acond = Assembler::lessEqual; break; + case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break; + case lir_cond_greater: acond = Assembler::greater; break; + case lir_cond_belowEqual: acond = Assembler::belowEqual; break; + case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break; + default: ShouldNotReachHere(); + } + __ jcc(acond, ok); + } + if (op->halt()) { + const char* str = __ code_string(op->msg()); + __ stop(str); + } else { + breakpoint(); + } + __ bind(ok); +} +#endif void LIR_Assembler::membar() { // QQQ sparc TSO uses this, diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index 5ef14861966..6810ae54216 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -263,7 +263,7 @@ void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { assert(x->is_pinned(),""); - bool needs_range_check = true; + bool needs_range_check = x->compute_needs_range_check(); bool use_length = x->length() != NULL; bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT; bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL || @@ -278,12 +278,10 @@ void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { array.load_item(); index.load_nonconstant(); - if (use_length) { - needs_range_check = x->compute_needs_range_check(); - if (needs_range_check) { - length.set_instruction(x->length()); - length.load_item(); - } + if (use_length && needs_range_check) { + length.set_instruction(x->length()); + length.load_item(); + } if (needs_store_check) { value.load_item(); diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp index 7956a6af59f..baecb9df93d 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -675,7 +675,8 @@ void FpuStackAllocator::handle_op2(LIR_Op2* op2) { switch (op2->code()) { case lir_cmp: case lir_cmp_fd2i: - case lir_ucmp_fd2i: { + case lir_ucmp_fd2i: + case lir_assert: { assert(left->is_fpu_register(), "invalid LIR"); assert(right->is_fpu_register(), "invalid LIR"); diff --git a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp index d3ac75e4013..ff9c11d86f5 100644 --- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp @@ -1807,6 +1807,24 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; #endif // INCLUDE_ALL_GCS + case predicate_failed_trap_id: + { + StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments); + + OopMap* map = save_live_registers(sasm, 1); + + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); + oop_maps = new OopMapSet(); + oop_maps->add_gc_map(call_offset, map); + restore_live_registers(sasm); + __ leave(); + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); + assert(deopt_blob != NULL, "deoptimization blob must have been created"); + + __ jump(RuntimeAddress(deopt_blob->unpack_with_reexecution())); + } + break; + default: { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments); __ movptr(rax, (int)id); diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp index 40ecd64900b..a4cda5f904f 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp @@ -937,4 +937,6 @@ void Canonicalizer::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {} void Canonicalizer::do_ProfileCall(ProfileCall* x) {} void Canonicalizer::do_ProfileInvoke(ProfileInvoke* x) {} void Canonicalizer::do_RuntimeCall(RuntimeCall* x) {} +void Canonicalizer::do_RangeCheckPredicate(RangeCheckPredicate* x) {} +void Canonicalizer::do_Assert(Assert* x) {} void Canonicalizer::do_MemBar(MemBar* x) {} diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp index d1eb55b07c7..b8bcfd7e65f 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp @@ -107,6 +107,8 @@ class Canonicalizer: InstructionVisitor { virtual void do_ProfileInvoke (ProfileInvoke* x); virtual void do_RuntimeCall (RuntimeCall* x); virtual void do_MemBar (MemBar* x); + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); + virtual void do_Assert (Assert* x); }; #endif // SHARE_VM_C1_C1_CANONICALIZER_HPP diff --git a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp index 9fbeb29b5a4..7235cd6c38a 100644 --- a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp +++ b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp @@ -166,6 +166,22 @@ class RangeCheckStub: public CodeStub { #endif // PRODUCT }; +// stub used when predicate fails and deoptimization is needed +class PredicateFailedStub: public CodeStub { + private: + CodeEmitInfo* _info; + + public: + PredicateFailedStub(CodeEmitInfo* info); + virtual void emit_code(LIR_Assembler* e); + virtual CodeEmitInfo* info() const { return _info; } + virtual void visit(LIR_OpVisitState* visitor) { + visitor->do_slow_case(_info); + } +#ifndef PRODUCT + virtual void print_name(outputStream* out) const { out->print("PredicateFailedStub"); } +#endif // PRODUCT +}; class DivByZeroStub: public CodeStub { private: diff --git a/hotspot/src/share/vm/c1/c1_Compilation.cpp b/hotspot/src/share/vm/c1/c1_Compilation.cpp index cc268ef1450..a8effa4bccf 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.cpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp @@ -33,13 +33,16 @@ #include "c1/c1_ValueStack.hpp" #include "code/debugInfoRec.hpp" #include "compiler/compileLog.hpp" +#include "c1/c1_RangeCheckElimination.hpp" typedef enum { _t_compile, _t_setup, - _t_optimizeIR, _t_buildIR, + _t_optimize_blocks, + _t_optimize_null_checks, + _t_rangeCheckElimination, _t_emit_lir, _t_linearScan, _t_lirGeneration, @@ -52,8 +55,10 @@ typedef enum { static const char * timer_name[] = { "compile", "setup", - "optimizeIR", "buildIR", + "optimize_blocks", + "optimize_null_checks", + "rangeCheckElimination", "emit_lir", "linearScan", "lirGeneration", @@ -159,9 +164,9 @@ void Compilation::build_hir() { if (UseC1Optimizations) { NEEDS_CLEANUP // optimization - PhaseTraceTime timeit(_t_optimizeIR); + PhaseTraceTime timeit(_t_optimize_blocks); - _hir->optimize(); + _hir->optimize_blocks(); } _hir->verify(); @@ -180,13 +185,47 @@ void Compilation::build_hir() { _hir->compute_code(); if (UseGlobalValueNumbering) { - ResourceMark rm; + // No resource mark here! LoopInvariantCodeMotion can allocate ValueStack objects. int instructions = Instruction::number_of_instructions(); GlobalValueNumbering gvn(_hir); assert(instructions == Instruction::number_of_instructions(), "shouldn't have created an instructions"); } + _hir->verify(); + +#ifndef PRODUCT + if (PrintCFGToFile) { + CFGPrinter::print_cfg(_hir, "Before RangeCheckElimination", true, false); + } +#endif + + if (RangeCheckElimination) { + if (_hir->osr_entry() == NULL) { + PhaseTraceTime timeit(_t_rangeCheckElimination); + RangeCheckElimination::eliminate(_hir); + } + } + +#ifndef PRODUCT + if (PrintCFGToFile) { + CFGPrinter::print_cfg(_hir, "After RangeCheckElimination", true, false); + } +#endif + + if (UseC1Optimizations) { + // loop invariant code motion reorders instructions and range + // check elimination adds new instructions so do null check + // elimination after. + NEEDS_CLEANUP + // optimization + PhaseTraceTime timeit(_t_optimize_null_checks); + + _hir->eliminate_null_checks(); + } + + _hir->verify(); + // compute use counts after global value numbering _hir->compute_use_counts(); @@ -502,6 +541,7 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho , _next_id(0) , _next_block_id(0) , _code(buffer_blob) +, _has_access_indexed(false) , _current_instruction(NULL) #ifndef PRODUCT , _last_instruction_printed(NULL) @@ -567,7 +607,9 @@ void Compilation::print_timers() { tty->print_cr(" Detailed C1 Timings"); tty->print_cr(" Setup time: %6.3f s (%4.1f%%)", timers[_t_setup].seconds(), (timers[_t_setup].seconds() / total) * 100.0); tty->print_cr(" Build IR: %6.3f s (%4.1f%%)", timers[_t_buildIR].seconds(), (timers[_t_buildIR].seconds() / total) * 100.0); - tty->print_cr(" Optimize: %6.3f s (%4.1f%%)", timers[_t_optimizeIR].seconds(), (timers[_t_optimizeIR].seconds() / total) * 100.0); + float t_optimizeIR = timers[_t_optimize_blocks].seconds() + timers[_t_optimize_null_checks].seconds(); + tty->print_cr(" Optimize: %6.3f s (%4.1f%%)", t_optimizeIR, (t_optimizeIR / total) * 100.0); + tty->print_cr(" RCE: %6.3f s (%4.1f%%)", timers[_t_rangeCheckElimination].seconds(), (timers[_t_rangeCheckElimination].seconds() / total) * 100.0); tty->print_cr(" Emit LIR: %6.3f s (%4.1f%%)", timers[_t_emit_lir].seconds(), (timers[_t_emit_lir].seconds() / total) * 100.0); tty->print_cr(" LIR Gen: %6.3f s (%4.1f%%)", timers[_t_lirGeneration].seconds(), (timers[_t_lirGeneration].seconds() / total) * 100.0); tty->print_cr(" Linear Scan: %6.3f s (%4.1f%%)", timers[_t_linearScan].seconds(), (timers[_t_linearScan].seconds() / total) * 100.0); diff --git a/hotspot/src/share/vm/c1/c1_Compilation.hpp b/hotspot/src/share/vm/c1/c1_Compilation.hpp index 0a7373da875..897da9762cb 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.hpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp @@ -26,8 +26,10 @@ #define SHARE_VM_C1_C1_COMPILATION_HPP #include "ci/ciEnv.hpp" +#include "ci/ciMethodData.hpp" #include "code/exceptionHandlerTable.hpp" #include "memory/resourceArea.hpp" +#include "runtime/deoptimization.hpp" class CompilationResourceObj; class XHandlers; @@ -85,6 +87,7 @@ class Compilation: public StackObj { LinearScan* _allocator; CodeOffsets _offsets; CodeBuffer _code; + bool _has_access_indexed; // compilation helpers void initialize(); @@ -140,6 +143,7 @@ class Compilation: public StackObj { C1_MacroAssembler* masm() const { return _masm; } CodeOffsets* offsets() { return &_offsets; } Arena* arena() { return _arena; } + bool has_access_indexed() { return _has_access_indexed; } // Instruction ids int get_next_id() { return _next_id++; } @@ -154,6 +158,7 @@ class Compilation: public StackObj { void set_has_fpu_code(bool f) { _has_fpu_code = f; } void set_has_unsafe_access(bool f) { _has_unsafe_access = f; } void set_would_profile(bool f) { _would_profile = f; } + void set_has_access_indexed(bool f) { _has_access_indexed = f; } // Add a set of exception handlers covering the given PC offset void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers); // Statistics gathering @@ -233,6 +238,14 @@ class Compilation: public StackObj { return env()->comp_level() == CompLevel_full_profile && C1UpdateMethodData && C1ProfileCheckcasts; } + + // will compilation make optimistic assumptions that might lead to + // deoptimization and that the runtime will account for? + bool is_optimistic() const { + return !TieredCompilation && + (RangeCheckElimination || UseLoopInvariantCodeMotion) && + method()->method_data()->trap_count(Deoptimization::Reason_none) == 0; + } }; diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 9491607adfa..8d7619eedd6 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -947,7 +947,9 @@ void GraphBuilder::store_local(ValueStack* state, Value x, int index) { void GraphBuilder::load_indexed(BasicType type) { - ValueStack* state_before = copy_state_for_exception(); + // In case of in block code motion in range check elimination + ValueStack* state_before = copy_state_indexed_access(); + compilation()->set_has_access_indexed(true); Value index = ipop(); Value array = apop(); Value length = NULL; @@ -961,7 +963,9 @@ void GraphBuilder::load_indexed(BasicType type) { void GraphBuilder::store_indexed(BasicType type) { - ValueStack* state_before = copy_state_for_exception(); + // In case of in block code motion in range check elimination + ValueStack* state_before = copy_state_indexed_access(); + compilation()->set_has_access_indexed(true); Value value = pop(as_ValueType(type)); Value index = ipop(); Value array = apop(); @@ -1179,7 +1183,9 @@ void GraphBuilder::if_node(Value x, If::Condition cond, Value y, ValueStack* sta BlockBegin* tsux = block_at(stream()->get_dest()); BlockBegin* fsux = block_at(stream()->next_bci()); bool is_bb = tsux->bci() < stream()->cur_bci() || fsux->bci() < stream()->cur_bci(); - Instruction *i = append(new If(x, cond, false, y, tsux, fsux, is_bb ? state_before : NULL, is_bb)); + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + Instruction *i = append(new If(x, cond, false, y, tsux, fsux, (is_bb || compilation()->is_optimistic()) ? state_before : NULL, is_bb)); assert(i->as_Goto() == NULL || (i->as_Goto()->sux_at(0) == tsux && i->as_Goto()->is_safepoint() == tsux->bci() < stream()->cur_bci()) || @@ -1294,7 +1300,9 @@ void GraphBuilder::table_switch() { BlockBegin* tsux = block_at(bci() + sw.dest_offset_at(0)); BlockBegin* fsux = block_at(bci() + sw.default_offset()); bool is_bb = tsux->bci() < bci() || fsux->bci() < bci(); - ValueStack* state_before = is_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(is_bb); append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); } else { // collect successors @@ -1308,7 +1316,9 @@ void GraphBuilder::table_switch() { // add default successor if (sw.default_offset() < 0) has_bb = true; sux->at_put(i, block_at(bci() + sw.default_offset())); - ValueStack* state_before = has_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(has_bb); Instruction* res = append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb)); #ifdef ASSERT if (res->as_Goto()) { @@ -1336,7 +1346,9 @@ void GraphBuilder::lookup_switch() { BlockBegin* tsux = block_at(bci() + pair.offset()); BlockBegin* fsux = block_at(bci() + sw.default_offset()); bool is_bb = tsux->bci() < bci() || fsux->bci() < bci(); - ValueStack* state_before = is_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(is_bb);; append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); } else { // collect successors & keys @@ -1353,7 +1365,9 @@ void GraphBuilder::lookup_switch() { // add default successor if (sw.default_offset() < 0) has_bb = true; sux->at_put(i, block_at(bci() + sw.default_offset())); - ValueStack* state_before = has_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(has_bb); Instruction* res = append(new LookupSwitch(ipop(), sux, keys, state_before, has_bb)); #ifdef ASSERT if (res->as_Goto()) { diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp index 1eca297cd15..ae5afd4e04d 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp @@ -301,6 +301,8 @@ class GraphBuilder VALUE_OBJ_CLASS_SPEC { ValueStack* copy_state_exhandling(); ValueStack* copy_state_for_exception_with_bci(int bci); ValueStack* copy_state_for_exception(); + ValueStack* copy_state_if_bb(bool is_bb) { return (is_bb || compilation()->is_optimistic()) ? copy_state_before() : NULL; } + ValueStack* copy_state_indexed_access() { return compilation()->is_optimistic() ? copy_state_before() : copy_state_for_exception(); } // // Inlining support diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp index 015874ac0d3..e9e73db0c06 100644 --- a/hotspot/src/share/vm/c1/c1_IR.cpp +++ b/hotspot/src/share/vm/c1/c1_IR.cpp @@ -182,13 +182,14 @@ bool IRScopeDebugInfo::should_reexecute() { // Implementation of CodeEmitInfo // Stack must be NON-null -CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers) +CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception) : _scope(stack->scope()) , _scope_debug_info(NULL) , _oop_map(NULL) , _stack(stack) , _exception_handlers(exception_handlers) - , _is_method_handle_invoke(false) { + , _is_method_handle_invoke(false) + , _deoptimize_on_exception(deoptimize_on_exception) { assert(_stack != NULL, "must be non null"); } @@ -199,7 +200,8 @@ CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack) , _scope_debug_info(NULL) , _oop_map(NULL) , _stack(stack == NULL ? info->_stack : stack) - , _is_method_handle_invoke(info->_is_method_handle_invoke) { + , _is_method_handle_invoke(info->_is_method_handle_invoke) + , _deoptimize_on_exception(info->_deoptimize_on_exception) { // deep copy of exception handlers if (info->_exception_handlers != NULL) { @@ -239,7 +241,7 @@ IR::IR(Compilation* compilation, ciMethod* method, int osr_bci) : } -void IR::optimize() { +void IR::optimize_blocks() { Optimizer opt(this); if (!compilation()->profile_branches()) { if (DoCEE) { @@ -257,6 +259,10 @@ void IR::optimize() { #endif } } +} + +void IR::eliminate_null_checks() { + Optimizer opt(this); if (EliminateNullChecks) { opt.eliminate_null_checks(); #ifndef PRODUCT @@ -429,6 +435,7 @@ class ComputeLinearScanOrder : public StackObj { BlockList _loop_end_blocks; // list of all loop end blocks collected during count_edges BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop BlockList _work_list; // temporary list (used in mark_loops and compute_order) + BlockList _loop_headers; Compilation* _compilation; @@ -594,6 +601,7 @@ void ComputeLinearScanOrder::count_edges(BlockBegin* cur, BlockBegin* parent) { TRACE_LINEAR_SCAN(3, tty->print_cr("Block B%d is loop header of loop %d", cur->block_id(), _num_loops)); cur->set_loop_index(_num_loops); + _loop_headers.append(cur); _num_loops++; } @@ -656,6 +664,16 @@ void ComputeLinearScanOrder::clear_non_natural_loops(BlockBegin* start_block) { // -> this is not a natural loop, so ignore it TRACE_LINEAR_SCAN(2, tty->print_cr("Loop %d is non-natural, so it is ignored", i)); + BlockBegin *loop_header = _loop_headers.at(i); + assert(loop_header->is_set(BlockBegin::linear_scan_loop_header_flag), "Must be loop header"); + + for (int j = 0; j < loop_header->number_of_preds(); j++) { + BlockBegin *pred = loop_header->pred_at(j); + pred->clear(BlockBegin::linear_scan_loop_end_flag); + } + + loop_header->clear(BlockBegin::linear_scan_loop_header_flag); + for (int block_id = _max_block_id - 1; block_id >= 0; block_id--) { clear_block_in_loop(i, block_id); } @@ -729,9 +747,20 @@ void ComputeLinearScanOrder::compute_dominator(BlockBegin* cur, BlockBegin* pare } else if (!(cur->is_set(BlockBegin::linear_scan_loop_header_flag) && parent->is_set(BlockBegin::linear_scan_loop_end_flag))) { TRACE_LINEAR_SCAN(4, tty->print_cr("DOM: computing dominator of B%d: common dominator of B%d and B%d is B%d", cur->block_id(), parent->block_id(), cur->dominator()->block_id(), common_dominator(cur->dominator(), parent)->block_id())); - assert(cur->number_of_preds() > 1, ""); + // Does not hold for exception blocks + assert(cur->number_of_preds() > 1 || cur->is_set(BlockBegin::exception_entry_flag), ""); cur->set_dominator(common_dominator(cur->dominator(), parent)); } + + // Additional edge to xhandler of all our successors + // range check elimination needs that the state at the end of a + // block be valid in every block it dominates so cur must dominate + // the exception handlers of its successors. + int num_cur_xhandler = cur->number_of_exception_handlers(); + for (int j = 0; j < num_cur_xhandler; j++) { + BlockBegin* xhandler = cur->exception_handler_at(j); + compute_dominator(xhandler, parent); + } } @@ -898,7 +927,6 @@ void ComputeLinearScanOrder::compute_order(BlockBegin* start_block) { num_sux = cur->number_of_exception_handlers(); for (i = 0; i < num_sux; i++) { BlockBegin* sux = cur->exception_handler_at(i); - compute_dominator(sux, cur); if (ready_for_processing(sux)) { sort_into_work_list(sux); } @@ -918,8 +946,23 @@ bool ComputeLinearScanOrder::compute_dominators_iter() { BlockBegin* dominator = block->pred_at(0); int num_preds = block->number_of_preds(); - for (int i = 1; i < num_preds; i++) { - dominator = common_dominator(dominator, block->pred_at(i)); + + TRACE_LINEAR_SCAN(4, tty->print_cr("DOM: Processing B%d", block->block_id())); + + for (int j = 0; j < num_preds; j++) { + + BlockBegin *pred = block->pred_at(j); + TRACE_LINEAR_SCAN(4, tty->print_cr(" DOM: Subrocessing B%d", pred->block_id())); + + if (block->is_set(BlockBegin::exception_entry_flag)) { + dominator = common_dominator(dominator, pred); + int num_pred_preds = pred->number_of_preds(); + for (int k = 0; k < num_pred_preds; k++) { + dominator = common_dominator(dominator, pred->pred_at(k)); + } + } else { + dominator = common_dominator(dominator, pred); + } } if (dominator != block->dominator()) { @@ -946,6 +989,21 @@ void ComputeLinearScanOrder::compute_dominators() { // check that dominators are correct assert(!compute_dominators_iter(), "fix point not reached"); + + // Add Blocks to dominates-Array + int num_blocks = _linear_scan_order->length(); + for (int i = 0; i < num_blocks; i++) { + BlockBegin* block = _linear_scan_order->at(i); + + BlockBegin *dom = block->dominator(); + if (dom) { + assert(dom->dominator_depth() != -1, "Dominator must have been visited before"); + dom->dominates()->append(block); + block->set_dominator_depth(dom->dominator_depth() + 1); + } else { + block->set_dominator_depth(0); + } + } } @@ -1032,7 +1090,7 @@ void ComputeLinearScanOrder::verify() { BlockBegin* sux = cur->sux_at(j); assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->index_of(sux), "incorrect linear_scan_number"); - if (!cur->is_set(BlockBegin::linear_scan_loop_end_flag)) { + if (!sux->is_set(BlockBegin::backward_branch_target_flag)) { assert(cur->linear_scan_number() < sux->linear_scan_number(), "invalid order"); } if (cur->loop_depth() == sux->loop_depth()) { @@ -1044,7 +1102,7 @@ void ComputeLinearScanOrder::verify() { BlockBegin* pred = cur->pred_at(j); assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->index_of(pred), "incorrect linear_scan_number"); - if (!cur->is_set(BlockBegin::linear_scan_loop_header_flag)) { + if (!cur->is_set(BlockBegin::backward_branch_target_flag)) { assert(cur->linear_scan_number() > pred->linear_scan_number(), "invalid order"); } if (cur->loop_depth() == pred->loop_depth()) { @@ -1060,7 +1118,8 @@ void ComputeLinearScanOrder::verify() { } else { assert(cur->dominator() != NULL, "all but first block must have dominator"); } - assert(cur->number_of_preds() != 1 || cur->dominator() == cur->pred_at(0), "Single predecessor must also be dominator"); + // Assertion does not hold for exception handlers + assert(cur->number_of_preds() != 1 || cur->dominator() == cur->pred_at(0) || cur->is_set(BlockBegin::exception_entry_flag), "Single predecessor must also be dominator"); } // check that all loops are continuous @@ -1249,9 +1308,22 @@ class PredecessorValidator : public BlockClosure { } }; +class VerifyBlockBeginField : public BlockClosure { + +public: + + virtual void block_do(BlockBegin *block) { + for ( Instruction *cur = block; cur != NULL; cur = cur->next()) { + assert(cur->block() == block, "Block begin is not correct"); + } + } +}; + void IR::verify() { #ifdef ASSERT PredecessorValidator pv(this); + VerifyBlockBeginField verifier; + this->iterate_postorder(&verifier); #endif } diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp index e1f4c15ebcc..bc57300c1f0 100644 --- a/hotspot/src/share/vm/c1/c1_IR.hpp +++ b/hotspot/src/share/vm/c1/c1_IR.hpp @@ -254,6 +254,7 @@ class CodeEmitInfo: public CompilationResourceObj { OopMap* _oop_map; ValueStack* _stack; // used by deoptimization (contains also monitors bool _is_method_handle_invoke; // true if the associated call site is a MethodHandle call site. + bool _deoptimize_on_exception; FrameMap* frame_map() const { return scope()->compilation()->frame_map(); } Compilation* compilation() const { return scope()->compilation(); } @@ -261,7 +262,7 @@ class CodeEmitInfo: public CompilationResourceObj { public: // use scope from ValueStack - CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers); + CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception = false); // make a copy CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack = NULL); @@ -272,6 +273,7 @@ class CodeEmitInfo: public CompilationResourceObj { IRScope* scope() const { return _scope; } XHandlers* exception_handlers() const { return _exception_handlers; } ValueStack* stack() const { return _stack; } + bool deoptimize_on_exception() const { return _deoptimize_on_exception; } void add_register_oop(LIR_Opr opr); void record_debug_info(DebugInformationRecorder* recorder, int pc_offset); @@ -309,7 +311,8 @@ class IR: public CompilationResourceObj { int max_stack() const { return top_scope()->max_stack(); } // expensive // ir manipulation - void optimize(); + void optimize_blocks(); + void eliminate_null_checks(); void compute_predecessors(); void split_critical_edges(); void compute_code(); diff --git a/hotspot/src/share/vm/c1/c1_Instruction.cpp b/hotspot/src/share/vm/c1/c1_Instruction.cpp index 985cb098e6f..a026b4cbea0 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.cpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp @@ -34,6 +34,15 @@ // Implementation of Instruction +int Instruction::dominator_depth() { + int result = -1; + if (block()) { + result = block()->dominator_depth(); + } + assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1"); + return result; +} + Instruction::Condition Instruction::mirror(Condition cond) { switch (cond) { case eql: return eql; @@ -42,6 +51,8 @@ Instruction::Condition Instruction::mirror(Condition cond) { case leq: return geq; case gtr: return lss; case geq: return leq; + case aeq: return beq; + case beq: return aeq; } ShouldNotReachHere(); return eql; @@ -56,6 +67,8 @@ Instruction::Condition Instruction::negate(Condition cond) { case leq: return gtr; case gtr: return leq; case geq: return lss; + case aeq: assert(false, "Above equal cannot be negated"); + case beq: assert(false, "Below equal cannot be negated"); } ShouldNotReachHere(); return eql; @@ -70,10 +83,10 @@ void Instruction::update_exception_state(ValueStack* state) { } } - -Instruction* Instruction::prev(BlockBegin* block) { +// Prev without need to have BlockBegin +Instruction* Instruction::prev() { Instruction* p = NULL; - Instruction* q = block; + Instruction* q = block(); while (q != this) { assert(q != NULL, "this is not in the block's instruction list"); p = q; q = q->next(); @@ -122,15 +135,24 @@ void Instruction::print(InstructionPrinter& ip) { // perform constant and interval tests on index value bool AccessIndexed::compute_needs_range_check() { - Constant* clength = length()->as_Constant(); - Constant* cindex = index()->as_Constant(); - if (clength && cindex) { - IntConstant* l = clength->type()->as_IntConstant(); - IntConstant* i = cindex->type()->as_IntConstant(); - if (l && i && i->value() < l->value() && i->value() >= 0) { - return false; + + if (length()) { + + Constant* clength = length()->as_Constant(); + Constant* cindex = index()->as_Constant(); + if (clength && cindex) { + IntConstant* l = clength->type()->as_IntConstant(); + IntConstant* i = cindex->type()->as_IntConstant(); + if (l && i && i->value() < l->value() && i->value() >= 0) { + return false; + } } } + + if (!this->check_flag(NeedsRangeCheckFlag)) { + return false; + } + return true; } @@ -631,19 +653,25 @@ void BlockBegin::substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux) { // of the inserted block, without recomputing the values of the other blocks // in the CFG. Therefore the value of "depth_first_number" in BlockBegin becomes meaningless. BlockBegin* BlockBegin::insert_block_between(BlockBegin* sux) { - BlockBegin* new_sux = new BlockBegin(end()->state()->bci()); + int bci = sux->bci(); + // critical edge splitting may introduce a goto after a if and array + // bound check elimination may insert a predicate between the if and + // goto. The bci of the goto can't be the one of the if otherwise + // the state and bci are inconsistent and a deoptimization triggered + // by the predicate would lead to incorrect execution/a crash. + BlockBegin* new_sux = new BlockBegin(bci); // mark this block (special treatment when block order is computed) new_sux->set(critical_edge_split_flag); // This goto is not a safepoint. Goto* e = new Goto(sux, false); - new_sux->set_next(e, end()->state()->bci()); + new_sux->set_next(e, bci); new_sux->set_end(e); // setup states ValueStack* s = end()->state(); - new_sux->set_state(s->copy()); - e->set_state(s->copy()); + new_sux->set_state(s->copy(s->kind(), bci)); + e->set_state(s->copy(s->kind(), bci)); assert(new_sux->state()->locals_size() == s->locals_size(), "local size mismatch!"); assert(new_sux->state()->stack_size() == s->stack_size(), "stack size mismatch!"); assert(new_sux->state()->locks_size() == s->locks_size(), "locks size mismatch!"); @@ -960,15 +988,14 @@ void BlockEnd::set_begin(BlockBegin* begin) { BlockList* sux = NULL; if (begin != NULL) { sux = begin->successors(); - } else if (_begin != NULL) { + } else if (this->begin() != NULL) { // copy our sux list - BlockList* sux = new BlockList(_begin->number_of_sux()); - for (int i = 0; i < _begin->number_of_sux(); i++) { - sux->append(_begin->sux_at(i)); + BlockList* sux = new BlockList(this->begin()->number_of_sux()); + for (int i = 0; i < this->begin()->number_of_sux(); i++) { + sux->append(this->begin()->sux_at(i)); } } _sux = sux; - _begin = begin; } @@ -1008,7 +1035,38 @@ int Phi::operand_count() const { } } +#ifdef ASSERT +// Constructor of Assert +Assert::Assert(Value x, Condition cond, bool unordered_is_true, Value y) : Instruction(illegalType) + , _x(x) + , _cond(cond) + , _y(y) +{ + set_flag(UnorderedIsTrueFlag, unordered_is_true); + assert(x->type()->tag() == y->type()->tag(), "types must match"); + pin(); + stringStream strStream; + Compilation::current()->method()->print_name(&strStream); + + stringStream strStream1; + InstructionPrinter ip1(1, &strStream1); + ip1.print_instr(x); + + stringStream strStream2; + InstructionPrinter ip2(1, &strStream2); + ip2.print_instr(y); + + stringStream ss; + ss.print("Assertion %s %s %s in method %s", strStream1.as_string(), ip2.cond_name(cond), strStream2.as_string(), strStream.as_string()); + + _message = ss.as_string(); +} +#endif + +void RangeCheckPredicate::check_state() { + assert(state()->kind() != ValueStack::EmptyExceptionState && state()->kind() != ValueStack::ExceptionState, "will deopt with empty state"); +} void ProfileInvoke::state_values_do(ValueVisitor* f) { if (state() != NULL) state()->values_do(f); diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp index 4fff026e0c2..b93525bf502 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.hpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp @@ -110,6 +110,8 @@ class ProfileCall; class ProfileInvoke; class RuntimeCall; class MemBar; +class RangeCheckPredicate; +class Assert; // A Value is a reference to the instruction creating the value typedef Instruction* Value; @@ -210,6 +212,10 @@ class InstructionVisitor: public StackObj { virtual void do_ProfileInvoke (ProfileInvoke* x) = 0; virtual void do_RuntimeCall (RuntimeCall* x) = 0; virtual void do_MemBar (MemBar* x) = 0; + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0; +#ifdef ASSERT + virtual void do_Assert (Assert* x) = 0; +#endif }; @@ -306,8 +312,9 @@ class Instruction: public CompilationResourceObj { void update_exception_state(ValueStack* state); - //protected: - public: + protected: + BlockBegin* _block; // Block that contains this instruction + void set_type(ValueType* type) { assert(type != NULL, "type must exist"); _type = type; @@ -342,6 +349,9 @@ class Instruction: public CompilationResourceObj { ThrowIncompatibleClassChangeErrorFlag, ProfileMDOFlag, IsLinkedInBlockFlag, + NeedsRangeCheckFlag, + InWorkListFlag, + DeoptimizeOnException, InstructionLastFlag }; @@ -351,7 +361,7 @@ class Instruction: public CompilationResourceObj { // 'globally' used condition values enum Condition { - eql, neq, lss, leq, gtr, geq + eql, neq, lss, leq, gtr, geq, aeq, beq }; // Instructions may be pinned for many reasons and under certain conditions @@ -381,6 +391,7 @@ class Instruction: public CompilationResourceObj { , _pin_state(0) , _type(type) , _next(NULL) + , _block(NULL) , _subst(NULL) , _flags(0) , _operand(LIR_OprFact::illegalOpr) @@ -399,11 +410,13 @@ class Instruction: public CompilationResourceObj { int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; } void set_printable_bci(int bci) { _printable_bci = bci; } #endif + int dominator_depth(); int use_count() const { return _use_count; } int pin_state() const { return _pin_state; } bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; } ValueType* type() const { return _type; } - Instruction* prev(BlockBegin* block); // use carefully, expensive operation + BlockBegin *block() const { return _block; } + Instruction* prev(); // use carefully, expensive operation Instruction* next() const { return _next; } bool has_subst() const { return _subst != NULL; } Instruction* subst() { return _subst == NULL ? this : _subst->subst(); } @@ -432,6 +445,9 @@ class Instruction: public CompilationResourceObj { assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next"); assert(next->can_be_linked(), "shouldn't link these instructions into list"); + BlockBegin *block = this->block(); + next->_block = block; + next->set_flag(Instruction::IsLinkedInBlockFlag, true); _next = next; return next; @@ -444,6 +460,29 @@ class Instruction: public CompilationResourceObj { return set_next(next); } + // when blocks are merged + void fixup_block_pointers() { + Instruction *cur = next()->next(); // next()'s block is set in set_next + while (cur && cur->_block != block()) { + cur->_block = block(); + cur = cur->next(); + } + } + + Instruction *insert_after(Instruction *i) { + Instruction* n = _next; + set_next(i); + i->set_next(n); + return _next; + } + + Instruction *insert_after_same_bci(Instruction *i) { +#ifndef PRODUCT + i->set_printable_bci(printable_bci()); +#endif + return insert_after(i); + } + void set_subst(Instruction* subst) { assert(subst == NULL || type()->base() == subst->type()->base() || @@ -452,6 +491,7 @@ class Instruction: public CompilationResourceObj { } void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; } void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; } + void set_state_before(ValueStack* s) { check_state(s); _state_before = s; } // machine-specifics void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; } @@ -509,6 +549,11 @@ class Instruction: public CompilationResourceObj { virtual ExceptionObject* as_ExceptionObject() { return NULL; } virtual UnsafeOp* as_UnsafeOp() { return NULL; } virtual ProfileInvoke* as_ProfileInvoke() { return NULL; } + virtual RangeCheckPredicate* as_RangeCheckPredicate() { return NULL; } + +#ifdef ASSERT + virtual Assert* as_Assert() { return NULL; } +#endif virtual void visit(InstructionVisitor* v) = 0; @@ -570,7 +615,6 @@ class AssertValues: public ValueVisitor { LEAF(Phi, Instruction) private: - BlockBegin* _block; // the block to which the phi function belongs int _pf_flags; // the flags of the phi function int _index; // to value on operand stack (index < 0) or to local public: @@ -578,9 +622,9 @@ LEAF(Phi, Instruction) Phi(ValueType* type, BlockBegin* b, int index) : Instruction(type->base()) , _pf_flags(0) - , _block(b) , _index(index) { + _block = b; NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci())); if (type->is_illegal()) { make_illegal(); @@ -603,8 +647,6 @@ LEAF(Phi, Instruction) Value operand_at(int i) const; int operand_count() const; - BlockBegin* block() const { return _block; } - void set(Flag f) { _pf_flags |= f; } void clear(Flag f) { _pf_flags &= ~f; } bool is_set(Flag f) const { return (_pf_flags & f) != 0; } @@ -670,6 +712,7 @@ LEAF(Constant, Instruction) pin(); } + // generic virtual bool can_trap() const { return state_before() != NULL; } virtual void input_values_do(ValueVisitor* f) { /* no values */ } @@ -852,6 +895,7 @@ BASE(AccessIndexed, AccessArray) , _length(length) , _elt_type(elt_type) { + set_flag(Instruction::NeedsRangeCheckFlag, true); ASSERT_VALUES } @@ -860,6 +904,7 @@ BASE(AccessIndexed, AccessArray) Value length() const { return _length; } BasicType elt_type() const { return _elt_type; } + void clear_length() { _length = NULL; } // perform elimination of range checks involving constants bool compute_needs_range_check(); @@ -1524,6 +1569,7 @@ LEAF(BlockBegin, StateSplit) int _bci; // start-bci of block int _depth_first_number; // number of this block in a depth-first ordering int _linear_scan_number; // number of this block in linear-scan ordering + int _dominator_depth; int _loop_depth; // the loop nesting level of this block int _loop_index; // number of the innermost loop of this block int _flags; // the flags associated with this block @@ -1535,6 +1581,7 @@ LEAF(BlockBegin, StateSplit) // SSA specific fields: (factor out later) BlockList _successors; // the successors of this block BlockList _predecessors; // the predecessors of this block + BlockList _dominates; // list of blocks that are dominated by this block BlockBegin* _dominator; // the dominator of this block // SSA specific ends BlockEnd* _end; // the last instruction of this block @@ -1583,10 +1630,12 @@ LEAF(BlockBegin, StateSplit) , _linear_scan_number(-1) , _loop_depth(0) , _flags(0) + , _dominator_depth(-1) , _dominator(NULL) , _end(NULL) , _predecessors(2) , _successors(2) + , _dominates(2) , _exception_handlers(1) , _exception_states(NULL) , _exception_handler_pco(-1) @@ -1603,6 +1652,7 @@ LEAF(BlockBegin, StateSplit) , _total_preds(0) , _stores_to_locals() { + _block = this; #ifndef PRODUCT set_printable_bci(bci); #endif @@ -1612,8 +1662,10 @@ LEAF(BlockBegin, StateSplit) int block_id() const { return _block_id; } int bci() const { return _bci; } BlockList* successors() { return &_successors; } + BlockList* dominates() { return &_dominates; } BlockBegin* dominator() const { return _dominator; } int loop_depth() const { return _loop_depth; } + int dominator_depth() const { return _dominator_depth; } int depth_first_number() const { return _depth_first_number; } int linear_scan_number() const { return _linear_scan_number; } BlockEnd* end() const { return _end; } @@ -1634,6 +1686,7 @@ LEAF(BlockBegin, StateSplit) // manipulation void set_dominator(BlockBegin* dom) { _dominator = dom; } void set_loop_depth(int d) { _loop_depth = d; } + void set_dominator_depth(int d) { _dominator_depth = d; } void set_depth_first_number(int dfn) { _depth_first_number = dfn; } void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; } void set_end(BlockEnd* end); @@ -1695,7 +1748,8 @@ LEAF(BlockBegin, StateSplit) parser_loop_header_flag = 1 << 7, // set by parser to identify blocks where phi functions can not be created on demand critical_edge_split_flag = 1 << 8, // set for all blocks that are introduced when critical edges are split linear_scan_loop_header_flag = 1 << 9, // set during loop-detection for LinearScan - linear_scan_loop_end_flag = 1 << 10 // set during loop-detection for LinearScan + linear_scan_loop_end_flag = 1 << 10, // set during loop-detection for LinearScan + donot_eliminate_range_checks = 1 << 11 // Should be try to eliminate range checks in this block }; void set(Flag f) { _flags |= f; } @@ -1728,7 +1782,6 @@ LEAF(BlockBegin, StateSplit) BASE(BlockEnd, StateSplit) private: - BlockBegin* _begin; BlockList* _sux; protected: @@ -1746,7 +1799,6 @@ BASE(BlockEnd, StateSplit) // creation BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint) : StateSplit(type, state_before) - , _begin(NULL) , _sux(NULL) { set_flag(IsSafepointFlag, is_safepoint); @@ -1754,7 +1806,8 @@ BASE(BlockEnd, StateSplit) // accessors bool is_safepoint() const { return check_flag(IsSafepointFlag); } - BlockBegin* begin() const { return _begin; } + // For compatibility with old code, for new code use block() + BlockBegin* begin() const { return _block; } // manipulation void set_begin(BlockBegin* begin); @@ -1811,6 +1864,74 @@ LEAF(Goto, BlockEnd) void set_direction(Direction d) { _direction = d; } }; +#ifdef ASSERT +LEAF(Assert, Instruction) + private: + Value _x; + Condition _cond; + Value _y; + char *_message; + + public: + // creation + // unordered_is_true is valid for float/double compares only + Assert(Value x, Condition cond, bool unordered_is_true, Value y); + + // accessors + Value x() const { return _x; } + Condition cond() const { return _cond; } + bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } + Value y() const { return _y; } + const char *message() const { return _message; } + + // generic + virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); } +}; +#endif + +LEAF(RangeCheckPredicate, StateSplit) + private: + Value _x; + Condition _cond; + Value _y; + + void check_state(); + + public: + // creation + // unordered_is_true is valid for float/double compares only + RangeCheckPredicate(Value x, Condition cond, bool unordered_is_true, Value y, ValueStack* state) : StateSplit(illegalType) + , _x(x) + , _cond(cond) + , _y(y) + { + ASSERT_VALUES + set_flag(UnorderedIsTrueFlag, unordered_is_true); + assert(x->type()->tag() == y->type()->tag(), "types must match"); + this->set_state(state); + check_state(); + } + + // Always deoptimize + RangeCheckPredicate(ValueStack* state) : StateSplit(illegalType) + { + this->set_state(state); + _x = _y = NULL; + check_state(); + } + + // accessors + Value x() const { return _x; } + Condition cond() const { return _cond; } + bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } + Value y() const { return _y; } + + void always_fail() { _x = _y = NULL; } + + // generic + virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); } + HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond()) +}; LEAF(If, BlockEnd) private: diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp index 68e0feb5b83..4c88e50cb21 100644 --- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp +++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp @@ -57,6 +57,8 @@ const char* InstructionPrinter::cond_name(If::Condition cond) { case If::leq: return "<="; case If::gtr: return ">"; case If::geq: return ">="; + case If::aeq: return "|>=|"; + case If::beq: return "|<=|"; } ShouldNotReachHere(); return NULL; @@ -181,6 +183,11 @@ void InstructionPrinter::print_indexed(AccessIndexed* indexed) { output()->put('['); print_value(indexed->index()); output()->put(']'); + if (indexed->length() != NULL) { + output()->put('('); + print_value(indexed->length()); + output()->put(')'); + } } @@ -373,6 +380,7 @@ void InstructionPrinter::do_Constant(Constant* x) { void InstructionPrinter::do_LoadField(LoadField* x) { print_field(x); output()->print(" (%c)", type2char(x->field()->type()->basic_type())); + output()->print(" %s", x->field()->name()->as_utf8()); } @@ -381,6 +389,7 @@ void InstructionPrinter::do_StoreField(StoreField* x) { output()->print(" := "); print_value(x->value()); output()->print(" (%c)", type2char(x->field()->type()->basic_type())); + output()->print(" %s", x->field()->name()->as_utf8()); } @@ -393,6 +402,9 @@ void InstructionPrinter::do_ArrayLength(ArrayLength* x) { void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) { print_indexed(x); output()->print(" (%c)", type2char(x->elt_type())); + if (x->check_flag(Instruction::NeedsRangeCheckFlag)) { + output()->print(" [rc]"); + } } @@ -401,6 +413,9 @@ void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) { output()->print(" := "); print_value(x->value()); output()->print(" (%c)", type2char(x->elt_type())); + if (x->check_flag(Instruction::NeedsRangeCheckFlag)) { + output()->print(" [rc]"); + } } void InstructionPrinter::do_NegateOp(NegateOp* x) { @@ -843,6 +858,25 @@ void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) { output()->put(')'); } +void InstructionPrinter::do_RangeCheckPredicate(RangeCheckPredicate* x) { + + if (x->x() != NULL && x->y() != NULL) { + output()->print("if "); + print_value(x->x()); + output()->print(" %s ", cond_name(x->cond())); + print_value(x->y()); + output()->print(" then deoptimize!"); + } else { + output()->print("always deoptimize!"); + } +} + +void InstructionPrinter::do_Assert(Assert* x) { + output()->print("assert "); + print_value(x->x()); + output()->print(" %s ", cond_name(x->cond())); + print_value(x->y()); +} void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { print_unsafe_object_op(x, "UnsafePrefetchWrite"); diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp index d1d99cc2116..d8d6502ebd6 100644 --- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp +++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp @@ -135,6 +135,8 @@ class InstructionPrinter: public InstructionVisitor { virtual void do_ProfileInvoke (ProfileInvoke* x); virtual void do_RuntimeCall (RuntimeCall* x); virtual void do_MemBar (MemBar* x); + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); + virtual void do_Assert (Assert* x); }; #endif // PRODUCT diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp index 2082b526822..df0828ee555 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.cpp +++ b/hotspot/src/share/vm/c1/c1_LIR.cpp @@ -633,6 +633,7 @@ void LIR_OpVisitState::visit(LIR_Op* op) { case lir_ushr: case lir_xadd: case lir_xchg: + case lir_assert: { assert(op->as_Op2() != NULL, "must be"); LIR_Op2* op2 = (LIR_Op2*)op; @@ -1112,6 +1113,11 @@ void LIR_OpLock::emit_code(LIR_Assembler* masm) { } } +#ifdef ASSERT +void LIR_OpAssert::emit_code(LIR_Assembler* masm) { + masm->emit_assert(this); +} +#endif void LIR_OpDelay::emit_code(LIR_Assembler* masm) { masm->emit_delay(this); @@ -1771,6 +1777,8 @@ const char * LIR_Op::name() const { case lir_cas_int: s = "cas_int"; break; // LIR_OpProfileCall case lir_profile_call: s = "profile_call"; break; + // LIR_OpAssert + case lir_assert: s = "assert"; break; case lir_none: ShouldNotReachHere();break; default: s = "illegal_op"; break; } @@ -2017,6 +2025,13 @@ void LIR_OpLock::print_instr(outputStream* out) const { out->print("[lbl:0x%x]", stub()->entry()); } +void LIR_OpAssert::print_instr(outputStream* out) const { + print_condition(out, condition()); out->print(" "); + in_opr1()->print(out); out->print(" "); + in_opr2()->print(out); out->print(", \""); + out->print(msg()); out->print("\""); +} + void LIR_OpDelay::print_instr(outputStream* out) const { _op->print_on(out); diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp index 72051f19f34..5bd0e57d6f9 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.hpp +++ b/hotspot/src/share/vm/c1/c1_LIR.hpp @@ -881,6 +881,7 @@ class LIR_OpLock; class LIR_OpTypeCheck; class LIR_OpCompareAndSwap; class LIR_OpProfileCall; +class LIR_OpAssert; // LIR operation codes @@ -1000,6 +1001,9 @@ enum LIR_Code { , begin_opMDOProfile , lir_profile_call , end_opMDOProfile + , begin_opAssert + , lir_assert + , end_opAssert }; @@ -1135,6 +1139,7 @@ class LIR_Op: public CompilationResourceObj { virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; } virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; } virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; } + virtual LIR_OpAssert* as_OpAssert() { return NULL; } virtual void verify() const {} }; @@ -1623,7 +1628,7 @@ class LIR_Op2: public LIR_Op { , _tmp3(LIR_OprFact::illegalOpr) , _tmp4(LIR_OprFact::illegalOpr) , _tmp5(LIR_OprFact::illegalOpr) { - assert(code == lir_cmp, "code check"); + assert(code == lir_cmp || code == lir_assert, "code check"); } LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) @@ -1683,7 +1688,7 @@ class LIR_Op2: public LIR_Op { LIR_Opr tmp4_opr() const { return _tmp4; } LIR_Opr tmp5_opr() const { return _tmp5; } LIR_Condition condition() const { - assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove"); return _condition; + assert(code() == lir_cmp || code() == lir_cmove || code() == lir_assert, "only valid for cmp and cmove and assert"); return _condition; } void set_condition(LIR_Condition condition) { assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove"); _condition = condition; @@ -1823,6 +1828,30 @@ class LIR_OpDelay: public LIR_Op { CodeEmitInfo* call_info() const { return info(); } }; +#ifdef ASSERT +// LIR_OpAssert +class LIR_OpAssert : public LIR_Op2 { + friend class LIR_OpVisitState; + + private: + const char* _msg; + bool _halt; + + public: + LIR_OpAssert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) + : LIR_Op2(lir_assert, condition, opr1, opr2) + , _halt(halt) + , _msg(msg) { + } + + const char* msg() const { return _msg; } + bool halt() const { return _halt; } + + virtual void emit_code(LIR_Assembler* masm); + virtual LIR_OpAssert* as_OpAssert() { return this; } + virtual void print_instr(outputStream* out) const PRODUCT_RETURN; +}; +#endif // LIR_OpCompareAndSwap class LIR_OpCompareAndSwap : public LIR_Op { @@ -2196,6 +2225,9 @@ class LIR_List: public CompilationResourceObj { void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); } void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); } +#ifdef ASSERT + void lir_assert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) { append(new LIR_OpAssert(condition, opr1, opr2, msg, halt)); } +#endif }; void print_LIR(BlockList* blocks); diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp index 5cce9d0b71c..87dd8dbae15 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp @@ -210,6 +210,9 @@ class LIR_Assembler: public CompilationResourceObj { void arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack); void arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info); void intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, LIR_Opr dest, LIR_Op* op); +#ifdef ASSERT + void emit_assert(LIR_OpAssert* op); +#endif void logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index b46acec1474..a3970cb3f8f 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -403,6 +403,10 @@ void LIRGenerator::walk(Value instr) { CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) { assert(state != NULL, "state must be defined"); +#ifndef PRODUCT + state->verify(); +#endif + ValueStack* s = state; for_each_state(s) { if (s->kind() == ValueStack::EmptyExceptionState) { @@ -453,7 +457,7 @@ CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ig } } - return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers()); + return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers(), x->check_flag(Instruction::DeoptimizeOnException)); } @@ -1792,11 +1796,18 @@ void LIRGenerator::do_LoadField(LoadField* x) { } #endif + bool stress_deopt = StressLoopInvariantCodeMotion && info && info->deoptimize_on_exception(); if (x->needs_null_check() && (needs_patching || - MacroAssembler::needs_explicit_null_check(x->offset()))) { + MacroAssembler::needs_explicit_null_check(x->offset()) || + stress_deopt)) { + LIR_Opr obj = object.result(); + if (stress_deopt) { + obj = new_register(T_OBJECT); + __ move(LIR_OprFact::oopConst(NULL), obj); + } // emit an explicit null check because the offset is too large - __ null_check(object.result(), new CodeEmitInfo(info)); + __ null_check(obj, new CodeEmitInfo(info)); } LIR_Opr reg = rlock_result(x, field_type); @@ -1861,6 +1872,8 @@ void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) { void LIRGenerator::do_ArrayLength(ArrayLength* x) { + if (x->use_count() == 0 && !x->can_trap()) return; + LIRItem array(x->array(), this); array.load_item(); LIR_Opr reg = rlock_result(x); @@ -1873,6 +1886,11 @@ void LIRGenerator::do_ArrayLength(ArrayLength* x) { } else { info = state_for(nc); } + if (StressLoopInvariantCodeMotion && info->deoptimize_on_exception()) { + LIR_Opr obj = new_register(T_OBJECT); + __ move(LIR_OprFact::oopConst(NULL), obj); + __ null_check(obj, new CodeEmitInfo(info)); + } } __ load(new LIR_Address(array.result(), arrayOopDesc::length_offset_in_bytes(), T_INT), reg, info, lir_patch_none); } @@ -1883,14 +1901,11 @@ void LIRGenerator::do_LoadIndexed(LoadIndexed* x) { LIRItem array(x->array(), this); LIRItem index(x->index(), this); LIRItem length(this); - bool needs_range_check = true; + bool needs_range_check = x->compute_needs_range_check(); - if (use_length) { - needs_range_check = x->compute_needs_range_check(); - if (needs_range_check) { - length.set_instruction(x->length()); - length.load_item(); - } + if (use_length && needs_range_check) { + length.set_instruction(x->length()); + length.load_item(); } array.load_item(); @@ -1910,13 +1925,20 @@ void LIRGenerator::do_LoadIndexed(LoadIndexed* x) { } else { null_check_info = range_check_info; } + if (StressLoopInvariantCodeMotion && null_check_info->deoptimize_on_exception()) { + LIR_Opr obj = new_register(T_OBJECT); + __ move(LIR_OprFact::oopConst(NULL), obj); + __ null_check(obj, new CodeEmitInfo(null_check_info)); + } } // emit array address setup early so it schedules better LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), false); if (GenerateRangeChecks && needs_range_check) { - if (use_length) { + if (StressLoopInvariantCodeMotion && range_check_info->deoptimize_on_exception()) { + __ branch(lir_cond_always, T_ILLEGAL, new RangeCheckStub(range_check_info, index.result())); + } else if (use_length) { // TODO: use a (modified) version of array_range_check that does not require a // constant length to be loaded to a register __ cmp(lir_cond_belowEqual, length.result(), index.result()); @@ -2634,7 +2656,7 @@ void LIRGenerator::do_Base(Base* x) { LIR_Opr lock = new_register(T_INT); __ load_stack_address_monitor(0, lock); - CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL); + CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, x->check_flag(Instruction::DeoptimizeOnException)); CodeStub* slow_path = new MonitorEnterStub(obj, lock, info); // receiver is guaranteed non-NULL so don't need CodeEmitInfo @@ -2644,7 +2666,7 @@ void LIRGenerator::do_Base(Base* x) { // increment invocation counters if needed if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting. - CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL); + CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false); increment_invocation_counter(info); } @@ -3102,6 +3124,95 @@ void LIRGenerator::do_RuntimeCall(RuntimeCall* x) { } } +void LIRGenerator::do_Assert(Assert *x) { +#ifdef ASSERT + ValueTag tag = x->x()->type()->tag(); + If::Condition cond = x->cond(); + + LIRItem xitem(x->x(), this); + LIRItem yitem(x->y(), this); + LIRItem* xin = &xitem; + LIRItem* yin = &yitem; + + assert(tag == intTag, "Only integer assertions are valid!"); + + xin->load_item(); + yin->dont_load_item(); + + set_no_result(x); + + LIR_Opr left = xin->result(); + LIR_Opr right = yin->result(); + + __ lir_assert(lir_cond(x->cond()), left, right, x->message(), true); +#endif +} + + +void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) { + + + Instruction *a = x->x(); + Instruction *b = x->y(); + if (!a || StressRangeCheckElimination) { + assert(!b || StressRangeCheckElimination, "B must also be null"); + + CodeEmitInfo *info = state_for(x, x->state()); + CodeStub* stub = new PredicateFailedStub(info); + + __ jump(stub); + } else if (a->type()->as_IntConstant() && b->type()->as_IntConstant()) { + int a_int = a->type()->as_IntConstant()->value(); + int b_int = b->type()->as_IntConstant()->value(); + + bool ok = false; + + switch(x->cond()) { + case Instruction::eql: ok = (a_int == b_int); break; + case Instruction::neq: ok = (a_int != b_int); break; + case Instruction::lss: ok = (a_int < b_int); break; + case Instruction::leq: ok = (a_int <= b_int); break; + case Instruction::gtr: ok = (a_int > b_int); break; + case Instruction::geq: ok = (a_int >= b_int); break; + case Instruction::aeq: ok = ((unsigned int)a_int >= (unsigned int)b_int); break; + case Instruction::beq: ok = ((unsigned int)a_int <= (unsigned int)b_int); break; + default: ShouldNotReachHere(); + } + + if (ok) { + + CodeEmitInfo *info = state_for(x, x->state()); + CodeStub* stub = new PredicateFailedStub(info); + + __ jump(stub); + } + } else { + + ValueTag tag = x->x()->type()->tag(); + If::Condition cond = x->cond(); + LIRItem xitem(x->x(), this); + LIRItem yitem(x->y(), this); + LIRItem* xin = &xitem; + LIRItem* yin = &yitem; + + assert(tag == intTag, "Only integer deoptimizations are valid!"); + + xin->load_item(); + yin->dont_load_item(); + set_no_result(x); + + LIR_Opr left = xin->result(); + LIR_Opr right = yin->result(); + + CodeEmitInfo *info = state_for(x, x->state()); + CodeStub* stub = new PredicateFailedStub(info); + + __ cmp(lir_cond(cond), left, right); + __ branch(lir_cond(cond), right->type(), stub); + } +} + + LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) { LIRItemList args(1); LIRItem value(arg1, this); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index aedd6a69c94..4c70a9f64fd 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -412,6 +412,8 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { case If::leq: l = lir_cond_lessEqual; break; case If::geq: l = lir_cond_greaterEqual; break; case If::gtr: l = lir_cond_greater; break; + case If::aeq: l = lir_cond_aboveEqual; break; + case If::beq: l = lir_cond_belowEqual; break; }; return l; } @@ -534,6 +536,8 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { virtual void do_ProfileInvoke (ProfileInvoke* x); virtual void do_RuntimeCall (RuntimeCall* x); virtual void do_MemBar (MemBar* x); + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); + virtual void do_Assert (Assert* x); }; diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index 1db08a8573a..65d4c60b670 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -6231,26 +6231,29 @@ void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) { assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch"); LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op; - LIR_Op2* prev_cmp = NULL; + if (prev_branch->stub() == NULL) { - for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { - prev_op = instructions->at(j); - if(prev_op->code() == lir_cmp) { - assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); - prev_cmp = (LIR_Op2*)prev_op; - assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); + LIR_Op2* prev_cmp = NULL; + + for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { + prev_op = instructions->at(j); + if (prev_op->code() == lir_cmp) { + assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); + prev_cmp = (LIR_Op2*)prev_op; + assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); + } } - } - assert(prev_cmp != NULL, "should have found comp instruction for branch"); - if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) { + assert(prev_cmp != NULL, "should have found comp instruction for branch"); + if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) { - TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id())); + TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id())); - // eliminate a conditional branch to the immediate successor - prev_branch->change_block(last_branch->block()); - prev_branch->negate_cond(); - prev_cmp->set_condition(prev_branch->cond()); - instructions->truncate(instructions->length() - 1); + // eliminate a conditional branch to the immediate successor + prev_branch->change_block(last_branch->block()); + prev_branch->negate_cond(); + prev_cmp->set_condition(prev_branch->cond()); + instructions->truncate(instructions->length() - 1); + } } } } diff --git a/hotspot/src/share/vm/c1/c1_Optimizer.cpp b/hotspot/src/share/vm/c1/c1_Optimizer.cpp index 7d24a126b20..74e9d2240db 100644 --- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp @@ -178,7 +178,7 @@ void CE_Eliminator::block_do(BlockBegin* block) { // 2) substitute conditional expression // with an IfOp followed by a Goto // cut if_ away and get node before - Instruction* cur_end = if_->prev(block); + Instruction* cur_end = if_->prev(); // append constants of true- and false-block if necessary // clone constants because original block must not be destroyed @@ -202,7 +202,7 @@ void CE_Eliminator::block_do(BlockBegin* block) { } // append Goto to successor - ValueStack* state_before = if_->is_safepoint() ? if_->state_before() : NULL; + ValueStack* state_before = if_->state_before(); Goto* goto_ = new Goto(sux, state_before, if_->is_safepoint() || t_goto->is_safepoint() || f_goto->is_safepoint()); // prepare state for Goto @@ -367,10 +367,11 @@ class BlockMerger: public BlockClosure { #endif // find instruction before end & append first instruction of sux block - Instruction* prev = end->prev(block); + Instruction* prev = end->prev(); Instruction* next = sux->next(); assert(prev->as_BlockEnd() == NULL, "must not be a BlockEnd"); prev->set_next(next); + prev->fixup_block_pointers(); sux->disconnect_from_graph(); block->set_end(sux->end()); // add exception handlers of deleted block, if any @@ -533,6 +534,8 @@ public: void do_ProfileInvoke (ProfileInvoke* x); void do_RuntimeCall (RuntimeCall* x); void do_MemBar (MemBar* x); + void do_RangeCheckPredicate(RangeCheckPredicate* x); + void do_Assert (Assert* x); }; @@ -714,6 +717,8 @@ void NullCheckVisitor::do_ProfileCall (ProfileCall* x) { nce()->clear_las void NullCheckVisitor::do_ProfileInvoke (ProfileInvoke* x) {} void NullCheckVisitor::do_RuntimeCall (RuntimeCall* x) {} void NullCheckVisitor::do_MemBar (MemBar* x) {} +void NullCheckVisitor::do_RangeCheckPredicate(RangeCheckPredicate* x) {} +void NullCheckVisitor::do_Assert (Assert* x) {} void NullCheckEliminator::visit(Value* p) { diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp new file mode 100644 index 00000000000..948f635c27f --- /dev/null +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp @@ -0,0 +1,1517 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "c1/c1_ValueStack.hpp" +#include "c1/c1_RangeCheckElimination.hpp" +#include "c1/c1_IR.hpp" +#include "c1/c1_Canonicalizer.hpp" +#include "c1/c1_ValueMap.hpp" +#include "ci/ciMethodData.hpp" +#include "runtime/deoptimization.hpp" + +// Macros for the Trace and the Assertion flag +#ifdef ASSERT +#define TRACE_RANGE_CHECK_ELIMINATION(code) if (TraceRangeCheckElimination) { code; } +#define ASSERT_RANGE_CHECK_ELIMINATION(code) if (AssertRangeCheckElimination) { code; } +#define TRACE_OR_ASSERT_RANGE_CHECK_ELIMINATION(code) if (TraceRangeCheckElimination || AssertRangeCheckElimination) { code; } +#else +#define TRACE_RANGE_CHECK_ELIMINATION(code) +#define ASSERT_RANGE_CHECK_ELIMINATION(code) +#define TRACE_OR_ASSERT_RANGE_CHECK_ELIMINATION(code) +#endif + +// Entry point for the optimization +void RangeCheckElimination::eliminate(IR *ir) { + bool do_elimination = ir->compilation()->has_access_indexed(); + ASSERT_RANGE_CHECK_ELIMINATION(do_elimination = true); + if (do_elimination) { + RangeCheckEliminator rce(ir); + } +} + +// Constructor +RangeCheckEliminator::RangeCheckEliminator(IR *ir) : + _bounds(Instruction::number_of_instructions(), NULL), + _access_indexed_info(Instruction::number_of_instructions(), NULL) +{ + _visitor.set_range_check_eliminator(this); + _ir = ir; + _number_of_instructions = Instruction::number_of_instructions(); + _optimistic = ir->compilation()->is_optimistic(); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr(""); + tty->print_cr("Range check elimination"); + ir->method()->print_name(tty); + tty->print_cr(""); + ); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("optimistic=%d", (int)_optimistic); + ); + +#ifdef ASSERT + // Verifies several conditions that must be true on the IR-input. Only used for debugging purposes. + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Verification of IR . . ."); + ); + Verification verification(ir); +#endif + + // Set process block flags + // Optimization so a blocks is only processed if it contains an access indexed instruction or if + // one of its children in the dominator tree contains an access indexed instruction. + set_process_block_flags(ir->start()); + + // Pass over instructions in the dominator tree + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Starting pass over dominator tree . . .") + ); + calc_bounds(ir->start(), NULL); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Finished!") + ); +} + +// Instruction specific work for some instructions +// Constant +void RangeCheckEliminator::Visitor::do_Constant(Constant *c) { + IntConstant *ic = c->type()->as_IntConstant(); + if (ic != NULL) { + int value = ic->value(); + _bound = new Bound(value, NULL, value, NULL); + } +} + +// LogicOp +void RangeCheckEliminator::Visitor::do_LogicOp(LogicOp *lo) { + if (lo->type()->as_IntType() && lo->op() == Bytecodes::_iand && (lo->x()->as_Constant() || lo->y()->as_Constant())) { + int constant = 0; + Constant *c = lo->x()->as_Constant(); + if (c != NULL) { + constant = c->type()->as_IntConstant()->value(); + } else { + constant = lo->y()->as_Constant()->type()->as_IntConstant()->value(); + } + if (constant >= 0) { + _bound = new Bound(0, NULL, constant, NULL); + } + } +} + +// Phi +void RangeCheckEliminator::Visitor::do_Phi(Phi *phi) { + if (!phi->type()->as_IntType() && !phi->type()->as_ObjectType()) return; + + BlockBegin *block = phi->block(); + int op_count = phi->operand_count(); + bool has_upper = true; + bool has_lower = true; + assert(phi, "Phi must not be null"); + Bound *bound = NULL; + + // TODO: support more difficult phis + for (int i=0; ioperand_at(i); + + if (v == phi) continue; + + // Check if instruction is connected with phi itself + Op2 *op2 = v->as_Op2(); + if (op2 != NULL) { + Value x = op2->x(); + Value y = op2->y(); + if ((x == phi || y == phi)) { + Value other = x; + if (other == phi) { + other = y; + } + ArithmeticOp *ao = v->as_ArithmeticOp(); + if (ao != NULL && ao->op() == Bytecodes::_iadd) { + assert(ao->op() == Bytecodes::_iadd, "Has to be add!"); + if (ao->type()->as_IntType()) { + Constant *c = other->as_Constant(); + if (c != NULL) { + assert(c->type()->as_IntConstant(), "Constant has to be of type integer"); + int value = c->type()->as_IntConstant()->value(); + if (value == 1) { + has_upper = false; + } else if (value > 1) { + // Overflow not guaranteed + has_upper = false; + has_lower = false; + } else if (value < 0) { + has_lower = false; + } + continue; + } + } + } + } + } + + // No connection -> new bound + Bound *v_bound = _rce->get_bound(v); + Bound *cur_bound; + int cur_constant = 0; + Value cur_value = v; + + if (v->type()->as_IntConstant()) { + cur_constant = v->type()->as_IntConstant()->value(); + cur_value = NULL; + } + if (!v_bound->has_upper() || !v_bound->has_lower()) { + cur_bound = new Bound(cur_constant, cur_value, cur_constant, cur_value); + } else { + cur_bound = v_bound; + } + if (cur_bound) { + if (!bound) { + bound = cur_bound->copy(); + } else { + bound->or_op(cur_bound); + } + } else { + // No bound! + bound = NULL; + break; + } + } + + if (bound) { + if (!has_upper) { + bound->remove_upper(); + } + if (!has_lower) { + bound->remove_lower(); + } + _bound = bound; + } else { + _bound = new Bound(); + } +} + + +// ArithmeticOp +void RangeCheckEliminator::Visitor::do_ArithmeticOp(ArithmeticOp *ao) { + Value x = ao->x(); + Value y = ao->y(); + + if (ao->op() == Bytecodes::_irem) { + Bound* x_bound = _rce->get_bound(x); + Bound* y_bound = _rce->get_bound(y); + if (x_bound->lower() >= 0 && x_bound->lower_instr() == NULL && y->as_ArrayLength() != NULL) { + _bound = new Bound(0, NULL, -1, y); + } else { + _bound = new Bound(); + } + } else if (!x->as_Constant() || !y->as_Constant()) { + assert(!x->as_Constant() || !y->as_Constant(), "One of the operands must be non-constant!"); + if (((x->as_Constant() || y->as_Constant()) && (ao->op() == Bytecodes::_iadd)) || (y->as_Constant() && ao->op() == Bytecodes::_isub)) { + assert(ao->op() == Bytecodes::_iadd || ao->op() == Bytecodes::_isub, "Operand must be iadd or isub"); + + if (y->as_Constant()) { + Value tmp = x; + x = y; + y = tmp; + } + assert(x->as_Constant()->type()->as_IntConstant(), "Constant must be int constant!"); + + // Constant now in x + int const_value = x->as_Constant()->type()->as_IntConstant()->value(); + if (ao->op() == Bytecodes::_iadd || const_value != min_jint) { + if (ao->op() == Bytecodes::_isub) { + const_value = -const_value; + } + + Bound * bound = _rce->get_bound(y); + if (bound->has_upper() && bound->has_lower()) { + int new_lower = bound->lower() + const_value; + jlong new_lowerl = ((jlong)bound->lower()) + const_value; + int new_upper = bound->upper() + const_value; + jlong new_upperl = ((jlong)bound->upper()) + const_value; + + if (((jlong)new_lower) == new_lowerl && ((jlong)new_upper == new_upperl)) { + Bound *newBound = new Bound(new_lower, bound->lower_instr(), new_upper, bound->upper_instr()); + _bound = newBound; + } else { + // overflow + _bound = new Bound(); + } + } else { + _bound = new Bound(); + } + } else { + _bound = new Bound(); + } + } else { + Bound *bound = _rce->get_bound(x); + if (ao->op() == Bytecodes::_isub) { + if (bound->lower_instr() == y) { + _bound = new Bound(Instruction::geq, NULL, bound->lower()); + } else { + _bound = new Bound(); + } + } else { + _bound = new Bound(); + } + } + } +} + +// IfOp +void RangeCheckEliminator::Visitor::do_IfOp(IfOp *ifOp) +{ + if (ifOp->tval()->type()->as_IntConstant() && ifOp->fval()->type()->as_IntConstant()) { + int min = ifOp->tval()->type()->as_IntConstant()->value(); + int max = ifOp->fval()->type()->as_IntConstant()->value(); + if (min > max) { + // min ^= max ^= min ^= max; + int tmp = min; + min = max; + max = tmp; + } + _bound = new Bound(min, NULL, max, NULL); + } +} + +// Get bound. Returns the current bound on Value v. Normally this is the topmost element on the bound stack. +RangeCheckEliminator::Bound *RangeCheckEliminator::get_bound(Value v) { + // Wrong type or NULL -> No bound + if (!v || (!v->type()->as_IntType() && !v->type()->as_ObjectType())) return NULL; + + if (!_bounds[v->id()]) { + // First (default) bound is calculated + // Create BoundStack + _bounds[v->id()] = new BoundStack(); + _visitor.clear_bound(); + Value visit_value = v; + visit_value->visit(&_visitor); + Bound *bound = _visitor.bound(); + if (bound) { + _bounds[v->id()]->push(bound); + } + if (_bounds[v->id()]->length() == 0) { + assert(!(v->as_Constant() && v->type()->as_IntConstant()), "constants not handled here"); + _bounds[v->id()]->push(new Bound()); + } + } else if (_bounds[v->id()]->length() == 0) { + // To avoid endless loops, bound is currently in calculation -> nothing known about it + return new Bound(); + } + + // Return bound + return _bounds[v->id()]->top(); +} + +// Update bound +void RangeCheckEliminator::update_bound(IntegerStack &pushed, Value v, Instruction::Condition cond, Value value, int constant) { + if (cond == Instruction::gtr) { + cond = Instruction::geq; + constant++; + } else if (cond == Instruction::lss) { + cond = Instruction::leq; + constant--; + } + Bound *bound = new Bound(cond, value, constant); + update_bound(pushed, v, bound); +} + +// Checks for loop invariance. Returns true if the instruction is outside of the loop which is identified by loop_header. +bool RangeCheckEliminator::loop_invariant(BlockBegin *loop_header, Instruction *instruction) { + assert(loop_header, "Loop header must not be null!"); + if (!instruction) return true; + return instruction->dominator_depth() < loop_header->dominator_depth(); +} + +// Update bound. Pushes a new bound onto the stack. Tries to do a conjunction with the current bound. +void RangeCheckEliminator::update_bound(IntegerStack &pushed, Value v, Bound *bound) { + if (v->as_Constant()) { + // No bound update for constants + return; + } + if (!_bounds[v->id()]) { + get_bound(v); + assert(_bounds[v->id()], "Now Stack must exist"); + } + Bound *top = NULL; + if (_bounds[v->id()]->length() > 0) { + top = _bounds[v->id()]->top(); + } + if (top) { + bound->and_op(top); + } + _bounds[v->id()]->push(bound); + pushed.append(v->id()); +} + +// Add instruction + idx for in block motion +void RangeCheckEliminator::add_access_indexed_info(InstructionList &indices, int idx, Value instruction, AccessIndexed *ai) { + int id = instruction->id(); + AccessIndexedInfo *aii = _access_indexed_info[id]; + if (aii == NULL) { + aii = new AccessIndexedInfo(); + _access_indexed_info[id] = aii; + indices.append(instruction); + aii->_min = idx; + aii->_max = idx; + aii->_list = new AccessIndexedList(); + } else if (idx >= aii->_min && idx <= aii->_max) { + remove_range_check(ai); + return; + } + aii->_min = MIN2(aii->_min, idx); + aii->_max = MAX2(aii->_max, idx); + aii->_list->append(ai); +} + +// In block motion. Tries to reorder checks in order to reduce some of them. +// Example: +// a[i] = 0; +// a[i+2] = 0; +// a[i+1] = 0; +// In this example the check for a[i+1] would be considered as unnecessary during the first iteration. +// After this i is only checked once for i >= 0 and i+2 < a.length before the first array access. If this +// check fails, deoptimization is called. +void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList &accessIndexed, InstructionList &arrays) { + InstructionList indices; + + // Now iterate over all arrays + for (int i=0; iarray() != array || !ai->check_flag(Instruction::NeedsRangeCheckFlag)) continue; + + Value index = ai->index(); + Constant *c = index->as_Constant(); + if (c != NULL) { + int constant_value = c->type()->as_IntConstant()->value(); + if (constant_value >= 0) { + if (constant_value <= max_constant) { + // No range check needed for this + remove_range_check(ai); + } else { + max_constant = constant_value; + list_constant.append(ai); + } + } + } else { + int last_integer = 0; + Instruction *last_instruction = index; + int base = 0; + ArithmeticOp *ao = index->as_ArithmeticOp(); + + while (ao != NULL && (ao->x()->as_Constant() || ao->y()->as_Constant()) && (ao->op() == Bytecodes::_iadd || ao->op() == Bytecodes::_isub)) { + c = ao->y()->as_Constant(); + Instruction *other = ao->x(); + if (!c && ao->op() == Bytecodes::_iadd) { + c = ao->x()->as_Constant(); + other = ao->y(); + } + + if (c) { + int value = c->type()->as_IntConstant()->value(); + if (value != min_jint) { + if (ao->op() == Bytecodes::_isub) { + value = -value; + } + base += value; + last_integer = base; + last_instruction = other; + } + index = other; + } else { + break; + } + ao = index->as_ArithmeticOp(); + } + add_access_indexed_info(indices, last_integer, last_instruction, ai); + } + } + + // Iterate over all different indices + if (_optimistic) { + for (int i=0; iid()]; + assert(info != NULL, "Info must not be null"); + + // if idx < 0, max > 0, max + idx may fall between 0 and + // length-1 and if min < 0, min + idx may overflow and be >= + // 0. The predicate wouldn't trigger but some accesses could + // be with a negative index. This test guarantees that for the + // min and max value that are kept the predicate can't let + // some incorrect accesses happen. + bool range_cond = (info->_max < 0 || info->_max + min_jint <= info->_min); + + // Generate code only if more than 2 range checks can be eliminated because of that. + // 2 because at least 2 comparisons are done + if (info->_list->length() > 2 && range_cond) { + AccessIndexed *first = info->_list->at(0); + Instruction *insert_position = first->prev(); + assert(insert_position->next() == first, "prev was calculated"); + ValueStack *state = first->state_before(); + + // Load min Constant + Constant *min_constant = NULL; + if (info->_min != 0) { + min_constant = new Constant(new IntConstant(info->_min)); + NOT_PRODUCT(min_constant->set_printable_bci(first->printable_bci())); + insert_position = insert_position->insert_after(min_constant); + } + + // Load max Constant + Constant *max_constant = NULL; + if (info->_max != 0) { + max_constant = new Constant(new IntConstant(info->_max)); + NOT_PRODUCT(max_constant->set_printable_bci(first->printable_bci())); + insert_position = insert_position->insert_after(max_constant); + } + + // Load array length + Value length_instr = first->length(); + if (!length_instr) { + ArrayLength *length = new ArrayLength(array, first->state_before()->copy()); + length->set_exception_state(length->state_before()); + length->set_flag(Instruction::DeoptimizeOnException, true); + insert_position = insert_position->insert_after_same_bci(length); + length_instr = length; + } + + // Calculate lower bound + Instruction *lower_compare = index_instruction; + if (min_constant) { + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, min_constant, lower_compare, false, NULL); + insert_position = insert_position->insert_after_same_bci(ao); + lower_compare = ao; + } + + // Calculate upper bound + Instruction *upper_compare = index_instruction; + if (max_constant) { + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, max_constant, upper_compare, false, NULL); + insert_position = insert_position->insert_after_same_bci(ao); + upper_compare = ao; + } + + // Trick with unsigned compare is done + int bci = NOT_PRODUCT(first->printable_bci()) PRODUCT_ONLY(-1); + insert_position = predicate(upper_compare, Instruction::aeq, length_instr, state, insert_position, bci); + insert_position = predicate_cmp_with_const(lower_compare, Instruction::leq, -1, state, insert_position); + for (int j = 0; j_list->length(); j++) { + AccessIndexed *ai = info->_list->at(j); + remove_range_check(ai); + } + } + _access_indexed_info[index_instruction->id()] = NULL; + } + indices.clear(); + + if (list_constant.length() > 1) { + AccessIndexed *first = list_constant.at(0); + Instruction *insert_position = first->prev(); + ValueStack *state = first->state_before(); + // Load max Constant + Constant *constant = new Constant(new IntConstant(max_constant)); + NOT_PRODUCT(constant->set_printable_bci(first->printable_bci())); + insert_position = insert_position->insert_after(constant); + Instruction *compare_instr = constant; + Value length_instr = first->length(); + if (!length_instr) { + ArrayLength *length = new ArrayLength(array, state->copy()); + length->set_exception_state(length->state_before()); + length->set_flag(Instruction::DeoptimizeOnException, true); + insert_position = insert_position->insert_after_same_bci(length); + length_instr = length; + } + // Compare for greater or equal to array length + insert_position = predicate(compare_instr, Instruction::geq, length_instr, state, insert_position); + for (int j = 0; jas_AccessIndexed() != NULL); + cur = cur->next(); + } + + BlockList *dominates = block->dominates(); + for (int i=0; ilength(); i++) { + BlockBegin *next = dominates->at(i); + process |= set_process_block_flags(next); + } + + if (!process) { + block->set(BlockBegin::donot_eliminate_range_checks); + } + return process; +} + +bool RangeCheckEliminator::is_ok_for_deoptimization(Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper) { + bool upper_check = true; + assert(lower_instr || lower >= 0, "If no lower_instr present, lower must be greater 0"); + assert(!lower_instr || lower_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + assert(!upper_instr || upper_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + assert(array_instr, "Array instruction must exist"); + assert(array_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + assert(!length_instr || length_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + + if (upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr) { + // static check + if (upper >= 0) return false; // would always trigger a deopt: + // array_length + x >= array_length, x >= 0 is always true + upper_check = false; + } + if (lower_instr && lower_instr->as_ArrayLength() && lower_instr->as_ArrayLength()->array() == array_instr) { + if (lower > 0) return false; + } + // No upper check required -> skip + if (upper_check && upper_instr && upper_instr->type()->as_ObjectType() && upper_instr == array_instr) { + // upper_instr is object means that the upper bound is the length + // of the upper_instr. + return false; + } + return true; +} + +Instruction* RangeCheckEliminator::insert_after(Instruction* insert_position, Instruction* instr, int bci) { + if (bci != -1) { + NOT_PRODUCT(instr->set_printable_bci(bci)); + return insert_position->insert_after(instr); + } else { + return insert_position->insert_after_same_bci(instr); + } +} + +Instruction* RangeCheckEliminator::predicate(Instruction* left, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci) { + RangeCheckPredicate *deoptimize = new RangeCheckPredicate(left, cond, true, right, state->copy()); + return insert_after(insert_position, deoptimize, bci); +} + +Instruction* RangeCheckEliminator::predicate_cmp_with_const(Instruction* instr, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci) { + Constant *const_instr = new Constant(new IntConstant(constant)); + insert_position = insert_after(insert_position, const_instr, bci); + return predicate(instr, cond, const_instr, state, insert_position); +} + +Instruction* RangeCheckEliminator::predicate_add(Instruction* left, int left_const, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci) { + Constant *constant = new Constant(new IntConstant(left_const)); + insert_position = insert_after(insert_position, constant, bci); + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, constant, left, false, NULL); + insert_position = insert_position->insert_after_same_bci(ao); + return predicate(ao, cond, right, state, insert_position); +} + +Instruction* RangeCheckEliminator::predicate_add_cmp_with_const(Instruction* left, int left_const, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci) { + Constant *const_instr = new Constant(new IntConstant(constant)); + insert_position = insert_after(insert_position, const_instr, bci); + return predicate_add(left, left_const, cond, const_instr, state, insert_position); +} + +// Insert deoptimization, returns true if sucessful or false if range check should not be removed +void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper, AccessIndexed *ai) { + assert(is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, lower, upper_instr, upper), "should have been tested before"); + bool upper_check = !(upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr); + + int bci = NOT_PRODUCT(ai->printable_bci()) PRODUCT_ONLY(-1); + if (lower_instr) { + assert(!lower_instr->type()->as_ObjectType(), "Must not be object type"); + if (lower == 0) { + // Compare for less than 0 + insert_position = predicate_cmp_with_const(lower_instr, Instruction::lss, 0, state, insert_position, bci); + } else if (lower > 0) { + // Compare for smaller 0 + insert_position = predicate_add_cmp_with_const(lower_instr, lower, Instruction::lss, 0, state, insert_position, bci); + } else { + assert(lower < 0, ""); + // Add 1 + lower++; + lower = -lower; + // Compare for smaller or equal 0 + insert_position = predicate_cmp_with_const(lower_instr, Instruction::leq, lower, state, insert_position, bci); + } + } + + // We need to know length of array + if (!length_instr) { + // Load length if necessary + ArrayLength *length = new ArrayLength(array_instr, state->copy()); + NOT_PRODUCT(length->set_printable_bci(ai->printable_bci())); + length->set_exception_state(length->state_before()); + length->set_flag(Instruction::DeoptimizeOnException, true); + insert_position = insert_position->insert_after(length); + length_instr = length; + } + + // No upper check required -> skip + if (!upper_check) return; + + if (!upper_instr) { + // Compare for geq array.length + insert_position = predicate_cmp_with_const(length_instr, Instruction::leq, upper, state, insert_position, bci); + } else { + if (upper_instr->type()->as_ObjectType()) { + assert(state, "must not be null"); + assert(upper_instr != array_instr, "should be"); + ArrayLength *length = new ArrayLength(upper_instr, state->copy()); + NOT_PRODUCT(length->set_printable_bci(ai->printable_bci())); + length->set_flag(Instruction::DeoptimizeOnException, true); + length->set_exception_state(length->state_before()); + insert_position = insert_position->insert_after(length); + upper_instr = length; + } + assert(upper_instr->type()->as_IntType(), "Must not be object type!"); + + if (upper == 0) { + // Compare for geq array.length + insert_position = predicate(upper_instr, Instruction::geq, length_instr, state, insert_position, bci); + } else if (upper < 0) { + // Compare for geq array.length + insert_position = predicate_add(upper_instr, upper, Instruction::geq, length_instr, state, insert_position, bci); + } else { + assert(upper > 0, ""); + upper = -upper; + // Compare for geq array.length + insert_position = predicate_add(length_instr, upper, Instruction::leq, upper_instr, state, insert_position, bci); + } + } +} + +// Add if condition +void RangeCheckEliminator::add_if_condition(IntegerStack &pushed, Value x, Value y, Instruction::Condition condition) { + if (y->as_Constant()) return; + + int const_value = 0; + Value instr_value = x; + Constant *c = x->as_Constant(); + ArithmeticOp *ao = x->as_ArithmeticOp(); + + if (c != NULL) { + const_value = c->type()->as_IntConstant()->value(); + instr_value = NULL; + } else if (ao != NULL && (!ao->x()->as_Constant() || !ao->y()->as_Constant()) && ((ao->op() == Bytecodes::_isub && ao->y()->as_Constant()) || ao->op() == Bytecodes::_iadd)) { + assert(!ao->x()->as_Constant() || !ao->y()->as_Constant(), "At least one operator must be non-constant!"); + assert(ao->op() == Bytecodes::_isub || ao->op() == Bytecodes::_iadd, "Operation has to be add or sub!"); + c = ao->x()->as_Constant(); + if (c != NULL) { + const_value = c->type()->as_IntConstant()->value(); + instr_value = ao->y(); + } else { + c = ao->y()->as_Constant(); + if (c != NULL) { + const_value = c->type()->as_IntConstant()->value(); + instr_value = ao->x(); + } + } + if (ao->op() == Bytecodes::_isub) { + assert(ao->y()->as_Constant(), "1 - x not supported, only x - 1 is valid!"); + if (const_value > min_jint) { + const_value = -const_value; + } else { + const_value = 0; + instr_value = x; + } + } + } + + update_bound(pushed, y, condition, instr_value, const_value); +} + +// Process If +void RangeCheckEliminator::process_if(IntegerStack &pushed, BlockBegin *block, If *cond) { + // Only if we are direct true / false successor and NOT both ! (even this may occur) + if ((cond->tsux() == block || cond->fsux() == block) && cond->tsux() != cond->fsux()) { + Instruction::Condition condition = cond->cond(); + if (cond->fsux() == block) { + condition = Instruction::negate(condition); + } + Value x = cond->x(); + Value y = cond->y(); + if (x->type()->as_IntType() && y->type()->as_IntType()) { + add_if_condition(pushed, y, x, condition); + add_if_condition(pushed, x, y, Instruction::mirror(condition)); + } + } +} + +// Process access indexed +void RangeCheckEliminator::process_access_indexed(BlockBegin *loop_header, BlockBegin *block, AccessIndexed *ai) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2) + ); + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), ai->length()->id()) + ); + + if (ai->check_flag(Instruction::NeedsRangeCheckFlag)) { + Bound *index_bound = get_bound(ai->index()); + if (!index_bound->has_lower() || !index_bound->has_upper()) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Index instruction %d has no lower and/or no upper bound!", ai->index()->id()) + ); + return; + } + + Bound *array_bound; + if (ai->length()) { + array_bound = get_bound(ai->length()); + } else { + array_bound = get_bound(ai->array()); + } + + if (in_array_bound(index_bound, ai->array()) || + (index_bound && array_bound && index_bound->is_smaller(array_bound) && !index_bound->lower_instr() && index_bound->lower() >= 0)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Bounds check for instruction %d in block B%d can be fully eliminated!", ai->id(), ai->block()->block_id()) + ); + + remove_range_check(ai); + } else if (_optimistic && loop_header) { + assert(ai->array(), "Array must not be null!"); + assert(ai->index(), "Index must not be null!"); + + // Array instruction + Instruction *array_instr = ai->array(); + if (!loop_invariant(loop_header, array_instr)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Array %d is not loop invariant to header B%d", ai->array()->id(), loop_header->block_id()) + ); + return; + } + + // Lower instruction + Value index_instr = ai->index(); + Value lower_instr = index_bound->lower_instr(); + if (!loop_invariant(loop_header, lower_instr)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Lower instruction %d not loop invariant!", lower_instr->id()) + ); + return; + } + if (!lower_instr && index_bound->lower() < 0) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Lower bound smaller than 0 (%d)!", index_bound->lower()) + ); + return; + } + + // Upper instruction + Value upper_instr = index_bound->upper_instr(); + if (!loop_invariant(loop_header, upper_instr)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Upper instruction %d not loop invariant!", upper_instr->id()) + ); + return; + } + + // Length instruction + Value length_instr = ai->length(); + if (!loop_invariant(loop_header, length_instr)) { + // Generate length instruction yourself! + length_instr = NULL; + } + + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("LOOP INVARIANT access indexed %d found in block B%d!", ai->id(), ai->block()->block_id()) + ); + + BlockBegin *pred_block = loop_header->dominator(); + assert(pred_block != NULL, "Every loop header has a dominator!"); + BlockEnd *pred_block_end = pred_block->end(); + Instruction *insert_position = pred_block_end->prev(); + ValueStack *state = pred_block_end->state_before(); + if (pred_block_end->as_Goto() && state == NULL) state = pred_block_end->state(); + assert(state, "State must not be null"); + + // Add deoptimization to dominator of loop header + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Inserting deopt at bci %d in block B%d!", state->bci(), insert_position->block()->block_id()) + ); + + if (!is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, index_bound->lower(), upper_instr, index_bound->upper())) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Could not eliminate because of static analysis!") + ); + return; + } + + insert_deoptimization(state, insert_position, array_instr, length_instr, lower_instr, index_bound->lower(), upper_instr, index_bound->upper(), ai); + + // Finally remove the range check! + remove_range_check(ai); + } + } +} + +void RangeCheckEliminator::remove_range_check(AccessIndexed *ai) { + ai->set_flag(Instruction::NeedsRangeCheckFlag, false); + // no range check, no need for the length instruction anymore + ai->clear_length(); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(ai->dominator_depth()*2); + tty->print_cr("Range check for instruction %d eliminated!", ai->id()); + ); + + ASSERT_RANGE_CHECK_ELIMINATION( + Value array_length = ai->length(); + if (!array_length) { + array_length = ai->array(); + assert(array_length->type()->as_ObjectType(), "Has to be object type!"); + } + int cur_constant = -1; + Value cur_value = array_length; + if (cur_value->type()->as_IntConstant()) { + cur_constant += cur_value->type()->as_IntConstant()->value(); + cur_value = NULL; + } + Bound *new_index_bound = new Bound(0, NULL, cur_constant, cur_value); + add_assertions(new_index_bound, ai->index(), ai); + ); +} + +// Calculate bounds for instruction in this block and children blocks in the dominator tree +void RangeCheckEliminator::calc_bounds(BlockBegin *block, BlockBegin *loop_header) { + // Ensures a valid loop_header + assert(!loop_header || loop_header->is_set(BlockBegin::linear_scan_loop_header_flag), "Loop header has to be real !"); + + // Tracing output + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Block B%d", block->block_id()); + ); + + // Pushed stack for conditions + IntegerStack pushed; + // Process If + BlockBegin *parent = block->dominator(); + if (parent != NULL) { + If *cond = parent->end()->as_If(); + if (cond != NULL) { + process_if(pushed, block, cond); + } + } + + // Interate over current block + InstructionList arrays; + AccessIndexedList accessIndexed; + Instruction *cur = block; + + while (cur) { + // Ensure cur wasn't inserted during the elimination + if (cur->id() < this->_bounds.length()) { + // Process only if it is an access indexed instruction + AccessIndexed *ai = cur->as_AccessIndexed(); + if (ai != NULL) { + process_access_indexed(loop_header, block, ai); + accessIndexed.append(ai); + if (!arrays.contains(ai->array())) { + arrays.append(ai->array()); + } + Bound *b = get_bound(ai->index()); + if (!b->lower_instr()) { + // Lower bound is constant + update_bound(pushed, ai->index(), Instruction::geq, NULL, 0); + } + if (!b->has_upper()) { + if (ai->length() && ai->length()->type()->as_IntConstant()) { + int value = ai->length()->type()->as_IntConstant()->value(); + update_bound(pushed, ai->index(), Instruction::lss, NULL, value); + } else { + // Has no upper bound + Instruction *instr = ai->length(); + if (instr != NULL) instr = ai->array(); + update_bound(pushed, ai->index(), Instruction::lss, instr, 0); + } + } + } + } + cur = cur->next(); + } + + // Output current condition stack + TRACE_RANGE_CHECK_ELIMINATION(dump_condition_stack(block)); + + // Do in block motion of range checks + in_block_motion(block, accessIndexed, arrays); + + // Call all dominated blocks + for (int i=0; idominates()->length(); i++) { + BlockBegin *next = block->dominates()->at(i); + if (!next->is_set(BlockBegin::donot_eliminate_range_checks)) { + // if current block is a loop header and: + // - next block belongs to the same loop + // or + // - next block belongs to an inner loop + // then current block is the loop header for next block + if (block->is_set(BlockBegin::linear_scan_loop_header_flag) && (block->loop_index() == next->loop_index() || next->loop_depth() > block->loop_depth())) { + calc_bounds(next, block); + } else { + calc_bounds(next, loop_header); + } + } + } + + // Reset stack + for (int i=0; ipop(); + } +} + +#ifndef PRODUCT +// Dump condition stack +void RangeCheckEliminator::dump_condition_stack(BlockBegin *block) { + for (int i=0; i<_ir->linear_scan_order()->length(); i++) { + BlockBegin *cur_block = _ir->linear_scan_order()->at(i); + Instruction *instr = cur_block; + for_each_phi_fun(cur_block, phi, + BoundStack *bound_stack = _bounds.at(phi->id()); + if (bound_stack && bound_stack->length() > 0) { + Bound *bound = bound_stack->top(); + if ((bound->has_lower() || bound->has_upper()) && (bound->lower_instr() != phi || bound->upper_instr() != phi || bound->lower() != 0 || bound->upper() != 0)) { + TRACE_RANGE_CHECK_ELIMINATION(tty->fill_to(2*block->dominator_depth()); + tty->print("i%d", phi->id()); + tty->print(": "); + bound->print(); + tty->print_cr(""); + ); + } + }); + + while (!instr->as_BlockEnd()) { + if (instr->id() < _bounds.length()) { + BoundStack *bound_stack = _bounds.at(instr->id()); + if (bound_stack && bound_stack->length() > 0) { + Bound *bound = bound_stack->top(); + if ((bound->has_lower() || bound->has_upper()) && (bound->lower_instr() != instr || bound->upper_instr() != instr || bound->lower() != 0 || bound->upper() != 0)) { + TRACE_RANGE_CHECK_ELIMINATION(tty->fill_to(2*block->dominator_depth()); + tty->print("i%d", instr->id()); + tty->print(": "); + bound->print(); + tty->print_cr(""); + ); + } + } + } + instr = instr->next(); + } + } +} +#endif + +// Verification or the IR +RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), false) { + this->_ir = ir; + ir->iterate_linear_scan_order(this); +} + +// Verify this block +void RangeCheckEliminator::Verification::block_do(BlockBegin *block) { + If *cond = block->end()->as_If(); + // Watch out: tsux and fsux can be the same! + if (block->number_of_sux() > 1) { + for (int i=0; inumber_of_sux(); i++) { + BlockBegin *sux = block->sux_at(i); + BlockBegin *pred = NULL; + for (int j=0; jnumber_of_preds(); j++) { + BlockBegin *cur = sux->pred_at(j); + assert(cur != NULL, "Predecessor must not be null"); + if (!pred) { + pred = cur; + } + assert(cur == pred, "Block must not have more than one predecessor if its predecessor has more than one successor"); + } + assert(sux->number_of_preds() >= 1, "Block must have at least one predecessor"); + assert(sux->pred_at(0) == block, "Wrong successor"); + } + } + + BlockBegin *dominator = block->dominator(); + if (dominator) { + assert(block != _ir->start(), "Start block must not have a dominator!"); + assert(can_reach(dominator, block), "Dominator can't reach his block !"); + assert(can_reach(_ir->start(), dominator), "Dominator is unreachable !"); + assert(!can_reach(_ir->start(), block, dominator), "Wrong dominator ! Block can be reached anyway !"); + BlockList *all_blocks = _ir->linear_scan_order(); + for (int i=0; ilength(); i++) { + BlockBegin *cur = all_blocks->at(i); + if (cur != dominator && cur != block) { + assert(can_reach(dominator, block, cur), "There has to be another dominator!"); + } + } + } else { + assert(block == _ir->start(), "Only start block must not have a dominator"); + } + + if (block->is_set(BlockBegin::linear_scan_loop_header_flag)) { + int loop_index = block->loop_index(); + BlockList *all_blocks = _ir->linear_scan_order(); + assert(block->number_of_preds() >= 1, "Block must have at least one predecessor"); + assert(!block->is_set(BlockBegin::exception_entry_flag), "Loop header must not be exception handler!"); + // Sometimes, the backbranch comes from an exception handler. In + // this case, loop indexes/loop depths may not appear correct. + bool loop_through_xhandler = false; + for (int i = 0; i < block->number_of_exception_handlers(); i++) { + BlockBegin *xhandler = block->exception_handler_at(i); + for (int j = 0; j < block->number_of_preds(); j++) { + if (dominates(xhandler, block->pred_at(j)) || xhandler == block->pred_at(j)) { + loop_through_xhandler = true; + } + } + } + + for (int i=0; inumber_of_sux(); i++) { + BlockBegin *sux = block->sux_at(i); + assert(sux->loop_depth() != block->loop_depth() || sux->loop_index() == block->loop_index() || loop_through_xhandler, "Loop index has to be same"); + assert(sux->loop_depth() == block->loop_depth() || sux->loop_index() != block->loop_index(), "Loop index has to be different"); + } + + for (int i=0; ilength(); i++) { + BlockBegin *cur = all_blocks->at(i); + if (cur->loop_index() == loop_index && cur != block) { + assert(dominates(block->dominator(), cur), "Dominator of loop header must dominate all loop blocks"); + } + } + } + + Instruction *cur = block; + while (cur) { + assert(cur->block() == block, "Block begin has to be set correctly!"); + cur = cur->next(); + } +} + +// Loop header must dominate all loop blocks +bool RangeCheckEliminator::Verification::dominates(BlockBegin *dominator, BlockBegin *block) { + BlockBegin *cur = block->dominator(); + while (cur && cur != dominator) { + cur = cur->dominator(); + } + return cur == dominator; +} + +// Try to reach Block end beginning in Block start and not using Block dont_use +bool RangeCheckEliminator::Verification::can_reach(BlockBegin *start, BlockBegin *end, BlockBegin *dont_use /* = NULL */) { + if (start == end) return start != dont_use; + // Simple BSF from start to end + // BlockBeginList _current; + for (int i=0; i<_used.length(); i++) { + _used[i] = false; + } + _current.truncate(0); + _successors.truncate(0); + if (start != dont_use) { + _current.push(start); + _used[start->block_id()] = true; + } + + // BlockBeginList _successors; + while (_current.length() > 0) { + BlockBegin *cur = _current.pop(); + // Add exception handlers to list + for (int i=0; inumber_of_exception_handlers(); i++) { + BlockBegin *xhandler = cur->exception_handler_at(i); + _successors.push(xhandler); + // Add exception handlers of _successors to list + for (int j=0; jnumber_of_exception_handlers(); j++) { + BlockBegin *sux_xhandler = xhandler->exception_handler_at(j); + _successors.push(sux_xhandler); + } + } + // Add normal _successors to list + for (int i=0; inumber_of_sux(); i++) { + BlockBegin *sux = cur->sux_at(i); + _successors.push(sux); + // Add exception handlers of _successors to list + for (int j=0; jnumber_of_exception_handlers(); j++) { + BlockBegin *xhandler = sux->exception_handler_at(j); + _successors.push(xhandler); + } + } + for (int i=0; i<_successors.length(); i++) { + BlockBegin *sux = _successors[i]; + assert(sux != NULL, "Successor must not be NULL!"); + if (sux == end) { + return true; + } + if (sux != dont_use && !_used[sux->block_id()]) { + _used[sux->block_id()] = true; + _current.push(sux); + } + } + _successors.truncate(0); + } + + return false; +} + +// Bound +RangeCheckEliminator::Bound::~Bound() { +} + +// Bound constructor +RangeCheckEliminator::Bound::Bound() { + init(); + this->_lower = min_jint; + this->_upper = max_jint; + this->_lower_instr = NULL; + this->_upper_instr = NULL; +} + +// Bound constructor +RangeCheckEliminator::Bound::Bound(int lower, Value lower_instr, int upper, Value upper_instr) { + init(); + assert(!lower_instr || !lower_instr->as_Constant() || !lower_instr->type()->as_IntConstant(), "Must not be constant!"); + assert(!upper_instr || !upper_instr->as_Constant() || !upper_instr->type()->as_IntConstant(), "Must not be constant!"); + this->_lower = lower; + this->_upper = upper; + this->_lower_instr = lower_instr; + this->_upper_instr = upper_instr; +} + +// Bound constructor +RangeCheckEliminator::Bound::Bound(Instruction::Condition cond, Value v, int constant) { + assert(!v || (v->type() && (v->type()->as_IntType() || v->type()->as_ObjectType())), "Type must be array or integer!"); + assert(!v || !v->as_Constant() || !v->type()->as_IntConstant(), "Must not be constant!"); + + init(); + if (cond == Instruction::eql) { + _lower = constant; + _lower_instr = v; + _upper = constant; + _upper_instr = v; + } else if (cond == Instruction::neq) { + _lower = min_jint; + _upper = max_jint; + _lower_instr = NULL; + _upper_instr = NULL; + if (v == NULL) { + if (constant == min_jint) { + _lower++; + } + if (constant == max_jint) { + _upper--; + } + } + } else if (cond == Instruction::geq) { + _lower = constant; + _lower_instr = v; + _upper = max_jint; + _upper_instr = NULL; + } else if (cond == Instruction::leq) { + _lower = min_jint; + _lower_instr = NULL; + _upper = constant; + _upper_instr = v; + } else { + ShouldNotReachHere(); + } +} + +// Set lower +void RangeCheckEliminator::Bound::set_lower(int value, Value v) { + assert(!v || !v->as_Constant() || !v->type()->as_IntConstant(), "Must not be constant!"); + this->_lower = value; + this->_lower_instr = v; +} + +// Set upper +void RangeCheckEliminator::Bound::set_upper(int value, Value v) { + assert(!v || !v->as_Constant() || !v->type()->as_IntConstant(), "Must not be constant!"); + this->_upper = value; + this->_upper_instr = v; +} + +// Add constant -> no overflow may occur +void RangeCheckEliminator::Bound::add_constant(int value) { + this->_lower += value; + this->_upper += value; +} + +// Init +void RangeCheckEliminator::Bound::init() { +} + +// or +void RangeCheckEliminator::Bound::or_op(Bound *b) { + // Watch out, bound is not guaranteed not to overflow! + // Update lower bound + if (_lower_instr != b->_lower_instr || (_lower_instr && _lower != b->_lower)) { + _lower_instr = NULL; + _lower = min_jint; + } else { + _lower = MIN2(_lower, b->_lower); + } + // Update upper bound + if (_upper_instr != b->_upper_instr || (_upper_instr && _upper != b->_upper)) { + _upper_instr = NULL; + _upper = max_jint; + } else { + _upper = MAX2(_upper, b->_upper); + } +} + +// and +void RangeCheckEliminator::Bound::and_op(Bound *b) { + // Update lower bound + if (_lower_instr == b->_lower_instr) { + _lower = MAX2(_lower, b->_lower); + } + if (b->has_lower()) { + bool set = true; + if (_lower_instr != NULL && b->_lower_instr != NULL) { + set = (_lower_instr->dominator_depth() > b->_lower_instr->dominator_depth()); + } + if (set) { + _lower = b->_lower; + _lower_instr = b->_lower_instr; + } + } + // Update upper bound + if (_upper_instr == b->_upper_instr) { + _upper = MIN2(_upper, b->_upper); + } + if (b->has_upper()) { + bool set = true; + if (_upper_instr != NULL && b->_upper_instr != NULL) { + set = (_upper_instr->dominator_depth() > b->_upper_instr->dominator_depth()); + } + if (set) { + _upper = b->_upper; + _upper_instr = b->_upper_instr; + } + } +} + +// has_upper +bool RangeCheckEliminator::Bound::has_upper() { + return _upper_instr != NULL || _upper < max_jint; +} + +// is_smaller +bool RangeCheckEliminator::Bound::is_smaller(Bound *b) { + if (b->_lower_instr != _upper_instr) { + return false; + } + return _upper < b->_lower; +} + +// has_lower +bool RangeCheckEliminator::Bound::has_lower() { + return _lower_instr != NULL || _lower > min_jint; +} + +// in_array_bound +bool RangeCheckEliminator::in_array_bound(Bound *bound, Value array){ + if (!bound) return false; + assert(array != NULL, "Must not be null!"); + assert(bound != NULL, "Must not be null!"); + if (bound->lower() >=0 && bound->lower_instr() == NULL && bound->upper() < 0 && bound->upper_instr() != NULL) { + ArrayLength *len = bound->upper_instr()->as_ArrayLength(); + if (bound->upper_instr() == array || (len != NULL && len->array() == array)) { + return true; + } + } + return false; +} + +// remove_lower +void RangeCheckEliminator::Bound::remove_lower() { + _lower = min_jint; + _lower_instr = NULL; +} + +// remove_upper +void RangeCheckEliminator::Bound::remove_upper() { + _upper = max_jint; + _upper_instr = NULL; +} + +// upper +int RangeCheckEliminator::Bound::upper() { + return _upper; +} + +// lower +int RangeCheckEliminator::Bound::lower() { + return _lower; +} + +// upper_instr +Value RangeCheckEliminator::Bound::upper_instr() { + return _upper_instr; +} + +// lower_instr +Value RangeCheckEliminator::Bound::lower_instr() { + return _lower_instr; +} + +// print +void RangeCheckEliminator::Bound::print() { + tty->print(""); + if (this->_lower_instr || this->_lower != min_jint) { + if (this->_lower_instr) { + tty->print("i%d", this->_lower_instr->id()); + if (this->_lower > 0) { + tty->print("+%d", _lower); + } + if (this->_lower < 0) { + tty->print("%d", _lower); + } + } else { + tty->print("%d", _lower); + } + tty->print(" <= "); + } + tty->print("x"); + if (this->_upper_instr || this->_upper != max_jint) { + tty->print(" <= "); + if (this->_upper_instr) { + tty->print("i%d", this->_upper_instr->id()); + if (this->_upper > 0) { + tty->print("+%d", _upper); + } + if (this->_upper < 0) { + tty->print("%d", _upper); + } + } else { + tty->print("%d", _upper); + } + } +} + +// Copy +RangeCheckEliminator::Bound *RangeCheckEliminator::Bound::copy() { + Bound *b = new Bound(); + b->_lower = _lower; + b->_lower_instr = _lower_instr; + b->_upper = _upper; + b->_upper_instr = _upper_instr; + return b; +} + +#ifdef ASSERT +// Add assertion +void RangeCheckEliminator::Bound::add_assertion(Instruction *instruction, Instruction *position, int i, Value instr, Instruction::Condition cond) { + Instruction *result = position; + Instruction *compare_with = NULL; + ValueStack *state = position->state_before(); + if (position->as_BlockEnd() && !position->as_Goto()) { + state = position->as_BlockEnd()->state_before(); + } + Instruction *instruction_before = position->prev(); + if (position->as_Return() && Compilation::current()->method()->is_synchronized() && instruction_before->as_MonitorExit()) { + instruction_before = instruction_before->prev(); + } + result = instruction_before; + // Load constant only if needed + Constant *constant = NULL; + if (i != 0 || !instr) { + constant = new Constant(new IntConstant(i)); + NOT_PRODUCT(constant->set_printable_bci(position->printable_bci())); + result = result->insert_after(constant); + compare_with = constant; + } + + if (instr) { + assert(instr->type()->as_ObjectType() || instr->type()->as_IntType(), "Type must be array or integer!"); + compare_with = instr; + // Load array length if necessary + Instruction *op = instr; + if (instr->type()->as_ObjectType()) { + assert(state, "must not be null"); + ArrayLength *length = new ArrayLength(instr, state->copy()); + NOT_PRODUCT(length->set_printable_bci(position->printable_bci())); + length->set_exception_state(length->state_before()); + result = result->insert_after(length); + op = length; + compare_with = length; + } + // Add operation only if necessary + if (constant) { + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, constant, op, false, NULL); + NOT_PRODUCT(ao->set_printable_bci(position->printable_bci())); + result = result->insert_after(ao); + compare_with = ao; + // TODO: Check that add operation does not overflow! + } + } + assert(compare_with != NULL, "You have to compare with something!"); + assert(instruction != NULL, "Instruction must not be null!"); + + if (instruction->type()->as_ObjectType()) { + // Load array length if necessary + Instruction *op = instruction; + assert(state, "must not be null"); + ArrayLength *length = new ArrayLength(instruction, state->copy()); + length->set_exception_state(length->state_before()); + NOT_PRODUCT(length->set_printable_bci(position->printable_bci())); + result = result->insert_after(length); + instruction = length; + } + + Assert *assert = new Assert(instruction, cond, false, compare_with); + NOT_PRODUCT(assert->set_printable_bci(position->printable_bci())); + result->insert_after(assert); +} + +// Add assertions +void RangeCheckEliminator::add_assertions(Bound *bound, Instruction *instruction, Instruction *position) { + // Add lower bound assertion + if (bound->has_lower()) { + bound->add_assertion(instruction, position, bound->lower(), bound->lower_instr(), Instruction::geq); + } + // Add upper bound assertion + if (bound->has_upper()) { + bound->add_assertion(instruction, position, bound->upper(), bound->upper_instr(), Instruction::leq); + } +} +#endif + diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp new file mode 100644 index 00000000000..af6d9d94815 --- /dev/null +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp @@ -0,0 +1,241 @@ +/* + * 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. + * + */ + +#ifndef SHARE_VM_C1_C1_RANGECHECKELIMINATION_HPP +#define SHARE_VM_C1_C1_RANGECHECKELIMINATION_HPP + +#include "c1/c1_Instruction.hpp" + +// Base class for range check elimination +class RangeCheckElimination : AllStatic { +public: + static void eliminate(IR *ir); +}; + +// Implementation +class RangeCheckEliminator VALUE_OBJ_CLASS_SPEC { +private: + int _number_of_instructions; + bool _optimistic; // Insert predicates and deoptimize when they fail + IR *_ir; + + define_array(BlockBeginArray, BlockBegin*) + define_stack(BlockBeginList, BlockBeginArray) + define_stack(IntegerStack, intArray) + define_array(IntegerMap, IntegerStack*) + + class Verification : public _ValueObj /*VALUE_OBJ_CLASS_SPEC*/, public BlockClosure { + private: + IR *_ir; + boolArray _used; + BlockBeginList _current; + BlockBeginList _successors; + + public: + Verification(IR *ir); + virtual void block_do(BlockBegin *block); + bool can_reach(BlockBegin *start, BlockBegin *end, BlockBegin *dont_use = NULL); + bool dominates(BlockBegin *dominator, BlockBegin *block); + }; + +public: + // Bounds for an instruction in the form x + c which c integer + // constant and x another instruction + class Bound : public CompilationResourceObj { + private: + int _upper; + Value _upper_instr; + int _lower; + Value _lower_instr; + + public: + Bound(); + Bound(Value v); + Bound(Instruction::Condition cond, Value v, int constant = 0); + Bound(int lower, Value lower_instr, int upper, Value upper_instr); + ~Bound(); + +#ifdef ASSERT + void add_assertion(Instruction *instruction, Instruction *position, int i, Value instr, Instruction::Condition cond); +#endif + int upper(); + Value upper_instr(); + int lower(); + Value lower_instr(); + void print(); + bool check_no_overflow(int const_value); + void or_op(Bound *b); + void and_op(Bound *b); + bool has_upper(); + bool has_lower(); + void set_upper(int upper, Value upper_instr); + void set_lower(int lower, Value lower_instr); + bool is_smaller(Bound *b); + void remove_upper(); + void remove_lower(); + void add_constant(int value); + Bound *copy(); + + private: + void init(); + }; + + + class Visitor : public InstructionVisitor { + private: + Bound *_bound; + RangeCheckEliminator *_rce; + + public: + void set_range_check_eliminator(RangeCheckEliminator *rce) { _rce = rce; } + Bound *bound() const { return _bound; } + void clear_bound() { _bound = NULL; } + + protected: + // visitor functions + void do_Constant (Constant* x); + void do_IfOp (IfOp* x); + void do_LogicOp (LogicOp* x); + void do_ArithmeticOp (ArithmeticOp* x); + void do_Phi (Phi* x); + + void do_StoreField (StoreField* x) { /* nothing to do */ }; + void do_StoreIndexed (StoreIndexed* x) { /* nothing to do */ }; + void do_MonitorEnter (MonitorEnter* x) { /* nothing to do */ }; + void do_MonitorExit (MonitorExit* x) { /* nothing to do */ }; + void do_Invoke (Invoke* x) { /* nothing to do */ }; + void do_UnsafePutRaw (UnsafePutRaw* x) { /* nothing to do */ }; + void do_UnsafePutObject(UnsafePutObject* x) { /* nothing to do */ }; + void do_Intrinsic (Intrinsic* x) { /* nothing to do */ }; + void do_Local (Local* x) { /* nothing to do */ }; + void do_LoadField (LoadField* x) { /* nothing to do */ }; + void do_ArrayLength (ArrayLength* x) { /* nothing to do */ }; + void do_LoadIndexed (LoadIndexed* x) { /* nothing to do */ }; + void do_NegateOp (NegateOp* x) { /* nothing to do */ }; + void do_ShiftOp (ShiftOp* x) { /* nothing to do */ }; + void do_CompareOp (CompareOp* x) { /* nothing to do */ }; + void do_Convert (Convert* x) { /* nothing to do */ }; + void do_NullCheck (NullCheck* x) { /* nothing to do */ }; + void do_TypeCast (TypeCast* x) { /* nothing to do */ }; + void do_NewInstance (NewInstance* x) { /* nothing to do */ }; + void do_NewTypeArray (NewTypeArray* x) { /* nothing to do */ }; + void do_NewObjectArray (NewObjectArray* x) { /* nothing to do */ }; + void do_NewMultiArray (NewMultiArray* x) { /* nothing to do */ }; + void do_CheckCast (CheckCast* x) { /* nothing to do */ }; + void do_InstanceOf (InstanceOf* x) { /* nothing to do */ }; + void do_BlockBegin (BlockBegin* x) { /* nothing to do */ }; + void do_Goto (Goto* x) { /* nothing to do */ }; + void do_If (If* x) { /* nothing to do */ }; + void do_IfInstanceOf (IfInstanceOf* x) { /* nothing to do */ }; + void do_TableSwitch (TableSwitch* x) { /* nothing to do */ }; + void do_LookupSwitch (LookupSwitch* x) { /* nothing to do */ }; + void do_Return (Return* x) { /* nothing to do */ }; + void do_Throw (Throw* x) { /* nothing to do */ }; + void do_Base (Base* x) { /* nothing to do */ }; + void do_OsrEntry (OsrEntry* x) { /* nothing to do */ }; + void do_ExceptionObject(ExceptionObject* x) { /* nothing to do */ }; + void do_RoundFP (RoundFP* x) { /* nothing to do */ }; + void do_UnsafeGetRaw (UnsafeGetRaw* x) { /* nothing to do */ }; + void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ }; + void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { /* nothing to do */ }; + void do_UnsafePrefetchRead (UnsafePrefetchRead* x) { /* nothing to do */ }; + void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ }; + void do_ProfileCall (ProfileCall* x) { /* nothing to do */ }; + void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ }; + void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ }; + void do_MemBar (MemBar* x) { /* nothing to do */ }; + void do_RangeCheckPredicate(RangeCheckPredicate* x) { /* nothing to do */ }; + void do_Assert (Assert* x) { /* nothing to do */ }; + }; + +#ifdef ASSERT + void add_assertions(Bound *bound, Instruction *instruction, Instruction *position); +#endif + + define_array(BoundArray, Bound *) + define_stack(BoundStack, BoundArray) + define_array(BoundMap, BoundStack *) + define_array(AccessIndexedArray, AccessIndexed *) + define_stack(AccessIndexedList, AccessIndexedArray) + define_array(InstructionArray, Instruction *) + define_stack(InstructionList, InstructionArray) + + class AccessIndexedInfo : public CompilationResourceObj { + public: + AccessIndexedList *_list; + int _min; + int _max; + }; + + define_array(AccessIndexedInfoArray, AccessIndexedInfo *) + BoundMap _bounds; // Mapping from Instruction's id to current bound + AccessIndexedInfoArray _access_indexed_info; // Mapping from Instruction's id to AccessIndexedInfo for in block motion + Visitor _visitor; + +public: + RangeCheckEliminator(IR *ir); + + IR *ir() const { return _ir; } + + // Pass over the dominator tree to identify blocks where there's an oppportunity for optimization + bool set_process_block_flags(BlockBegin *block); + // The core of the optimization work: pass over the dominator tree + // to propagate bound information, insert predicate out of loops, + // eliminate bound checks when possible and perform in block motion + void calc_bounds(BlockBegin *block, BlockBegin *loop_header); + // reorder bound checks within a block in order to eliminate some of them + void in_block_motion(BlockBegin *block, AccessIndexedList &accessIndexed, InstructionList &arrays); + + // update/access current bound + void update_bound(IntegerStack &pushed, Value v, Instruction::Condition cond, Value value, int constant); + void update_bound(IntegerStack &pushed, Value v, Bound *bound); + Bound *get_bound(Value v); + + bool loop_invariant(BlockBegin *loop_header, Instruction *instruction); // check for loop invariance + void add_access_indexed_info(InstructionList &indices, int i, Value instruction, AccessIndexed *ai); // record indexed access for in block motion + void remove_range_check(AccessIndexed *ai); // Mark this instructions as not needing a range check + void add_if_condition(IntegerStack &pushed, Value x, Value y, Instruction::Condition condition); // Update bound for an If + bool in_array_bound(Bound *bound, Value array); // Check whether bound is known to fall within array + + // helper functions to work with predicates + Instruction* insert_after(Instruction* insert_position, Instruction* instr, int bci); + Instruction* predicate(Instruction* left, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci=-1); + Instruction* predicate_cmp_with_const(Instruction* instr, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci=1); + Instruction* predicate_add(Instruction* left, int left_const, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci=-1); + Instruction* predicate_add_cmp_with_const(Instruction* left, int left_const, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci=-1); + + void insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, // Add predicate + Instruction *length_instruction, Instruction *lower_instr, int lower, + Instruction *upper_instr, int upper, AccessIndexed *ai); + bool is_ok_for_deoptimization(Instruction *insert_position, Instruction *array_instr, // Can we safely add a predicate? + Instruction *length_instr, Instruction *lower_instr, + int lower, Instruction *upper_instr, int upper); + void process_if(IntegerStack &pushed, BlockBegin *block, If *cond); // process If Instruction + void process_access_indexed(BlockBegin *loop_header, BlockBegin *block, AccessIndexed *ai); // process indexed access + + void dump_condition_stack(BlockBegin *cur_block); + static void print_statistics(); +}; + +#endif // SHARE_VM_C1_C1_RANGECHECKELIMINATION_HPP diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 3002c1304a1..e274076d06b 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -1330,6 +1330,50 @@ JRT_LEAF(int, Runtime1::is_instance_of(oopDesc* mirror, oopDesc* obj)) return (k != NULL && obj != NULL && obj->is_a(k)) ? 1 : 0; JRT_END +JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* thread)) + ResourceMark rm; + + assert(!TieredCompilation, "incompatible with tiered compilation"); + + RegisterMap reg_map(thread, false); + frame runtime_frame = thread->last_frame(); + frame caller_frame = runtime_frame.sender(®_map); + + nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); + assert (nm != NULL, "no more nmethod?"); + nm->make_not_entrant(); + + methodHandle m(nm->method()); + MethodData* mdo = m->method_data(); + + if (mdo == NULL && !HAS_PENDING_EXCEPTION) { + // Build an MDO. Ignore errors like OutOfMemory; + // that simply means we won't have an MDO to update. + Method::build_interpreter_method_data(m, THREAD); + if (HAS_PENDING_EXCEPTION) { + assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); + CLEAR_PENDING_EXCEPTION; + } + mdo = m->method_data(); + } + + if (mdo != NULL) { + mdo->inc_trap_count(Deoptimization::Reason_none); + } + + if (TracePredicateFailedTraps) { + stringStream ss1, ss2; + vframeStream vfst(thread); + methodHandle inlinee = methodHandle(vfst.method()); + inlinee->print_short_name(&ss1); + m->print_short_name(&ss2); + tty->print_cr("Predicate failed trap in method %s at bci %d inlined in %s at pc %x", ss1.as_string(), vfst.bci(), ss2.as_string(), caller_frame.pc()); + } + + + Deoptimization::deoptimize_frame(thread, caller_frame.id()); + +JRT_END #ifndef PRODUCT void Runtime1::print_statistics() { diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.hpp b/hotspot/src/share/vm/c1/c1_Runtime1.hpp index 06ef147a9f1..9b12d26226e 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.hpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.hpp @@ -71,6 +71,7 @@ class StubAssembler; stub(g1_post_barrier_slow) \ stub(fpu2long_stub) \ stub(counter_overflow) \ + stub(predicate_failed_trap) \ last_entry(number_of_ids) #define DECLARE_STUB_ID(x) x ## _id , @@ -190,6 +191,8 @@ class Runtime1: public AllStatic { static void oop_arraycopy(HeapWord* src, HeapWord* dst, int length); static int is_instance_of(oopDesc* mirror, oopDesc* obj); + static void predicate_failed_trap(JavaThread* thread); + static void print_statistics() PRODUCT_RETURN; }; diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.cpp b/hotspot/src/share/vm/c1/c1_ValueMap.cpp index a759854102a..fb9b931e336 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp @@ -26,9 +26,9 @@ #include "c1/c1_Canonicalizer.hpp" #include "c1/c1_IR.hpp" #include "c1/c1_ValueMap.hpp" +#include "c1/c1_ValueStack.hpp" #include "utilities/bitMap.inline.hpp" - #ifndef PRODUCT int ValueMap::_number_of_finds = 0; @@ -192,10 +192,6 @@ Value ValueMap::find_insert(Value x) { && lf->field()->holder() == field->holder() \ && (all_offsets || lf->field()->offset() == field->offset()); -#define MUST_KILL_EXCEPTION(must_kill, entry, value) \ - assert(entry->nesting() < nesting(), "must not find bigger nesting than current"); \ - bool must_kill = (entry->nesting() == nesting() - 1); - void ValueMap::kill_memory() { GENERIC_KILL_VALUE(MUST_KILL_MEMORY); @@ -209,11 +205,6 @@ void ValueMap::kill_field(ciField* field, bool all_offsets) { GENERIC_KILL_VALUE(MUST_KILL_FIELD); } -void ValueMap::kill_exception() { - GENERIC_KILL_VALUE(MUST_KILL_EXCEPTION); -} - - void ValueMap::kill_map(ValueMap* map) { assert(is_global_value_numbering(), "only for global value numbering"); _killed_values.set_union(&map->_killed_values); @@ -274,6 +265,8 @@ class ShortLoopOptimizer : public ValueNumberingVisitor { GlobalValueNumbering* _gvn; BlockList _loop_blocks; bool _too_complicated_loop; + bool _has_field_store[T_ARRAY + 1]; + bool _has_indexed_store[T_ARRAY + 1]; // simplified access to methods of GlobalValueNumbering ValueMap* current_map() { return _gvn->current_map(); } @@ -281,8 +274,16 @@ class ShortLoopOptimizer : public ValueNumberingVisitor { // implementation for abstract methods of ValueNumberingVisitor void kill_memory() { _too_complicated_loop = true; } - void kill_field(ciField* field, bool all_offsets) { current_map()->kill_field(field, all_offsets); }; - void kill_array(ValueType* type) { current_map()->kill_array(type); }; + void kill_field(ciField* field, bool all_offsets) { + current_map()->kill_field(field, all_offsets); + assert(field->type()->basic_type() >= 0 && field->type()->basic_type() <= T_ARRAY, "Invalid type"); + _has_field_store[field->type()->basic_type()] = true; + } + void kill_array(ValueType* type) { + current_map()->kill_array(type); + BasicType basic_type = as_BasicType(type); assert(basic_type >= 0 && basic_type <= T_ARRAY, "Invalid type"); + _has_indexed_store[basic_type] = true; + } public: ShortLoopOptimizer(GlobalValueNumbering* gvn) @@ -290,11 +291,141 @@ class ShortLoopOptimizer : public ValueNumberingVisitor { , _loop_blocks(ValueMapMaxLoopSize) , _too_complicated_loop(false) { + for (int i=0; i<= T_ARRAY; i++){ + _has_field_store[i] = false; + _has_indexed_store[i] = false; + } + } + + bool has_field_store(BasicType type) { + assert(type >= 0 && type <= T_ARRAY, "Invalid type"); + return _has_field_store[type]; + } + + bool has_indexed_store(BasicType type) { + assert(type >= 0 && type <= T_ARRAY, "Invalid type"); + return _has_indexed_store[type]; } bool process(BlockBegin* loop_header); }; +class LoopInvariantCodeMotion : public StackObj { + private: + GlobalValueNumbering* _gvn; + ShortLoopOptimizer* _short_loop_optimizer; + Instruction* _insertion_point; + ValueStack * _state; + + void set_invariant(Value v) const { _gvn->set_processed(v); } + bool is_invariant(Value v) const { return _gvn->is_processed(v); } + + void process_block(BlockBegin* block); + + public: + LoopInvariantCodeMotion(ShortLoopOptimizer *slo, GlobalValueNumbering* gvn, BlockBegin* loop_header, BlockList* loop_blocks); +}; + +LoopInvariantCodeMotion::LoopInvariantCodeMotion(ShortLoopOptimizer *slo, GlobalValueNumbering* gvn, BlockBegin* loop_header, BlockList* loop_blocks) + : _gvn(gvn), _short_loop_optimizer(slo) { + + TRACE_VALUE_NUMBERING(tty->print_cr("using loop invariant code motion loop_header = %d", loop_header->block_id())); + TRACE_VALUE_NUMBERING(tty->print_cr("** loop invariant code motion for short loop B%d", loop_header->block_id())); + + BlockBegin* insertion_block = loop_header->dominator(); + if (insertion_block->number_of_preds() == 0) { + return; // only the entry block does not have a predecessor + } + + assert(insertion_block->end()->as_Base() == NULL, "cannot insert into entry block"); + _insertion_point = insertion_block->end()->prev(); + + BlockEnd *block_end = insertion_block->end(); + _state = block_end->state_before(); + + if (!_state) { + // If, TableSwitch and LookupSwitch always have state_before when + // loop invariant code motion happens.. + assert(block_end->as_Goto(), "Block has to be goto"); + _state = block_end->state(); + } + + // the loop_blocks are filled by going backward from the loop header, so this processing order is best + assert(loop_blocks->at(0) == loop_header, "loop header must be first loop block"); + process_block(loop_header); + for (int i = loop_blocks->length() - 1; i >= 1; i--) { + process_block(loop_blocks->at(i)); + } +} + +void LoopInvariantCodeMotion::process_block(BlockBegin* block) { + TRACE_VALUE_NUMBERING(tty->print_cr("processing block B%d", block->block_id())); + + Instruction* prev = block; + Instruction* cur = block->next(); + + while (cur != NULL) { + + // determine if cur instruction is loop invariant + // only selected instruction types are processed here + bool cur_invariant = false; + + if (cur->as_Constant() != NULL) { + cur_invariant = !cur->can_trap(); + } else if (cur->as_ArithmeticOp() != NULL || cur->as_LogicOp() != NULL || cur->as_ShiftOp() != NULL) { + assert(cur->as_Op2() != NULL, "must be Op2"); + Op2* op2 = (Op2*)cur; + cur_invariant = !op2->can_trap() && is_invariant(op2->x()) && is_invariant(op2->y()); + } else if (cur->as_LoadField() != NULL) { + LoadField* lf = (LoadField*)cur; + // deoptimizes on NullPointerException + cur_invariant = !lf->needs_patching() && !lf->field()->is_volatile() && !_short_loop_optimizer->has_field_store(lf->field()->type()->basic_type()) && is_invariant(lf->obj()); + } else if (cur->as_ArrayLength() != NULL) { + ArrayLength *length = cur->as_ArrayLength(); + cur_invariant = is_invariant(length->array()); + } else if (cur->as_LoadIndexed() != NULL) { + LoadIndexed *li = (LoadIndexed *)cur->as_LoadIndexed(); + cur_invariant = !_short_loop_optimizer->has_indexed_store(as_BasicType(cur->type())) && is_invariant(li->array()) && is_invariant(li->index()); + } + + if (cur_invariant) { + // perform value numbering and mark instruction as loop-invariant + _gvn->substitute(cur); + + if (cur->as_Constant() == NULL) { + // ensure that code for non-constant instructions is always generated + cur->pin(); + } + + // remove cur instruction from loop block and append it to block before loop + Instruction* next = cur->next(); + Instruction* in = _insertion_point->next(); + _insertion_point = _insertion_point->set_next(cur); + cur->set_next(in); + + // Deoptimize on exception + cur->set_flag(Instruction::DeoptimizeOnException, true); + + // Clear exception handlers + cur->set_exception_handlers(NULL); + + TRACE_VALUE_NUMBERING(tty->print_cr("Instruction %c%d is loop invariant", cur->type()->tchar(), cur->id())); + + if (cur->state_before() != NULL) { + cur->set_state_before(_state->copy()); + } + if (cur->exception_state() != NULL) { + cur->set_exception_state(_state->copy()); + } + + cur = prev->set_next(next); + + } else { + prev = cur; + cur = cur->next(); + } + } +} bool ShortLoopOptimizer::process(BlockBegin* loop_header) { TRACE_VALUE_NUMBERING(tty->print_cr("** loop header block")); @@ -316,6 +447,10 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { for (int j = block->number_of_preds() - 1; j >= 0; j--) { BlockBegin* pred = block->pred_at(j); + if (pred->is_set(BlockBegin::osr_entry_flag)) { + return false; + } + ValueMap* pred_map = value_map_of(pred); if (pred_map != NULL) { current_map()->kill_map(pred_map); @@ -336,6 +471,12 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { } } + bool optimistic = this->_gvn->compilation()->is_optimistic(); + + if (UseLoopInvariantCodeMotion && optimistic) { + LoopInvariantCodeMotion code_motion(this, _gvn, loop_header, &_loop_blocks); + } + TRACE_VALUE_NUMBERING(tty->print_cr("** loop successfully optimized")); return true; } @@ -344,11 +485,11 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { GlobalValueNumbering::GlobalValueNumbering(IR* ir) : _current_map(NULL) , _value_maps(ir->linear_scan_order()->length(), NULL) + , _compilation(ir->compilation()) { TRACE_VALUE_NUMBERING(tty->print_cr("****** start of global value numbering")); ShortLoopOptimizer short_loop_optimizer(this); - int subst_count = 0; BlockList* blocks = ir->linear_scan_order(); int num_blocks = blocks->length(); @@ -357,6 +498,12 @@ GlobalValueNumbering::GlobalValueNumbering(IR* ir) assert(start_block == ir->start() && start_block->number_of_preds() == 0 && start_block->dominator() == NULL, "must be start block"); assert(start_block->next()->as_Base() != NULL && start_block->next()->next() == NULL, "start block must not have instructions"); + // method parameters are not linked in instructions list, so process them separateley + for_each_state_value(start_block->state(), value, + assert(value->as_Local() != NULL, "only method parameters allowed"); + set_processed(value); + ); + // initial, empty value map with nesting 0 set_value_map_of(start_block, new ValueMap()); @@ -374,7 +521,7 @@ GlobalValueNumbering::GlobalValueNumbering(IR* ir) // create new value map with increased nesting _current_map = new ValueMap(value_map_of(dominator)); - if (num_preds == 1) { + if (num_preds == 1 && !block->is_set(BlockBegin::exception_entry_flag)) { assert(dominator == block->pred_at(0), "dominator must be equal to predecessor"); // nothing to do here @@ -403,36 +550,41 @@ GlobalValueNumbering::GlobalValueNumbering(IR* ir) } } - if (block->is_set(BlockBegin::exception_entry_flag)) { - current_map()->kill_exception(); - } + // phi functions are not linked in instructions list, so process them separateley + for_each_phi_fun(block, phi, + set_processed(phi); + ); TRACE_VALUE_NUMBERING(tty->print("value map before processing block: "); current_map()->print()); // visit all instructions of this block for (Value instr = block->next(); instr != NULL; instr = instr->next()) { - assert(!instr->has_subst(), "substitution already set"); - // check if instruction kills any values instr->visit(this); - - if (instr->hash() != 0) { - Value f = current_map()->find_insert(instr); - if (f != instr) { - assert(!f->has_subst(), "can't have a substitution"); - instr->set_subst(f); - subst_count++; - } - } + // perform actual value numbering + substitute(instr); } // remember value map for successors set_value_map_of(block, current_map()); } - if (subst_count != 0) { + if (_has_substitutions) { SubstitutionResolver resolver(ir); } TRACE_VALUE_NUMBERING(tty->print("****** end of global value numbering. "); ValueMap::print_statistics()); } + +void GlobalValueNumbering::substitute(Instruction* instr) { + assert(!instr->has_subst(), "substitution already set"); + Value subst = current_map()->find_insert(instr); + if (subst != instr) { + assert(!subst->has_subst(), "can't have a substitution"); + + TRACE_VALUE_NUMBERING(tty->print_cr("substitution for %d set to %d", instr->id(), subst->id())); + instr->set_subst(subst); + _has_substitutions = true; + } + set_processed(instr); +} diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp index 07dd9ddfb3d..c76ef46bef4 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp @@ -206,6 +206,8 @@ class ValueNumberingVisitor: public InstructionVisitor { void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ }; void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ }; void do_MemBar (MemBar* x) { /* nothing to do */ }; + void do_RangeCheckPredicate(RangeCheckPredicate* x) { /* nothing to do */ }; + void do_Assert (Assert* x) { /* nothing to do */ }; }; @@ -225,15 +227,22 @@ class ValueNumberingEffects: public ValueNumberingVisitor { class GlobalValueNumbering: public ValueNumberingVisitor { private: + Compilation* _compilation; // compilation data ValueMap* _current_map; // value map of current block ValueMapArray _value_maps; // list of value maps for all blocks + ValueSet _processed_values; // marker for instructions that were already processed + bool _has_substitutions; // set to true when substitutions must be resolved public: // accessors + Compilation* compilation() const { return _compilation; } ValueMap* current_map() { return _current_map; } ValueMap* value_map_of(BlockBegin* block) { return _value_maps.at(block->linear_scan_number()); } void set_value_map_of(BlockBegin* block, ValueMap* map) { assert(value_map_of(block) == NULL, ""); _value_maps.at_put(block->linear_scan_number(), map); } + bool is_processed(Value v) { return _processed_values.contains(v); } + void set_processed(Value v) { _processed_values.put(v); } + // implementation for abstract methods of ValueNumberingVisitor void kill_memory() { current_map()->kill_memory(); } void kill_field(ciField* field, bool all_offsets) { current_map()->kill_field(field, all_offsets); } @@ -241,6 +250,7 @@ class GlobalValueNumbering: public ValueNumberingVisitor { // main entry point that performs global value numbering GlobalValueNumbering(IR* ir); + void substitute(Instruction* instr); // substitute instruction if it is contained in current value map }; #endif // SHARE_VM_C1_C1_VALUEMAP_HPP diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index 16451f6d526..844880be256 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -119,6 +119,24 @@ develop(bool, UseGlobalValueNumbering, true, \ "Use Global Value Numbering (separate phase)") \ \ + product(bool, UseLoopInvariantCodeMotion, true, \ + "Simple loop invariant code motion for short loops during GVN") \ + \ + develop(bool, TracePredicateFailedTraps, false, \ + "trace runtime traps caused by predicate failure") \ + \ + develop(bool, StressLoopInvariantCodeMotion, false, \ + "stress loop invariant code motion") \ + \ + develop(bool, TraceRangeCheckElimination, false, \ + "Trace Range Check Elimination") \ + \ + develop(bool, AssertRangeCheckElimination, false, \ + "Assert Range Check Elimination") \ + \ + develop(bool, StressRangeCheckElimination, false, \ + "stress Range Check Elimination") \ + \ develop(bool, PrintValueNumbering, false, \ "Print Value Numbering") \ \ diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index 1b1e2d1cdd5..63207d082be 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -2166,6 +2166,9 @@ void CompileBroker::print_times() { comp->print_timers(); } tty->cr(); + tty->print_cr(" Total compiled methods : %6d methods", CompileBroker::_total_compile_count); + tty->print_cr(" Standard compilation : %6d methods", CompileBroker::_total_standard_compile_count); + tty->print_cr(" On stack replacement : %6d methods", CompileBroker::_total_osr_compile_count); int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled; tty->print_cr(" Total compiled bytecodes : %6d bytes", tcb); tty->print_cr(" Standard compilation : %6d bytes", CompileBroker::_sum_standard_bytes_compiled); diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index e296c501ccb..78d158a86d6 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2228,8 +2228,6 @@ void InstanceKlass::clean_implementors_list(BoolObjectClosure* is_alive) { } void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { -#ifdef COMPILER2 - // Currently only used by C2. for (int m = 0; m < methods()->length(); m++) { MethodData* mdo = methods()->at(m)->method_data(); if (mdo != NULL) { @@ -2240,15 +2238,6 @@ void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { } } } -#else -#ifdef ASSERT - // Verify that we haven't started to use MDOs for C1. - for (int m = 0; m < methods()->length(); m++) { - MethodData* mdo = methods()->at(m)->method_data(); - assert(mdo == NULL, "Didn't expect C1 to use MDOs"); - } -#endif // ASSERT -#endif // !COMPILER2 } diff --git a/hotspot/src/share/vm/oops/methodData.cpp b/hotspot/src/share/vm/oops/methodData.cpp index c9687fb32b6..e43b93bafc0 100644 --- a/hotspot/src/share/vm/oops/methodData.cpp +++ b/hotspot/src/share/vm/oops/methodData.cpp @@ -392,6 +392,9 @@ MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle meth } int MethodData::bytecode_cell_count(Bytecodes::Code code) { +#if defined(COMPILER1) && !defined(COMPILER2) + return no_profile_data; +#else switch (code) { case Bytecodes::_checkcast: case Bytecodes::_instanceof: @@ -438,6 +441,7 @@ int MethodData::bytecode_cell_count(Bytecodes::Code code) { return variable_cell_count; } return no_profile_data; +#endif } // Compute the size of the profiling information corresponding to @@ -509,6 +513,9 @@ int MethodData::compute_allocation_size_in_words(methodHandle method) { // the segment in bytes. int MethodData::initialize_data(BytecodeStream* stream, int data_index) { +#if defined(COMPILER1) && !defined(COMPILER2) + return 0; +#else int cell_count = -1; int tag = DataLayout::no_tag; DataLayout* data_layout = data_layout_at(data_index); @@ -587,6 +594,7 @@ int MethodData::initialize_data(BytecodeStream* stream, assert(!bytecode_has_profile(c), "agree w/ !BHP"); return 0; } +#endif } // Get the data at an arbitrary (sort of) data index. diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9645f625a85..caf44b4b148 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2515,7 +2515,7 @@ class CommandLineFlags { "disable locking assertions (for speed)") \ \ product(bool, RangeCheckElimination, true, \ - "Split loop iterations to eliminate range checks") \ + "Eliminate range checks") \ \ develop_pd(bool, UncommonNullCast, \ "track occurrences of null in casts; adjust compiler tactics") \ From 9bf86a475ef72b783cfdcd26aafe8e7c48484ff6 Mon Sep 17 00:00:00 2001 From: Joseph Provino Date: Thu, 21 Mar 2013 10:18:05 -0400 Subject: [PATCH 037/155] 8009904: jvmtiClassFileReconstituter.cpp needs to be excluded from the minimal jvm JvmtiClassFileReconstituter.cpp needs to be added to the list of files to exclude when JVMTI is excluded from the jvm Reviewed-by: dholmes, sspitsyn --- hotspot/make/excludeSrc.make | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make index 1f044812352..5ec9566caea 100644 --- a/hotspot/make/excludeSrc.make +++ b/hotspot/make/excludeSrc.make @@ -28,7 +28,8 @@ ifeq ($(INCLUDE_JVMTI), false) Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp forte.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \ jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \ jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \ - jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp + jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \ + jvmtiClassFileReconstituter.cpp endif ifeq ($(INCLUDE_FPROF), false) From 2a57075d8505cdfe82aba09532d76a572ccad8b9 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Tue, 26 Mar 2013 13:34:54 -0700 Subject: [PATCH 038/155] 8007905: To add a system property to create zip file without using ZIP64 end table when entry count > 64k Provide a system property to inhibit ZIP64 mode for >64k entries Reviewed-by: alanb, sherman --- .../java/util/zip/ZipOutputStream.java | 20 ++- jdk/test/java/util/zip/EntryCount64k.java | 119 ++++++++++++++++++ 2 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/util/zip/EntryCount64k.java diff --git a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java index 91b28a6113e..0c980823e3f 100644 --- a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java +++ b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java @@ -43,6 +43,20 @@ import static java.util.zip.ZipConstants64.*; public class ZipOutputStream extends DeflaterOutputStream implements ZipConstants { + /** + * Whether to use ZIP64 for zip files with more than 64k entries. + * Until ZIP64 support in zip implementations is ubiquitous, this + * system property allows the creation of zip files which can be + * read by legacy zip implementations which tolerate "incorrect" + * total entry count fields, such as the ones in jdk6, and even + * some in jdk7. + */ + private static final boolean inhibitZip64 = + Boolean.parseBoolean( + java.security.AccessController.doPrivileged( + new sun.security.action.GetPropertyAction( + "jdk.util.zip.inhibitZip64", "false"))); + private static class XEntry { public final ZipEntry entry; public final long offset; @@ -534,8 +548,10 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants { } int count = xentries.size(); if (count >= ZIP64_MAGICCOUNT) { - count = ZIP64_MAGICCOUNT; - hasZip64 = true; + hasZip64 |= !inhibitZip64; + if (hasZip64) { + count = ZIP64_MAGICCOUNT; + } } if (hasZip64) { long off64 = written; diff --git a/jdk/test/java/util/zip/EntryCount64k.java b/jdk/test/java/util/zip/EntryCount64k.java new file mode 100644 index 00000000000..c815efdded6 --- /dev/null +++ b/jdk/test/java/util/zip/EntryCount64k.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2013 Google Inc. 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 java.util.zip behavior with ~64k entries + * @run main/othervm EntryCount64k + * @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k + * @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k + */ + +import java.io.*; +import java.util.*; +import java.util.zip.*; + +public class EntryCount64k { + + public static void main(String[] args) throws Exception { + for (int i = (1 << 16) - 2; i < (1 << 16) + 2; i++) + test(i); + } + + static void test(int entryCount) throws Exception { + File zipFile = new File("EntryCount64k-tmp.zip"); + zipFile.delete(); + + try (ZipOutputStream zos = + new ZipOutputStream( + new BufferedOutputStream( + new FileOutputStream(zipFile)))) { + for (int i = 0; i < entryCount; i++) { + ZipEntry e = new ZipEntry(Integer.toString(i)); + zos.putNextEntry(e); + zos.closeEntry(); + } + } + + String p = System.getProperty("jdk.util.zip.inhibitZip64"); + boolean tooManyEntries = entryCount >= (1 << 16) - 1; + boolean shouldUseZip64 = tooManyEntries & !("true".equals(p)); + boolean usesZip64 = usesZip64(zipFile); + String details = String.format + ("entryCount=%d shouldUseZip64=%s usesZip64=%s zipSize=%d%n", + entryCount, shouldUseZip64, usesZip64, zipFile.length()); + System.err.println(details); + checkCanRead(zipFile, entryCount); + if (shouldUseZip64 != usesZip64) + throw new Error(details); + zipFile.delete(); + } + + static boolean usesZip64(File zipFile) throws Exception { + RandomAccessFile raf = new RandomAccessFile(zipFile, "r"); + byte[] buf = new byte[4096]; + raf.seek(raf.length() - buf.length); + raf.read(buf); + for (int i = 0; i < buf.length - 4; i++) { + // Look for ZIP64 End Header Signature + // Phil Katz: yes, we will always remember you + if (buf[i+0] == 'P' && + buf[i+1] == 'K' && + buf[i+2] == 6 && + buf[i+3] == 6) + return true; + } + return false; + } + + static void checkCanRead(File zipFile, int entryCount) throws Exception { + // Check ZipInputStream API + try (ZipInputStream zis = + new ZipInputStream( + new BufferedInputStream( + new FileInputStream(zipFile)))) { + for (int i = 0; i < entryCount; i++) { + ZipEntry e = zis.getNextEntry(); + if (Integer.parseInt(e.getName()) != i) + throw new AssertionError(); + } + if (zis.getNextEntry() != null) + throw new AssertionError(); + } + + // Check ZipFile API + try (ZipFile zf = new ZipFile(zipFile)) { + Enumeration en = zf.entries(); + for (int i = 0; i < entryCount; i++) { + ZipEntry e = en.nextElement(); + if (Integer.parseInt(e.getName()) != i) + throw new AssertionError(); + } + if (en.hasMoreElements() + || (zf.size() != entryCount) + || (zf.getEntry(Integer.toString(entryCount - 1)) == null) + || (zf.getEntry(Integer.toString(entryCount)) != null)) + throw new AssertionError(); + } + } +} From edcaf2323302ce255cbd6c0b2a745f65e4c85794 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Tue, 26 Mar 2013 13:36:51 -0700 Subject: [PATCH 039/155] 8010316: Improve handling of char sequences containing surrogates Fix and optimize codePointAt, codePointBefore and similar methods Reviewed-by: sherman, okutsu, ulfzibis, kizune --- .../java/lang/AbstractStringBuilder.java | 49 ++++++++++--------- .../share/classes/java/lang/Character.java | 48 ++++++++---------- .../lang/StringBuilder/Supplementary.java | 14 ++++++ 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java index 6e4881cb832..2d71795a5ca 100644 --- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java +++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java @@ -236,7 +236,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { if ((index < 0) || (index >= count)) { throw new StringIndexOutOfBoundsException(index); } - return Character.codePointAt(value, index); + return Character.codePointAtImpl(value, index, count); } /** @@ -265,7 +265,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { if ((i < 0) || (i >= count)) { throw new StringIndexOutOfBoundsException(index); } - return Character.codePointBefore(value, index); + return Character.codePointBeforeImpl(value, index, 0); } /** @@ -1370,32 +1370,37 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * @return a reference to this object. */ public AbstractStringBuilder reverse() { - boolean hasSurrogate = false; + boolean hasSurrogates = false; int n = count - 1; - for (int j = (n-1) >> 1; j >= 0; --j) { - char temp = value[j]; - char temp2 = value[n - j]; - if (!hasSurrogate) { - hasSurrogate = (temp >= Character.MIN_SURROGATE && temp <= Character.MAX_SURROGATE) - || (temp2 >= Character.MIN_SURROGATE && temp2 <= Character.MAX_SURROGATE); + for (int j = (n-1) >> 1; j >= 0; j--) { + int k = n - j; + char cj = value[j]; + char ck = value[k]; + value[j] = ck; + value[k] = cj; + if (Character.isSurrogate(cj) || + Character.isSurrogate(ck)) { + hasSurrogates = true; } - value[j] = temp2; - value[n - j] = temp; } - if (hasSurrogate) { - // Reverse back all valid surrogate pairs - for (int i = 0; i < count - 1; i++) { - char c2 = value[i]; - if (Character.isLowSurrogate(c2)) { - char c1 = value[i + 1]; - if (Character.isHighSurrogate(c1)) { - value[i++] = c1; - value[i] = c2; - } + if (hasSurrogates) { + reverseAllValidSurrogatePairs(); + } + return this; + } + + /** Outlined helper method for reverse() */ + private void reverseAllValidSurrogatePairs() { + for (int i = 0; i < count - 1; i++) { + char c2 = value[i]; + if (Character.isLowSurrogate(c2)) { + char c1 = value[i + 1]; + if (Character.isHighSurrogate(c1)) { + value[i++] = c1; + value[i] = c2; } } } - return this; } /** diff --git a/jdk/src/share/classes/java/lang/Character.java b/jdk/src/share/classes/java/lang/Character.java index 0f440067b45..531263d3894 100644 --- a/jdk/src/share/classes/java/lang/Character.java +++ b/jdk/src/share/classes/java/lang/Character.java @@ -4862,13 +4862,11 @@ class Character implements java.io.Serializable, Comparable { * @since 1.5 */ public static int codePointAt(CharSequence seq, int index) { - char c1 = seq.charAt(index++); - if (isHighSurrogate(c1)) { - if (index < seq.length()) { - char c2 = seq.charAt(index); - if (isLowSurrogate(c2)) { - return toCodePoint(c1, c2); - } + char c1 = seq.charAt(index); + if (isHighSurrogate(c1) && ++index < seq.length()) { + char c2 = seq.charAt(index); + if (isLowSurrogate(c2)) { + return toCodePoint(c1, c2); } } return c1; @@ -4931,15 +4929,13 @@ class Character implements java.io.Serializable, Comparable { return codePointAtImpl(a, index, limit); } - // throws ArrayIndexOutofBoundsException if index out of bounds + // throws ArrayIndexOutOfBoundsException if index out of bounds static int codePointAtImpl(char[] a, int index, int limit) { - char c1 = a[index++]; - if (isHighSurrogate(c1)) { - if (index < limit) { - char c2 = a[index]; - if (isLowSurrogate(c2)) { - return toCodePoint(c1, c2); - } + char c1 = a[index]; + if (isHighSurrogate(c1) && ++index < limit) { + char c2 = a[index]; + if (isLowSurrogate(c2)) { + return toCodePoint(c1, c2); } } return c1; @@ -4968,12 +4964,10 @@ class Character implements java.io.Serializable, Comparable { */ public static int codePointBefore(CharSequence seq, int index) { char c2 = seq.charAt(--index); - if (isLowSurrogate(c2)) { - if (index > 0) { - char c1 = seq.charAt(--index); - if (isHighSurrogate(c1)) { - return toCodePoint(c1, c2); - } + if (isLowSurrogate(c2) && index > 0) { + char c1 = seq.charAt(--index); + if (isHighSurrogate(c1)) { + return toCodePoint(c1, c2); } } return c2; @@ -5038,15 +5032,13 @@ class Character implements java.io.Serializable, Comparable { return codePointBeforeImpl(a, index, start); } - // throws ArrayIndexOutofBoundsException if index-1 out of bounds + // throws ArrayIndexOutOfBoundsException if index-1 out of bounds static int codePointBeforeImpl(char[] a, int index, int start) { char c2 = a[--index]; - if (isLowSurrogate(c2)) { - if (index > start) { - char c1 = a[--index]; - if (isHighSurrogate(c1)) { - return toCodePoint(c1, c2); - } + if (isLowSurrogate(c2) && index > start) { + char c1 = a[--index]; + if (isHighSurrogate(c1)) { + return toCodePoint(c1, c2); } } return c2; diff --git a/jdk/test/java/lang/StringBuilder/Supplementary.java b/jdk/test/java/lang/StringBuilder/Supplementary.java index 30ff5e901c0..f5af9a0599e 100644 --- a/jdk/test/java/lang/StringBuilder/Supplementary.java +++ b/jdk/test/java/lang/StringBuilder/Supplementary.java @@ -37,6 +37,7 @@ public class Supplementary { test4(); // Test for appendCodePoint(int codePoint) test5(); // Test for codePointCount(int beginIndex, int endIndex) test6(); // Test for offsetByCodePoints(int index, int offset) + testDontReadOutOfBoundsTrailingSurrogate(); } /* Text strings which are used as input data. @@ -305,6 +306,19 @@ public class Supplementary { } } + static void testDontReadOutOfBoundsTrailingSurrogate() { + StringBuilder sb = new StringBuilder(); + int suppl = Character.MIN_SUPPLEMENTARY_CODE_POINT; + sb.appendCodePoint(suppl); + check(sb.codePointAt(0) != (int) suppl, + "codePointAt(0)", sb.codePointAt(0), suppl); + check(sb.length() != 2, "sb.length()"); + sb.setLength(1); + check(sb.length() != 1, "sb.length()"); + check(sb.codePointAt(0) != Character.highSurrogate(suppl), + "codePointAt(0)", + sb.codePointAt(0), Character.highSurrogate(suppl)); + } static final boolean At = true, Before = false; From 5391834dcf3b776674650da8d5e0f4734d124ad6 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Thu, 21 Mar 2013 20:35:49 +0100 Subject: [PATCH 040/155] 8009427: Re-enable tests that were disable to ease complicated push Reviewed-by: sla, mchung, dcubed --- jdk/test/ProblemList.txt | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 90d29821665..d13975499d8 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -339,23 +339,6 @@ tools/launcher/UnicodeTest.java macosx-all # 8007410 tools/launcher/FXLauncherTest.java linux-all -# 8004172 -sun/tools/jstat/jstatGcCapacityOutput1.sh generic-all -sun/tools/jstat/jstatGcCauseOutput1.sh generic-all -sun/tools/jstat/jstatGcOldOutput1.sh generic-all -sun/tools/jstat/jstatGcOutput1.sh generic-all -sun/tools/jstat/jstatGcPermCapacityOutput1.sh generic-all -sun/tools/jstat/jstatLineCounts1.sh generic-all -sun/tools/jstat/jstatLineCounts2.sh generic-all -sun/tools/jstat/jstatLineCounts3.sh generic-all -sun/tools/jstat/jstatLineCounts4.sh generic-all -sun/tools/jstat/jstatOptions1.sh generic-all -sun/tools/jstat/jstatTimeStamp1.sh generic-all -sun/tools/jstatd/jstatdExternalRegistry.sh generic-all -sun/tools/jstatd/jstatdDefaults.sh generic-all -sun/tools/jstatd/jstatdPort.sh generic-all -sun/tools/jstatd/jstatdServerName.sh generic-all - ############################################################################ # jdk_jdi From ba67f14480f2c60aae9a8d4a7db2e69ff8823bb3 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 21 Mar 2013 20:46:46 -0700 Subject: [PATCH 041/155] 8010389: After fix for 7107135 a failed dlopen() call results in a VM crash Call dlerror() in VM thread as necessary. Reviewed-by: coleenp, dholmes --- hotspot/src/os/linux/vm/os_linux.cpp | 32 ++++++++------ hotspot/src/os/linux/vm/os_linux.hpp | 3 +- .../test/runtime/8010389/VMThreadDlopen.java | 44 +++++++++++++++++++ 3 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 hotspot/test/runtime/8010389/VMThreadDlopen.java diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 59cb59d6805..29842b223f0 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -1811,13 +1811,15 @@ bool os::Linux::_stack_is_executable = false; class VM_LinuxDllLoad: public VM_Operation { private: const char *_filename; + char *_ebuf; + int _ebuflen; void *_lib; public: - VM_LinuxDllLoad(const char *fn) : - _filename(fn), _lib(NULL) {} + VM_LinuxDllLoad(const char *fn, char *ebuf, int ebuflen) : + _filename(fn), _ebuf(ebuf), _ebuflen(ebuflen), _lib(NULL) {} VMOp_Type type() const { return VMOp_LinuxDllLoad; } void doit() { - _lib = os::Linux::dll_load_inner(_filename); + _lib = os::Linux::dll_load_in_vmthread(_filename, _ebuf, _ebuflen); os::Linux::_stack_is_executable = true; } void* loaded_library() { return _lib; } @@ -1865,13 +1867,13 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) // This is for the case where the DLL has an static // constructor function that executes JNI code. We cannot // load such DLLs in the VMThread. - result = ::dlopen(filename, RTLD_LAZY); + result = os::Linux::dlopen_helper(filename, ebuf, ebuflen); } ThreadInVMfromNative tiv(jt); debug_only(VMNativeEntryWrapper vew;) - VM_LinuxDllLoad op(filename); + VM_LinuxDllLoad op(filename, ebuf, ebuflen); VMThread::execute(&op); if (LoadExecStackDllInVMThread) { result = op.loaded_library(); @@ -1883,7 +1885,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) } if (!load_attempted) { - result = ::dlopen(filename, RTLD_LAZY); + result = os::Linux::dlopen_helper(filename, ebuf, ebuflen); } if (result != NULL) { @@ -1892,11 +1894,6 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) } Elf32_Ehdr elf_head; - - // Read system error message into ebuf - // It may or may not be overwritten below - ::strncpy(ebuf, ::dlerror(), ebuflen-1); - ebuf[ebuflen-1]='\0'; int diag_msg_max_length=ebuflen-strlen(ebuf); char* diag_msg_buf=ebuf+strlen(ebuf); @@ -2039,10 +2036,19 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) return NULL; } -void * os::Linux::dll_load_inner(const char *filename) { +void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) { + void * result = ::dlopen(filename, RTLD_LAZY); + if (result == NULL) { + ::strncpy(ebuf, ::dlerror(), ebuflen - 1); + ebuf[ebuflen-1] = '\0'; + } + return result; +} + +void * os::Linux::dll_load_in_vmthread(const char *filename, char *ebuf, int ebuflen) { void * result = NULL; if (LoadExecStackDllInVMThread) { - result = ::dlopen(filename, RTLD_LAZY); + result = dlopen_helper(filename, ebuf, ebuflen); } // Since 7019808, libjvm.so is linked with -noexecstack. If the VM loads a diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 356f7f67afa..c09be025c12 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -95,7 +95,8 @@ class Linux { public: static bool _stack_is_executable; - static void *dll_load_inner(const char *name); + static void *dlopen_helper(const char *name, char *ebuf, int ebuflen); + static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen); static void init_thread_fpu_state(); static int get_fpu_control_word(); diff --git a/hotspot/test/runtime/8010389/VMThreadDlopen.java b/hotspot/test/runtime/8010389/VMThreadDlopen.java new file mode 100644 index 00000000000..04407233773 --- /dev/null +++ b/hotspot/test/runtime/8010389/VMThreadDlopen.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.io.File; + +/* + * @test + * @key regression + * @bug 8010389 + * @run main/othervm -Djava.library.path=. VMThreadDlopen + */ + +public class VMThreadDlopen { + public static void main(String[] args) throws Exception { + File file = new File("libbroken.so"); + file.createNewFile(); + try { + System.loadLibrary("broken"); + } catch (UnsatisfiedLinkError e) { + e.printStackTrace(); + // expected + } + } +} From 2454c8c5ae7f712fde8fa373e3c4345acc73e51a Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 22 Mar 2013 12:38:12 +0000 Subject: [PATCH 042/155] 8009649: Lambda back-end should generate invokespecial for method handles referring to private instance methods Private lambda methods should be accessed through invokespecial Reviewed-by: jjg --- .../sun/tools/javac/comp/LambdaToMethod.java | 26 +- .../lambda/bytecode/TestLambdaBytecode.java | 365 ++++++++++++++++++ 2 files changed, 378 insertions(+), 13 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index fad0a51512e..6d37769fd39 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1019,14 +1019,14 @@ public class LambdaToMethod extends TreeTranslator { } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { - return ClassFile.REF_invokeVirtual; + return (refSym.flags() & PRIVATE) != 0 ? + ClassFile.REF_invokeSpecial : + ClassFile.REF_invokeVirtual; } } } - // - - // \ + // /** * This visitor collects information about translation of a lambda expression. * More specifically, it keeps track of the enclosing contexts and captured locals @@ -1635,16 +1635,16 @@ public class LambdaToMethod extends TreeTranslator { * Translate a symbol of a given kind into something suitable for the * synthetic lambda body */ - Symbol translate(String name, final Symbol sym, LambdaSymbolKind skind) { + Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) { switch (skind) { case CAPTURED_THIS: return sym; // self represented case TYPE_VAR: // Just erase the type var - return new VarSymbol(sym.flags(), names.fromString(name), + return new VarSymbol(sym.flags(), name, types.erasure(sym.type), sym.owner); case CAPTURED_VAR: - return new VarSymbol(SYNTHETIC | FINAL, names.fromString(name), types.erasure(sym.type), translatedSym) { + return new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) { @Override public Symbol baseSymbol() { //keep mapping with original captured symbol @@ -1658,27 +1658,27 @@ public class LambdaToMethod extends TreeTranslator { void addSymbol(Symbol sym, LambdaSymbolKind skind) { Map transMap = null; - String preferredName; + Name preferredName; switch (skind) { case CAPTURED_THIS: transMap = capturedThis; - preferredName = "encl$" + capturedThis.size(); + preferredName = names.fromString("encl$" + capturedThis.size()); break; case CAPTURED_VAR: transMap = capturedLocals; - preferredName = "cap$" + capturedLocals.size(); + preferredName = names.fromString("cap$" + capturedLocals.size()); break; case LOCAL_VAR: transMap = lambdaLocals; - preferredName = sym.name.toString(); + preferredName = sym.name; break; case PARAM: transMap = lambdaParams; - preferredName = sym.name.toString(); + preferredName = sym.name; break; case TYPE_VAR: transMap = typeVars; - preferredName = sym.name.toString(); + preferredName = sym.name; break; default: throw new AssertionError(); } diff --git a/langtools/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java b/langtools/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java new file mode 100644 index 00000000000..38818f6c931 --- /dev/null +++ b/langtools/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2013, 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 8009649 + * @summary Lambda back-end should generate invokespecial for method handles referring to private instance methods + * @library ../../lib + * @build JavacTestingAbstractThreadedTest + * @run main/othervm TestLambdaBytecode + */ + +// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047) +// see JDK-8006746 + +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.BootstrapMethods_attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.ConstantPool.*; +import com.sun.tools.classfile.Instruction; +import com.sun.tools.classfile.Method; + +import com.sun.tools.javac.api.JavacTaskImpl; + + +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Locale; + +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; + +import static com.sun.tools.javac.jvm.ClassFile.*; + +public class TestLambdaBytecode + extends JavacTestingAbstractThreadedTest + implements Runnable { + + enum ClassKind { + CLASS("class"), + INTERFACE("interface"); + + String classStr; + + ClassKind(String classStr) { + this.classStr = classStr; + } + } + + enum AccessKind { + PUBLIC("public"), + PRIVATE("private"); + + String accessStr; + + AccessKind(String accessStr) { + this.accessStr = accessStr; + } + } + + enum StaticKind { + STATIC("static"), + INSTANCE(""); + + String staticStr; + + StaticKind(String staticStr) { + this.staticStr = staticStr; + } + } + + enum DefaultKind { + DEFAULT("default"), + NO_DEFAULT(""); + + String defaultStr; + + DefaultKind(String defaultStr) { + this.defaultStr = defaultStr; + } + } + + enum ExprKind { + LAMBDA("Runnable r = ()->{ target(); };"); + + String exprString; + + ExprKind(String exprString) { + this.exprString = exprString; + } + } + + static class MethodKind { + ClassKind ck; + AccessKind ak; + StaticKind sk; + DefaultKind dk; + + MethodKind(ClassKind ck, AccessKind ak, StaticKind sk, DefaultKind dk) { + this.ck = ck; + this.ak = ak; + this.sk = sk; + this.dk = dk; + } + + boolean inInterface() { + return ck == ClassKind.INTERFACE; + } + + boolean isPrivate() { + return ak == AccessKind.PRIVATE; + } + + boolean isStatic() { + return sk == StaticKind.STATIC; + } + + boolean isDefault() { + return dk == DefaultKind.DEFAULT; + } + + boolean isOK() { + if (isDefault() && (!inInterface() || isStatic())) { + return false; + } else if (inInterface() && + ((!isStatic() && !isDefault()) || isPrivate())) { + return false; + } else { + return true; + } + } + + String mods() { + StringBuilder buf = new StringBuilder(); + buf.append(ak.accessStr); + buf.append(' '); + buf.append(sk.staticStr); + buf.append(' '); + buf.append(dk.defaultStr); + return buf.toString(); + } + } + + public static void main(String... args) throws Exception { + for (ClassKind ck : ClassKind.values()) { + for (AccessKind ak1 : AccessKind.values()) { + for (StaticKind sk1 : StaticKind.values()) { + for (DefaultKind dk1 : DefaultKind.values()) { + for (AccessKind ak2 : AccessKind.values()) { + for (StaticKind sk2 : StaticKind.values()) { + for (DefaultKind dk2 : DefaultKind.values()) { + for (ExprKind ek : ExprKind.values()) { + pool.execute(new TestLambdaBytecode(ck, ak1, ak2, sk1, sk2, dk1, dk2, ek)); + } + } + } + } + } + } + } + } + + checkAfterExec(); + } + + MethodKind mk1, mk2; + ExprKind ek; + DiagChecker dc; + + TestLambdaBytecode(ClassKind ck, AccessKind ak1, AccessKind ak2, StaticKind sk1, + StaticKind sk2, DefaultKind dk1, DefaultKind dk2, ExprKind ek) { + mk1 = new MethodKind(ck, ak1, sk1, dk1); + mk2 = new MethodKind(ck, ak2, sk2, dk2); + this.ek = ek; + dc = new DiagChecker(); + } + + public void run() { + int id = checkCount.incrementAndGet(); + JavaSource source = new JavaSource(id); + JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc, + null, null, Arrays.asList(source)); + try { + ct.generate(); + } catch (Throwable t) { + t.printStackTrace(); + throw new AssertionError( + String.format("Error thrown when compiling following code\n%s", + source.source)); + } + if (dc.diagFound) { + boolean errorExpected = !mk1.isOK() || !mk2.isOK(); + errorExpected |= mk1.isStatic() && !mk2.isStatic(); + + if (!errorExpected) { + throw new AssertionError( + String.format("Diags found when compiling following code\n%s\n\n%s", + source.source, dc.printDiags())); + } + return; + } + verifyBytecode(id, source); + } + + void verifyBytecode(int id, JavaSource source) { + File compiledTest = new File(String.format("Test%d.class", id)); + try { + ClassFile cf = ClassFile.read(compiledTest); + Method testMethod = null; + for (Method m : cf.methods) { + if (m.getName(cf.constant_pool).equals("test")) { + testMethod = m; + break; + } + } + if (testMethod == null) { + throw new Error("Test method not found"); + } + Code_attribute ea = + (Code_attribute)testMethod.attributes.get(Attribute.Code); + if (testMethod == null) { + throw new Error("Code attribute for test() method not found"); + } + + int bsmIdx = -1; + + for (Instruction i : ea.getInstructions()) { + if (i.getMnemonic().equals("invokedynamic")) { + CONSTANT_InvokeDynamic_info indyInfo = + (CONSTANT_InvokeDynamic_info)cf + .constant_pool.get(i.getShort(1)); + bsmIdx = indyInfo.bootstrap_method_attr_index; + if (!indyInfo.getNameAndTypeInfo().getType().equals(makeIndyType(id))) { + throw new + AssertionError("type mismatch for CONSTANT_InvokeDynamic_info " + source.source + "\n" + indyInfo.getNameAndTypeInfo().getType() + "\n" + makeIndyType(id)); + } + } + } + if (bsmIdx == -1) { + throw new Error("Missing invokedynamic in generated code"); + } + + BootstrapMethods_attribute bsm_attr = + (BootstrapMethods_attribute)cf + .getAttribute(Attribute.BootstrapMethods); + if (bsm_attr.bootstrap_method_specifiers.length != 1) { + throw new Error("Bad number of method specifiers " + + "in BootstrapMethods attribute"); + } + BootstrapMethods_attribute.BootstrapMethodSpecifier bsm_spec = + bsm_attr.bootstrap_method_specifiers[0]; + + if (bsm_spec.bootstrap_arguments.length != MF_ARITY) { + throw new Error("Bad number of static invokedynamic args " + + "in BootstrapMethod attribute"); + } + + CONSTANT_MethodHandle_info mh = + (CONSTANT_MethodHandle_info)cf.constant_pool.get(bsm_spec.bootstrap_arguments[1]); + + boolean kindOK; + switch (mh.reference_kind) { + case REF_invokeStatic: kindOK = mk2.isStatic(); break; + case REF_invokeSpecial: kindOK = !mk2.isStatic(); break; + case REF_invokeInterface: kindOK = mk2.inInterface(); break; + default: + kindOK = false; + } + + if (!kindOK) { + throw new Error("Bad invoke kind in implementation method handle"); + } + + if (!mh.getCPRefInfo().getNameAndTypeInfo().getType().toString().equals(MH_SIG)) { + throw new Error("Type mismatch in implementation method handle"); + } + } catch (Exception e) { + e.printStackTrace(); + throw new Error("error reading " + compiledTest +": " + e); + } + } + String makeIndyType(int id) { + StringBuilder buf = new StringBuilder(); + buf.append("("); + if (!mk2.isStatic() || mk1.inInterface()) { + buf.append(String.format("LTest%d;", id)); + } + buf.append(")Ljava/lang/Runnable;"); + return buf.toString(); + } + + static final int MF_ARITY = 3; + static final String MH_SIG = "()V"; + + class JavaSource extends SimpleJavaFileObject { + + static final String source_template = + "#CK Test#ID {\n" + + " #MOD1 void test() { #EK }\n" + + " #MOD2 void target() { }\n" + + "}\n"; + + String source; + + JavaSource(int id) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = source_template.replace("#CK", mk1.ck.classStr) + .replace("#MOD1", mk1.mods()) + .replace("#MOD2", mk2.mods()) + .replace("#EK", ek.exprString) + .replace("#ID", String.valueOf(id)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + static class DiagChecker + implements javax.tools.DiagnosticListener { + + boolean diagFound; + ArrayList diags = new ArrayList<>(); + + public void report(Diagnostic diagnostic) { + diags.add(diagnostic.getMessage(Locale.getDefault())); + diagFound = true; + } + + String printDiags() { + StringBuilder buf = new StringBuilder(); + for (String s : diags) { + buf.append(s); + buf.append("\n"); + } + return buf.toString(); + } + } + +} From cec722fe8ff2d517f48e96e5f3b7719a7f8c65b1 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 22 Mar 2013 12:39:34 +0000 Subject: [PATCH 043/155] 8010101: Intersection type cast issues redundant unchecked warning Code for checking intersection type cast is incorrectly swapping operands, leading to spurious warnings Reviewed-by: jjg --- .../com/sun/tools/javac/code/Types.java | 50 +++++++++++-------- .../tools/javac/lambda/Intersection02.java | 41 +++++++++++++++ .../tools/javac/lambda/Intersection02.out | 4 ++ 3 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/Intersection02.java create mode 100644 langtools/test/tools/javac/lambda/Intersection02.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index df1e4042143..03bdaa17b8a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -1418,23 +1418,10 @@ public class Types { } } - if (t.isCompound()) { - Warner oldWarner = warnStack.head; - warnStack.head = noWarnings; - if (!visit(supertype(t), s)) - return false; - for (Type intf : interfaces(t)) { - if (!visit(intf, s)) - return false; - } - if (warnStack.head.hasLint(LintCategory.UNCHECKED)) - oldWarner.warn(LintCategory.UNCHECKED); - return true; - } - - if (s.isCompound()) { - // call recursively to reuse the above code - return visitClassType((ClassType)s, t); + if (t.isCompound() || s.isCompound()) { + return !t.isCompound() ? + visitIntersectionType((IntersectionClassType)s, t, true) : + visitIntersectionType((IntersectionClassType)t, s, false); } if (s.tag == CLASS || s.tag == ARRAY) { @@ -1512,6 +1499,18 @@ public class Types { return false; } + boolean visitIntersectionType(IntersectionClassType ict, Type s, boolean reverse) { + Warner warn = noWarnings; + for (Type c : ict.getComponents()) { + warn.clear(); + if (reverse ? !isCastable(s, c, warn) : !isCastable(c, s, warn)) + return false; + } + if (warn.hasLint(LintCategory.UNCHECKED)) + warnStack.head.warn(LintCategory.UNCHECKED); + return true; + } + @Override public Boolean visitArrayType(ArrayType t, Type s) { switch (s.tag) { @@ -3889,11 +3888,18 @@ public class Types { } private boolean giveWarning(Type from, Type to) { - Type subFrom = asSub(from, to.tsym); - return to.isParameterized() && - (!(isUnbounded(to) || - isSubtype(from, to) || - ((subFrom != null) && containsType(to.allparams(), subFrom.allparams())))); + List bounds = to.isCompound() ? + ((IntersectionClassType)to).getComponents() : List.of(to); + for (Type b : bounds) { + Type subFrom = asSub(from, b.tsym); + if (b.isParameterized() && + (!(isUnbounded(b) || + isSubtype(from, b) || + ((subFrom != null) && containsType(b.allparams(), subFrom.allparams()))))) { + return true; + } + } + return false; } private List superClosure(Type t, Type s) { diff --git a/langtools/test/tools/javac/lambda/Intersection02.java b/langtools/test/tools/javac/lambda/Intersection02.java new file mode 100644 index 00000000000..2afcec15ffc --- /dev/null +++ b/langtools/test/tools/javac/lambda/Intersection02.java @@ -0,0 +1,41 @@ +/* + * 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 8010101 + * @summary Intersection type cast issues redundant unchecked warning + * @compile/fail/ref=Intersection02.out -Werror -Xlint:unchecked -XDrawDiagnostics Intersection02.java + */ +import java.io.Serializable; +import java.util.List; + +class Intersection02 { + + interface P { } + + void test(List ls) { + Object o1 = (List & Serializable)ls; + Object o2 = (List & Serializable & P)ls; + } +} diff --git a/langtools/test/tools/javac/lambda/Intersection02.out b/langtools/test/tools/javac/lambda/Intersection02.out new file mode 100644 index 00000000000..f3844e278ce --- /dev/null +++ b/langtools/test/tools/javac/lambda/Intersection02.out @@ -0,0 +1,4 @@ +Intersection02.java:39:62: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.util.List, java.lang.Object&java.util.List&java.io.Serializable&Intersection02.P +- compiler.err.warnings.and.werror +1 error +1 warning From 710a687c15c4a381d93f10869efce291f70d090c Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 22 Mar 2013 12:41:13 +0000 Subject: [PATCH 044/155] 8009820: AssertionError when compiling java code with two identical static imports Speculative attribution is carried out twice with same method symbol in case of static imports Reviewed-by: jjg --- .../sun/tools/javac/comp/DeferredAttr.java | 6 +-- .../javac/lambda/DoubleStaticImport.java | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/DoubleStaticImport.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 317b6024bf8..dd0d6125c81 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -229,9 +229,9 @@ public class DeferredAttr extends JCTree.Visitor { public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) { switch (deferredAttrContext.mode) { case SPECULATIVE: - Assert.check(dt.mode == null || - (dt.mode == AttrMode.SPECULATIVE && - dt.speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).hasTag(NONE))); + //Note: if a symbol is imported twice we might do two identical + //speculative rounds... + Assert.check(dt.mode == null || dt.mode == AttrMode.SPECULATIVE); JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo); dt.speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase); return speculativeTree.type; diff --git a/langtools/test/tools/javac/lambda/DoubleStaticImport.java b/langtools/test/tools/javac/lambda/DoubleStaticImport.java new file mode 100644 index 00000000000..611690010df --- /dev/null +++ b/langtools/test/tools/javac/lambda/DoubleStaticImport.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8009820 + * @summary AssertionError when compiling java code with two identical static imports + * @compile DoubleStaticImport.java + */ + +import static java.lang.Thread.holdsLock; +import static java.lang.Thread.holdsLock; //dup + +class DoubleStaticImport { + public void test() { + holdsLock(null); + } +} From 2b66afe14de29cc8074945e1ca114826b055569a Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 22 Mar 2013 12:43:09 +0000 Subject: [PATCH 045/155] 8010303: Graph inference: missing incorporation step causes spurious inference error Multiple equality constraints on inference vars are not used to generate new inference constraints Reviewed-by: jjg --- .../com/sun/tools/javac/code/Types.java | 11 ++++ .../com/sun/tools/javac/comp/Infer.java | 32 +++++----- .../test/tools/javac/lambda/TargetType28.out | 2 +- .../test/tools/javac/lambda/TargetType67.java | 50 +++++++++++++++ .../test/tools/javac/lambda/TargetType68.java | 63 +++++++++++++++++++ .../test/tools/javac/lambda/TargetType69.java | 51 +++++++++++++++ 6 files changed, 194 insertions(+), 15 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/TargetType67.java create mode 100644 langtools/test/tools/javac/lambda/TargetType68.java create mode 100644 langtools/test/tools/javac/lambda/TargetType69.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index 03bdaa17b8a..a99a775a488 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -1178,6 +1178,17 @@ public class Types { protected boolean containsTypes(List ts1, List ts2) { return isSameTypes(ts1, ts2, true); } + + @Override + public Boolean visitWildcardType(WildcardType t, Type s) { + if (!s.hasTag(WILDCARD)) { + return false; + } else { + WildcardType t2 = (WildcardType)s; + return t.kind == t2.kind && + isSameType(t.type, t2.type, true); + } + } }; // diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index 296b50d9a03..55d0b195916 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -585,11 +585,7 @@ public class Infer { Infer infer = inferenceContext.infer(); for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { - if (!inferenceContext.inferenceVars().contains(b1) && - !inferenceContext.inferenceVars().contains(b2) && - infer.types.asSuper(b2, b1.tsym) != null) { - infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); - } + infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); } } } @@ -603,11 +599,7 @@ public class Infer { Infer infer = inferenceContext.infer(); for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { for (Type b2 : uv.getBounds(InferenceBound.EQ)) { - if (!inferenceContext.inferenceVars().contains(b1) && - !inferenceContext.inferenceVars().contains(b2) && - infer.types.asSuper(b2, b1.tsym) != null) { - infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); - } + infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); } } } @@ -621,10 +613,22 @@ public class Infer { Infer infer = inferenceContext.infer(); for (Type b1 : uv.getBounds(InferenceBound.EQ)) { for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { - if (!inferenceContext.inferenceVars().contains(b1) && - !inferenceContext.inferenceVars().contains(b2) && - infer.types.asSuper(b2, b1.tsym) != null) { - infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); + infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); + } + } + } + }, + /** + * Given a bound set containing {@code alpha == S} and {@code alpha == T} + * perform {@code S == T} (which could lead to new bounds). + */ + CROSS_EQ_EQ() { + public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) { + Infer infer = inferenceContext.infer(); + for (Type b1 : uv.getBounds(InferenceBound.EQ)) { + for (Type b2 : uv.getBounds(InferenceBound.EQ)) { + if (b1 != b2) { + infer.types.isSameType(inferenceContext.asFree(b2), inferenceContext.asFree(b1)); } } } diff --git a/langtools/test/tools/javac/lambda/TargetType28.out b/langtools/test/tools/javac/lambda/TargetType28.out index bb0c8a0d722..57a38f35f13 100644 --- a/langtools/test/tools/javac/lambda/TargetType28.out +++ b/langtools/test/tools/javac/lambda/TargetType28.out @@ -1,2 +1,2 @@ -TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String,R, java.lang.Object,java.lang.Number) +TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, R,java.lang.String, java.lang.Object,java.lang.Number) 1 error diff --git a/langtools/test/tools/javac/lambda/TargetType67.java b/langtools/test/tools/javac/lambda/TargetType67.java new file mode 100644 index 00000000000..b949b32cc68 --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType67.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2013, 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 8010303 + * @summary Graph inference: missing incorporation step causes spurious inference error + * @compile TargetType67.java + */ +class TargetType67 { + + interface Func { + B f(A a); + } + + class List { + + List map(Func f) { + return null; + } + + List apply(final List> lf) { + return null; + } + + List bind(final List lb, final Func> f) { + return lb.apply(map(f)); + } + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType68.java b/langtools/test/tools/javac/lambda/TargetType68.java new file mode 100644 index 00000000000..92ce99bd8ad --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType68.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2013, 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 8010303 + * @summary Graph inference: missing incorporation step causes spurious inference error + * @compile TargetType68.java + */ +import java.util.*; + +class TargetType68 { + + //derived from FX 2.2 API + static class XYChart { + static final class Series { + Series(java.lang.String name, ObservableList> data) { } + } + + static final class Data { } + + ObservableList> getData() { return null; } + } + + //derived from FX 2.2 API + interface ObservableList extends List { + boolean setAll(Collection col); + } + + //derived from FX 2.2 API + static class FXCollections { + static ObservableList observableList(List l) { return null; } + } + + private void testMethod() { + XYChart numberChart = null; + List> data_1 = new ArrayList<>(); + List> data_2 = new ArrayList<>(); + numberChart.getData().setAll( + Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)), + new XYChart.Series<>("Data", FXCollections.observableList(data_2)))); + } +} diff --git a/langtools/test/tools/javac/lambda/TargetType69.java b/langtools/test/tools/javac/lambda/TargetType69.java new file mode 100644 index 00000000000..0b47bb099af --- /dev/null +++ b/langtools/test/tools/javac/lambda/TargetType69.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, 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 8010303 + * @summary Graph inference: missing incorporation step causes spurious inference error + * @compile TargetType68.java + */ +import java.util.*; + +class TargetType68 { + + interface Function { + Y m(X x); + } + + abstract class TabulationAssertion { } + + class GroupedMapAssertion> extends TabulationAssertion { + GroupedMapAssertion(Function classifier) { } + } + + + void exerciseMapTabulation(Function collector, + TabulationAssertion assertion) { } + + void test(Function classifier, Function>> coll) { + exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier)); + } +} From 7ee4846b45934fb9a4469fd8f725ae465d830cf4 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 22 Mar 2013 12:44:48 +0000 Subject: [PATCH 046/155] 8010387: Javac crashes when diagnostic mentions anonymous inner class' type variables Rich formatter doesn't preprocess supertypes of an anonymous inner class Reviewed-by: jjg --- .../javac/util/RichDiagnosticFormatter.java | 12 +++++++++++- .../javac/Diagnostics/8010387/T8010387.java | 17 +++++++++++++++++ .../javac/Diagnostics/8010387/T8010387.out | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/Diagnostics/8010387/T8010387.java create mode 100644 langtools/test/tools/javac/Diagnostics/8010387/T8010387.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java index 932801cd3ad..d242cc18c07 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java @@ -509,6 +509,16 @@ public class RichDiagnosticFormatter extends visit(supertype); visit(interfaces); } + } else if (t.tsym.name.isEmpty()) { + //anon class + ClassType norm = (ClassType) t.tsym.type; + if (norm != null) { + if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { + visit(norm.interfaces_field.head); + } else { + visit(norm.supertype_field); + } + } } nameSimplifier.addUsage(t.tsym); visit(t.getTypeArguments()); @@ -562,7 +572,7 @@ public class RichDiagnosticFormatter extends // /** * Preprocess a given symbol looking for (i) additional info (where clauses) to be - * asdded to the main diagnostic (ii) names to be compacted + * added to the main diagnostic (ii) names to be compacted */ protected void preprocessSymbol(Symbol s) { symbolPreprocessor.visit(s, null); diff --git a/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java new file mode 100644 index 00000000000..2077ef1377d --- /dev/null +++ b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java @@ -0,0 +1,17 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8010387 + * @summary rich diagnostic sometimes contain wrong type variable numbering + * @compile/fail/ref=T8010387.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T8010387.java + */ +abstract class T8010387 { + + interface F { } + +

    void test() { + m(new F

    () { }); + } + + + abstract T8010387 m(F fx); +} diff --git a/langtools/test/tools/javac/Diagnostics/8010387/T8010387.out b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.out new file mode 100644 index 00000000000..e42c7080a41 --- /dev/null +++ b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.out @@ -0,0 +1,3 @@ +T8010387.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, T8010387.F, compiler.misc.anonymous.class: T8010387.F

    , kindname.class, T8010387, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: T8010387.F

    , T8010387.F)) +- compiler.misc.where.description.typevar.1: X,P,T,{(compiler.misc.where.typevar: X, java.lang.Object, kindname.class, T8010387),(compiler.misc.where.typevar: P, java.lang.Object, kindname.method,

    test()),(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, m(T8010387.F))} +1 error From 6132db352dc632d3db74d022db174f27a4a65948 Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Fri, 22 Mar 2013 07:58:55 -0700 Subject: [PATCH 047/155] 8009539: JVM crash when run lambda testng tests Ensure class pointer is non-null before dereferencing it to check if it is loaded. Reviewed-by: kvn --- hotspot/src/share/vm/opto/parse2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp index 9a14c9a58f9..73be6aae570 100644 --- a/hotspot/src/share/vm/opto/parse2.cpp +++ b/hotspot/src/share/vm/opto/parse2.cpp @@ -104,7 +104,8 @@ Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { if (C->log() != NULL) C->log()->elem("observe that='!need_range_check'"); } - if (!arytype->klass()->is_loaded()) { + ciKlass * arytype_klass = arytype->klass(); + if ((arytype_klass != NULL) && (!arytype_klass->is_loaded())) { // Only fails for some -Xcomp runs // The class is unloaded. We have to run this bytecode in the interpreter. uncommon_trap(Deoptimization::Reason_unloaded, @@ -1385,6 +1386,7 @@ void Parse::do_one_bytecode() { if (TraceOptoParse) { tty->print(" @"); dump_bci(bci()); + tty->cr(); } #endif From 902be4665bd0f42d5add136a3c13f61175a78cf2 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Fri, 22 Mar 2013 16:10:01 +0100 Subject: [PATCH 048/155] 8000754: NPG: Implement a MemoryPool MXBean for Metaspace Reviewed-by: jmasa, stefank --- hotspot/src/share/vm/memory/metaspace.hpp | 8 +- hotspot/src/share/vm/memory/universe.cpp | 1 + .../src/share/vm/services/memoryManager.cpp | 4 + .../src/share/vm/services/memoryManager.hpp | 10 +++ hotspot/src/share/vm/services/memoryPool.cpp | 34 +++++++++ hotspot/src/share/vm/services/memoryPool.hpp | 26 +++++++ .../src/share/vm/services/memoryService.cpp | 21 +++++- .../src/share/vm/services/memoryService.hpp | 5 ++ .../metaspace/TestMetaspaceMemoryPools.java | 75 +++++++++++++++++++ 9 files changed, 177 insertions(+), 7 deletions(-) create mode 100644 hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index f704804795f..56197fdd070 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -157,16 +157,16 @@ class Metaspace : public CHeapObj { class MetaspaceAux : AllStatic { + static size_t free_chunks_total(Metaspace::MetadataType mdtype); + static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); + + public: // Statistics for class space and data space in metaspace. static size_t used_in_bytes(Metaspace::MetadataType mdtype); static size_t free_in_bytes(Metaspace::MetadataType mdtype); static size_t capacity_in_bytes(Metaspace::MetadataType mdtype); static size_t reserved_in_bytes(Metaspace::MetadataType mdtype); - static size_t free_chunks_total(Metaspace::MetadataType mdtype); - static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); - - public: // Total of space allocated to metadata in all Metaspaces static size_t used_in_bytes() { return used_in_bytes(Metaspace::ClassType) + diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 79e092a3b19..4406addc9e8 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -1108,6 +1108,7 @@ bool universe_post_init() { // Initialize performance counters for metaspaces MetaspaceCounters::initialize_performance_counters(); + MemoryService::add_metaspace_memory_pools(); GC_locker::unlock(); // allow gc after bootstrapping diff --git a/hotspot/src/share/vm/services/memoryManager.cpp b/hotspot/src/share/vm/services/memoryManager.cpp index 3996d2163c8..d5e54f5ff15 100644 --- a/hotspot/src/share/vm/services/memoryManager.cpp +++ b/hotspot/src/share/vm/services/memoryManager.cpp @@ -61,6 +61,10 @@ MemoryManager* MemoryManager::get_code_cache_memory_manager() { return (MemoryManager*) new CodeCacheMemoryManager(); } +MemoryManager* MemoryManager::get_metaspace_memory_manager() { + return (MemoryManager*) new MetaspaceMemoryManager(); +} + GCMemoryManager* MemoryManager::get_copy_memory_manager() { return (GCMemoryManager*) new CopyMemoryManager(); } diff --git a/hotspot/src/share/vm/services/memoryManager.hpp b/hotspot/src/share/vm/services/memoryManager.hpp index 370d830e977..12c0a0ec458 100644 --- a/hotspot/src/share/vm/services/memoryManager.hpp +++ b/hotspot/src/share/vm/services/memoryManager.hpp @@ -56,6 +56,7 @@ public: enum Name { Abstract, CodeCache, + Metaspace, Copy, MarkSweepCompact, ParNew, @@ -88,6 +89,7 @@ public: // Static factory methods to get a memory manager of a specific type static MemoryManager* get_code_cache_memory_manager(); + static MemoryManager* get_metaspace_memory_manager(); static GCMemoryManager* get_copy_memory_manager(); static GCMemoryManager* get_msc_memory_manager(); static GCMemoryManager* get_parnew_memory_manager(); @@ -108,6 +110,14 @@ public: const char* name() { return "CodeCacheManager"; } }; +class MetaspaceMemoryManager : public MemoryManager { +public: + MetaspaceMemoryManager() : MemoryManager() {} + + MemoryManager::Name kind() { return MemoryManager::Metaspace; } + const char *name() { return "MetaspaceManager"; } +}; + class GCStatInfo : public ResourceObj { private: size_t _index; diff --git a/hotspot/src/share/vm/services/memoryPool.cpp b/hotspot/src/share/vm/services/memoryPool.cpp index e2895b1f816..969ed7f22bf 100644 --- a/hotspot/src/share/vm/services/memoryPool.cpp +++ b/hotspot/src/share/vm/services/memoryPool.cpp @@ -26,12 +26,15 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "oops/oop.inline.hpp" +#include "runtime/globals.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/os.hpp" #include "services/lowMemoryDetector.hpp" #include "services/management.hpp" #include "services/memoryManager.hpp" #include "services/memoryPool.hpp" +#include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" MemoryPool::MemoryPool(const char* name, @@ -256,3 +259,34 @@ MemoryUsage CodeHeapPool::get_memory_usage() { return MemoryUsage(initial_size(), used, committed, maxSize); } + +MetaspacePoolBase::MetaspacePoolBase(const char *name, + Metaspace::MetadataType md_type, + size_t max_size) : + _md_type(md_type), + MemoryPool(name, NonHeap, MetaspaceAux::capacity_in_bytes(_md_type), max_size, + true, false) { } + +size_t MetaspacePoolBase::used_in_bytes() { + return MetaspaceAux::used_in_bytes(_md_type); +} + +MemoryUsage MetaspacePoolBase::get_memory_usage() { + size_t used = MetaspaceAux::used_in_bytes(_md_type); + size_t committed = align_size_down_(MetaspaceAux::capacity_in_bytes(_md_type), os::vm_page_size()); + return MemoryUsage(initial_size(), used, committed, max_size()); +} + +ClassMetaspacePool::ClassMetaspacePool() : + MetaspacePoolBase("Class Metaspace", Metaspace::ClassType, calculate_max_size()) { } + +size_t ClassMetaspacePool::calculate_max_size() { + return UseCompressedKlassPointers ? ClassMetaspaceSize : _undefined_max_size; +} + +MetaspacePool::MetaspacePool() : + MetaspacePoolBase("Metaspace", Metaspace::NonClassType, calculate_max_size()) { } + +size_t MetaspacePool::calculate_max_size() { + return FLAG_IS_CMDLINE(MaxMetaspaceSize) ? MaxMetaspaceSize : _undefined_max_size; +} diff --git a/hotspot/src/share/vm/services/memoryPool.hpp b/hotspot/src/share/vm/services/memoryPool.hpp index 82606185340..f36c3984ced 100644 --- a/hotspot/src/share/vm/services/memoryPool.hpp +++ b/hotspot/src/share/vm/services/memoryPool.hpp @@ -28,6 +28,7 @@ #include "gc_implementation/shared/mutableSpace.hpp" #include "memory/defNewGeneration.hpp" #include "memory/heap.hpp" +#include "memory/metaspace.hpp" #include "memory/space.hpp" #include "services/memoryUsage.hpp" #include "utilities/macros.hpp" @@ -222,4 +223,29 @@ public: size_t used_in_bytes() { return _codeHeap->allocated_capacity(); } }; +class MetaspacePoolBase : public MemoryPool { +private: + Metaspace::MetadataType _md_type; +protected: + static const size_t _undefined_max_size = (size_t) -1; +public: + MetaspacePoolBase(const char *name, Metaspace::MetadataType md_type, size_t max_size); + MemoryUsage get_memory_usage(); + size_t used_in_bytes(); +}; + +class ClassMetaspacePool : public MetaspacePoolBase { +private: + size_t calculate_max_size(); +public: + ClassMetaspacePool(); +}; + +class MetaspacePool : public MetaspacePoolBase { +private: + size_t calculate_max_size(); +public: + MetaspacePool(); +}; + #endif // SHARE_VM_SERVICES_MEMORYPOOL_HPP diff --git a/hotspot/src/share/vm/services/memoryService.cpp b/hotspot/src/share/vm/services/memoryService.cpp index 0040f9d96fc..168d9909c9b 100644 --- a/hotspot/src/share/vm/services/memoryService.cpp +++ b/hotspot/src/share/vm/services/memoryService.cpp @@ -60,9 +60,11 @@ GrowableArray* MemoryService::_pools_list = GrowableArray* MemoryService::_managers_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_managers_list_size, true); -GCMemoryManager* MemoryService::_minor_gc_manager = NULL; -GCMemoryManager* MemoryService::_major_gc_manager = NULL; -MemoryPool* MemoryService::_code_heap_pool = NULL; +GCMemoryManager* MemoryService::_minor_gc_manager = NULL; +GCMemoryManager* MemoryService::_major_gc_manager = NULL; +MemoryPool* MemoryService::_code_heap_pool = NULL; +MemoryPool* MemoryService::_metaspace_pool = NULL; +MemoryPool* MemoryService::_class_metaspace_pool = NULL; class GcThreadCountClosure: public ThreadClosure { private: @@ -398,6 +400,19 @@ void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) { _managers_list->append(mgr); } +void MemoryService::add_metaspace_memory_pools() { + _metaspace_pool = new MetaspacePool(); + _class_metaspace_pool = new ClassMetaspacePool(); + + MemoryManager* mgr = MemoryManager::get_metaspace_memory_manager(); + mgr->add_pool(_metaspace_pool); + mgr->add_pool(_class_metaspace_pool); + + _pools_list->append(_metaspace_pool); + _pools_list->append(_class_metaspace_pool); + _managers_list->append(mgr); +} + MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) { for (int i = 0; i < _managers_list->length(); i++) { MemoryManager* mgr = _managers_list->at(i); diff --git a/hotspot/src/share/vm/services/memoryService.hpp b/hotspot/src/share/vm/services/memoryService.hpp index 44cf62ea3cb..fcd2fdf421d 100644 --- a/hotspot/src/share/vm/services/memoryService.hpp +++ b/hotspot/src/share/vm/services/memoryService.hpp @@ -73,6 +73,10 @@ private: // Code heap memory pool static MemoryPool* _code_heap_pool; + // Metaspace pools + static MemoryPool* _metaspace_pool; + static MemoryPool* _class_metaspace_pool; + static void add_generation_memory_pool(Generation* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr); @@ -121,6 +125,7 @@ private: public: static void set_universe_heap(CollectedHeap* heap); static void add_code_heap_memory_pool(CodeHeap* heap); + static void add_metaspace_memory_pools(); static MemoryPool* get_memory_pool(instanceHandle pool); static MemoryManager* get_memory_manager(instanceHandle mgr); diff --git a/hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java b/hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java new file mode 100644 index 00000000000..884f377bc22 --- /dev/null +++ b/hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java @@ -0,0 +1,75 @@ +import java.util.List; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryManagerMXBean; +import java.lang.management.MemoryPoolMXBean; +import java.lang.management.MemoryUsage; + +/* @test TestMetaspaceMemoryPools + * @bug 8000754 + * @summary Tests that two MemoryPoolMXBeans are created, one for metaspace and + * one for class metaspace, is created and that a MemoryManagerMXBean + * is created. + * @run main/othervm TestMetaspaceMemoryPools defined undefined + * @run main/othervm -XX:-UseCompressedKlassPointers TestMetaspaceMemoryPools undefined undefined + * @run main/othervm -XX:-UseCompressedKlassPointers -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPools undefined defined + */ +public class TestMetaspaceMemoryPools { + public static void main(String[] args) { + boolean isClassMetaspaceMaxDefined = args[0].equals("defined"); + boolean isMetaspaceMaxDefined = args[1].equals("defined"); + + verifyThatMetaspaceMemoryManagerExists(); + + verifyMemoryPool(getMemoryPool("Class Metaspace"), isClassMetaspaceMaxDefined); + verifyMemoryPool(getMemoryPool("Metaspace"), isMetaspaceMaxDefined); + } + + private static void verifyThatMetaspaceMemoryManagerExists() { + List managers = ManagementFactory.getMemoryManagerMXBeans(); + for (MemoryManagerMXBean manager : managers) { + if (manager.getName().equals("MetaspaceManager")) { + return; + } + } + + throw new RuntimeException("Expected to find a metaspace memory manager"); + } + + private static MemoryPoolMXBean getMemoryPool(String name) { + List pools = ManagementFactory.getMemoryPoolMXBeans(); + for (MemoryPoolMXBean pool : pools) { + if (pool.getName().equals(name)) { + return pool; + } + } + + throw new RuntimeException("Expected to find a memory pool with name " + name); + } + + private static void verifyMemoryPool(MemoryPoolMXBean pool, boolean isMaxDefined) { + MemoryUsage mu = pool.getUsage(); + assertDefined(mu.getInit(), "init"); + assertDefined(mu.getUsed(), "used"); + assertDefined(mu.getCommitted(), "committed"); + + if (isMaxDefined) { + assertDefined(mu.getMax(), "max"); + } else { + assertUndefined(mu.getMax(), "max"); + } + } + + private static void assertDefined(long value, String name) { + assertTrue(value != -1, "Expected " + name + " to be defined"); + } + + private static void assertUndefined(long value, String name) { + assertTrue(value == -1, "Expected " + name + " to be undefined"); + } + + private static void assertTrue(boolean condition, String msg) { + if (!condition) { + throw new RuntimeException(msg); + } + } +} From d54accaf5c4839bf0f7f0a3f06d4362823cc8b13 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 22 Mar 2013 10:08:46 -0700 Subject: [PATCH 049/155] 7080464: langtools regression test failures when assertions are enabled Reviewed-by: jjg --- langtools/test/tools/javac/api/TestJavacTaskScanner.java | 2 -- langtools/test/tools/javac/diags/MessageFile.java | 4 ++-- langtools/test/tools/javac/diags/MessageInfo.java | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/langtools/test/tools/javac/api/TestJavacTaskScanner.java b/langtools/test/tools/javac/api/TestJavacTaskScanner.java index ba50138ecc1..da862644dc4 100644 --- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java +++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java @@ -179,7 +179,6 @@ class MyScanner extends Scanner { @Override public Scanner newScanner(CharSequence input, boolean keepDocComments) { - assert !keepDocComments; if (input instanceof CharBuffer) { return new MyScanner(this, (CharBuffer)input, test); } else { @@ -190,7 +189,6 @@ class MyScanner extends Scanner { @Override public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { - assert !keepDocComments; return new MyScanner(this, input, inputLength, test); } diff --git a/langtools/test/tools/javac/diags/MessageFile.java b/langtools/test/tools/javac/diags/MessageFile.java index 72b79285644..da4dc5c511d 100644 --- a/langtools/test/tools/javac/diags/MessageFile.java +++ b/langtools/test/tools/javac/diags/MessageFile.java @@ -65,7 +65,7 @@ class MessageFile { } void insertAfter(Line l) { - assert prev == null && next == null; + assert l.prev == null && l.next == null; l.prev = this; l.next = next; if (next == null) @@ -82,7 +82,7 @@ class MessageFile { } void insertBefore(Line l) { - assert prev == null && next == null; + assert l.prev == null && l.next == null; l.prev = prev; l.next = this; if (prev == null) diff --git a/langtools/test/tools/javac/diags/MessageInfo.java b/langtools/test/tools/javac/diags/MessageInfo.java index 80809affe8f..aaeaeeda064 100644 --- a/langtools/test/tools/javac/diags/MessageInfo.java +++ b/langtools/test/tools/javac/diags/MessageInfo.java @@ -409,5 +409,3 @@ public class MessageInfo { } } - - From 7188961426d46639e8ed1f0ab134d4f91fb1cdca Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Sat, 23 Mar 2013 00:58:39 +0100 Subject: [PATCH 050/155] 8010652: Eliminate non-child references in Block/FunctionNode, and make few node types immutable Reviewed-by: jlaskey, lagergren --- nashorn/make/project.properties | 2 +- .../jdk/nashorn/internal/codegen/Attr.java | 443 +++++++++++------- .../internal/codegen/ClassEmitter.java | 12 +- .../internal/codegen/CodeGenerator.java | 236 +++++----- .../internal/codegen/CompilationPhase.java | 49 +- .../nashorn/internal/codegen/Compiler.java | 3 +- .../internal/codegen/FinalizeTypes.java | 164 ++++--- .../internal/codegen/FoldConstants.java | 14 +- .../internal/codegen/FunctionSignature.java | 2 +- .../jdk/nashorn/internal/codegen/Lower.java | 247 +++++----- .../internal/codegen/MethodEmitter.java | 5 +- .../nashorn/internal/codegen/Splitter.java | 81 ++-- .../nashorn/internal/codegen/WeighNodes.java | 81 ++-- .../jdk/nashorn/internal/ir/AccessNode.java | 15 +- .../jdk/nashorn/internal/ir/Assignment.java | 7 + .../src/jdk/nashorn/internal/ir/BaseNode.java | 13 +- .../jdk/nashorn/internal/ir/BinaryNode.java | 22 +- .../src/jdk/nashorn/internal/ir/Block.java | 360 ++------------ .../jdk/nashorn/internal/ir/BreakNode.java | 4 +- .../src/jdk/nashorn/internal/ir/CallNode.java | 12 +- .../src/jdk/nashorn/internal/ir/CaseNode.java | 4 +- .../jdk/nashorn/internal/ir/CatchNode.java | 4 +- .../jdk/nashorn/internal/ir/ContinueNode.java | 4 +- .../jdk/nashorn/internal/ir/DoWhileNode.java | 4 +- .../jdk/nashorn/internal/ir/EmptyNode.java | 4 +- .../jdk/nashorn/internal/ir/ExecuteNode.java | 4 +- .../src/jdk/nashorn/internal/ir/ForNode.java | 4 +- .../jdk/nashorn/internal/ir/FunctionNode.java | 326 ++++--------- .../jdk/nashorn/internal/ir/IdentNode.java | 63 ++- .../src/jdk/nashorn/internal/ir/IfNode.java | 4 +- .../jdk/nashorn/internal/ir/IndexNode.java | 9 +- .../jdk/nashorn/internal/ir/LabelNode.java | 4 +- .../nashorn/internal/ir/LexicalContext.java | 198 ++++++++ .../nashorn/internal/ir/LineNumberNode.java | 4 +- .../jdk/nashorn/internal/ir/LiteralNode.java | 34 +- .../src/jdk/nashorn/internal/ir/Location.java | 6 +- nashorn/src/jdk/nashorn/internal/ir/Node.java | 18 +- .../jdk/nashorn/internal/ir/ObjectNode.java | 4 +- .../jdk/nashorn/internal/ir/PropertyNode.java | 4 +- .../nashorn/internal/ir/ReferenceNode.java | 91 ---- .../jdk/nashorn/internal/ir/ReturnNode.java | 4 +- .../jdk/nashorn/internal/ir/RuntimeNode.java | 9 +- .../jdk/nashorn/internal/ir/SplitNode.java | 4 +- .../jdk/nashorn/internal/ir/SwitchNode.java | 4 +- .../src/jdk/nashorn/internal/ir/Symbol.java | 60 +-- .../jdk/nashorn/internal/ir/TernaryNode.java | 18 +- .../jdk/nashorn/internal/ir/ThrowNode.java | 4 +- .../src/jdk/nashorn/internal/ir/TryNode.java | 13 +- .../jdk/nashorn/internal/ir/TypeOverride.java | 6 +- .../jdk/nashorn/internal/ir/UnaryNode.java | 22 +- .../src/jdk/nashorn/internal/ir/VarNode.java | 88 ++-- .../jdk/nashorn/internal/ir/WhileNode.java | 4 +- .../src/jdk/nashorn/internal/ir/WithNode.java | 4 +- .../nashorn/internal/ir/debug/JSONWriter.java | 79 ++-- .../internal/ir/debug/PrintVisitor.java | 78 ++- .../ir/visitor/NodeOperatorVisitor.java | 16 +- .../internal/ir/visitor/NodeVisitor.java | 151 +++--- .../jdk/nashorn/internal/parser/Parser.java | 219 +++++---- .../jdk/nashorn/internal/runtime/Context.java | 2 +- .../runtime/resources/Messages.properties | 4 +- nashorn/test/script/basic/JDK-8006755.js | 2 +- nashorn/test/script/basic/NASHORN-837.js | 24 +- .../internal/codegen/CompilerTest.java | 12 +- 63 files changed, 1671 insertions(+), 1721 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java delete mode 100644 nashorn/src/jdk/nashorn/internal/ir/ReferenceNode.java diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index 60444de766b..58da977dc4a 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -210,7 +210,7 @@ run.test.xms=2G # add '-Dtest.js.outofprocess' to run each test in a new sub-process run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:-TieredCompilation -esa -ea -Dnashorn.debug=true -Dfile.encoding=UTF-8 #-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M -run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs} +run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.main} run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java index a441ef4d94c..938055984cd 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java @@ -37,14 +37,16 @@ import static jdk.nashorn.internal.ir.Symbol.IS_GLOBAL; import static jdk.nashorn.internal.ir.Symbol.IS_INTERNAL; import static jdk.nashorn.internal.ir.Symbol.IS_LET; import static jdk.nashorn.internal.ir.Symbol.IS_PARAM; +import static jdk.nashorn.internal.ir.Symbol.IS_SCOPE; import static jdk.nashorn.internal.ir.Symbol.IS_THIS; import static jdk.nashorn.internal.ir.Symbol.IS_VAR; +import static jdk.nashorn.internal.ir.Symbol.KINDMASK; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import java.util.Set; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.AccessNode; @@ -52,19 +54,19 @@ import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.CallNode.EvalArgs; -import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.CaseNode; import jdk.nashorn.internal.ir.CatchNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IndexNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.ObjectNode; import jdk.nashorn.internal.ir.PropertyNode; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.RuntimeNode.Request; @@ -117,6 +119,8 @@ final class Attr extends NodeOperatorVisitor { */ private Set localUses; + private final LexicalContext lexicalContext = new LexicalContext(); + private static final DebugLogger LOG = new DebugLogger("attr"); private static final boolean DEBUG = LOG.isEnabled(); @@ -137,14 +141,15 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final AccessNode accessNode) { + public Node leaveAccessNode(final AccessNode accessNode) { newTemporary(Type.OBJECT, accessNode); //While Object type is assigned here, Access Specialization in FinalizeTypes may narrow this end(accessNode); return accessNode; } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { + lexicalContext.push(block); start(block); final Set savedLocalDefs = localDefs; @@ -160,9 +165,7 @@ final class Attr extends NodeOperatorVisitor { localDefs = new HashSet<>(savedLocalDefs); localUses = new HashSet<>(savedLocalUses); - for (final Node statement : block.getStatements()) { - statement.accept(this); - } + block.visitStatements(this); } finally { localDefs = savedLocalDefs; localUses = savedLocalUses; @@ -172,11 +175,12 @@ final class Attr extends NodeOperatorVisitor { end(block); + lexicalContext.pop(block); return null; } @Override - public Node enter(final CallNode callNode) { + public Node enterCallNode(final CallNode callNode) { start(callNode); callNode.getFunction().accept(this); @@ -197,8 +201,7 @@ final class Attr extends NodeOperatorVisitor { evalArgs.setThis(thisNode); } - newTemporary(Type.OBJECT, callNode); // object type here, access specialization in FinalizeTypes may narrow it later - newType(callNode.getFunction().getSymbol(), Type.OBJECT); + newTemporary(callNode.getType(), callNode); // access specialization in FinalizeTypes may narrow it further later end(callNode); @@ -206,29 +209,106 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node enter(final CatchNode catchNode) { + public Node enterCatchNode(final CatchNode catchNode) { final IdentNode exception = catchNode.getException(); final Block block = getCurrentBlock(); start(catchNode); // define block-local exception variable - final Symbol def = block.defineSymbol(exception.getName(), IS_VAR | IS_LET, exception); + final Symbol def = defineSymbol(block, exception.getName(), IS_VAR | IS_LET, exception); newType(def, Type.OBJECT); addLocalDef(exception.getName()); return catchNode; } + /** + * Declare the definition of a new symbol. + * + * @param name Name of symbol. + * @param symbolFlags Symbol flags. + * @param node Defining Node. + * + * @return Symbol for given name or null for redefinition. + */ + private Symbol defineSymbol(final Block block, final String name, final int symbolFlags, final Node node) { + int flags = symbolFlags; + Symbol symbol = findSymbol(block, name); // Locate symbol. + + if ((flags & KINDMASK) == IS_GLOBAL) { + flags |= IS_SCOPE; + } + + final FunctionNode function = lexicalContext.getFunction(block); + if (symbol != null) { + // Symbol was already defined. Check if it needs to be redefined. + if ((flags & KINDMASK) == IS_PARAM) { + if (!isLocal(function, symbol)) { + // Not defined in this function. Create a new definition. + symbol = null; + } else if (symbol.isParam()) { + // Duplicate parameter. Null return will force an error. + assert false : "duplicate parameter"; + return null; + } + } else if ((flags & KINDMASK) == IS_VAR) { + if ((flags & IS_INTERNAL) == IS_INTERNAL || (flags & IS_LET) == IS_LET) { + assert !((flags & IS_LET) == IS_LET && symbol.getBlock() == block) : "duplicate let variable in block"; + // Always create a new definition. + symbol = null; + } else { + // Not defined in this function. Create a new definition. + if (!isLocal(function, symbol) || symbol.less(IS_VAR)) { + symbol = null; + } + } + } + } + + if (symbol == null) { + // If not found, then create a new one. + Block symbolBlock; + + // Determine where to create it. + if ((flags & Symbol.KINDMASK) == IS_VAR && ((flags & IS_INTERNAL) == IS_INTERNAL || (flags & IS_LET) == IS_LET)) { + symbolBlock = block; + } else { + symbolBlock = function; + } + + // Create and add to appropriate block. + symbol = new Symbol(name, flags, node, symbolBlock); + symbolBlock.putSymbol(name, symbol); + + if ((flags & Symbol.KINDMASK) != IS_GLOBAL) { + symbolBlock.getFrame().addSymbol(symbol); + symbol.setNeedsSlot(true); + } + } else if (symbol.less(flags)) { + symbol.setFlags(flags); + } + + if (node != null) { + node.setSymbol(symbol); + } + + return symbol; + } + @Override - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { start(functionNode, false); if (functionNode.isLazy()) { - LOG.info("LAZY: " + functionNode.getName()); + LOG.info("LAZY: " + functionNode.getName() + " => Promoting to OBJECT"); + newTemporary(lexicalContext.getCurrentFunction(), Type.OBJECT, functionNode); + functionNode.setReturnType(Type.OBJECT); end(functionNode); return null; } + lexicalContext.push(functionNode); + clearLocalDefs(); clearLocalUses(); @@ -244,24 +324,36 @@ final class Attr extends NodeOperatorVisitor { initScope(functionNode); initReturn(functionNode); - // Add all nested functions as symbols in this function - for (final FunctionNode nestedFunction : functionNode.getFunctions()) { + // Add all nested declared functions as symbols in this function + for (final FunctionNode nestedFunction : functionNode.getDeclaredFunctions()) { final IdentNode ident = nestedFunction.getIdent(); - if (ident != null && nestedFunction.isStatement()) { - final Symbol functionSymbol = functionNode.defineSymbol(ident.getName(), IS_VAR, nestedFunction); + if (ident != null) { + assert nestedFunction.isDeclared(); + final Symbol functionSymbol = defineSymbol(functionNode, ident.getName(), IS_VAR, nestedFunction); newType(functionSymbol, Type.typeFor(ScriptFunction.class)); } } - if (functionNode.isScript()) { + if (functionNode.isProgram()) { initFromPropertyMap(functionNode); } // Add function name as local symbol - if (!functionNode.isStatement() && !functionNode.isAnonymous() && !functionNode.isScript()) { - final Symbol selfSymbol = functionNode.defineSymbol(functionNode.getIdent().getName(), IS_VAR, functionNode); - newType(selfSymbol, Type.OBJECT); - selfSymbol.setNode(functionNode); + if (!functionNode.isDeclared() && !functionNode.isProgram()) { + if(functionNode.getSymbol() != null) { + // a temporary left over from an earlier pass when the function was lazy + assert functionNode.getSymbol().isTemp(); + // remove it + functionNode.setSymbol(null); + } + final Symbol selfSymbol; + if(functionNode.isAnonymous()) { + selfSymbol = newTemporary(functionNode, Type.OBJECT, functionNode); + } else { + selfSymbol = defineSymbol(functionNode, functionNode.getIdent().getName(), IS_VAR, functionNode); + newType(selfSymbol, Type.OBJECT); + selfSymbol.setNode(functionNode); + } } /* @@ -282,32 +374,26 @@ final class Attr extends NodeOperatorVisitor { */ final List declaredSymbols = new ArrayList<>(); - for (final VarNode decl : functionNode.getDeclarations()) { - final IdentNode ident = decl.getName(); - // any declared symbols that aren't visited need to be typed as well, hence the list - declaredSymbols.add(functionNode.defineSymbol(ident.getName(), IS_VAR, new IdentNode(ident))); - } - - // Every nested function needs a definition in the outer function with its name. Add these. - for (final FunctionNode nestedFunction : functionNode.getFunctions()) { - final VarNode varNode = nestedFunction.getFunctionVarNode(); - if (varNode != null) { - varNode.accept(this); - assert varNode.isFunctionVarNode() : varNode + " should be function var node"; + // This visitor will assign symbol to all declared variables, except function declarations (which are taken care + // in a separate step above) and "var" declarations in for loop initializers. + functionNode.accept(new NodeOperatorVisitor() { + @Override + public Node enterFunctionNode(FunctionNode nestedFn) { + // Don't descend into nested functions + return nestedFn == functionNode ? nestedFn : null; } - } - - for (final Node statement : functionNode.getStatements()) { - if (statement instanceof VarNode && ((VarNode)statement).isFunctionVarNode()) { - continue; //var nodes have already been processed, skip or they will generate additional defs/uses and false "can be undefined" + @Override + public Node enterVarNode(VarNode varNode) { + if(varNode.isStatement() && !varNode.isFunctionDeclaration()) { + final IdentNode ident = varNode.getName(); + // any declared symbols that aren't visited need to be typed as well, hence the list + declaredSymbols.add(defineSymbol(functionNode, ident.getName(), IS_VAR, new IdentNode(ident))); + } + return null; } - statement.accept(this); - } + }); - for (final FunctionNode nestedFunction : functionNode.getFunctions()) { - LOG.info("Going into nested function " + functionNode.getName() + " -> " + nestedFunction.getName()); - nestedFunction.accept(this); - } + visitFunctionStatements(functionNode); //unknown parameters are promoted to object type. finalizeParameters(functionNode); @@ -343,10 +429,19 @@ final class Attr extends NodeOperatorVisitor { functionNode.setState(CompilationState.ATTR); end(functionNode, false); + lexicalContext.pop(functionNode); return null; } + private void visitFunctionStatements(final FunctionNode functionNode) { + final List newStatements = new ArrayList<>(functionNode.getStatements()); + for(ListIterator stmts = newStatements.listIterator(); stmts.hasNext();) { + stmts.set(stmts.next().accept(this)); + } + functionNode.setStatements(newStatements); + } + @Override public Node leaveCONVERT(final UnaryNode unaryNode) { assert false : "There should be no convert operators in IR during Attribution"; @@ -355,7 +450,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node enter(final IdentNode identNode) { + public Node enterIdentNode(final IdentNode identNode) { final String name = identNode.getName(); start(identNode); @@ -372,7 +467,7 @@ final class Attr extends NodeOperatorVisitor { final Block block = getCurrentBlock(); final Symbol oldSymbol = identNode.getSymbol(); - Symbol symbol = block.findSymbol(name); + Symbol symbol = findSymbol(block, name); //If an existing symbol with the name is found, use that otherwise, declare a new one if (symbol != null) { @@ -396,22 +491,13 @@ final class Attr extends NodeOperatorVisitor { } identNode.setSymbol(symbol); - if (!getCurrentFunctionNode().isLocal(symbol)) { - // non-local: we need to put symbol in scope (if it isn't already) - if (!symbol.isScope()) { - final List lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction()); - for (final Block lookupBlock : lookupBlocks) { - final Symbol refSymbol = lookupBlock.findSymbol(name); - if (refSymbol != null) { // See NASHORN-837, function declaration in lexical scope: try {} catch (x){ function f() { use(x) } } f() - LOG.finest("Found a ref symbol that must be scope " + refSymbol); - refSymbol.setIsScope(); - } - } - } + // non-local: we need to put symbol in scope (if it isn't already) + if (!isLocal(getCurrentFunctionNode(), symbol) && !symbol.isScope()) { + symbol.setIsScope(); } } else { LOG.info("No symbol exists. Declare undefined: " + symbol); - symbol = block.useSymbol(name, identNode); + symbol = useSymbol(block, name, identNode); // we have never seen this before, it can be undefined newType(symbol, Type.OBJECT); // TODO unknown -we have explicit casts anyway? symbol.setCanBeUndefined(); @@ -420,9 +506,10 @@ final class Attr extends NodeOperatorVisitor { assert symbol != null; if(symbol.isGlobal()) { - getCurrentFunctionNode().setUsesGlobalSymbol(); + setUsesGlobalSymbol(); } else if(symbol.isScope()) { - getCurrentFunctionNode().setUsesScopeSymbol(symbol); + final Iterator blocks = lexicalContext.getBlocks(); + blocks.next().setUsesScopeSymbol(symbol, blocks); } if (symbol != oldSymbol && !identNode.isInitializedHere()) { @@ -435,15 +522,68 @@ final class Attr extends NodeOperatorVisitor { return null; } + /** + * Marks the current function as one using any global symbol. The function and all its parent functions will all be + * marked as needing parent scope. + * @see #needsParentScope() + */ + private void setUsesGlobalSymbol() { + for(final Iterator fns = lexicalContext.getFunctions(); fns.hasNext();) { + fns.next().setUsesAncestorScope(); + } + } + + /** + * Declare the use of a symbol in a block. + * + * @param block block in which the symbol is used + * @param name Name of symbol. + * @param node Using node + * + * @return Symbol for given name. + */ + private Symbol useSymbol(final Block block, final String name, final Node node) { + Symbol symbol = findSymbol(block, name); + + if (symbol == null) { + // If not found, declare as a free var. + symbol = defineSymbol(block, name, IS_GLOBAL, node); + } else { + node.setSymbol(symbol); + } + + return symbol; + } + + + /** + * Search for symbol in the lexical context starting from the given block. + * @param name Symbol name. + * @return Found symbol or null if not found. + */ + private Symbol findSymbol(final Block block, final String name) { + // Search up block chain to locate symbol. + + for(final Iterator blocks = lexicalContext.getBlocks(block); blocks.hasNext();) { + // Find name. + final Symbol symbol = blocks.next().getExistingSymbol(name); + // If found then we are good. + if(symbol != null) { + return symbol; + } + } + return null; + } + @Override - public Node leave(final IndexNode indexNode) { + public Node leaveIndexNode(final IndexNode indexNode) { newTemporary(Type.OBJECT, indexNode); //TORO return indexNode; } @SuppressWarnings("rawtypes") @Override - public Node enter(final LiteralNode literalNode) { + public Node enterLiteralNode(final LiteralNode literalNode) { try { start(literalNode); assert !literalNode.isTokenType(TokenType.THIS) : "tokentype for " + literalNode + " is this"; //guard against old dead code case. literal nodes should never inherit tokens @@ -472,14 +612,14 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final ObjectNode objectNode) { + public Node leaveObjectNode(final ObjectNode objectNode) { newTemporary(Type.OBJECT, objectNode); end(objectNode); return objectNode; } @Override - public Node enter(final PropertyNode propertyNode) { + public Node enterPropertyNode(final PropertyNode propertyNode) { // assign a pseudo symbol to property name, see NASHORN-710 propertyNode.setSymbol(new Symbol(propertyNode.getKeyName(), 0, Type.OBJECT)); end(propertyNode); @@ -487,31 +627,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node enter(final ReferenceNode referenceNode) { - final FunctionNode functionNode = referenceNode.getReference(); - if (functionNode != null) { - functionNode.addReferencingParentBlock(getCurrentBlock()); - } - return referenceNode; - } - - @Override - public Node leave(final ReferenceNode referenceNode) { - newTemporary(Type.OBJECT, referenceNode); //reference node type is always an object, i.e. the scriptFunction. the function return type varies though - - final FunctionNode functionNode = referenceNode.getReference(); - //assert !functionNode.getType().isUnknown() || functionNode.isLazy() : functionNode.getType(); - if (functionNode.isLazy()) { - LOG.info("Lazy function node call reference: " + functionNode.getName() + " => Promoting to OBJECT"); - functionNode.setReturnType(Type.OBJECT); - } - end(referenceNode); - - return referenceNode; - } - - @Override - public Node leave(final ReturnNode returnNode) { + public Node leaveReturnNode(final ReturnNode returnNode) { final Node expr = returnNode.getExpression(); if (expr != null) { @@ -530,7 +646,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final SwitchNode switchNode) { + public Node leaveSwitchNode(final SwitchNode switchNode) { Type type = Type.UNKNOWN; for (final CaseNode caseNode : switchNode.getCases()) { @@ -567,7 +683,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final TryNode tryNode) { + public Node leaveTryNode(final TryNode tryNode) { tryNode.setException(exceptionSymbol()); if (tryNode.getFinallyBody() != null) { @@ -580,13 +696,13 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node enter(final VarNode varNode) { + public Node enterVarNode(final VarNode varNode) { start(varNode); final IdentNode ident = varNode.getName(); final String name = ident.getName(); - final Symbol symbol = getCurrentBlock().defineSymbol(name, IS_VAR, ident); + final Symbol symbol = defineSymbol(getCurrentBlock(), name, IS_VAR, ident); assert symbol != null; LOG.info("VarNode " + varNode + " set symbol " + symbol); @@ -598,23 +714,15 @@ final class Attr extends NodeOperatorVisitor { symbol.setCanBeUndefined(); } - if (varNode.getInit() != null) { - varNode.getInit().accept(this); - } - return varNode; } @Override - public Node leave(final VarNode varNode) { + public Node leaveVarNode(final VarNode varNode) { final Node init = varNode.getInit(); final IdentNode ident = varNode.getName(); final String name = ident.getName(); - if (init != null) { - addLocalDef(name); - } - if (init == null) { // var x; with no init will be treated like a use of x by // visit(IdentNode) unless we remove the name @@ -623,8 +731,10 @@ final class Attr extends NodeOperatorVisitor { return varNode; } + addLocalDef(name); + final Symbol symbol = varNode.getSymbol(); - final boolean isScript = symbol.getBlock().getFunction().isScript(); //see NASHORN-56 + final boolean isScript = lexicalContext.getFunction(symbol.getBlock()).isProgram(); //see NASHORN-56 if ((init.getType().isNumeric() || init.getType().isBoolean()) && !isScript) { // Forbid integers as local vars for now as we have no way to treat them as undefined newType(symbol, init.getType()); @@ -718,11 +828,9 @@ final class Attr extends NodeOperatorVisitor { runtimeNode = new RuntimeNode(unaryNode, request, args); assert runtimeNode.getSymbol() == unaryNode.getSymbol(); //clone constructor should do this - runtimeNode.accept(this); - return runtimeNode; + return leaveRuntimeNode(runtimeNode); } - @Override public Node leaveNEW(final UnaryNode unaryNode) { newTemporary(Type.OBJECT, unaryNode); @@ -755,7 +863,7 @@ final class Attr extends NodeOperatorVisitor { runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); assert runtimeNode.getSymbol() == unaryNode.getSymbol(); - runtimeNode.accept(this); + runtimeNode = (RuntimeNode)leaveRuntimeNode(runtimeNode); end(unaryNode); @@ -763,7 +871,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final RuntimeNode runtimeNode) { + public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { newTemporary(runtimeNode.getRequest().getReturnType(), runtimeNode); return runtimeNode; } @@ -823,12 +931,12 @@ final class Attr extends NodeOperatorVisitor { final IdentNode ident = (IdentNode)lhs; final String name = ident.getName(); - Symbol symbol = getCurrentBlock().findSymbol(name); + Symbol symbol = findSymbol(getCurrentBlock(), name); if (symbol == null) { - symbol = block.defineSymbol(name, IS_GLOBAL, ident); + symbol = defineSymbol(block, name, IS_GLOBAL, ident); binaryNode.setSymbol(symbol); - } else if (!getCurrentFunctionNode().isLocal(symbol)) { + } else if (!isLocal(getCurrentFunctionNode(), symbol)) { symbol.setIsScope(); } @@ -838,6 +946,12 @@ final class Attr extends NodeOperatorVisitor { return binaryNode; } + private boolean isLocal(FunctionNode function, Symbol symbol) { + final Block block = symbol.getBlock(); + // some temp symbols have no block, so can be assumed local + return block == null || lexicalContext.getFunction(block) == function; + } + @Override public Node enterASSIGN(final BinaryNode binaryNode) { return enterAssignmentNode(binaryNode); @@ -995,7 +1109,7 @@ final class Attr extends NodeOperatorVisitor { return leaveBinaryArithmetic(binaryNode); } - private Node leaveCmp(final BinaryNode binaryNode, final RuntimeNode.Request request) { + private Node leaveCmp(final BinaryNode binaryNode) { final Node lhs = binaryNode.lhs(); final Node rhs = binaryNode.rhs(); @@ -1033,37 +1147,38 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveEQ(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.EQ); + return leaveCmp(binaryNode); } @Override public Node leaveEQ_STRICT(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.EQ_STRICT); + return leaveCmp(binaryNode); } @Override public Node leaveGE(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.GE); + return leaveCmp(binaryNode); } @Override public Node leaveGT(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.GT); + return leaveCmp(binaryNode); } @Override public Node leaveIN(final BinaryNode binaryNode) { - try { - return new RuntimeNode(binaryNode, Request.IN).accept(this); - } finally { - end(binaryNode); - } + return leaveBinaryRuntimeOperator(binaryNode, Request.IN); } @Override public Node leaveINSTANCEOF(final BinaryNode binaryNode) { + return leaveBinaryRuntimeOperator(binaryNode, Request.INSTANCEOF); + } + + private Node leaveBinaryRuntimeOperator(final BinaryNode binaryNode, final Request request) { try { - return new RuntimeNode(binaryNode, Request.INSTANCEOF).accept(this); + // Don't do a full RuntimeNode.accept, as we don't want to double-visit the binary node operands + return leaveRuntimeNode(new RuntimeNode(binaryNode, request)); } finally { end(binaryNode); } @@ -1071,12 +1186,12 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveLE(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.LE); + return leaveCmp(binaryNode); } @Override public Node leaveLT(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.LT); + return leaveCmp(binaryNode); } @Override @@ -1091,12 +1206,12 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveNE(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.NE); + return leaveCmp(binaryNode); } @Override public Node leaveNE_STRICT(final BinaryNode binaryNode) { - return leaveCmp(binaryNode, Request.NE_STRICT); + return leaveCmp(binaryNode); } @Override @@ -1127,9 +1242,9 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final ForNode forNode) { + public Node leaveForNode(final ForNode forNode) { if (forNode.isForIn()) { - forNode.setIterator(newInternal(getCurrentFunctionNode(), getCurrentFunctionNode().uniqueName(ITERATOR_PREFIX.tag()), Type.OBJECT)); //NASHORN-73 + forNode.setIterator(newInternal(getCurrentFunctionNode().uniqueName(ITERATOR_PREFIX.tag()), Type.OBJECT)); //NASHORN-73 /* * Iterators return objects, so we need to widen the scope of the * init variable if it, for example, has been assigned double type @@ -1144,7 +1259,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node leave(final TernaryNode ternaryNode) { + public Node leaveTernaryNode(final TernaryNode ternaryNode) { final Node lhs = ternaryNode.rhs(); final Node rhs = ternaryNode.third(); @@ -1159,24 +1274,24 @@ final class Attr extends NodeOperatorVisitor { return ternaryNode; } - private static void initThis(final FunctionNode functionNode) { - final Symbol thisSymbol = functionNode.defineSymbol(THIS.tag(), IS_PARAM | IS_THIS, null); + private void initThis(final FunctionNode functionNode) { + final Symbol thisSymbol = defineSymbol(functionNode, THIS.tag(), IS_PARAM | IS_THIS, null); newType(thisSymbol, Type.OBJECT); thisSymbol.setNeedsSlot(true); functionNode.getThisNode().setSymbol(thisSymbol); LOG.info("Initialized scope symbol: " + thisSymbol); } - private static void initScope(final FunctionNode functionNode) { - final Symbol scopeSymbol = functionNode.defineSymbol(SCOPE.tag(), IS_VAR | IS_INTERNAL, null); + private void initScope(final FunctionNode functionNode) { + final Symbol scopeSymbol = defineSymbol(functionNode, SCOPE.tag(), IS_VAR | IS_INTERNAL, null); newType(scopeSymbol, Type.typeFor(ScriptObject.class)); scopeSymbol.setNeedsSlot(true); functionNode.getScopeNode().setSymbol(scopeSymbol); LOG.info("Initialized scope symbol: " + scopeSymbol); } - private static void initReturn(final FunctionNode functionNode) { - final Symbol returnSymbol = functionNode.defineSymbol(SCRIPT_RETURN.tag(), IS_VAR | IS_INTERNAL, null); + private void initReturn(final FunctionNode functionNode) { + final Symbol returnSymbol = defineSymbol(functionNode, SCRIPT_RETURN.tag(), IS_VAR | IS_INTERNAL, null); newType(returnSymbol, Type.OBJECT); returnSymbol.setNeedsSlot(true); functionNode.getResultNode().setSymbol(returnSymbol); @@ -1186,7 +1301,7 @@ final class Attr extends NodeOperatorVisitor { private void initVarArg(final FunctionNode functionNode) { if (functionNode.isVarArg()) { - final Symbol varArgsSymbol = functionNode.defineSymbol(VARARGS.tag(), IS_PARAM | IS_INTERNAL, null); + final Symbol varArgsSymbol = defineSymbol(functionNode, VARARGS.tag(), IS_PARAM | IS_INTERNAL, null); varArgsSymbol.setTypeOverride(Type.OBJECT_ARRAY); varArgsSymbol.setNeedsSlot(true); functionNode.getVarArgsNode().setSymbol(varArgsSymbol); @@ -1194,7 +1309,7 @@ final class Attr extends NodeOperatorVisitor { if (functionNode.needsArguments()) { final String argumentsName = functionNode.getArgumentsNode().getName(); - final Symbol argumentsSymbol = functionNode.defineSymbol(argumentsName, IS_VAR | IS_INTERNAL, null); + final Symbol argumentsSymbol = defineSymbol(functionNode, argumentsName, IS_VAR | IS_INTERNAL, null); newType(argumentsSymbol, Type.typeFor(ScriptObject.class)); argumentsSymbol.setNeedsSlot(true); functionNode.getArgumentsNode().setSymbol(argumentsSymbol); @@ -1204,9 +1319,9 @@ final class Attr extends NodeOperatorVisitor { } } - private static void initCallee(final FunctionNode functionNode) { + private void initCallee(final FunctionNode functionNode) { assert functionNode.getCalleeNode() != null : functionNode + " has no callee"; - final Symbol calleeSymbol = functionNode.defineSymbol(CALLEE.tag(), IS_PARAM | IS_INTERNAL, null); + final Symbol calleeSymbol = defineSymbol(functionNode, CALLEE.tag(), IS_PARAM | IS_INTERNAL, null); newType(calleeSymbol, Type.typeFor(ScriptFunction.class)); calleeSymbol.setNeedsSlot(true); functionNode.getCalleeNode().setSymbol(calleeSymbol); @@ -1226,7 +1341,7 @@ final class Attr extends NodeOperatorVisitor { for (final IdentNode param : functionNode.getParameters()) { addLocalDef(param.getName()); - final Symbol paramSymbol = functionNode.defineSymbol(param.getName(), IS_PARAM, param); + final Symbol paramSymbol = defineSymbol(functionNode, param.getName(), IS_PARAM, param); if (paramSymbol != null) { final Type callSiteParamType = functionNode.getSpecializedType(param); if (callSiteParamType != null) { @@ -1279,15 +1394,15 @@ final class Attr extends NodeOperatorVisitor { * Move any properties from a global map into the scope of this method * @param functionNode the function node for which to init scope vars */ - private static void initFromPropertyMap(final FunctionNode functionNode) { + private void initFromPropertyMap(final FunctionNode functionNode) { // For a script, add scope symbols as defined in the property map - assert functionNode.isScript(); + assert functionNode.isProgram(); final PropertyMap map = Context.getGlobalMap(); for (final Property property : map.getProperties()) { final String key = property.getKey(); - final Symbol symbol = functionNode.defineSymbol(key, IS_GLOBAL, null); + final Symbol symbol = defineSymbol(functionNode, key, IS_GLOBAL, null); newType(symbol, Type.OBJECT); LOG.info("Added global symbol from property map " + symbol); } @@ -1354,7 +1469,7 @@ final class Attr extends NodeOperatorVisitor { private static void ensureAssignmentSlots(final FunctionNode functionNode, final Node assignmentDest) { assignmentDest.accept(new NodeVisitor() { @Override - public Node leave(final IndexNode indexNode) { + public Node leaveIndexNode(final IndexNode indexNode) { final Node index = indexNode.getIndex(); index.getSymbol().setNeedsSlot(!index.getSymbol().isConstant()); return indexNode; @@ -1399,7 +1514,7 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node enter(final FunctionNode node) { + public Node enterFunctionNode(final FunctionNode node) { return node.isLazy() ? null : node; } @@ -1419,7 +1534,7 @@ final class Attr extends NodeOperatorVisitor { */ @SuppressWarnings("fallthrough") @Override - public Node leave(final BinaryNode binaryNode) { + public Node leaveBinaryNode(final BinaryNode binaryNode) { final Type widest = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType()); switch (binaryNode.tokenType()) { default: @@ -1477,22 +1592,6 @@ final class Attr extends NodeOperatorVisitor { return binaryNode; } - private static List findLookupBlocksHelper(final FunctionNode currentFunction, final FunctionNode topFunction) { - if (currentFunction.findParentFunction() == topFunction) { - final List blocks = new LinkedList<>(); - - blocks.add(currentFunction.getParent()); - blocks.addAll(currentFunction.getReferencingParentBlocks()); - return blocks; - } - /* - * assumption: all parent blocks of an inner function will always be in the same outer function; - * therefore we can simply skip through intermediate functions. - * @see FunctionNode#addReferencingParentBlock(Block) - */ - return findLookupBlocksHelper(currentFunction.findParentFunction(), topFunction); - } - private static boolean isFunctionExpressionSelfReference(final Symbol symbol) { if (symbol.isVar() && symbol.getNode() == symbol.getBlock() && symbol.getNode() instanceof FunctionNode) { return ((FunctionNode)symbol.getNode()).getIdent().getName().equals(symbol.getName()); @@ -1509,16 +1608,12 @@ final class Attr extends NodeOperatorVisitor { return newTemporary(getCurrentFunctionNode(), type, node); } - private Symbol newInternal(final FunctionNode functionNode, final String name, final Type type) { - final Symbol iter = getCurrentFunctionNode().defineSymbol(name, IS_VAR | IS_INTERNAL, null); + private Symbol newInternal(final String name, final Type type) { + final Symbol iter = defineSymbol(getCurrentFunctionNode(), name, IS_VAR | IS_INTERNAL, null); iter.setType(type); // NASHORN-73 return iter; } - private Symbol newInternal(final String name, final Type type) { - return newInternal(getCurrentFunctionNode(), name, type); - } - private static void newType(final Symbol symbol, final Type type) { final Type oldType = symbol.getSymbolType(); symbol.setType(type); @@ -1577,13 +1672,13 @@ final class Attr extends NodeOperatorVisitor { } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { toObject(block); return block; } @Override - public Node enter(final FunctionNode node) { + public Node enterFunctionNode(final FunctionNode node) { toObject(node); if (node.isLazy()) { return null; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/ClassEmitter.java b/nashorn/src/jdk/nashorn/internal/codegen/ClassEmitter.java index 35e74824958..7ca7f994311 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/ClassEmitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/ClassEmitter.java @@ -194,6 +194,14 @@ public class ClassEmitter implements Emitter { defineCommonStatics(strictMode); } + /** + * Returns the name of the compile unit class name. + * @return the name of the compile unit class name. + */ + String getUnitClassName() { + return unitClassName; + } + /** * Convert a binary name to a package/class name. * @@ -244,7 +252,7 @@ public class ClassEmitter implements Emitter { // $getMap - get the ith entry from the constants table and cast to PropertyMap. final MethodEmitter getMapMethod = method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), GET_MAP.tag(), PropertyMap.class, int.class); getMapMethod.begin(); - getMapMethod.loadConstants(unitClassName) + getMapMethod.loadConstants() .load(Type.INT, 0) .arrayload() .checkcast(PropertyMap.class) @@ -254,7 +262,7 @@ public class ClassEmitter implements Emitter { // $setMap - overwrite an existing map. final MethodEmitter setMapMethod = method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), SET_MAP.tag(), void.class, int.class, PropertyMap.class); setMapMethod.begin(); - setMapMethod.loadConstants(unitClassName) + setMapMethod.loadConstants() .load(Type.INT, 0) .load(Type.OBJECT, 1) .arraystore(); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index ce6a1fcdfdf..1d09e9c98e0 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -76,18 +76,18 @@ import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LineNumberNode; import jdk.nashorn.internal.ir.LiteralNode; -import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.ObjectNode; import jdk.nashorn.internal.ir.PropertyNode; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.RuntimeNode.Request; @@ -107,6 +107,7 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Lexer.RegexToken; import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.Context; +import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.Property; import jdk.nashorn.internal.runtime.PropertyMap; @@ -156,12 +157,20 @@ final class CodeGenerator extends NodeOperatorVisitor { /** How many regexp fields have been emitted */ private int regexFieldCount; + /** Used for temporary signaling between enterCallNode and enterFunctionNode to handle the special case of calling + * a just-defined anonymous function expression. */ + private boolean functionNodeIsCallee; + /** Map of shared scope call sites */ private final Map scopeCalls = new HashMap<>(); + private final LexicalContext lexicalContext = new LexicalContext(); + /** When should we stop caching regexp expressions in fields to limit bytecode size? */ private static final int MAX_REGEX_FIELDS = 2 * 1024; + private static final DebugLogger LOG = new DebugLogger("codegen", "nashorn.codegen.debug"); + /** * Constructor. * @@ -210,7 +219,7 @@ final class CodeGenerator extends NodeOperatorVisitor { final int flags = CALLSITE_SCOPE | getCallSiteFlags(); method.loadScope(); - if (symbol.isFastScope(getCurrentFunctionNode())) { + if (isFastScope(symbol)) { // Only generate shared scope getter for fast-scope symbols so we know we can dial in correct scope. if (symbol.getUseCount() > SharedScopeCall.FAST_SCOPE_GET_THRESHOLD) { return loadSharedScopeVar(identNode.getType(), symbol, flags); @@ -221,8 +230,28 @@ final class CodeGenerator extends NodeOperatorVisitor { } } + /** + * Check if this symbol can be accessed directly with a putfield or getfield or dynamic load + * + * @param function function to check for fast scope + * @return true if fast scope + */ + private boolean isFastScope(final Symbol symbol) { + if (!symbol.isScope() || !symbol.getBlock().needsScope()) { + return false; + } + // Allow fast scope access if no function contains with or eval + for(final Iterator it = lexicalContext.getFunctions(getCurrentFunctionNode()); it.hasNext();) { + final FunctionNode func = it.next(); + if (func.hasWith() || func.hasEval()) { + return false; + } + } + return true; + } + private MethodEmitter loadSharedScopeVar(final Type valueType, final Symbol symbol, final int flags) { - method.load(symbol.isFastScope(getCurrentFunctionNode()) ? getScopeProtoDepth(getCurrentBlock(), symbol) : -1); + method.load(isFastScope(symbol) ? getScopeProtoDepth(getCurrentBlock(), symbol) : -1); final SharedScopeCall scopeCall = getScopeGet(valueType, symbol, flags | CALLSITE_FAST_SCOPE); scopeCall.generateInvoke(method); return method; @@ -240,30 +269,18 @@ final class CodeGenerator extends NodeOperatorVisitor { return method; } - private static int getScopeProtoDepth(final Block currentBlock, final Symbol symbol) { - if (currentBlock == symbol.getBlock()) { - return 0; - } - - final int delta = currentBlock.needsScope() ? 1 : 0; - final Block parentBlock = currentBlock.getParent(); - - if (parentBlock != null) { - final int result = getScopeProtoDepth(parentBlock, symbol); - if (result != -1) { - return delta + result; + private int getScopeProtoDepth(final Block startingBlock, final Symbol symbol) { + int depth = 0; + final Block definingBlock = symbol.getBlock(); + for(final Iterator blocks = lexicalContext.getBlocks(startingBlock); blocks.hasNext();) { + final Block currentBlock = blocks.next(); + if (currentBlock == definingBlock) { + return depth; + } + if (currentBlock.needsScope()) { + ++depth; } } - - if (currentBlock instanceof FunctionNode) { - for (final Block lookupBlock : ((FunctionNode)currentBlock).getReferencingParentBlocks()) { - final int result = getScopeProtoDepth(lookupBlock, symbol); - if (result != -1) { - return delta + result; - } - } - } - return -1; } @@ -313,13 +330,13 @@ final class CodeGenerator extends NodeOperatorVisitor { node.accept(new NodeVisitor(getCurrentCompileUnit(), method) { @Override - public Node enter(final IdentNode identNode) { + public Node enterIdentNode(final IdentNode identNode) { loadIdent(identNode); return null; } @Override - public Node enter(final AccessNode accessNode) { + public Node enterAccessNode(final AccessNode accessNode) { if (!baseAlreadyOnStack) { load(accessNode.getBase()).convert(Type.OBJECT); } @@ -329,7 +346,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final IndexNode indexNode) { + public Node enterIndexNode(final IndexNode indexNode) { if (!baseAlreadyOnStack) { load(indexNode.getBase()).convert(Type.OBJECT); load(indexNode.getIndex()); @@ -338,6 +355,14 @@ final class CodeGenerator extends NodeOperatorVisitor { return null; } + @Override + public Node enterFunctionNode(FunctionNode functionNode) { + // function nodes will always leave a constructed function object on stack, no need to load the symbol + // separately as in enterDefault() + functionNode.accept(codegen); + return null; + } + @Override public Node enterDefault(final Node otherNode) { otherNode.accept(codegen); // generate code for whatever we are looking at. @@ -350,7 +375,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final AccessNode accessNode) { + public Node enterAccessNode(final AccessNode accessNode) { if (accessNode.testResolved()) { return null; } @@ -422,10 +447,11 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { if (block.testResolved()) { return null; } + lexicalContext.push(block); method.label(block.getEntryLabel()); initLocals(block); @@ -434,14 +460,14 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node leave(final Block block) { + public Node leaveBlock(final Block block) { method.label(block.getBreakLabel()); symbolInfo(block); if (block.needsScope()) { popBlockScope(block); } - + lexicalContext.pop(block); return block; } @@ -467,7 +493,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final BreakNode breakNode) { + public Node enterBreakNode(final BreakNode breakNode) { if (breakNode.testResolved()) { return null; } @@ -515,14 +541,13 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final CallNode callNode) { + public Node enterCallNode(final CallNode callNode) { if (callNode.testResolved()) { return null; } final List args = callNode.getArgs(); final Node function = callNode.getFunction(); - final FunctionNode currentFunction = getCurrentFunctionNode(); final Block currentBlock = getCurrentBlock(); function.accept(new NodeVisitor(getCurrentCompileUnit(), method) { @@ -531,7 +556,7 @@ final class CodeGenerator extends NodeOperatorVisitor { final Symbol symbol = identNode.getSymbol(); int scopeCallFlags = flags; method.loadScope(); - if (symbol.isFastScope(currentFunction)) { + if (isFastScope(symbol)) { method.load(getScopeProtoDepth(currentBlock, symbol)); scopeCallFlags |= CALLSITE_FAST_SCOPE; } else { @@ -593,7 +618,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final IdentNode node) { + public Node enterIdentNode(final IdentNode node) { final Symbol symbol = node.getSymbol(); if (symbol.isScope()) { @@ -606,7 +631,7 @@ final class CodeGenerator extends NodeOperatorVisitor { if (callNode.isEval()) { evalCall(node, flags); } else if (useCount <= SharedScopeCall.FAST_SCOPE_CALL_THRESHOLD - || (!symbol.isFastScope(currentFunction) && useCount <= SharedScopeCall.SLOW_SCOPE_CALL_THRESHOLD) + || (!isFastScope(symbol) && useCount <= SharedScopeCall.SLOW_SCOPE_CALL_THRESHOLD) || callNode.inWithBlock()) { scopeCall(node, flags); } else { @@ -621,7 +646,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final AccessNode node) { + public Node enterAccessNode(final AccessNode node) { load(node.getBase()); method.convert(Type.OBJECT); method.dup(); @@ -634,8 +659,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final ReferenceNode node) { - final FunctionNode callee = node.getReference(); + public Node enterFunctionNode(final FunctionNode callee) { final boolean isVarArg = callee.isVarArg(); final int argCount = isVarArg ? -1 : callee.getParameters().size(); @@ -653,12 +677,13 @@ final class CodeGenerator extends NodeOperatorVisitor { loadArgs(args, signature, isVarArg, argCount); method.invokestatic(callee.getCompileUnit().getUnitClassName(), callee.getName(), signature); assert method.peekType().equals(callee.getReturnType()) : method.peekType() + " != " + callee.getReturnType(); - + functionNodeIsCallee = true; + callee.accept(CodeGenerator.this); return null; } @Override - public Node enter(final IndexNode node) { + public Node enterIndexNode(final IndexNode node) { load(node.getBase()); method.convert(Type.OBJECT); method.dup(); @@ -694,7 +719,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final ContinueNode continueNode) { + public Node enterContinueNode(final ContinueNode continueNode) { if (continueNode.testResolved()) { return null; } @@ -709,17 +734,17 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final DoWhileNode doWhileNode) { - return enter((WhileNode)doWhileNode); + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { + return enterWhileNode(doWhileNode); } @Override - public Node enter(final EmptyNode emptyNode) { + public Node enterEmptyNode(final EmptyNode emptyNode) { return null; } @Override - public Node enter(final ExecuteNode executeNode) { + public Node enterExecuteNode(final ExecuteNode executeNode) { if (executeNode.testResolved()) { return null; } @@ -731,7 +756,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final ForNode forNode) { + public Node enterForNode(final ForNode forNode) { if (forNode.testResolved()) { return null; } @@ -813,7 +838,7 @@ final class CodeGenerator extends NodeOperatorVisitor { * @param block block with local vars. */ private void initLocals(final Block block) { - final FunctionNode function = block.getFunction(); + final FunctionNode function = lexicalContext.getFunction(block); final boolean isFunctionNode = block == function; /* @@ -915,7 +940,7 @@ final class CodeGenerator extends NodeOperatorVisitor { foc.makeObject(method); // runScript(): merge scope into global - if (isFunctionNode && function.isScript()) { + if (isFunctionNode && function.isProgram()) { method.invoke(ScriptRuntime.MERGE_SCOPE); } @@ -958,19 +983,29 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final FunctionNode functionNode) { - if (functionNode.isLazy()) { - return null; - } + public Node enterFunctionNode(final FunctionNode functionNode) { + final boolean isCallee = functionNodeIsCallee; + functionNodeIsCallee = false; if (functionNode.testResolved()) { return null; } + if(!(isCallee || functionNode == compiler.getFunctionNode())) { + newFunctionObject(functionNode); + } + + if (functionNode.isLazy()) { + return null; + } + + LOG.info("=== BEGIN " + functionNode.getName()); + lexicalContext.push(functionNode); + setCurrentCompileUnit(functionNode.getCompileUnit()); assert getCurrentCompileUnit() != null; - method = getCurrentCompileUnit().getClassEmitter().method(functionNode); + setCurrentMethodEmitter(getCurrentCompileUnit().getClassEmitter().method(functionNode)); functionNode.setMethodEmitter(method); // Mark end for variable tables. method.begin(); @@ -983,7 +1018,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node leave(final FunctionNode functionNode) { + public Node leaveFunctionNode(final FunctionNode functionNode) { // Mark end for variable tables. method.label(functionNode.getBreakLabel()); @@ -1001,16 +1036,18 @@ final class CodeGenerator extends NodeOperatorVisitor { throw e; } + lexicalContext.pop(functionNode); + LOG.info("=== END " + functionNode.getName()); return functionNode; } @Override - public Node enter(final IdentNode identNode) { + public Node enterIdentNode(final IdentNode identNode) { return null; } @Override - public Node enter(final IfNode ifNode) { + public Node enterIfNode(final IfNode ifNode) { if (ifNode.testResolved()) { return null; } @@ -1049,7 +1086,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final IndexNode indexNode) { + public Node enterIndexNode(final IndexNode indexNode) { if (indexNode.testResolved()) { return null; } @@ -1060,7 +1097,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final LineNumberNode lineNumberNode) { + public Node enterLineNumberNode(final LineNumberNode lineNumberNode) { if (lineNumberNode.testResolved()) { return null; } @@ -1068,7 +1105,6 @@ final class CodeGenerator extends NodeOperatorVisitor { final Label label = new Label("line:" + lineNumberNode.getLineNumber() + " (" + getCurrentFunctionNode().getName() + ")"); method.label(label); method.lineNumber(lineNumberNode.getLineNumber(), label); - return null; } @@ -1106,7 +1142,7 @@ final class CodeGenerator extends NodeOperatorVisitor { final String name = getCurrentFunctionNode().uniqueName(SPLIT_PREFIX.tag()); final String signature = methodDescriptor(type, Object.class, ScriptFunction.class, ScriptObject.class, type); - method = getCurrentCompileUnit().getClassEmitter().method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), name, signature); + setCurrentMethodEmitter(getCurrentCompileUnit().getClassEmitter().method(EnumSet.of(Flag.PUBLIC, Flag.STATIC), name, signature)); method.setFunctionNode(getCurrentFunctionNode()); method.begin(); @@ -1212,7 +1248,7 @@ final class CodeGenerator extends NodeOperatorVisitor { method.invokestatic(unitClassName, methodName, methodDescriptor(cls, int.class)); classEmitter.needGetConstantMethod(cls); } else { - method.loadConstants(unitClassName).load(index).arrayload(); + method.loadConstants().load(index).arrayload(); if (cls != Object.class) { method.checkcast(cls); } @@ -1292,14 +1328,14 @@ final class CodeGenerator extends NodeOperatorVisitor { @SuppressWarnings("rawtypes") @Override - public Node enter(final LiteralNode literalNode) { + public Node enterLiteralNode(final LiteralNode literalNode) { assert literalNode.getSymbol() != null : literalNode + " has no symbol"; load(literalNode).store(literalNode.getSymbol()); return null; } @Override - public Node enter(final ObjectNode objectNode) { + public Node enterObjectNode(final ObjectNode objectNode) { if (objectNode.testResolved()) { return null; } @@ -1372,10 +1408,10 @@ final class CodeGenerator extends NodeOperatorVisitor { } for (final Node element : elements) { - final PropertyNode propertyNode = (PropertyNode)element; - final Object key = propertyNode.getKey(); - final ReferenceNode getter = (ReferenceNode)propertyNode.getGetter(); - final ReferenceNode setter = (ReferenceNode)propertyNode.getSetter(); + final PropertyNode propertyNode = (PropertyNode)element; + final Object key = propertyNode.getKey(); + final FunctionNode getter = (FunctionNode)propertyNode.getGetter(); + final FunctionNode setter = (FunctionNode)propertyNode.getSetter(); if (getter == null && setter == null) { continue; @@ -1404,18 +1440,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final ReferenceNode referenceNode) { - if (referenceNode.testResolved()) { - return null; - } - - newFunctionObject(referenceNode.getReference()); - - return null; - } - - @Override - public Node enter(final ReturnNode returnNode) { + public Node enterReturnNode(final ReturnNode returnNode) { if (returnNode.testResolved()) { return null; } @@ -1556,7 +1581,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final RuntimeNode runtimeNode) { + public Node enterRuntimeNode(final RuntimeNode runtimeNode) { if (runtimeNode.testResolved()) { return null; } @@ -1637,7 +1662,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final SplitNode splitNode) { + public Node enterSplitNode(final SplitNode splitNode) { if (splitNode.testResolved()) { return null; } @@ -1706,7 +1731,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node leave(final SplitNode splitNode) { + public Node leaveSplitNode(final SplitNode splitNode) { try { // Wrap up this method. method.loadResult(); @@ -1763,7 +1788,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final SwitchNode switchNode) { + public Node enterSwitchNode(final SwitchNode switchNode) { if (switchNode.testResolved()) { return null; } @@ -1895,7 +1920,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final ThrowNode throwNode) { + public Node enterThrowNode(final ThrowNode throwNode) { if (throwNode.testResolved()) { return null; } @@ -1922,7 +1947,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final TryNode tryNode) { + public Node enterTryNode(final TryNode tryNode) { if (tryNode.testResolved()) { return null; } @@ -1955,7 +1980,7 @@ final class CodeGenerator extends NodeOperatorVisitor { setCurrentBlock(catchBlock); try { - enter(catchBlock); + enterBlock(catchBlock); final CatchNode catchNode = (CatchNode)catchBlocks.get(i).getStatements().get(0); final IdentNode exception = catchNode.getException(); @@ -1966,6 +1991,7 @@ final class CodeGenerator extends NodeOperatorVisitor { // Generate catch body (inlined finally) and rethrow exception catchBody.accept(this); method.load(symbol).athrow(); + lexicalContext.pop(catchBlock); continue; } @@ -2012,7 +2038,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } } - leave(catchBlock); + leaveBlock(catchBlock); } finally { setCurrentBlock(saveBlock); } @@ -2027,7 +2053,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final VarNode varNode) { + public Node enterVarNode(final VarNode varNode) { final Node init = varNode.getInit(); if (varNode.testResolved() || init == null) { @@ -2049,7 +2075,7 @@ final class CodeGenerator extends NodeOperatorVisitor { int flags = CALLSITE_SCOPE | getCallSiteFlags(); final IdentNode identNode = varNode.getName(); final Type type = identNode.getType(); - if (varSymbol.isFastScope(getCurrentFunctionNode())) { + if (isFastScope(varSymbol)) { storeFastScopeVar(type, varSymbol, flags); } else { method.dynamicSet(type, identNode.getName(), flags); @@ -2065,7 +2091,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final WhileNode whileNode) { + public Node enterWhileNode(final WhileNode whileNode) { if (whileNode.testResolved()) { return null; } @@ -2098,7 +2124,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final WithNode withNode) { + public Node enterWithNode(final WithNode withNode) { if (withNode.testResolved()) { return null; } @@ -2864,7 +2890,7 @@ final class CodeGenerator extends NodeOperatorVisitor { * Ternary visits. */ @Override - public Node enter(final TernaryNode ternaryNode) { + public Node enterTernaryNode(final TernaryNode ternaryNode) { if (ternaryNode.testResolved()) { return null; } @@ -3060,7 +3086,7 @@ final class CodeGenerator extends NodeOperatorVisitor { target.accept(new NodeVisitor(getCurrentCompileUnit(), method) { @Override - public Node enter(final IdentNode node) { + public Node enterIdentNode(final IdentNode node) { if (targetSymbol.isScope()) { method.load(scopeSymbol); depth++; @@ -3083,13 +3109,13 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final AccessNode node) { + public Node enterAccessNode(final AccessNode node) { enterBaseNode(); return null; } @Override - public Node enter(final IndexNode node) { + public Node enterIndexNode(final IndexNode node) { enterBaseNode(); final Node index = node.getIndex(); @@ -3155,8 +3181,6 @@ final class CodeGenerator extends NodeOperatorVisitor { } private void epilogue() { - final FunctionNode currentFunction = getCurrentFunctionNode(); - /** * Take the original target args from the stack and use them * together with the value to be stored to emit the store code @@ -3174,7 +3198,7 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final UnaryNode node) { + public Node enterUnaryNode(final UnaryNode node) { if(node.tokenType() == TokenType.CONVERT && node.getSymbol() != null) { method.convert(node.rhs().getType()); } @@ -3182,11 +3206,11 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final IdentNode node) { + public Node enterIdentNode(final IdentNode node) { final Symbol symbol = node.getSymbol(); assert symbol != null; if (symbol.isScope()) { - if (symbol.isFastScope(currentFunction)) { + if (isFastScope(symbol)) { storeFastScopeVar(node.getType(), symbol, CALLSITE_SCOPE | getCallSiteFlags()); } else { method.dynamicSet(node.getType(), node.getName(), CALLSITE_SCOPE | getCallSiteFlags()); @@ -3199,13 +3223,13 @@ final class CodeGenerator extends NodeOperatorVisitor { } @Override - public Node enter(final AccessNode node) { + public Node enterAccessNode(final AccessNode node) { method.dynamicSet(node.getProperty().getType(), node.getProperty().getName(), getCallSiteFlags()); return null; } @Override - public Node enter(final IndexNode node) { + public Node enterIndexNode(final IndexNode node) { method.dynamicSetIndex(getCallSiteFlags()); return null; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java index 0125efff65e..8b905f87e1d 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java @@ -14,16 +14,16 @@ import java.io.IOException; import java.util.EnumSet; import java.util.HashSet; import java.util.Set; - import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.Node; -import jdk.nashorn.internal.ir.ReferenceNode; -import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.ir.debug.ASTWriter; import jdk.nashorn.internal.ir.debug.PrintVisitor; +import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; +import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.ECMAErrors; import jdk.nashorn.internal.runtime.ScriptEnvironment; import jdk.nashorn.internal.runtime.Timing; @@ -65,17 +65,17 @@ enum CompilationPhase { outermostFunctionNode.accept(new NodeVisitor() { // self references are done with invokestatic and thus cannot have trampolines - never lazy @Override - public Node enter(final CallNode node) { + public Node enterCallNode(final CallNode node) { final Node callee = node.getFunction(); - if (callee instanceof ReferenceNode) { - neverLazy.add(((ReferenceNode)callee).getReference()); + if (callee instanceof FunctionNode) { + neverLazy.add(((FunctionNode)callee)); return null; } return node; } @Override - public Node enter(final FunctionNode node) { + public Node enterFunctionNode(final FunctionNode node) { if (node == outermostFunctionNode) { return node; } @@ -94,15 +94,24 @@ enum CompilationPhase { lazy.remove(node); } - for (final FunctionNode node : lazy) { - Compiler.LOG.fine("Marking " + node.getName() + " as lazy"); - node.setIsLazy(true); - final FunctionNode parent = node.findParentFunction(); - if (parent != null) { - Compiler.LOG.fine("Marking " + parent.getName() + " as having lazy children - it needs scope for all variables"); - parent.setHasLazyChildren(); + outermostFunctionNode.accept(new NodeOperatorVisitor() { + private final LexicalContext lexicalContext = new LexicalContext(); + @Override + public Node enterFunctionNode(FunctionNode functionNode) { + lexicalContext.push(functionNode); + if(lazy.contains(functionNode)) { + Compiler.LOG.fine("Marking " + functionNode.getName() + " as lazy"); + functionNode.setIsLazy(true); + lexicalContext.getParentFunction(functionNode).setHasLazyChildren(); + } + return functionNode; } - } + @Override + public Node leaveFunctionNode(FunctionNode functionNode) { + lexicalContext.pop(functionNode); + return functionNode; + } + }); } @Override @@ -241,6 +250,16 @@ enum CompilationPhase { final CodeGenerator codegen = new CodeGenerator(compiler); fn.accept(codegen); codegen.generateScopeCalls(); + fn.accept(new NodeOperatorVisitor() { + @Override + public Node enterFunctionNode(FunctionNode functionNode) { + if(functionNode.isLazy()) { + functionNode.resetResolved(); + return null; + } + return fn; + } + }); } catch (final VerifyError e) { if (env._verify_code || env._print_code) { diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index 87d26c1aab5..397f39a54b0 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -46,7 +46,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.logging.Level; - import jdk.internal.dynalink.support.NameCodec; import jdk.nashorn.internal.codegen.ClassEmitter.Flag; import jdk.nashorn.internal.codegen.types.Type; @@ -383,7 +382,7 @@ public final class Compiler { functionNode.accept(new NodeVisitor() { @Override - public Node enter(final FunctionNode node) { + public Node enterFunctionNode(final FunctionNode node) { if (node.isLazy()) { return null; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java index b302d6fe470..cd18524021d 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FinalizeTypes.java @@ -34,20 +34,20 @@ import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.CallNode; import jdk.nashorn.internal.ir.CallNode.EvalArgs; -import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.CaseNode; import jdk.nashorn.internal.ir.CatchNode; import jdk.nashorn.internal.ir.DoWhileNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.Node; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.RuntimeNode.Request; @@ -85,11 +85,13 @@ final class FinalizeTypes extends NodeOperatorVisitor { private static final DebugLogger LOG = new DebugLogger("finalize"); + private final LexicalContext lexicalContext = new LexicalContext(); + FinalizeTypes() { } @Override - public Node leave(final CallNode callNode) { + public Node leaveCallNode(final CallNode callNode) { final EvalArgs evalArgs = callNode.getEvalArgs(); if (evalArgs != null) { evalArgs.setCode(evalArgs.getCode().accept(this)); @@ -97,15 +99,14 @@ final class FinalizeTypes extends NodeOperatorVisitor { // AccessSpecializer - call return type may change the access for this location final Node function = callNode.getFunction(); - if (function instanceof ReferenceNode) { - setTypeOverride(callNode, ((ReferenceNode)function).getReference().getType()); + if (function instanceof FunctionNode) { + return setTypeOverride(callNode, ((FunctionNode)function).getReturnType()); } return callNode; } private Node leaveUnary(final UnaryNode unaryNode) { - unaryNode.setRHS(convert(unaryNode.rhs(), unaryNode.getType())); - return unaryNode; + return unaryNode.setRHS(convert(unaryNode.rhs(), unaryNode.getType())); } @Override @@ -126,8 +127,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leaveDECINC(final UnaryNode unaryNode) { - specialize(unaryNode); - return unaryNode; + return specialize(unaryNode).node; } @Override @@ -159,9 +159,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } } - binaryNode.setLHS(convert(lhs, type)); - binaryNode.setRHS(convert(rhs, type)); - return binaryNode; + return binaryNode.setLHS(convert(lhs, type)).setRHS(convert(rhs, type)); } @Override @@ -171,12 +169,13 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leaveASSIGN(final BinaryNode binaryNode) { - Type destType = specialize(binaryNode); + final SpecializedNode specialized = specialize(binaryNode); + final BinaryNode specBinaryNode = (BinaryNode)specialized.node; + Type destType = specialized.type; if (destType == null) { - destType = binaryNode.getType(); + destType = specBinaryNode.getType(); } - binaryNode.setRHS(convert(binaryNode.rhs(), destType)); - return binaryNode; + return specBinaryNode.setRHS(convert(specBinaryNode.rhs(), destType)); } @Override @@ -255,21 +254,21 @@ final class FinalizeTypes extends NodeOperatorVisitor { @Override public Node leaveCOMMALEFT(final BinaryNode binaryNode) { assert binaryNode.getSymbol() != null; - binaryNode.setRHS(discard(binaryNode.rhs())); + final BinaryNode newBinaryNode = (BinaryNode)binaryNode.setRHS(discard(binaryNode.rhs())); // AccessSpecializer - the type of lhs, which is the remaining value of this node may have changed // in that case, update the node type as well - propagateType(binaryNode, binaryNode.lhs().getType()); - return binaryNode; + propagateType(newBinaryNode, newBinaryNode.lhs().getType()); + return newBinaryNode; } @Override public Node leaveCOMMARIGHT(final BinaryNode binaryNode) { assert binaryNode.getSymbol() != null; - binaryNode.setLHS(discard(binaryNode.lhs())); + final BinaryNode newBinaryNode = binaryNode.setLHS(discard(binaryNode.lhs())); // AccessSpecializer - the type of rhs, which is the remaining value of this node may have changed // in that case, update the node type as well - propagateType(binaryNode, binaryNode.rhs().getType()); - return binaryNode; + propagateType(newBinaryNode, newBinaryNode.rhs().getType()); + return newBinaryNode; } @Override @@ -355,13 +354,20 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { + lexicalContext.push(block); updateSymbols(block); return block; } @Override - public Node leave(final CatchNode catchNode) { + public Node leaveBlock(Block block) { + lexicalContext.pop(block); + return super.leaveBlock(block); + } + + @Override + public Node leaveCatchNode(final CatchNode catchNode) { final Node exceptionCondition = catchNode.getExceptionCondition(); if (exceptionCondition != null) { catchNode.setExceptionCondition(convert(exceptionCondition, Type.BOOLEAN)); @@ -370,23 +376,23 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node enter(final DoWhileNode doWhileNode) { - return enter((WhileNode)doWhileNode); + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { + return enterWhileNode(doWhileNode); } @Override - public Node leave(final DoWhileNode doWhileNode) { - return leave((WhileNode)doWhileNode); + public Node leaveDoWhileNode(final DoWhileNode doWhileNode) { + return leaveWhileNode(doWhileNode); } @Override - public Node leave(final ExecuteNode executeNode) { + public Node leaveExecuteNode(final ExecuteNode executeNode) { executeNode.setExpression(discard(executeNode.getExpression())); return executeNode; } @Override - public Node leave(final ForNode forNode) { + public Node leaveForNode(final ForNode forNode) { final Node init = forNode.getInit(); final Node test = forNode.getTest(); final Node modify = forNode.getModify(); @@ -414,11 +420,12 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { if (functionNode.isLazy()) { return null; } + lexicalContext.push(functionNode); // If the function doesn't need a callee, we ensure its __callee__ symbol doesn't get a slot. We can't do // this earlier, as access to scoped variables, self symbol, etc. in previous phases can all trigger the // need for the callee. @@ -439,14 +446,20 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node leave(final IfNode ifNode) { + public Node leaveFunctionNode(FunctionNode functionNode) { + lexicalContext.pop(functionNode); + return super.leaveFunctionNode(functionNode); + } + + @Override + public Node leaveIfNode(final IfNode ifNode) { ifNode.setTest(convert(ifNode.getTest(), Type.BOOLEAN)); return ifNode; } @SuppressWarnings("rawtypes") @Override - public Node enter(final LiteralNode literalNode) { + public Node enterLiteralNode(final LiteralNode literalNode) { if (literalNode instanceof ArrayLiteralNode) { final ArrayLiteralNode arrayLiteralNode = (ArrayLiteralNode)literalNode; final Node[] array = arrayLiteralNode.getValue(); @@ -464,7 +477,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node leave(final ReturnNode returnNode) { + public Node leaveReturnNode(final ReturnNode returnNode) { final Node expr = returnNode.getExpression(); if (expr != null) { returnNode.setExpression(convert(expr, getCurrentFunctionNode().getReturnType())); @@ -473,7 +486,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node leave(final RuntimeNode runtimeNode) { + public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final List args = runtimeNode.getArgs(); for (final Node arg : args) { assert !arg.getType().isUnknown(); @@ -482,7 +495,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node leave(final SwitchNode switchNode) { + public Node leaveSwitchNode(final SwitchNode switchNode) { final Node expression = switchNode.getExpression(); final List cases = switchNode.getCases(); final boolean allInteger = switchNode.getTag().getSymbolType().isInteger(); @@ -501,33 +514,34 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node leave(final TernaryNode ternaryNode) { - ternaryNode.setLHS(convert(ternaryNode.lhs(), Type.BOOLEAN)); - return ternaryNode; + public Node leaveTernaryNode(final TernaryNode ternaryNode) { + return ternaryNode.setLHS(convert(ternaryNode.lhs(), Type.BOOLEAN)); } @Override - public Node leave(final ThrowNode throwNode) { + public Node leaveThrowNode(final ThrowNode throwNode) { throwNode.setExpression(convert(throwNode.getExpression(), Type.OBJECT)); return throwNode; } @Override - public Node leave(final VarNode varNode) { + public Node leaveVarNode(final VarNode varNode) { final Node rhs = varNode.getInit(); if (rhs != null) { - Type destType = specialize(varNode); + final SpecializedNode specialized = specialize(varNode); + final VarNode specVarNode = (VarNode)specialized.node; + Type destType = specialized.type; if (destType == null) { - destType = varNode.getType(); + destType = specVarNode.getType(); } - assert varNode.hasType() : varNode + " doesn't have a type"; - varNode.setInit(convert(rhs, destType)); + assert specVarNode.hasType() : specVarNode + " doesn't have a type"; + return specVarNode.setInit(convert(rhs, destType)); } return varNode; } @Override - public Node leave(final WhileNode whileNode) { + public Node leaveWhileNode(final WhileNode whileNode) { final Node test = whileNode.getTest(); if (test != null) { whileNode.setTest(convert(test, Type.BOOLEAN)); @@ -536,7 +550,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node leave(final WithNode withNode) { + public Node leaveWithNode(final WithNode withNode) { withNode.setExpression(convert(withNode.getExpression(), Type.OBJECT)); return withNode; } @@ -555,14 +569,14 @@ final class FinalizeTypes extends NodeOperatorVisitor { * that scope and slot information is correct for every symbol * @param block block for which to to finalize type info. */ - private static void updateSymbols(final Block block) { + private void updateSymbols(final Block block) { if (!block.needsScope()) { return; // nothing to do } - assert !(block instanceof FunctionNode) || block.getFunction() == block; + final FunctionNode functionNode = lexicalContext.getFunction(block); + assert !(block instanceof FunctionNode) || functionNode == block; - final FunctionNode functionNode = block.getFunction(); final List symbols = block.getFrame().getSymbols(); final boolean allVarsInScope = functionNode.allVarsInScope(); final boolean isVarArg = functionNode.isVarArg(); @@ -631,10 +645,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { break; } - binaryNode.setLHS(convert(lhs, widest)); - binaryNode.setRHS(convert(rhs, widest)); - - return binaryNode; + return binaryNode.setLHS(convert(lhs, widest)).setRHS(convert(rhs, widest)); } /** @@ -656,9 +667,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } private Node leaveBinary(final BinaryNode binaryNode, final Type lhsType, final Type rhsType) { - binaryNode.setLHS(convert(binaryNode.lhs(), lhsType)); - binaryNode.setRHS(convert(binaryNode.rhs(), rhsType)); - return binaryNode; + return binaryNode.setLHS(convert(binaryNode.lhs(), lhsType)).setRHS(convert(binaryNode.rhs(), rhsType)); } /** @@ -679,7 +688,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node enter(final IdentNode identNode) { + public Node enterIdentNode(final IdentNode identNode) { if (!exclude.contains(identNode)) { setCanBePrimitive(identNode.getSymbol()); } @@ -687,26 +696,36 @@ final class FinalizeTypes extends NodeOperatorVisitor { } @Override - public Node enter(final AccessNode accessNode) { + public Node enterAccessNode(final AccessNode accessNode) { setCanBePrimitive(accessNode.getProperty().getSymbol()); return null; } @Override - public Node enter(final IndexNode indexNode) { + public Node enterIndexNode(final IndexNode indexNode) { exclude.add(indexNode.getBase()); //prevent array base node to be flagged as primitive, but k in a[k++] is fine return indexNode; } }); } - private static Type specialize(final Assignment assignment) { + private static class SpecializedNode { + final Node node; + final Type type; + + SpecializedNode(Node node, Type type) { + this.node = node; + this.type = type; + } + } + + private static SpecializedNode specialize(final Assignment assignment) { final Node node = ((Node)assignment); - final Node lhs = assignment.getAssignmentDest(); + final T lhs = assignment.getAssignmentDest(); final Node rhs = assignment.getAssignmentSource(); if (!canHaveCallSiteType(lhs)) { - return null; + return new SpecializedNode(node, null); } final Type to; @@ -718,13 +737,13 @@ final class FinalizeTypes extends NodeOperatorVisitor { if (!isSupportedCallSiteType(to)) { //meaningless to specialize to boolean or object - return null; + return new SpecializedNode(node, null); } - setTypeOverride(lhs, to); - propagateType(node, to); + final Node newNode = assignment.setAssignmentDest(setTypeOverride(lhs, to)); + propagateType(newNode, to); - return to; + return new SpecializedNode(newNode, to); } @@ -736,7 +755,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { * @return true if node can have a callsite type */ private static boolean canHaveCallSiteType(final Node node) { - return node instanceof TypeOverride && ((TypeOverride)node).canHaveCallSiteType(); + return node instanceof TypeOverride && ((TypeOverride)node).canHaveCallSiteType(); } /** @@ -762,7 +781,8 @@ final class FinalizeTypes extends NodeOperatorVisitor { * @param node node for which to change type * @param to new type */ - private static void setTypeOverride(final Node node, final Type to) { + @SuppressWarnings("unchecked") + private static T setTypeOverride(final T node, final Type to) { final Type from = node.getType(); if (!node.getType().equals(to)) { LOG.info("Changing call override type for '" + node + "' from " + node.getType() + " to " + to); @@ -771,7 +791,7 @@ final class FinalizeTypes extends NodeOperatorVisitor { } } LOG.info("Type override for lhs in '" + node + "' => " + to); - ((TypeOverride)node).setType(to); + return ((TypeOverride)node).setType(to); } /** @@ -816,8 +836,8 @@ final class FinalizeTypes extends NodeOperatorVisitor { } } else { if (canHaveCallSiteType(node) && isSupportedCallSiteType(to)) { - setTypeOverride(node, to); - return resultNode; + assert node instanceof TypeOverride; + return setTypeOverride(node, to); } resultNode = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.CONVERT), node); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java index af2b02ab706..fbc62644835 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FoldConstants.java @@ -31,12 +31,12 @@ import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.UnaryNode; -import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.JSType; @@ -54,7 +54,7 @@ final class FoldConstants extends NodeVisitor { } @Override - public Node leave(final UnaryNode unaryNode) { + public Node leaveUnaryNode(final UnaryNode unaryNode) { final LiteralNode literalNode = new UnaryNodeConstantEvaluator(unaryNode).eval(); if (literalNode != null) { LOG.info("Unary constant folded " + unaryNode + " to " + literalNode); @@ -64,7 +64,7 @@ final class FoldConstants extends NodeVisitor { } @Override - public Node leave(final BinaryNode binaryNode) { + public Node leaveBinaryNode(final BinaryNode binaryNode) { final LiteralNode literalNode = new BinaryNodeConstantEvaluator(binaryNode).eval(); if (literalNode != null) { LOG.info("Binary constant folded " + binaryNode + " to " + literalNode); @@ -74,7 +74,7 @@ final class FoldConstants extends NodeVisitor { } @Override - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { if (functionNode.isLazy()) { return null; } @@ -82,13 +82,13 @@ final class FoldConstants extends NodeVisitor { } @Override - public Node leave(final FunctionNode functionNode) { + public Node leaveFunctionNode(final FunctionNode functionNode) { functionNode.setState(CompilationState.CONSTANT_FOLDED); return functionNode; } @Override - public Node leave(final IfNode ifNode) { + public Node leaveIfNode(final IfNode ifNode) { final Node test = ifNode.getTest(); if (test instanceof LiteralNode) { final Block shortCut = ((LiteralNode)test).isTrue() ? ifNode.getPass() : ifNode.getFail(); @@ -101,7 +101,7 @@ final class FoldConstants extends NodeVisitor { } @Override - public Node leave(final TernaryNode ternaryNode) { + public Node leaveTernaryNode(final TernaryNode ternaryNode) { final Node test = ternaryNode.lhs(); if (test instanceof LiteralNode) { return ((LiteralNode)test).isTrue() ? ternaryNode.rhs() : ternaryNode.third(); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java b/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java index 5f3740a7240..057d2d4e454 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java @@ -155,7 +155,7 @@ public final class FunctionSignature { true, functionNode.needsCallee(), functionNode.getReturnType(), - (functionNode.isVarArg() && !functionNode.isScript()) ? + (functionNode.isVarArg() && !functionNode.isProgram()) ? null : functionNode.getParameters()); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 5baa7af535e..715ddc6f4e7 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -37,8 +37,8 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Deque; +import java.util.Iterator; import java.util.List; -import jdk.nashorn.internal.ir.AccessNode; import jdk.nashorn.internal.ir.BaseNode; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; @@ -52,11 +52,12 @@ import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; -import jdk.nashorn.internal.ir.IndexNode; import jdk.nashorn.internal.ir.LabelNode; import jdk.nashorn.internal.ir.LabeledNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LineNumberNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; @@ -69,7 +70,6 @@ import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WhileNode; import jdk.nashorn.internal.ir.WithNode; -import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; @@ -103,6 +103,8 @@ final class Lower extends NodeOperatorVisitor { private List statements; + private LexicalContext lexicalContext = new LexicalContext(); + /** * Constructor. * @@ -114,14 +116,15 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { final Node savedLastStatement = lastStatement; final List savedStatements = statements; - + lexicalContext.push(block); try { this.statements = new ArrayList<>(); + NodeVisitor visitor = this; for (final Node statement : block.getStatements()) { - statement.accept(this); + statement.accept(visitor); /* * This is slightly unsound, for example if we have a loop with * a guarded statement like if (x) continue in the body and the @@ -133,7 +136,7 @@ final class Lower extends NodeOperatorVisitor { */ if (lastStatement != null && lastStatement.isTerminal()) { copyTerminal(block, lastStatement); - break; + visitor = new DeadCodeVarDeclarationVisitor(); } } block.setStatements(statements); @@ -141,18 +144,19 @@ final class Lower extends NodeOperatorVisitor { } finally { this.statements = savedStatements; this.lastStatement = savedLastStatement; + lexicalContext.pop(block); } return null; } @Override - public Node enter(final BreakNode breakNode) { + public Node enterBreakNode(final BreakNode breakNode) { return enterBreakOrContinue(breakNode); } @Override - public Node enter(final CallNode callNode) { + public Node enterCallNode(final CallNode callNode) { final Node function = markerFunction(callNode.getFunction()); callNode.setFunction(function); checkEval(callNode); //check if this is an eval call and store the information @@ -160,44 +164,44 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node leave(final CaseNode caseNode) { + public Node leaveCaseNode(final CaseNode caseNode) { caseNode.copyTerminalFlags(caseNode.getBody()); return caseNode; } @Override - public Node leave(final CatchNode catchNode) { + public Node leaveCatchNode(final CatchNode catchNode) { catchNode.copyTerminalFlags(catchNode.getBody()); addStatement(catchNode); return catchNode; } @Override - public Node enter(final ContinueNode continueNode) { + public Node enterContinueNode(final ContinueNode continueNode) { return enterBreakOrContinue(continueNode); } @Override - public Node enter(final DoWhileNode doWhileNode) { - return enter((WhileNode)doWhileNode); + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { + return enterWhileNode(doWhileNode); } @Override - public Node leave(final DoWhileNode doWhileNode) { - return leave((WhileNode)doWhileNode); + public Node leaveDoWhileNode(final DoWhileNode doWhileNode) { + return leaveWhileNode(doWhileNode); } @Override - public Node enter(final EmptyNode emptyNode) { + public Node enterEmptyNode(final EmptyNode emptyNode) { return null; } @Override - public Node leave(final ExecuteNode executeNode) { + public Node leaveExecuteNode(final ExecuteNode executeNode) { final Node expr = executeNode.getExpression(); - if (getCurrentFunctionNode().isScript()) { - if (!(expr instanceof Block)) { + if (getCurrentFunctionNode().isProgram()) { + if (!(expr instanceof Block) || expr instanceof FunctionNode) { // it's not a block, but can be a function if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { executeNode.setExpression(new BinaryNode(executeNode.getSource(), Token.recast(executeNode.getToken(), TokenType.ASSIGN), getCurrentFunctionNode().getResultNode(), @@ -213,13 +217,13 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node enter(final ForNode forNode) { + public Node enterForNode(final ForNode forNode) { nest(forNode); return forNode; } @Override - public Node leave(final ForNode forNode) { + public Node leaveForNode(final ForNode forNode) { final Node test = forNode.getTest(); final Block body = forNode.getBody(); @@ -247,18 +251,16 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { LOG.info("START FunctionNode: " + functionNode.getName()); if (functionNode.isLazy()) { LOG.info("LAZY: " + functionNode.getName()); return null; } - + lexicalContext.push(functionNode); initFunctionNode(functionNode); - Node initialEvalResult = LiteralNode.newInstance(functionNode, ScriptRuntime.UNDEFINED); - nest(functionNode); /* @@ -272,60 +274,40 @@ final class Lower extends NodeOperatorVisitor { statements = new ArrayList<>(); lastStatement = null; - // for initial eval result is the last declared function - for (final FunctionNode nestedFunction : functionNode.getFunctions()) { - final IdentNode ident = nestedFunction.getIdent(); - if (ident != null && nestedFunction.isStatement()) { - initialEvalResult = new IdentNode(ident); - } - } - if (functionNode.needsSelfSymbol()) { //function needs to start with var funcIdent = __callee_; statements.add(functionNode.getSelfSymbolInit().accept(this)); } + NodeVisitor visitor = this; try { - // Every nested function needs a definition in the outer function with its name. Add these. - for (final FunctionNode nestedFunction : functionNode.getFunctions()) { - final VarNode varNode = nestedFunction.getFunctionVarNode(); - if (varNode != null) { - final LineNumberNode lineNumberNode = nestedFunction.getFunctionVarLineNumberNode(); - if (lineNumberNode != null) { - lineNumberNode.accept(this); - } - varNode.accept(this); - varNode.setIsFunctionVarNode(); - } - } - - if (functionNode.isScript()) { - new ExecuteNode(functionNode.getSource(), functionNode.getFirstToken(), functionNode.getFinish(), initialEvalResult).accept(this); - } - //do the statements - this fills the block with code + boolean needsInitialEvalResult = functionNode.isProgram(); for (final Node statement : functionNode.getStatements()) { - statement.accept(this); + // If this function is a program, then insert an assignment to the initial eval result after all + // function declarations. + if(needsInitialEvalResult && !(statement instanceof LineNumberNode || (statement instanceof VarNode && ((VarNode)statement).isFunctionDeclaration()))) { + addInitialEvalResult(functionNode); + needsInitialEvalResult = false; + } + statement.accept(visitor); //If there are unused terminated endpoints in the function, we need // to add a "return undefined" in those places for correct semantics LOG.info("Checking lastStatement="+lastStatement+" for terminal flags"); if (lastStatement != null && lastStatement.hasTerminalFlags()) { copyTerminal(functionNode, lastStatement); - break; + assert !needsInitialEvalResult; + visitor = new DeadCodeVarDeclarationVisitor(); } } - + if(needsInitialEvalResult) { + addInitialEvalResult(functionNode); + } functionNode.setStatements(statements); if (!functionNode.isTerminal()) { guaranteeReturn(functionNode); } - - //lower all nested functions - for (final FunctionNode nestedFunction : functionNode.getFunctions()) { - nestedFunction.accept(this); - } - } finally { statements = savedStatements; lastStatement = savedLastStatement; @@ -333,19 +315,67 @@ final class Lower extends NodeOperatorVisitor { LOG.info("END FunctionNode: " + functionNode.getName()); unnest(functionNode); + lexicalContext.pop(functionNode); functionNode.setState(CompilationState.LOWERED); return null; } + /** + * This visitor is used to go over statements after a terminal statement. Those statements are dead code, but the + * var declarations in them still have the effect of declaring a local variable on the function level. Therefore, + * they aren't really dead code and must be preserved. Note that they're only preserved as no-op declarations; their + * initializers are wiped out as those are, in fact, dead code. + */ + private class DeadCodeVarDeclarationVisitor extends NodeOperatorVisitor { + DeadCodeVarDeclarationVisitor() { + } + + @Override + public Node enterVarNode(VarNode varNode) { + // Can't ever see a function declaration, as this visitor is only ever used after a terminal statement was + // encountered, and all function declarations precede any terminal statements. + assert !varNode.isFunctionDeclaration(); + if(varNode.getInit() == null) { + // No initializer, just pass it to Lower. + return varNode.accept(Lower.this); + } + // Wipe out the initializer and then pass it to Lower. + return varNode.setInit(null).accept(Lower.this); + } + } + + private void addInitialEvalResult(final FunctionNode functionNode) { + new ExecuteNode(functionNode.getSource(), functionNode.getFirstToken(), functionNode.getFinish(), + getInitialEvalResult(functionNode)).accept(this); + } + + /** + * Result of initial result of evaluating a particular program, which is either the last function it declares, or + * undefined if it doesn't declare any functions. + * @param program + * @return the initial result of evaluating the program + */ + private static Node getInitialEvalResult(final FunctionNode program) { + IdentNode lastFnName = null; + for (final FunctionNode fn : program.getDeclaredFunctions()) { + assert fn.isDeclared(); + final IdentNode fnName = fn.getIdent(); + if(fnName != null) { + lastFnName = fnName; + } + } + return lastFnName != null ? new IdentNode(lastFnName) : LiteralNode.newInstance(program, ScriptRuntime.UNDEFINED); + } + @Override - public Node enter(final IfNode ifNode) { + public Node enterIfNode(final IfNode ifNode) { return nest(ifNode); } @Override - public Node leave(final IfNode ifNode) { + public Node leaveIfNode(final IfNode ifNode) { final Node pass = ifNode.getPass(); final Node fail = ifNode.getFail(); @@ -360,7 +390,7 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node enter(LabelNode labelNode) { + public Node enterLabelNode(LabelNode labelNode) { final Block body = labelNode.getBody(); body.accept(this); copyTerminal(labelNode, body); @@ -369,13 +399,13 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node enter(final LineNumberNode lineNumberNode) { + public Node enterLineNumberNode(final LineNumberNode lineNumberNode) { addStatement(lineNumberNode, false); // don't put it in lastStatement cache return null; } @Override - public Node enter(final ReturnNode returnNode) { + public Node enterReturnNode(final ReturnNode returnNode) { final TryNode tryNode = returnNode.getTryChain(); final Node expr = returnNode.getExpression(); @@ -413,19 +443,19 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node leave(final ReturnNode returnNode) { + public Node leaveReturnNode(final ReturnNode returnNode) { addStatement(returnNode); //ReturnNodes are always terminal, marked as such in constructor return returnNode; } @Override - public Node enter(final SwitchNode switchNode) { + public Node enterSwitchNode(final SwitchNode switchNode) { nest(switchNode); return switchNode; } @Override - public Node leave(final SwitchNode switchNode) { + public Node leaveSwitchNode(final SwitchNode switchNode) { unnest(switchNode); final List cases = switchNode.getCases(); @@ -446,13 +476,13 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node leave(final ThrowNode throwNode) { + public Node leaveThrowNode(final ThrowNode throwNode) { addStatement(throwNode); //ThrowNodes are always terminal, marked as such in constructor return throwNode; } @Override - public Node enter(final TryNode tryNode) { + public Node enterTryNode(final TryNode tryNode) { final Block finallyBody = tryNode.getFinallyBody(); final long token = tryNode.getToken(); final int finish = tryNode.getFinish(); @@ -538,26 +568,19 @@ final class Lower extends NodeOperatorVisitor { // set outer tryNode's body to innerTryNode final Block outerBody; - outerBody = new Block(source, token, finish, tryNode.getBody().getParent(), getCurrentFunctionNode()); + outerBody = new Block(source, token, finish); outerBody.setStatements(new ArrayList(Arrays.asList(innerTryNode))); tryNode.setBody(outerBody); tryNode.setCatchBlocks(null); - - // now before we go on, we have to fix the block parents - // (we repair the block tree after the insertion so that all references are intact) - innerTryNode.getBody().setParent(tryNode.getBody()); - for (final Block block : innerTryNode.getCatchBlocks()) { - block.setParent(tryNode.getBody()); - } } // create a catch-all that inlines finally and rethrows - final Block catchBlock = new Block(source, token, finish, getCurrentBlock(), getCurrentFunctionNode()); + final Block catchBlock = new Block(source, token, finish); //this catch block should get define symbol - final Block catchBody = new Block(source, token, finish, catchBlock, getCurrentFunctionNode()); - final Node catchAllFinally = finallyBody.clone(); + final Block catchBody = new Block(source, token, finish); + final Node catchAllFinally = finallyBody.copy(); catchBody.addStatement(new ExecuteNode(source, finallyBody.getToken(), finallyBody.getFinish(), catchAllFinally)); setTerminal(catchBody, true); @@ -584,7 +607,7 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node leave(final TryNode tryNode) { + public Node leaveTryNode(final TryNode tryNode) { final Block finallyBody = tryNode.getFinallyBody(); boolean allTerminal = tryNode.getBody().isTerminal() && (finallyBody == null || finallyBody.isTerminal()); @@ -608,18 +631,18 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node leave(final VarNode varNode) { + public Node leaveVarNode(final VarNode varNode) { addStatement(varNode); return varNode; } @Override - public Node enter(final WhileNode whileNode) { + public Node enterWhileNode(final WhileNode whileNode) { return nest(whileNode); } @Override - public Node leave(final WhileNode whileNode) { + public Node leaveWhileNode(final WhileNode whileNode) { final Node test = whileNode.getTest(); if (test == null) { @@ -653,7 +676,7 @@ final class Lower extends NodeOperatorVisitor { } @Override - public Node leave(final WithNode withNode) { + public Node leaveWithNode(final WithNode withNode) { if (withNode.getBody().isTerminal()) { setTerminal(withNode, true); } @@ -682,28 +705,10 @@ final class Lower extends NodeOperatorVisitor { */ private static Node markerFunction(final Node function) { if (function instanceof IdentNode) { - return new IdentNode((IdentNode)function) { - @Override - public boolean isFunction() { - return true; - } - }; - } else if (function instanceof AccessNode) { - return new AccessNode((AccessNode)function) { - @Override - public boolean isFunction() { - return true; - } - }; - } else if (function instanceof IndexNode) { - return new IndexNode((IndexNode)function) { - @Override - public boolean isFunction() { - return true; - } - }; + return ((IdentNode)function).setIsFunction(); + } else if (function instanceof BaseNode) { + return ((BaseNode)function).setIsFunction(); } - return function; } @@ -746,7 +751,7 @@ final class Lower extends NodeOperatorVisitor { if (args.size() >= 1 && EVAL.tag().equals(callee.getName())) { final CallNode.EvalArgs evalArgs = new CallNode.EvalArgs( - args.get(0).clone().accept(this), //clone as we use this for the "is eval case". original evaluated separately for "is not eval case" + args.get(0).copy().accept(this), //clone as we use this for the "is eval case". original evaluated separately for "is not eval case" getCurrentFunctionNode().getThisNode(), evalLocation(callee), getCurrentFunctionNode().isStrictMode()); @@ -773,13 +778,13 @@ final class Lower extends NodeOperatorVisitor { loopBody.accept(new NodeVisitor() { @Override - public Node leave(final BreakNode node) { + public Node leaveBreakNode(final BreakNode node) { escapes.add(node); return node; } @Override - public Node leave(final ContinueNode node) { + public Node leaveContinueNode(final ContinueNode node) { // all inner loops have been popped. if (nesting.contains(node.getTargetNode())) { escapes.add(node); @@ -794,7 +799,7 @@ final class Lower extends NodeOperatorVisitor { private void guaranteeReturn(final FunctionNode functionNode) { Node resultNode; - if (functionNode.isScript()) { + if (functionNode.isProgram()) { resultNode = functionNode.getResultNode(); // the eval result, symbol assigned in Attr } else { if (lastStatement != null && lastStatement.isTerminal() || lastStatement instanceof ReturnNode) { @@ -859,18 +864,15 @@ final class Lower extends NodeOperatorVisitor { * @return true if try block is inside the target, false otherwise. */ private boolean isNestedTry(final TryNode tryNode, final Block target) { - for (Block current = getCurrentBlock(); current != target; current = current.getParent()) { - if (tryNode.getBody() == current) { + for(Iterator blocks = lexicalContext.getBlocks(getCurrentBlock()); blocks.hasNext();) { + final Block block = blocks.next(); + if(block == target) { + return false; + } + if(tryNode.isChildBlock(block)) { return true; } - - for (final Block catchBlock : tryNode.getCatchBlocks()) { - if (catchBlock == current) { - return true; - } - } } - return false; } @@ -899,7 +901,7 @@ final class Lower extends NodeOperatorVisitor { continue; } - finallyBody = (Block)finallyBody.clone(); + finallyBody = (Block)finallyBody.copy(); final boolean hasTerminalFlags = finallyBody.hasTerminalFlags(); new ExecuteNode(finallyBody.getSource(), finallyBody.getToken(), finallyBody.getFinish(), finallyBody).accept(this); @@ -974,6 +976,3 @@ final class Lower extends NodeOperatorVisitor { } } - - - diff --git a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java index 4cd0f5246b5..ae40ed33bee 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/MethodEmitter.java @@ -651,11 +651,10 @@ public class MethodEmitter implements Emitter { /** * Load the constants array - * @param unitClassName name of the compile unit from which to load constants * @return this method emitter */ - MethodEmitter loadConstants(final String unitClassName) { - getStatic(unitClassName, CONSTANTS.tag(), CONSTANTS.descriptor()); + MethodEmitter loadConstants() { + getStatic(classEmitter.getUnitClassName(), CONSTANTS.tag(), CONSTANTS.descriptor()); assert peekType().isArray() : peekType(); return this; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java index b338ced5f47..f9a84f9181e 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java @@ -41,6 +41,7 @@ import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.LabelNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; @@ -49,6 +50,7 @@ import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.SwitchNode; import jdk.nashorn.internal.ir.WhileNode; +import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.Source; @@ -70,6 +72,8 @@ final class Splitter extends NodeVisitor { /** Cache for calculated block weights. */ private final Map weightCache = new HashMap<>(); + private final LexicalContext lexicalContext = new LexicalContext(); + /** Weight threshold for when to start a split. */ public static final long SPLIT_THRESHOLD = Options.getIntProperty("nashorn.compiler.splitter.threshold", 32 * 1024); @@ -112,7 +116,7 @@ final class Splitter extends NodeVisitor { } if (weight >= SPLIT_THRESHOLD) { - weight = splitBlock(functionNode); + weight = splitBlock(functionNode, functionNode); } if (functionNode.isSplit()) { @@ -132,9 +136,20 @@ final class Splitter extends NodeVisitor { } // Recursively split nested functions - for (final FunctionNode function : functionNode.getFunctions()) { - new Splitter(compiler, function, outermostCompileUnit).split(); - } + functionNode.accept(new NodeOperatorVisitor() { + @Override + public Node enterFunctionNode(FunctionNode function) { + if(function == functionNode) { + // Don't process outermost function (it was already processed) but descend into it to find nested + // functions. + return function; + } + // Process a nested function + new Splitter(compiler, function, outermostCompileUnit).split(); + // Don't descend into a a nested function; Splitter.split() has taken care of nested-in-nested functions. + return null; + } + }); functionNode.setState(CompilationState.SPLIT); } @@ -155,7 +170,7 @@ final class Splitter extends NodeVisitor { * * @return new weight for the resulting block. */ - private long splitBlock(final Block block) { + private long splitBlock(final Block block, final FunctionNode function) { functionNode.setIsSplit(); final List splits = new ArrayList<>(); @@ -167,7 +182,7 @@ final class Splitter extends NodeVisitor { if (statementsWeight + weight >= SPLIT_THRESHOLD || statement.isTerminal()) { if (!statements.isEmpty()) { - splits.add(createBlockSplitNode(block, statements, statementsWeight)); + splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); statements = new ArrayList<>(); statementsWeight = 0; } @@ -183,7 +198,7 @@ final class Splitter extends NodeVisitor { } if (!statements.isEmpty()) { - splits.add(createBlockSplitNode(block, statements, statementsWeight)); + splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); } block.setStatements(splits); @@ -199,13 +214,13 @@ final class Splitter extends NodeVisitor { * * @return New split node. */ - private SplitNode createBlockSplitNode(final Block parent, final List statements, final long weight) { + private SplitNode createBlockSplitNode(final Block parent, final FunctionNode function, final List statements, final long weight) { final Source source = parent.getSource(); final long token = parent.getToken(); final int finish = parent.getFinish(); - final String name = parent.getFunction().uniqueName(SPLIT_PREFIX.tag()); + final String name = function.uniqueName(SPLIT_PREFIX.tag()); - final Block newBlock = new Block(source, token, finish, parent, functionNode); + final Block newBlock = new Block(source, token, finish); newBlock.setFrame(new Frame(parent.getFrame())); newBlock.setStatements(statements); @@ -217,15 +232,17 @@ final class Splitter extends NodeVisitor { } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { if (block.isCatchBlock()) { return null; } + lexicalContext.push(block); final long weight = WeighNodes.weigh(block, weightCache); if (weight < SPLIT_THRESHOLD) { weightCache.put(block, weight); + lexicalContext.pop(block); return null; } @@ -233,23 +250,24 @@ final class Splitter extends NodeVisitor { } @Override - public Node leave(final Block block) { + public Node leaveBlock(final Block block) { assert !block.isCatchBlock(); // Block was heavier than SLIT_THRESHOLD in enter, but a sub-block may have // been split already, so weigh again before splitting. long weight = WeighNodes.weigh(block, weightCache); if (weight >= SPLIT_THRESHOLD) { - weight = splitBlock(block); + weight = splitBlock(block, lexicalContext.getFunction(block)); } weightCache.put(block, weight); + lexicalContext.pop(block); return block; } @SuppressWarnings("rawtypes") @Override - public Node leave(final LiteralNode literal) { + public Node leaveLiteralNode(final LiteralNode literal) { long weight = WeighNodes.weigh(literal); if (weight < SPLIT_THRESHOLD) { @@ -294,17 +312,12 @@ final class Splitter extends NodeVisitor { } @Override - public Node enter(final FunctionNode node) { - if (node.isLazy()) { - return null; + public Node enterFunctionNode(final FunctionNode node) { + if(node == functionNode && !node.isLazy()) { + lexicalContext.push(node); + node.visitStatements(this); + lexicalContext.pop(node); } - - final List statements = node.getStatements(); - - for (final Node statement : statements) { - statement.accept(this); - } - return null; } @@ -321,38 +334,38 @@ final class Splitter extends NodeVisitor { } @Override - public Node enter(final LabelNode labelNode) { + public Node enterLabelNode(final LabelNode labelNode) { registerJumpTarget(labelNode.getBreakNode()); registerJumpTarget(labelNode.getContinueNode()); return labelNode; } @Override - public Node enter(final WhileNode whileNode) { + public Node enterWhileNode(final WhileNode whileNode) { registerJumpTarget(whileNode); return whileNode; } @Override - public Node enter(final DoWhileNode doWhileNode) { + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { registerJumpTarget(doWhileNode); return doWhileNode; } @Override - public Node enter(final ForNode forNode) { + public Node enterForNode(final ForNode forNode) { registerJumpTarget(forNode); return forNode; } @Override - public Node enter(final SwitchNode switchNode) { + public Node enterSwitchNode(final SwitchNode switchNode) { registerJumpTarget(switchNode); return switchNode; } @Override - public Node enter(final ReturnNode returnNode) { + public Node enterReturnNode(final ReturnNode returnNode) { for (final SplitNode split : splitStack) { split.setHasReturn(true); } @@ -360,25 +373,25 @@ final class Splitter extends NodeVisitor { } @Override - public Node enter(final ContinueNode continueNode) { + public Node enterContinueNode(final ContinueNode continueNode) { searchJumpTarget(continueNode.getTargetNode(), continueNode.getTargetLabel()); return continueNode; } @Override - public Node enter(final BreakNode breakNode) { + public Node enterBreakNode(final BreakNode breakNode) { searchJumpTarget(breakNode.getTargetNode(), breakNode.getTargetLabel()); return breakNode; } @Override - public Node enter(final SplitNode splitNode) { + public Node enterSplitNode(final SplitNode splitNode) { splitStack.addFirst(splitNode); return splitNode; } @Override - public Node leave(final SplitNode splitNode) { + public Node leaveSplitNode(final SplitNode splitNode) { assert splitNode == splitStack.peekFirst(); splitStack.removeFirst(); return splitNode; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java b/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java index 9f2e8be44e0..18bd95527c4 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java @@ -47,7 +47,6 @@ import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode.ArrayUnit; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.PropertyNode; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.SplitNode; @@ -80,7 +79,7 @@ final class WeighNodes extends NodeOperatorVisitor { private static final long LITERAL_WEIGHT = 10; private static final long LOOP_WEIGHT = 4; private static final long NEW_WEIGHT = 6; - private static final long REFERENCE_WEIGHT = 20; + private static final long FUNC_EXPR_WEIGHT = 20; private static final long RETURN_WEIGHT = 2; private static final long SPLIT_WEIGHT = 40; private static final long SWITCH_WEIGHT = 8; @@ -94,36 +93,37 @@ final class WeighNodes extends NodeOperatorVisitor { /** Optional cache for weight of block nodes. */ private final Map weightCache; - /* + private final FunctionNode topFunction; + + /** * Constructor * * @param weightCache cache of already calculated block weights */ - private WeighNodes(final Map weightCache) { + private WeighNodes(FunctionNode topFunction, final Map weightCache) { super(null, null); + this.topFunction = topFunction; this.weightCache = weightCache; } static long weigh(final Node node) { - final WeighNodes weighNodes = new WeighNodes(null); - node.accept(weighNodes); - return weighNodes.weight; + return weigh(node, null); } static long weigh(final Node node, final Map weightCache) { - final WeighNodes weighNodes = new WeighNodes(weightCache); + final WeighNodes weighNodes = new WeighNodes(node instanceof FunctionNode ? (FunctionNode)node : null, weightCache); node.accept(weighNodes); return weighNodes.weight; } @Override - public Node leave(final AccessNode accessNode) { + public Node leaveAccessNode(final AccessNode accessNode) { weight += ACCESS_WEIGHT; return accessNode; } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { if (weightCache != null && weightCache.containsKey(block)) { weight += weightCache.get(block); return null; @@ -133,78 +133,79 @@ final class WeighNodes extends NodeOperatorVisitor { } @Override - public Node leave(final BreakNode breakNode) { + public Node leaveBreakNode(final BreakNode breakNode) { weight += BREAK_WEIGHT; return breakNode; } @Override - public Node leave(final CallNode callNode) { + public Node leaveCallNode(final CallNode callNode) { weight += CALL_WEIGHT; return callNode; } @Override - public Node leave(final CatchNode catchNode) { + public Node leaveCatchNode(final CatchNode catchNode) { weight += CATCH_WEIGHT; return catchNode; } @Override - public Node leave(final ContinueNode continueNode) { + public Node leaveContinueNode(final ContinueNode continueNode) { weight += CONTINUE_WEIGHT; return continueNode; } @Override - public Node leave(final DoWhileNode doWhileNode) { + public Node leaveDoWhileNode(final DoWhileNode doWhileNode) { weight += LOOP_WEIGHT; return doWhileNode; } @Override - public Node leave(final ExecuteNode executeNode) { + public Node leaveExecuteNode(final ExecuteNode executeNode) { return executeNode; } @Override - public Node leave(final ForNode forNode) { + public Node leaveForNode(final ForNode forNode) { weight += LOOP_WEIGHT; return forNode; } @Override - public Node enter(final FunctionNode functionNode) { - final List statements = functionNode.getStatements(); - - for (final Node statement : statements) { - statement.accept(this); + public Node enterFunctionNode(final FunctionNode functionNode) { + if(functionNode == topFunction) { + // the function being weighted; descend into its statements + functionNode.visitStatements(this); + } else { + // just a reference to inner function from outer function + weight += FUNC_EXPR_WEIGHT; } - return null; } @Override - public Node leave(final IdentNode identNode) { + public Node leaveIdentNode(final IdentNode identNode) { weight += ACCESS_WEIGHT + identNode.getName().length() * 2; return identNode; } @Override - public Node leave(final IfNode ifNode) { + public Node leaveIfNode(final IfNode ifNode) { weight += IF_WEIGHT; return ifNode; } @Override - public Node leave(final IndexNode indexNode) { + public Node leaveIndexNode(final IndexNode indexNode) { weight += ACCESS_WEIGHT; return indexNode; } @SuppressWarnings("rawtypes") @Override - public Node enter(final LiteralNode literalNode) { + public Node enterLiteralNode(final LiteralNode literalNode) { weight += LITERAL_WEIGHT; if (literalNode instanceof ArrayLiteralNode) { @@ -230,67 +231,61 @@ final class WeighNodes extends NodeOperatorVisitor { } @Override - public Node leave(final PropertyNode propertyNode) { + public Node leavePropertyNode(final PropertyNode propertyNode) { weight += LITERAL_WEIGHT; return propertyNode; } @Override - public Node leave(final ReferenceNode referenceNode) { - weight += REFERENCE_WEIGHT; - return referenceNode; - } - - @Override - public Node leave(final ReturnNode returnNode) { + public Node leaveReturnNode(final ReturnNode returnNode) { weight += RETURN_WEIGHT; return returnNode; } @Override - public Node leave(final RuntimeNode runtimeNode) { + public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { weight += CALL_WEIGHT; return runtimeNode; } @Override - public Node enter(final SplitNode splitNode) { + public Node enterSplitNode(final SplitNode splitNode) { weight += SPLIT_WEIGHT; return null; } @Override - public Node leave(final SwitchNode switchNode) { + public Node leaveSwitchNode(final SwitchNode switchNode) { weight += SWITCH_WEIGHT; return switchNode; } @Override - public Node leave(final ThrowNode throwNode) { + public Node leaveThrowNode(final ThrowNode throwNode) { weight += THROW_WEIGHT; return throwNode; } @Override - public Node leave(final TryNode tryNode) { + public Node leaveTryNode(final TryNode tryNode) { weight += THROW_WEIGHT; return tryNode; } @Override - public Node leave(final VarNode varNode) { + public Node leaveVarNode(final VarNode varNode) { weight += VAR_WEIGHT; return varNode; } @Override - public Node leave(final WhileNode whileNode) { + public Node leaveWhileNode(final WhileNode whileNode) { weight += LOOP_WEIGHT; return whileNode; } @Override - public Node leave(final WithNode withNode) { + public Node leaveWithNode(final WithNode withNode) { weight += WITH_WEIGHT; return withNode; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java b/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java index 481e3855447..b7b76684147 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/AccessNode.java @@ -36,7 +36,7 @@ import jdk.nashorn.internal.runtime.Source; * IR representation of a property access (period operator.) * */ -public class AccessNode extends BaseNode implements TypeOverride { +public class AccessNode extends BaseNode implements TypeOverride { /** Property ident. */ private IdentNode property; @@ -56,9 +56,7 @@ public class AccessNode extends BaseNode implements TypeOverride { super(source, token, finish, base); this.start = base.getStart(); - this.property = property; - - this.property.setIsPropertyName(); + this.property = property.setIsPropertyName(); } /** @@ -106,10 +104,10 @@ public class AccessNode extends BaseNode implements TypeOverride { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterAccessNode(this) != null) { base = base.accept(visitor); property = (IdentNode)property.accept(visitor); - return visitor.leave(this); + return visitor.leaveAccessNode(this); } return this; @@ -150,13 +148,14 @@ public class AccessNode extends BaseNode implements TypeOverride { } @Override - public void setType(final Type type) { + public AccessNode setType(final Type type) { if (DEBUG_FIELDS && !Type.areEquivalent(getSymbol().getSymbolType(), type)) { ObjectClassGenerator.LOG.info(getClass().getName() + " " + this + " => " + type + " instead of " + getType()); } - property.setType(type); + property = property.setType(type); getSymbol().setTypeOverride(type); //always a temp so this is fine. hasCallSiteType = true; + return this; } @Override diff --git a/nashorn/src/jdk/nashorn/internal/ir/Assignment.java b/nashorn/src/jdk/nashorn/internal/ir/Assignment.java index 8107a8725f0..0c531bc2906 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Assignment.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Assignment.java @@ -46,4 +46,11 @@ public interface Assignment { * @return get the assignment source node */ public Node getAssignmentSource(); + + /** + * Set assignment destination node. + * @param n the assignment destination node. + * @return a node equivalent to this one except for the requested change. + */ + public Node setAssignmentDest(D n); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java b/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java index ea632d1b672..26a28368877 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BaseNode.java @@ -38,6 +38,8 @@ public abstract class BaseNode extends Node implements FunctionCall { /** Base Node. */ protected Node base; + private boolean function; + /** * Constructor * @@ -96,6 +98,15 @@ public abstract class BaseNode extends Node implements FunctionCall { @Override public boolean isFunction() { - return false; + return function; + } + + /** + * Mark this node as being the callee operand of a {@link CallNode}. + * @return a base node identical to this one in all aspects except with its function flag set. + */ + public BaseNode setIsFunction() { + function = true; + return this; } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java index 26964ba5ca5..42c7a6cceda 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java @@ -35,7 +35,7 @@ import jdk.nashorn.internal.runtime.Source; */ public class BinaryNode extends UnaryNode { /** Left hand side argument. */ - protected Node lhs; + private Node lhs; /** * Constructor @@ -139,6 +139,11 @@ public class BinaryNode extends UnaryNode { return isAssignment() ? lhs() : null; } + @Override + public Node setAssignmentDest(Node n) { + return setLHS(n); + } + @Override public Node getAssignmentSource() { return rhs(); @@ -163,10 +168,9 @@ public class BinaryNode extends UnaryNode { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - lhs = lhs.accept(visitor); - rhs = rhs.accept(visitor); - return visitor.leave(this); + if (visitor.enterBinaryNode(this) != null) { + // TODO: good cause for a separate visitMembers: we could delegate to UnaryNode.visitMembers + return visitor.leaveBinaryNode((BinaryNode)setLHS(lhs.accept(visitor)).setRHS(rhs().accept(visitor))); } return this; @@ -229,8 +233,12 @@ public class BinaryNode extends UnaryNode { /** * Set the left hand side expression for this node * @param lhs new left hand side expression + * @return a node equivalent to this one except for the requested change. */ - public void setLHS(final Node lhs) { - this.lhs = lhs; + public BinaryNode setLHS(final Node lhs) { + if(this.lhs == lhs) return this; + final BinaryNode n = (BinaryNode)clone(); + n.lhs = lhs; + return n; } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/Block.java b/nashorn/src/jdk/nashorn/internal/ir/Block.java index e729d307b8c..6f138f85f10 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Block.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Block.java @@ -25,14 +25,6 @@ package jdk.nashorn.internal.ir; -import static jdk.nashorn.internal.ir.Symbol.IS_GLOBAL; -import static jdk.nashorn.internal.ir.Symbol.IS_INTERNAL; -import static jdk.nashorn.internal.ir.Symbol.IS_LET; -import static jdk.nashorn.internal.ir.Symbol.IS_PARAM; -import static jdk.nashorn.internal.ir.Symbol.IS_SCOPE; -import static jdk.nashorn.internal.ir.Symbol.IS_VAR; -import static jdk.nashorn.internal.ir.Symbol.KINDMASK; - import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; @@ -40,9 +32,9 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import jdk.nashorn.internal.codegen.Frame; import jdk.nashorn.internal.codegen.Label; -import jdk.nashorn.internal.ir.annotations.Reference; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.Source; @@ -51,14 +43,6 @@ import jdk.nashorn.internal.runtime.Source; * basis for script body. */ public class Block extends Node { - /** Parent context */ - @Reference - private Block parent; - - /** Owning function - a FunctionNode has itself as function */ - @Reference - protected FunctionNode function; - /** List of statements */ protected List statements; @@ -83,14 +67,10 @@ public class Block extends Node { * @param source source code * @param token token * @param finish finish - * @param parent reference to parent block - * @param function function node this block is in */ - public Block(final Source source, final long token, final int finish, final Block parent, final FunctionNode function) { + public Block(final Source source, final long token, final int finish) { super(source, token, finish); - this.parent = parent; - this.function = function; this.statements = new ArrayList<>(); this.symbols = new HashMap<>(); this.entryLabel = new Label("block_entry"); @@ -106,8 +86,6 @@ public class Block extends Node { protected Block(final Block block, final CopyState cs) { super(block); - this.parent = block.parent; - this.function = block.function; this.statements = new ArrayList<>(); for (final Node statement : block.getStatements()) { statements.add(cs.existingOrCopy(statement)); @@ -122,55 +100,7 @@ public class Block extends Node { @Override protected Node copy(final CopyState cs) { - return fixBlockChain(new Block(this, cs)); - } - - /** - * Whenever a clone that contains a hierarchy of blocks is created, - * this function has to be called to ensure that the parents point - * to the correct parent blocks or two different ASTs would not - * be completely separated. - * - * @return the argument - */ - static Block fixBlockChain(final Block root) { - root.accept(new NodeVisitor() { - private Block parent = root.getParent(); - private final FunctionNode function = root.getFunction(); - - @Override - public Node enter(final Block block) { - assert block.getFunction() == function; - block.setParent(parent); - parent = block; - - return block; - } - - @Override - public Node leave(final Block block) { - parent = block.getParent(); - - return block; - } - - @Override - public Node enter(final FunctionNode functionNode) { - assert functionNode.getFunction() == function; - - return enter((Block)functionNode); - } - - @Override - public Node leave(final FunctionNode functionNode) { - assert functionNode.getFunction() == function; - - return leave((Block)functionNode); - } - - }); - - return root; + return new Block(this, cs); } /** @@ -188,17 +118,12 @@ public class Block extends Node { } /** - * Prepend a statement to the statement list + * Prepend statements to the statement list * - * @param statement Statement node to add + * @param prepended statement to add */ - public void prependStatement(final Node statement) { - if (statement != null) { - final List newStatements = new ArrayList<>(); - newStatements.add(statement); - newStatements.addAll(statements); - setStatements(newStatements); - } + public void prependStatements(final List prepended) { + statements.addAll(0, prepended); } /** @@ -210,39 +135,6 @@ public class Block extends Node { statements.addAll(statementList); } - /** - * Add a new function to the function list. - * - * @param functionNode Function node to add. - */ - public void addFunction(final FunctionNode functionNode) { - assert parent != null : "Parent context missing."; - - parent.addFunction(functionNode); - } - - /** - * Add a list of functions to the function list. - * - * @param functionNodes Function nodes to add. - */ - public void addFunctions(final List functionNodes) { - assert parent != null : "Parent context missing."; - - parent.addFunctions(functionNodes); - } - - /** - * Set the function list to a new one - * - * @param functionNodes the nodes to set - */ - public void setFunctions(final List functionNodes) { - assert parent != null : "Parent context missing."; - - parent.setFunctions(functionNodes); - } - /** * Assist in IR navigation. * @@ -257,13 +149,9 @@ public class Block extends Node { try { // Ignore parent to avoid recursion. - if (visitor.enter(this) != null) { - for (int i = 0, count = statements.size(); i < count; i++) { - final Node statement = statements.get(i); - statements.set(i, statement.accept(visitor)); - } - - return visitor.leave(this); + if (visitor.enterBlock(this) != null) { + visitStatements(visitor); + return visitor.leaveBlock(this); } } finally { visitor.setCurrentBlock(saveBlock); @@ -281,51 +169,13 @@ public class Block extends Node { } /** - * Search for symbol. - * - * @param name Symbol name. - * - * @return Found symbol or null if not found. + * Retrieves an existing symbol defined in the current block. + * @param name the name of the symbol + * @return an existing symbol with the specified name defined in the current block, or null if this block doesn't + * define a symbol with this name. */ - public Symbol findSymbol(final String name) { - // Search up block chain to locate symbol. - - for (Block block = this; block != null; block = block.getParent()) { - // Find name. - final Symbol symbol = block.symbols.get(name); - // If found then we are good. - if (symbol != null) { - return symbol; - } - } - return null; - } - - /** - * Search for symbol in current function. - * - * @param name Symbol name. - * - * @return Found symbol or null if not found. - */ - public Symbol findLocalSymbol(final String name) { - // Search up block chain to locate symbol. - for (Block block = this; block != null; block = block.getParent()) { - // Find name. - final Symbol symbol = block.symbols.get(name); - // If found then we are good. - if (symbol != null) { - return symbol; - } - - // If searched function then we are done. - if (block == block.function) { - break; - } - } - - // Not found. - return null; + public Symbol getExistingSymbol(final String name) { + return symbols.get(name); } /** @@ -338,122 +188,6 @@ public class Block extends Node { return statements.size() == 1 && statements.get(0) instanceof CatchNode; } - /** - * Test to see if a symbol is local to the function. - * - * @param symbol Symbol to test. - * @return True if a local symbol. - */ - public boolean isLocal(final Symbol symbol) { - // some temp symbols have no block, so can be assumed local - final Block block = symbol.getBlock(); - return block == null || block.getFunction() == function; - } - - /** - * Declare the definition of a new symbol. - * - * @param name Name of symbol. - * @param symbolFlags Symbol flags. - * @param node Defining Node. - * - * @return Symbol for given name or null for redefinition. - */ - public Symbol defineSymbol(final String name, final int symbolFlags, final Node node) { - int flags = symbolFlags; - Symbol symbol = findSymbol(name); // Locate symbol. - - if ((flags & KINDMASK) == IS_GLOBAL) { - flags |= IS_SCOPE; - } - - if (symbol != null) { - // Symbol was already defined. Check if it needs to be redefined. - if ((flags & KINDMASK) == IS_PARAM) { - if (!function.isLocal(symbol)) { - // Not defined in this function. Create a new definition. - symbol = null; - } else if (symbol.isParam()) { - // Duplicate parameter. Null return will force an error. - assert false : "duplicate parameter"; - return null; - } - } else if ((flags & KINDMASK) == IS_VAR) { - if ((flags & IS_INTERNAL) == IS_INTERNAL || (flags & Symbol.IS_LET) == Symbol.IS_LET) { - assert !((flags & IS_LET) == IS_LET && symbol.getBlock() == this) : "duplicate let variable in block"; - // Always create a new definition. - symbol = null; - } else { - // Not defined in this function. Create a new definition. - if (!function.isLocal(symbol) || symbol.less(IS_VAR)) { - symbol = null; - } - } - } - } - - if (symbol == null) { - // If not found, then create a new one. - Block symbolBlock; - - // Determine where to create it. - if ((flags & Symbol.KINDMASK) == IS_VAR && ((flags & IS_INTERNAL) == IS_INTERNAL || (flags & IS_LET) == IS_LET)) { - symbolBlock = this; - } else { - symbolBlock = getFunction(); - } - - // Create and add to appropriate block. - symbol = new Symbol(name, flags, node, symbolBlock); - symbolBlock.putSymbol(name, symbol); - - if ((flags & Symbol.KINDMASK) != IS_GLOBAL) { - symbolBlock.getFrame().addSymbol(symbol); - symbol.setNeedsSlot(true); - } - } else if (symbol.less(flags)) { - symbol.setFlags(flags); - } - - if (node != null) { - node.setSymbol(symbol); - } - - return symbol; - } - - /** - * Declare the use of a symbol. - * - * @param name Name of symbol. - * @param node Using node - * - * @return Symbol for given name. - */ - public Symbol useSymbol(final String name, final Node node) { - Symbol symbol = findSymbol(name); - - if (symbol == null) { - // If not found, declare as a free var. - symbol = defineSymbol(name, IS_GLOBAL, node); - } else { - node.setSymbol(symbol); - } - - return symbol; - } - - /** - * Add parent name to the builder. - * - * @param sb String bulder. - */ - public void addParentName(final StringBuilder sb) { - if (parent != null) { - parent.addParentName(sb); - } - } - @Override public void toString(final StringBuilder sb) { for (final Node statement : statements) { @@ -511,16 +245,6 @@ public class Block extends Node { return frame; } - /** - * Get the FunctionNode for this block, i.e. the function it - * belongs to - * - * @return the function node - */ - public FunctionNode getFunction() { - return function; - } - /** * Reset the frame for this block * @@ -530,24 +254,6 @@ public class Block extends Node { this.frame = frame; } - /** - * Get the parent block - * - * @return parent block, or null if none exists - */ - public Block getParent() { - return parent; - } - - /** - * Set the parent block - * - * @param parent the new parent block - */ - public void setParent(final Block parent) { - this.parent = parent; - } - /** * Get the list of statements in this block * @@ -557,6 +263,15 @@ public class Block extends Node { return Collections.unmodifiableList(statements); } + /** + * Applies the specified visitor to all statements in the block. + * @param visitor the visitor. + */ + public void visitStatements(NodeVisitor visitor) { + for (ListIterator stmts = statements.listIterator(); stmts.hasNext();) { + stmts.set(stmts.next().accept(visitor)); + } + } /** * Reset the statement list for this block * @@ -592,4 +307,29 @@ public class Block extends Node { needsScope = true; } + /** + * Marks this block as using a specified scoped symbol. The block and its parent blocks up to but not + * including the block defining the symbol will be marked as needing parent scope. The block defining the symbol + * will be marked as one that needs to have its own scope. + * @param symbol the symbol being used. + * @param ancestors the iterator over block's containing lexical context + */ + public void setUsesScopeSymbol(final Symbol symbol, Iterator ancestors) { + if(symbol.getBlock() == this) { + setNeedsScope(); + } else { + setUsesParentScopeSymbol(symbol, ancestors); + } + } + + /** + * Invoked when this block uses a scope symbol defined in one of its ancestors. + * @param symbol the scope symbol being used + * @param ancestors iterator over ancestor blocks + */ + void setUsesParentScopeSymbol(final Symbol symbol, Iterator ancestors) { + if(ancestors.hasNext()) { + ancestors.next().setUsesScopeSymbol(symbol, ancestors); + } + } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java b/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java index 81c572d4b1b..7ad0dc6d143 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BreakNode.java @@ -64,8 +64,8 @@ public class BreakNode extends LabeledNode { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); + if (visitor.enterBreakNode(this) != null) { + return visitor.leaveBreakNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java index 387369e62be..3410709caa6 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java @@ -37,7 +37,7 @@ import jdk.nashorn.internal.runtime.Source; * IR representation for a function call. * */ -public class CallNode extends Node implements TypeOverride { +public class CallNode extends Node implements TypeOverride { private Type type; @@ -176,13 +176,13 @@ public class CallNode extends Node implements TypeOverride { if (hasCallSiteType()) { return type; } - assert !function.getType().isUnknown(); - return function.getType(); + return function instanceof FunctionNode ? ((FunctionNode)function).getReturnType() : Type.OBJECT; } @Override - public void setType(final Type type) { + public CallNode setType(final Type type) { this.type = type; + return this; } private boolean hasCallSiteType() { @@ -208,14 +208,14 @@ public class CallNode extends Node implements TypeOverride { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterCallNode(this) != null) { function = function.accept(visitor); for (int i = 0, count = args.size(); i < count; i++) { args.set(i, args.get(i).accept(visitor)); } - return visitor.leave(this); + return visitor.leaveCallNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java index 928ba5bec61..61b892179d1 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java @@ -79,7 +79,7 @@ public class CaseNode extends BreakableNode { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterCaseNode(this) != null) { if (test != null) { test = test.accept(visitor); } @@ -87,7 +87,7 @@ public class CaseNode extends BreakableNode { body = (Block)body.accept(visitor); } - return visitor.leave(this); + return visitor.leaveCaseNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java index 187c3949ec2..005ffa8e008 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CatchNode.java @@ -84,7 +84,7 @@ public class CatchNode extends Node { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterCatchNode(this) != null) { exception = (IdentNode)exception.accept(visitor); if (exceptionCondition != null) { @@ -92,7 +92,7 @@ public class CatchNode extends Node { } body = (Block)body.accept(visitor); - return visitor.leave(this); + return visitor.leaveCatchNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java b/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java index 2063d6b2525..cbc7bff2a60 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ContinueNode.java @@ -61,8 +61,8 @@ public class ContinueNode extends LabeledNode { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); + if (visitor.enterContinueNode(this) != null) { + return visitor.leaveContinueNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/DoWhileNode.java b/nashorn/src/jdk/nashorn/internal/ir/DoWhileNode.java index 476643a1c2a..3939795e248 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/DoWhileNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/DoWhileNode.java @@ -63,11 +63,11 @@ public class DoWhileNode extends WhileNode { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterDoWhileNode(this) != null) { body = (Block)body.accept(visitor); test = test.accept(visitor); - return visitor.leave(this); + return visitor.leaveDoWhileNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java b/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java index 0bfacd5d5a0..15330a37288 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/EmptyNode.java @@ -57,8 +57,8 @@ public class EmptyNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); + if (visitor.enterEmptyNode(this) != null) { + return visitor.leaveEmptyNode(this); } return this; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java b/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java index 501468bb9a6..8ae7d556f3c 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ExecuteNode.java @@ -85,9 +85,9 @@ public class ExecuteNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterExecuteNode(this) != null) { setExpression(expression.accept(visitor)); - return visitor.leave(this); + return visitor.leaveExecuteNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/ForNode.java b/nashorn/src/jdk/nashorn/internal/ir/ForNode.java index 53b56752acc..e55054dde1f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ForNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ForNode.java @@ -76,7 +76,7 @@ public class ForNode extends WhileNode { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterForNode(this) != null) { if (init != null) { init = init.accept(visitor); } @@ -91,7 +91,7 @@ public class ForNode extends WhileNode { body = (Block)body.accept(visitor); - return visitor.leave(this); + return visitor.leaveForNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index 7fd77cd0471..2b0e109b7fa 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -34,7 +34,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.LinkedList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Stack; @@ -47,7 +47,7 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Parser; -import jdk.nashorn.internal.runtime.Debug; +import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.UserAccessorProperty; import jdk.nashorn.internal.runtime.linker.LinkerCallSite; @@ -57,6 +57,8 @@ import jdk.nashorn.internal.runtime.linker.LinkerCallSite; */ public class FunctionNode extends Block { + private static final Type FUNCTION_TYPE = Type.typeFor(ScriptFunction.class); + /** Function kinds */ public enum Kind { /** a normal function - nothing special */ @@ -112,9 +114,6 @@ public class FunctionNode extends Block { /** List of parameters. */ private List parameters; - /** List of nested functions. */ - private List functions; - /** First token of function. **/ private long firstToken; @@ -157,10 +156,6 @@ public class FunctionNode extends Block { /** Pending control list. */ private final Stack controlStack; - /** Variable declarations in the function's scope */ - @Ignore - private final List declarations; - /** VarNode for this function statement */ @Ignore //this is explicit code anyway and should not be traversed after lower private VarNode funcVarNode; @@ -184,33 +179,35 @@ public class FunctionNode extends Block { private int flags; /** Is anonymous function flag. */ - private static final int IS_ANONYMOUS = 0b0000_0000_0000_0001; - /** Is statement flag */ - private static final int IS_STATEMENT = 0b0000_0000_0000_0010; + private static final int IS_ANONYMOUS = 1 << 0; + /** Is the function created in a function declaration (as opposed to a function expression) */ + private static final int IS_DECLARED = 1 << 1; /** is this a strict mode function? */ - private static final int IS_STRICT_MODE = 0b0000_0000_0000_0100; + private static final int IS_STRICT_MODE = 1 << 2; /** Does the function use the "arguments" identifier ? */ - private static final int USES_ARGUMENTS = 0b0000_0000_0000_1000; + private static final int USES_ARGUMENTS = 1 << 3; /** Are we lowered ? */ - private static final int IS_LOWERED = 0b0000_0000_0001_0000; + private static final int IS_LOWERED = 1 << 4; /** Has this node been split because it was too large? */ - private static final int IS_SPLIT = 0b0000_0000_0010_0000; + private static final int IS_SPLIT = 1 << 5; /** Does the function call eval? */ - private static final int HAS_EVAL = 0b0000_0000_0100_0000; + private static final int HAS_EVAL = 1 << 6; /** Does the function contain a with block ? */ - private static final int HAS_WITH = 0b0000_0000_1000_0000; + private static final int HAS_WITH = 1 << 7; /** Does a descendant function contain a with or eval? */ - private static final int HAS_DESCENDANT_WITH_OR_EVAL = 0b0000_0001_0000_0000; + private static final int HAS_DESCENDANT_WITH_OR_EVAL = 1 << 8; /** Does the function define "arguments" identifier as a parameter of nested function name? */ - private static final int DEFINES_ARGUMENTS = 0b0000_0010_0000_0000; + private static final int DEFINES_ARGUMENTS = 1 << 9; /** Does the function need a self symbol? */ - private static final int NEEDS_SELF_SYMBOL = 0b0000_0100_0000_0000; + private static final int NEEDS_SELF_SYMBOL = 1 << 10; /** Does this function or any of its descendants use variables from an ancestor function's scope (incl. globals)? */ - private static final int USES_ANCESTOR_SCOPE = 0b0000_1000_0000_0000; + private static final int USES_ANCESTOR_SCOPE = 1 << 11; /** Is this function lazily compiled? */ - private static final int IS_LAZY = 0b0001_0000_0000_0000; + private static final int IS_LAZY = 1 << 12; /** Does this function have lazy, yet uncompiled children */ - private static final int HAS_LAZY_CHILDREN = 0b0010_0000_0000_0000; + private static final int HAS_LAZY_CHILDREN = 1 << 13; + /** Does this function have lazy, yet uncompiled children */ + private static final int IS_PROGRAM = 1 << 14; /** Does this function or any nested functions contain a with or an eval? */ private static final int HAS_DEEP_WITH_OR_EVAL = HAS_EVAL | HAS_WITH | HAS_DESCENDANT_WITH_OR_EVAL; @@ -225,14 +222,6 @@ public class FunctionNode extends Block { /** What is the return type of this function? */ private Type returnType = Type.UNKNOWN; - /** - * Used to keep track of a function's parent blocks. - * This is needed when a (finally body) block is cloned than contains inner functions. - * Does not include function.getParent(). - */ - @Ignore - private List referencingParentBlocks; - /** * Constructor * @@ -240,42 +229,28 @@ public class FunctionNode extends Block { * @param token token * @param finish finish * @param namespace the namespace - * @param parent the parent block * @param ident the identifier * @param name the name of the function */ - @SuppressWarnings("LeakingThisInConstructor") - public FunctionNode(final Source source, final long token, final int finish, final Namespace namespace, final Block parent, final IdentNode ident, final String name) { - super(source, token, finish, parent, null); + public FunctionNode(final Source source, final long token, final int finish, final Namespace namespace, final IdentNode ident, final String name) { + super(source, token, finish); this.ident = ident; this.name = name; this.kind = Kind.NORMAL; this.parameters = new ArrayList<>(); - this.functions = new ArrayList<>(); this.firstToken = token; this.lastToken = token; this.namespace = namespace; this.labelStack = new Stack<>(); this.controlStack = new Stack<>(); - this.declarations = new ArrayList<>(); - // my block -> function is this. We added @SuppressWarnings("LeakingThisInConstructor") as NetBeans identifies - // it as such a leak - this is a false positive as we're setting this into a field of the object being - // constructed, so it can't be seen from other threads. - this.function = this; this.compilationState = EnumSet.of(CompilationState.INITIALIZED); this.specializedTypes = new HashMap<>(); } - @SuppressWarnings("LeakingThisInConstructor") private FunctionNode(final FunctionNode functionNode, final CopyState cs) { super(functionNode, cs); - this.functions = new ArrayList<>(); - for (final FunctionNode f : functionNode.getFunctions()) { - this.functions.add((FunctionNode)cs.existingOrCopy(f)); - } - this.ident = (IdentNode)cs.existingOrCopy(functionNode.ident); this.name = functionNode.name; this.kind = functionNode.kind; @@ -296,22 +271,12 @@ public class FunctionNode extends Block { this.calleeNode = (IdentNode)cs.existingOrCopy(functionNode.calleeNode); this.labelStack = new Stack<>(); this.controlStack = new Stack<>(); - this.declarations = new ArrayList<>(); - - for (final VarNode decl : functionNode.getDeclarations()) { - declarations.add((VarNode) cs.existingOrCopy(decl)); //TODO same? - } this.flags = functionNode.flags; this.funcVarNode = (VarNode)cs.existingOrCopy(functionNode.funcVarNode); /** VarNode for this function statement */ - // my block -> function is this. We added @SuppressWarnings("LeakingThisInConstructor") as NetBeans identifies - // it as such a leak - this is a false positive as we're setting this into a field of the object being - // constructed, so it can't be seen from other threads. - this.function = this; - this.compilationState = EnumSet.copyOf(functionNode.compilationState); this.specializedTypes = new HashMap<>(); } @@ -319,21 +284,21 @@ public class FunctionNode extends Block { @Override protected Node copy(final CopyState cs) { // deep clone all parent blocks - return fixBlockChain(new FunctionNode(this, cs)); + return new FunctionNode(this, cs); } @Override public Node accept(final NodeVisitor visitor) { - final FunctionNode saveFunctionNode = visitor.getCurrentFunctionNode(); - final Block saveBlock = visitor.getCurrentBlock(); + final FunctionNode saveFunctionNode = visitor.getCurrentFunctionNode(); + final Block saveBlock = visitor.getCurrentBlock(); + final MethodEmitter saveMethodEmitter = visitor.getCurrentMethodEmitter(); + final CompileUnit saveCompileUnit = visitor.getCurrentCompileUnit(); visitor.setCurrentFunctionNode(this); - visitor.setCurrentCompileUnit(getCompileUnit()); - visitor.setCurrentMethodEmitter(getMethodEmitter()); visitor.setCurrentBlock(this); try { - if (visitor.enter(this) != null) { + if (visitor.enterFunctionNode(this) != null) { if (ident != null) { ident = (IdentNode)ident.accept(visitor); } @@ -342,51 +307,25 @@ public class FunctionNode extends Block { parameters.set(i, (IdentNode)parameters.get(i).accept(visitor)); } - for (int i = 0, count = functions.size(); i < count; i++) { - functions.set(i, (FunctionNode)functions.get(i).accept(visitor)); - } - for (int i = 0, count = statements.size(); i < count; i++) { statements.set(i, statements.get(i).accept(visitor)); } - return visitor.leave(this); + return visitor.leaveFunctionNode(this); } } finally { visitor.setCurrentBlock(saveBlock); visitor.setCurrentFunctionNode(saveFunctionNode); - visitor.setCurrentCompileUnit(saveFunctionNode != null ? saveFunctionNode.getCompileUnit() : null); - visitor.setCurrentMethodEmitter(saveFunctionNode != null ? saveFunctionNode.getMethodEmitter() : null); + visitor.setCurrentCompileUnit(saveCompileUnit); + visitor.setCurrentMethodEmitter(saveMethodEmitter); } return this; } - /** - * Locate the parent function. - * - * @return Parent function. - */ - public FunctionNode findParentFunction() { - return getParent() != null ? getParent().getFunction() : null; - } - - /** - * Add parent name to the builder. - * - * @param sb String builder. - */ - @Override - public void addParentName(final StringBuilder sb) { - if (!isScript()) { - sb.append(getName()); - sb.append("$"); - } - } - @Override public boolean needsScope() { - return super.needsScope() || isScript(); + return super.needsScope() || isProgram(); } /** @@ -544,12 +483,18 @@ public class FunctionNode extends Block { } /** - * Determine if script function. - * - * @return True if script function. + * Returns true if the function is the top-level program. + * @return True if this function node represents the top-level program. */ - public boolean isScript() { - return getParent() == null; + public boolean isProgram() { + return (flags & IS_PROGRAM) != 0; + } + + /** + * Marks the function as representing the top-level program. + */ + public void setProgram() { + flags |= IS_PROGRAM; } /** @@ -589,31 +534,31 @@ public class FunctionNode extends Block { /** * Flag this function as using the {@code with} keyword + * @param ancestors the iterator over functions in this functions's containing lexical context */ - public void setHasWith() { + public void setHasWith(final Iterator ancestors) { if(!hasWith()) { this.flags |= HAS_WITH; // with requires scope in parents. // TODO: refine this. with should not force all variables in parents to be in scope, only those that are // actually referenced as identifiers by name - markParentForWithOrEval(); + markParentForWithOrEval(ancestors); } } - private void markParentForWithOrEval() { + private void markParentForWithOrEval(final Iterator ancestors) { // If this is invoked, then either us or a descendant uses with or eval, meaning we must have our own scope. setNeedsScope(); - final FunctionNode parentFunction = findParentFunction(); - if(parentFunction != null) { - parentFunction.setDescendantHasWithOrEval(); + if(ancestors.hasNext()) { + ancestors.next().setDescendantHasWithOrEval(ancestors); } } - private void setDescendantHasWithOrEval() { + private void setDescendantHasWithOrEval(final Iterator ancestors) { if((flags & HAS_DESCENDANT_WITH_OR_EVAL) == 0) { flags |= HAS_DESCENDANT_WITH_OR_EVAL; - markParentForWithOrEval(); + markParentForWithOrEval(ancestors); } } @@ -628,11 +573,12 @@ public class FunctionNode extends Block { /** * Flag this function as calling the {@code eval} function + * @param ancestors the iterator over functions in this functions's containing lexical context */ - public void setHasEval() { + public void setHasEval(final Iterator ancestors) { if(!hasEval()) { this.flags |= HAS_EVAL; - markParentForWithOrEval(); + markParentForWithOrEval(ancestors); } } @@ -665,11 +611,34 @@ public class FunctionNode extends Block { } /** - * Get all nested functions - * @return list of nested functions in this function + * Returns a list of functions declared by this function. Only includes declared functions, and does not include any + * function expressions that might occur in its body. + * @return a list of functions declared by this function. */ - public List getFunctions() { - return Collections.unmodifiableList(functions); + public List getDeclaredFunctions() { + // Note that the function does not have a dedicated list of declared functions, but rather relies on the + // invariant that all function declarations are at the beginning of the statement list as VarNode with a + // FunctionNode marked as statement with its variable initializer. Every VarNode is also preceded by a + // LineNumberNode. This invariant is established by the parser and has to be preserved in visitors. + final List fns = new ArrayList<>(); + for (final Node stmt : statements) { + if(stmt instanceof LineNumberNode) { + continue; + } else if(stmt instanceof VarNode) { + final Node init = ((VarNode)stmt).getInit(); + if(init instanceof FunctionNode) { + final FunctionNode fn = (FunctionNode)init; + if(fn.isDeclared()) { + fns.add(fn); + continue; + } + } + } + // Node is neither a LineNumberNode, nor a function declaration VarNode. Since all function declarations are + // at the start of the function, we've reached the end of function declarations. + break; + } + return fns; } /** @@ -801,7 +770,7 @@ public class FunctionNode extends Block { public boolean needsArguments() { // uses "arguments" or calls eval, but it does not redefine "arguments", and finally, it's not a script, since // for top-level script, "arguments" is picked up from Context by Global.init() instead. - return (flags & MAYBE_NEEDS_ARGUMENTS) != 0 && (flags & DEFINES_ARGUMENTS) == 0 && !isScript(); + return (flags & MAYBE_NEEDS_ARGUMENTS) != 0 && (flags & DEFINES_ARGUMENTS) == 0 && !isProgram(); } /** @@ -820,7 +789,7 @@ public class FunctionNode extends Block { * @return true if the function needs parent scope. */ public boolean needsParentScope() { - return (flags & NEEDS_PARENT_SCOPE) != 0 || isScript(); + return (flags & NEEDS_PARENT_SCOPE) != 0 || isProgram(); } /** @@ -880,7 +849,7 @@ public class FunctionNode extends Block { * @return true if all variables should be in scope */ public boolean allVarsInScope() { - return isScript() || (flags & HAS_ALL_VARS_IN_SCOPE) != 0; + return isProgram() || (flags & HAS_ALL_VARS_IN_SCOPE) != 0; } /** @@ -989,19 +958,19 @@ public class FunctionNode extends Block { } /** - * Check if this function is a statement - * @return true if function is a statement + * Check if this function is created as a function declaration (as opposed to function expression) + * @return true if function is declared. */ - public boolean isStatement() { - return (flags & IS_STATEMENT) != 0; + public boolean isDeclared() { + return (flags & IS_DECLARED) != 0; } /** - * Flag this function as a statement + * Flag this function as being created as a function declaration (as opposed to a function expression). * @see Parser */ - public void setIsStatement() { - this.flags |= IS_STATEMENT; + public void setIsDeclared() { + this.flags |= IS_DECLARED; } /** @@ -1049,35 +1018,16 @@ public class FunctionNode extends Block { } /** - * Marks this function as one using any global symbol. The function and all its parent functions will all be marked - * as needing parent scope. - * @see #needsParentScope() + * Marks this function as using any of its ancestors' scopes. */ - public void setUsesGlobalSymbol() { + public void setUsesAncestorScope() { this.flags |= USES_ANCESTOR_SCOPE; - final FunctionNode parentFn = findParentFunction(); - if(parentFn != null) { - parentFn.setUsesGlobalSymbol(); - } } - /** - * Marks this function as using a specified scoped symbol. The function and its parent functions up to but not - * including the function defining the symbol will be marked as needing parent scope. The function defining the - * symbol will be marked as one that needs to have its own scope. - * @param symbol the symbol being used. - * @see #needsParentScope() - */ - public void setUsesScopeSymbol(final Symbol symbol) { - if(symbol.getBlock() == this) { - setNeedsScope(); - } else { - this.flags |= USES_ANCESTOR_SCOPE; - final FunctionNode parentFn = findParentFunction(); - if (parentFn != null) { - parentFn.setUsesScopeSymbol(symbol); - } - } + @Override + void setUsesParentScopeSymbol(Symbol symbol, Iterator ancestors) { + setUsesAncestorScope(); + super.setUsesParentScopeSymbol(symbol, ancestors); } /** @@ -1152,7 +1102,7 @@ public class FunctionNode extends Block { @Override public Type getType() { - return getReturnType(); + return FUNCTION_TYPE; } /** @@ -1211,56 +1161,6 @@ public class FunctionNode extends Block { return (flags & IS_LOWERED) != 0; } - /** - * Add a new function to the function list. - * - * @param functionNode Function node to add. - */ - @Override - public void addFunction(final FunctionNode functionNode) { - assert functionNode != null; - functions.add(functionNode); - } - - /** - * Add a list of functions to the function list. - * - * @param functionNodes Function nodes to add. - */ - @Override - public void addFunctions(final List functionNodes) { - functions.addAll(functionNodes); - } - - /** - * Set a function list - * - * @param functionNodes to set - */ - @Override - public void setFunctions(final List functionNodes) { - this.functions = functionNodes; - } - - /** - * Add a variable declaration that should be visible to the entire function - * scope. Parser does this. - * - * @param varNode a var node - */ - public void addDeclaration(final VarNode varNode) { - declarations.add(varNode); - } - - /** - * Return all variable declarations from this function scope - * - * @return all VarNodes in scope - */ - public List getDeclarations() { - return Collections.unmodifiableList(declarations); - } - /** * Get the compile unit used to compile this function * @see Compiler @@ -1294,32 +1194,4 @@ public class FunctionNode extends Block { public void setMethodEmitter(final MethodEmitter method) { this.method = method; } - - /** - * Each FunctionNode maintains a list of reference to its parent blocks. - * Add a parent block to this function. - * - * @param parentBlock a block to remember as parent - */ - public void addReferencingParentBlock(final Block parentBlock) { - assert parentBlock.getFunction() == function.findParentFunction() : Debug.id(parentBlock.getFunction()) + "!=" + Debug.id(function.findParentFunction()); // all parent blocks must be in the same function - if (parentBlock != function.getParent()) { - if (referencingParentBlocks == null) { - referencingParentBlocks = new LinkedList<>(); - } - referencingParentBlocks.add(parentBlock); - } - } - - /** - * Get the known parent blocks to this function - * - * @return list of parent blocks - */ - public List getReferencingParentBlocks() { - if (referencingParentBlocks == null) { - return Collections.emptyList(); - } - return Collections.unmodifiableList(referencingParentBlocks); - } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java index b0570a25ce5..889a870041e 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java @@ -38,18 +38,18 @@ import jdk.nashorn.internal.runtime.Source; /** * IR representation for an identifier. */ -public class IdentNode extends Node implements PropertyKey, TypeOverride, FunctionCall { +public class IdentNode extends Node implements PropertyKey, TypeOverride, FunctionCall { + private static final int PROPERTY_NAME = 1 << 0; + private static final int INITIALIZED_HERE = 1 << 1; + private static final int FUNCTION = 1 << 2; + /** Identifier. */ private final String name; /** Type for a callsite, e.g. X in a get()X or a set(X)V */ private Type callSiteType; - /** flag for an ident that is the property name of an AccessNode. */ - private boolean isPropertyName; - - /** flag for an ident on the left hand side of var lhs = rhs;. */ - private boolean isInitializedHere; + private byte flags; /** * Constructor @@ -71,9 +71,8 @@ public class IdentNode extends Node implements PropertyKey, TypeOverride, Functi */ public IdentNode(final IdentNode identNode) { super(identNode); - this.name = identNode.getName(); - this.isPropertyName = identNode.isPropertyName; - this.isInitializedHere = identNode.isInitializedHere; + this.name = identNode.getName(); + this.flags = identNode.flags; } @Override @@ -92,12 +91,17 @@ public class IdentNode extends Node implements PropertyKey, TypeOverride, Functi } @Override - public void setType(final Type type) { + public IdentNode setType(final Type type) { if (DEBUG_FIELDS && getSymbol() != null && !Type.areEquivalent(getSymbol().getSymbolType(), type)) { ObjectClassGenerator.LOG.info(getClass().getName() + " " + this + " => " + type + " instead of " + getType()); } - this.callSiteType = type; // do NOT, repeat NOT touch the symbol here. it might be a local variable or whatever. This is the override if it isn't + if(this.callSiteType == type) { + return this; + } + final IdentNode n = (IdentNode)clone(); + n.callSiteType = type; + return n; } @Override @@ -131,8 +135,8 @@ public class IdentNode extends Node implements PropertyKey, TypeOverride, Functi */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); + if (visitor.enterIdentNode(this) != null) { + return visitor.leaveIdentNode(this); } return this; @@ -179,14 +183,18 @@ public class IdentNode extends Node implements PropertyKey, TypeOverride, Functi * @return true if this is a property name */ public boolean isPropertyName() { - return isPropertyName; + return (flags & PROPERTY_NAME) != 0; } /** * Flag this IdentNode as a property name + * @return a node equivalent to this one except for the requested change. */ - public void setIsPropertyName() { - isPropertyName = true; + public IdentNode setIsPropertyName() { + if(isPropertyName()) return this; + final IdentNode n = (IdentNode)clone(); + n.flags |= PROPERTY_NAME; + return n; } /** @@ -194,14 +202,18 @@ public class IdentNode extends Node implements PropertyKey, TypeOverride, Functi * @return true if IdentNode is initialized on creation */ public boolean isInitializedHere() { - return isInitializedHere; + return (flags & INITIALIZED_HERE) != 0; } /** * Flag IdentNode to be initialized on creation + * @return a node equivalent to this one except for the requested change. */ - public void setIsInitializedHere() { - isInitializedHere = true; + public IdentNode setIsInitializedHere() { + if(isInitializedHere()) return this; + final IdentNode n = (IdentNode)clone(); + n.flags |= INITIALIZED_HERE; + return n; } /** @@ -216,6 +228,17 @@ public class IdentNode extends Node implements PropertyKey, TypeOverride, Functi @Override public boolean isFunction() { - return false; + return (flags & FUNCTION) != 0; + } + + /** + * Mark this node as being the callee operand of a {@link CallNode}. + * @return an ident node identical to this one in all aspects except with its function flag set. + */ + public IdentNode setIsFunction() { + if(isFunction()) return this; + final IdentNode n = (IdentNode)clone(); + n.flags |= FUNCTION; + return n; } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/IfNode.java b/nashorn/src/jdk/nashorn/internal/ir/IfNode.java index 81148c3867c..3ddcf1dc440 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IfNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IfNode.java @@ -75,7 +75,7 @@ public class IfNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterIfNode(this) != null) { test = test.accept(visitor); pass = (Block)pass.accept(visitor); @@ -84,7 +84,7 @@ public class IfNode extends Node { fail = (Block)fail.accept(visitor); } - return visitor.leave(this); + return visitor.leaveIfNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java b/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java index 9feb5ebf2bf..4745bf64211 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IndexNode.java @@ -36,7 +36,7 @@ import jdk.nashorn.internal.runtime.Source; * IR representation of an indexed access (brackets operator.) * */ -public class IndexNode extends BaseNode implements TypeOverride { +public class IndexNode extends BaseNode implements TypeOverride { /** Property ident. */ private Node index; @@ -92,10 +92,10 @@ public class IndexNode extends BaseNode implements TypeOverride { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterIndexNode(this) != null) { base = base.accept(visitor); index = index.accept(visitor); - return visitor.leave(this); + return visitor.leaveIndexNode(this); } return this; @@ -144,12 +144,13 @@ public class IndexNode extends BaseNode implements TypeOverride { } @Override - public void setType(final Type type) { + public IndexNode setType(final Type type) { if (DEBUG_FIELDS && !Type.areEquivalent(getSymbol().getSymbolType(), type)) { ObjectClassGenerator.LOG.info(getClass().getName() + " " + this + " => " + type + " instead of " + getType()); } hasCallSiteType = true; getSymbol().setTypeOverride(type); + return this; } @Override diff --git a/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java b/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java index c61bfcbd107..756ea2dfb9b 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LabelNode.java @@ -81,10 +81,10 @@ public class LabelNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterLabelNode(this) != null) { label = (IdentNode)label.accept(visitor); body = (Block)body.accept(visitor); - return visitor.leave(this); + return visitor.leaveLabelNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java b/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java new file mode 100644 index 00000000000..2db1f7963e5 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java @@ -0,0 +1,198 @@ +package jdk.nashorn.internal.ir; + +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * A class that tracks the current lexical context of node visitation as a stack of {@link Block} nodes. Has special + * methods to retrieve useful subsets of the context. + */ +public class LexicalContext implements Cloneable { + private final Deque lexicalContext; + + /** + * Creates a new empty lexical context. + */ + public LexicalContext() { + lexicalContext = new ArrayDeque<>(); + } + + /** + * Pushes a new block on top of the context, making it the innermost open block. + * @param block the new block + */ + public void push(Block block) { + //new Exception(block.toString()).printStackTrace(); + lexicalContext.push(block); + } + + /** + * Pops the innermost block off the context. + * @param the block expected to be popped, used to detect unbalanced pushes/pops + */ + public void pop(Block block) { + final Block popped = lexicalContext.pop(); + assert popped == block; + } + + /** + * Returns an iterator over all blocks in the context, with the top block (innermost lexical context) first. + * @return an iterator over all blocks in the context. + */ + public Iterator getBlocks() { + return lexicalContext.iterator(); + } + + /** + * Returns an iterator over all functions in the context, with the top (innermost open) function first. + * @return an iterator over all functions in the context. + */ + public Iterator getFunctions() { + return new FunctionIterator(getBlocks()); + } + + private static final class FunctionIterator implements Iterator { + private final Iterator it; + private FunctionNode next; + + FunctionIterator(Iterator it) { + this.it = it; + next = findNext(); + } + + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public FunctionNode next() { + if(next == null) { + throw new NoSuchElementException(); + } + FunctionNode lnext = next; + next = findNext(); + return lnext; + } + + private FunctionNode findNext() { + while(it.hasNext()) { + final Block block = it.next(); + if(block instanceof FunctionNode) { + return ((FunctionNode)block); + } + } + return null; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + } + + /** + * Returns an iterator over all ancestors block of the given block, with its parent block first. + * @param block the block whose ancestors are returned + * @return an iterator over all ancestors block of the given block. + */ + public Iterator getAncestorBlocks(Block block) { + final Iterator it = getBlocks(); + while(it.hasNext()) { + final Block b = it.next(); + if(block == b) { + return it; + } + } + throw new AssertionError("Block is not on the current lexical context stack"); + } + + /** + * Returns an iterator over a block and all its ancestors blocks, with the block first. + * @param block the block that is the starting point of the iteration. + * @return an iterator over a block and all its ancestors. + */ + public Iterator getBlocks(final Block block) { + final Iterator it = getAncestorBlocks(block); + return new Iterator() { + boolean blockReturned = false; + @Override + public boolean hasNext() { + return it.hasNext() || !blockReturned; + } + @Override + public Block next() { + if(blockReturned) { + return it.next(); + } + blockReturned = true; + return block; + } + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + + /** + * Returns the closest function node to the block. If the block is itself a function, it is returned. + * @param block the block + * @return the function closest to the block. + * @see #getParentFunction(Block) + */ + public FunctionNode getFunction(Block block) { + if(block instanceof FunctionNode) { + return (FunctionNode)block; + } + return getParentFunction(block); + } + + /** + * Returns the closest function node to the block and all its ancestor functions. If the block is itself a function, + * it is returned too. + * @param block the block + * @return the closest function node to the block and all its ancestor functions. + */ + public Iterator getFunctions(final Block block) { + return new FunctionIterator(getBlocks(block)); + } + + /** + * Returns the containing function of the block. If the block is itself a function, its parent function is returned. + * @param block the block + * @return the containing function of the block. + * @see #getFunction(Block) + */ + public FunctionNode getParentFunction(Block block) { + return getFirstFunction(getAncestorBlocks(block)); + } + + private static FunctionNode getFirstFunction(Iterator it) { + while(it.hasNext()) { + final Block ancestor = it.next(); + if(ancestor instanceof FunctionNode) { + return (FunctionNode)ancestor; + } + } + return null; + } + + /** + * Returns the innermost block in the context. + * @return the innermost block in the context. + */ + public Block getCurrentBlock() { + return lexicalContext.element(); + } + + /** + * Returns the innermost function in the context. + * @return the innermost function in the context. + */ + public FunctionNode getCurrentFunction() { + return getFirstFunction(getBlocks()); + } +} diff --git a/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java b/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java index ef1c05e13e8..c7912ff09e0 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LineNumberNode.java @@ -63,8 +63,8 @@ public class LineNumberNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); + if (visitor.enterLineNumberNode(this) != null) { + return visitor.leaveLineNumberNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java index f1bf1b80c64..cc424b7aad3 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java @@ -46,7 +46,7 @@ import jdk.nashorn.internal.runtime.Undefined; */ public abstract class LiteralNode extends Node implements PropertyKey { /** Literal value */ - protected T value; + protected final T value; /** * Constructor @@ -67,8 +67,17 @@ public abstract class LiteralNode extends Node implements PropertyKey { * @param literalNode source node */ protected LiteralNode(final LiteralNode literalNode) { + this(literalNode, literalNode.value); + } + + /** + * A copy constructor with value change. + * @param literalNode the original literal node + * @param newValue new value for this node + */ + protected LiteralNode(final LiteralNode literalNode, final T newValue) { super(literalNode); - this.value = literalNode.value; + this.value = newValue; } @Override @@ -217,8 +226,8 @@ public abstract class LiteralNode extends Node implements PropertyKey { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); + if (visitor.enterLiteralNode(this) != null) { + return visitor.leaveLiteralNode(this); } return this; @@ -544,6 +553,10 @@ public abstract class LiteralNode extends Node implements PropertyKey { super(literalNode); } + private NodeLiteralNode(final LiteralNode literalNode, final Node value) { + super(literalNode, value); + } + @Override protected Node copy(final CopyState cs) { return new NodeLiteralNode(this); @@ -551,11 +564,14 @@ public abstract class LiteralNode extends Node implements PropertyKey { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterLiteralNode(this) != null) { if (value != null) { - value = value.accept(visitor); + final Node newValue = value.accept(visitor); + if(value != newValue) { + return visitor.leaveLiteralNode(new NodeLiteralNode(this, newValue)); + } } - return visitor.leave(this); + return visitor.leaveLiteralNode(this); } return this; @@ -878,14 +894,14 @@ public abstract class LiteralNode extends Node implements PropertyKey { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterLiteralNode(this) != null) { for (int i = 0; i < value.length; i++) { final Node element = value[i]; if (element != null) { value[i] = element.accept(visitor); } } - return visitor.leave(this); + return visitor.leaveLiteralNode(this); } return this; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/Location.java b/nashorn/src/jdk/nashorn/internal/ir/Location.java index 16ee680dabf..c8e01dd35f8 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Location.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Location.java @@ -65,7 +65,11 @@ public class Location implements Cloneable { @Override protected Object clone() { - return new Location(this); + try { + return super.clone(); + } catch(CloneNotSupportedException e) { + throw new AssertionError(e); + } } @Override diff --git a/nashorn/src/jdk/nashorn/internal/ir/Node.java b/nashorn/src/jdk/nashorn/internal/ir/Node.java index 24ad87936bb..c5f01337a2b 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Node.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Node.java @@ -165,11 +165,18 @@ public abstract class Node extends Location { return true; } - setIsResolved(); + setIsResolved(true); return false; } + /** + * Reset the resolved flag. + */ + public void resetResolved() { + setIsResolved(false); + } + /** * Is this a debug info node like LineNumberNode etc? * @@ -234,8 +241,7 @@ public abstract class Node extends Location { * * @return Deep copy of the Node. */ - @Override - public final Node clone() { + public final Node copy() { return copy(new CopyState()); } @@ -349,10 +355,10 @@ public abstract class Node extends Location { } /** - * Flag this node as resolved, i.e. code has been generated for it + * Flag this node as resolved or not, i.e. code has been generated for it */ - public void setIsResolved() { - this.isResolved = true; + private void setIsResolved(boolean isResolved) { + this.isResolved = isResolved; } /** diff --git a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java index 8b720de41b0..f6724a62c45 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java @@ -72,12 +72,12 @@ public class ObjectNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterObjectNode(this) != null) { for (int i = 0, count = elements.size(); i < count; i++) { elements.set(i, elements.get(i).accept(visitor)); } - return visitor.leave(this); + return visitor.leaveObjectNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java b/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java index 75103377b39..a6bc49de894 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/PropertyNode.java @@ -88,7 +88,7 @@ public class PropertyNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterPropertyNode(this) != null) { key = (PropertyKey)((Node)key).accept(visitor); if (value != null) { @@ -103,7 +103,7 @@ public class PropertyNode extends Node { setter = setter.accept(visitor); } - return visitor.leave(this); + return visitor.leavePropertyNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/ReferenceNode.java b/nashorn/src/jdk/nashorn/internal/ir/ReferenceNode.java deleted file mode 100644 index 3cae7b522c9..00000000000 --- a/nashorn/src/jdk/nashorn/internal/ir/ReferenceNode.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2010, 2013, 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 jdk.nashorn.internal.ir; - -import jdk.nashorn.internal.ir.annotations.Reference; -import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; - -/** - * IR representation of a reference to another entity (function.) - */ -public class ReferenceNode extends Node { - /** Node referenced. */ - @Reference - private final FunctionNode reference; - - /** - * Constructor - * - * @param source the source - * @param token token - * @param finish finish - * @param reference the function node to reference - */ - public ReferenceNode(final Source source, final long token, final int finish, final FunctionNode reference) { - super(source, token, finish); - - this.reference = reference; - } - - private ReferenceNode(final ReferenceNode referenceNode) { - super(referenceNode); - - this.reference = referenceNode.reference; - } - - @Override - protected Node copy(final CopyState cs) { - return new ReferenceNode(this); - } - - @Override - public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - return visitor.leave(this); - } - - return this; - } - - @Override - public void toString(final StringBuilder sb) { - if (reference == null) { - sb.append("null"); - } else { - reference.toString(sb); - } - } - - /** - * Get there function node reference that this node points tp - * @return a function node reference - */ - public FunctionNode getReference() { - return reference; - } - -} diff --git a/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java b/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java index 35395b30d79..1400f395868 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ReturnNode.java @@ -100,12 +100,12 @@ public class ReturnNode extends Node { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterReturnNode(this) != null) { if (expression != null) { expression = expression.accept(visitor); } - return visitor.leave(this); + return visitor.leaveReturnNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java index bfc47d1871a..461007cdcd8 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java @@ -38,7 +38,7 @@ import jdk.nashorn.internal.runtime.Source; * IR representation for a runtime call. * */ -public class RuntimeNode extends Node implements TypeOverride { +public class RuntimeNode extends Node implements TypeOverride { /** * Request enum used for meta-information about the runtime request @@ -393,8 +393,9 @@ public class RuntimeNode extends Node implements TypeOverride { } @Override - public void setType(final Type type) { + public RuntimeNode setType(final Type type) { this.callSiteType = type; + return this; } @Override @@ -408,12 +409,12 @@ public class RuntimeNode extends Node implements TypeOverride { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterRuntimeNode(this) != null) { for (int i = 0, count = args.size(); i < count; i++) { args.set(i, args.get(i).accept(visitor)); } - return visitor.leave(this); + return visitor.leaveRuntimeNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java b/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java index c09a4f025a6..b751cdcbec0 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/SplitNode.java @@ -108,10 +108,10 @@ public class SplitNode extends Node { visitor.setCurrentMethodEmitter(getMethodEmitter()); try { - if (visitor.enter(this) != null) { + if (visitor.enterSplitNode(this) != null) { body = body.accept(visitor); - return visitor.leave(this); + return visitor.leaveSplitNode(this); } } finally { visitor.setCurrentCompileUnit(saveCompileUnit); diff --git a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java index 068398ee375..23d9c7eaee7 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java @@ -85,7 +85,7 @@ public class SwitchNode extends BreakableNode { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterSwitchNode(this) != null) { expression = expression.accept(visitor); for (int i = 0, count = cases.size(); i < count; i++) { @@ -94,7 +94,7 @@ public class SwitchNode extends BreakableNode { //the default case is in the cases list and should not be explicitly traversed! - return visitor.leave(this); + return visitor.leaveSwitchNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/Symbol.java b/nashorn/src/jdk/nashorn/internal/ir/Symbol.java index a58a7c14961..603b8b08329 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Symbol.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Symbol.java @@ -38,31 +38,31 @@ import jdk.nashorn.internal.runtime.options.Options; */ public final class Symbol implements Comparable { - /** Symbol flags. Kind ordered by precedence. */ - public static final int IS_TEMP = 0b0000_0001; + /** Symbol kinds. Kind ordered by precedence. */ + public static final int IS_TEMP = 1; /** Is this Global */ - public static final int IS_GLOBAL = 0b0000_0010; + public static final int IS_GLOBAL = 2; /** Is this a variable */ - public static final int IS_VAR = 0b0000_0011; + public static final int IS_VAR = 3; /** Is this a parameter */ - public static final int IS_PARAM = 0b0000_0100; + public static final int IS_PARAM = 4; /** Is this a constant */ - public static final int IS_CONSTANT = 0b0000_0101; - - static final int KINDMASK = 0b0000_1111; + public static final int IS_CONSTANT = 5; + /** Mask for kind flags */ + public static final int KINDMASK = (1 << 3) - 1; // Kinds are represented by lower three bits /** Is this scope */ - public static final int IS_SCOPE = 0b0000_0001_0000; + public static final int IS_SCOPE = 1 << 4; /** Is this a this symbol */ - public static final int IS_THIS = 0b0000_0010_0000; + public static final int IS_THIS = 1 << 5; /** Can this symbol ever be undefined */ - public static final int CAN_BE_UNDEFINED = 0b0000_0100_0000; + public static final int CAN_BE_UNDEFINED = 1 << 6; /** Can this symbol ever have primitive types */ - public static final int CAN_BE_PRIMITIVE = 0b0000_1000_0000; + public static final int CAN_BE_PRIMITIVE = 1 << 7; /** Is this a let */ - public static final int IS_LET = 0b0001_0000_0000; + public static final int IS_LET = 1 << 8; /** Is this an internal symbol, never represented explicitly in source code */ - public static final int IS_INTERNAL = 0b0010_0000_0000; + public static final int IS_INTERNAL = 1 << 9; /** Null or name identifying symbol. */ private final String name; @@ -269,15 +269,6 @@ public final class Symbol implements Comparable { return type.isCategory2() ? 2 : 1; } - /** - * Return the defining function (scope.) - * - * @return Defining function. - */ - public FunctionNode findFunction() { - return block != null ? block.getFunction() : null; - } - @Override public boolean equals(final Object other) { if (!(other instanceof Symbol)) { @@ -486,27 +477,6 @@ public final class Symbol implements Comparable { flags |= IS_LET; } - /** - * Check if this symbol can be accessed directly with a putfield or getfield or dynamic load - * - * @param currentFunction function to check for fast scope - * @return true if fast scope - */ - public boolean isFastScope(final FunctionNode currentFunction) { - if (!isScope() || !block.needsScope()) { - return false; - } - // Allow fast scope access if no parent function contains with or eval - FunctionNode func = currentFunction; - while (func != null) { - if (func.hasWith() || func.hasEval()) { - return false; - } - func = func.findParentFunction(); - } - return true; - } - /** * Get the block in which the symbol is defined * @return a block @@ -651,7 +621,7 @@ public final class Symbol implements Comparable { * @return true if this this is a global scope symbol */ public boolean isTopLevel() { - return block instanceof FunctionNode && ((FunctionNode) block).isScript(); + return block instanceof FunctionNode && ((FunctionNode) block).isProgram(); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java index a82991f9ab9..de333851d95 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/TernaryNode.java @@ -77,11 +77,11 @@ public class TernaryNode extends BinaryNode { @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - lhs = lhs.accept(visitor); - rhs = rhs.accept(visitor); - third = third.accept(visitor); - return visitor.leave(this); + if (visitor.enterTernaryNode(this) != null) { + final Node newLhs = lhs().accept(visitor); + final Node newRhs = rhs().accept(visitor); + final Node newThird = third.accept(visitor); + return visitor.leaveTernaryNode((TernaryNode)setThird(newThird).setLHS(newLhs).setRHS(newRhs)); } return this; @@ -133,8 +133,12 @@ public class TernaryNode extends BinaryNode { /** * Reset the "third" node for this ternary expression, i.e. "z" in x ? y : z * @param third a node + * @return a node equivalent to this one except for the requested change. */ - public void setThird(final Node third) { - this.third = third; + public TernaryNode setThird(final Node third) { + if(this.third == third) return this; + final TernaryNode n = (TernaryNode)clone(); + n.third = third; + return n; } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java index efa63d962be..ab6d59e2969 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ThrowNode.java @@ -75,9 +75,9 @@ public class ThrowNode extends Node { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterThrowNode(this) != null) { setExpression(expression.accept(visitor)); - return visitor.leave(this); + return visitor.leaveThrowNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java index b6aa439d4ed..7d3864bc0a2 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java @@ -101,7 +101,7 @@ public class TryNode extends Node { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterTryNode(this) != null) { // Need to do first for termination analysis. if (finallyBody != null) { finallyBody = (Block)finallyBody.accept(visitor); @@ -115,7 +115,7 @@ public class TryNode extends Node { } this.catchBlocks = newCatchBlocks; - return visitor.leave(this); + return visitor.leaveTryNode(this); } return this; @@ -154,6 +154,15 @@ public class TryNode extends Node { return catches; } + /** + * Returns true if the specified block is the body of this try block, or any of its catch blocks. + * @param block the block + * @return true if the specified block is the body of this try block, or any of its catch blocks. + */ + public boolean isChildBlock(Block block) { + return body == block || catchBlocks.contains(block); + } + /** * Get the catch blocks for this try block * @return a list of blocks diff --git a/nashorn/src/jdk/nashorn/internal/ir/TypeOverride.java b/nashorn/src/jdk/nashorn/internal/ir/TypeOverride.java index 8321318a5ef..61c1fe20a3f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/TypeOverride.java +++ b/nashorn/src/jdk/nashorn/internal/ir/TypeOverride.java @@ -36,15 +36,17 @@ import jdk.nashorn.internal.codegen.types.Type; * by using JSType.toInt32. Especially in scenarios where the field is already stored * as a primitive, this will be much faster than the "object is all I see" scope * available in the method + * @param the type of the node implementing the interface */ -public interface TypeOverride { +public interface TypeOverride { /** * Set the override type * * @param type the type + * @return a node equivalent to this one except for the requested change. */ - public void setType(final Type type); + public T setType(final Type type); /** * Returns true if this node can have a callsite override, e.g. all scope ident nodes diff --git a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java index 491151fa296..d823c0583fa 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java @@ -41,7 +41,7 @@ import jdk.nashorn.internal.runtime.Source; */ public class UnaryNode extends Node implements Assignment { /** Right hand side argument. */ - protected Node rhs; + private Node rhs; /** * Constructor @@ -103,6 +103,11 @@ public class UnaryNode extends Node implements Assignment { return isAssignment() ? rhs() : null; } + @Override + public Node setAssignmentDest(Node n) { + return setRHS(n); + } + @Override public Node getAssignmentSource() { return getAssignmentDest(); @@ -132,9 +137,8 @@ public class UnaryNode extends Node implements Assignment { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - rhs = rhs.accept(visitor); - return visitor.leave(this); + if (visitor.enterUnaryNode(this) != null) { + return visitor.leaveUnaryNode(setRHS(rhs.accept(visitor))); } return this; @@ -212,10 +216,12 @@ public class UnaryNode extends Node implements Assignment { * @see BinaryNode * * @param rhs right hand side or expression node + * @return a node equivalent to this one except for the requested change. */ - public void setRHS(final Node rhs) { - this.rhs = rhs; + public UnaryNode setRHS(final Node rhs) { + if(this.rhs == rhs) return this; + final UnaryNode n = (UnaryNode)clone(); + n.rhs = rhs; + return n; } - - } diff --git a/nashorn/src/jdk/nashorn/internal/ir/VarNode.java b/nashorn/src/jdk/nashorn/internal/ir/VarNode.java index 07b6f8eca50..b719c99dab5 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/VarNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/VarNode.java @@ -38,8 +38,8 @@ public class VarNode extends Node implements Assignment { /** Initialization expression. */ private Node init; - /** Is this a function var node */ - private boolean isFunctionVarNode; + /** Is this a var statement (as opposed to a "var" in a for loop statement) */ + private final boolean isStatement; /** * Constructor @@ -51,20 +51,34 @@ public class VarNode extends Node implements Assignment { * @param init init node or null if just a declaration */ public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init) { + this(source, token, finish, name, init, true); + } + + /** + * Constructor + * + * @param source the source + * @param token token + * @param finish finish + * @param name name of variable + * @param init init node or null if just a declaration + * @param isStatement if this is a var statement (true), or a for-loop initializer (false) + */ + public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init, boolean isStatement) { super(source, token, finish); - this.name = name; + this.name = init == null ? name : name.setIsInitializedHere(); this.init = init; - if (init != null) { - this.name.setIsInitializedHere(); - } + this.isStatement = isStatement; } + private VarNode(final VarNode varNode, final CopyState cs) { super(varNode); this.name = (IdentNode)cs.existingOrCopy(varNode.name); this.init = cs.existingOrCopy(varNode.init); + this.isStatement = varNode.isStatement; } @Override @@ -82,6 +96,11 @@ public class VarNode extends Node implements Assignment { return isAssignment() ? name : null; } + @Override + public Node setAssignmentDest(IdentNode n) { + return setName(n); + } + @Override public Node getAssignmentSource() { return isAssignment() ? getInit() : null; @@ -127,16 +146,19 @@ public class VarNode extends Node implements Assignment { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { - name = (IdentNode)name.accept(visitor); - - if (init != null) { - init = init.accept(visitor); + if (visitor.enterVarNode(this) != null) { + final IdentNode newName = (IdentNode)name.accept(visitor); + final Node newInit = init == null ? null : init.accept(visitor); + final VarNode newThis; + if(name != newName || init != newInit) { + newThis = (VarNode)clone(); + newThis.init = newInit; + newThis.name = newInit == null ? newName : newName.setIsInitializedHere(); + } else { + newThis = this; } - - return visitor.leave(this); + return visitor.leaveVarNode(newThis); } - return this; } @@ -162,9 +184,13 @@ public class VarNode extends Node implements Assignment { /** * Reset the initialization expression * @param init new initialization expression + * @return a node equivalent to this one except for the requested change. */ - public void setInit(final Node init) { - this.init = init; + public VarNode setInit(final Node init) { + if(this.init == init) return this; + final VarNode n = (VarNode)clone(); + n.init = init; + return n; } /** @@ -179,30 +205,26 @@ public class VarNode extends Node implements Assignment { * Reset the identifier for this VarNode * @param name new IdentNode representing the variable being set or declared */ - public void setName(final IdentNode name) { - this.name = name; + private VarNode setName(final IdentNode name) { + if(this.name == name) return this; + final VarNode n = (VarNode)clone(); + n.name = name; + return n; } /** - * Check if this is a virtual assignment of a function node. Function nodes declared - * with a name are hoisted to the top of the scope and appear as symbols too. This is - * implemented by representing them as virtual VarNode assignments added to the code - * during lowering - * - * @see FunctionNode - * - * @return true if this is a virtual function declaration + * Returns true if this is a var statement (as opposed to a var initializer in a for loop). + * @return true if this is a var statement (as opposed to a var initializer in a for loop). */ - public boolean isFunctionVarNode() { - return isFunctionVarNode; + public boolean isStatement() { + return isStatement; } /** - * Flag this var node as a virtual function var node assignment as described in - * {@link VarNode#isFunctionVarNode()} + * Returns true if this is a function declaration. + * @return true if this is a function declaration. */ - public void setIsFunctionVarNode() { - this.isFunctionVarNode = true; + public boolean isFunctionDeclaration() { + return init instanceof FunctionNode && ((FunctionNode)init).isDeclared(); } - } diff --git a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java index c51659b855b..8db31c088ff 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/WhileNode.java @@ -88,11 +88,11 @@ public class WhileNode extends BreakableNode { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterWhileNode(this) != null) { test = test.accept(visitor); body = (Block)body.accept(visitor); - return visitor.leave(this); + return visitor.leaveWhileNode(this); } return this; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/WithNode.java b/nashorn/src/jdk/nashorn/internal/ir/WithNode.java index 52f4e9b57c1..f5ad3b1379a 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/WithNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/WithNode.java @@ -73,10 +73,10 @@ public class WithNode extends Node { */ @Override public Node accept(final NodeVisitor visitor) { - if (visitor.enter(this) != null) { + if (visitor.enterWithNode(this) != null) { expression = expression.accept(visitor); body = (Block)body.accept(visitor); - return visitor.leave(this); + return visitor.leaveWithNode(this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java index 68fb68b024b..a8c3c4a420c 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/JSONWriter.java @@ -112,7 +112,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final AccessNode accessNode) { + public Node enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); @@ -132,7 +132,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { enterDefault(block); type("BlockStatement"); @@ -154,7 +154,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final BinaryNode binaryNode) { + public Node enterBinaryNode(final BinaryNode binaryNode) { enterDefault(binaryNode); final String name; @@ -183,7 +183,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final BreakNode breakNode) { + public Node enterBreakNode(final BreakNode breakNode) { enterDefault(breakNode); type("BreakStatement"); @@ -201,7 +201,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final CallNode callNode) { + public Node enterCallNode(final CallNode callNode) { enterDefault(callNode); type("CallExpression"); @@ -217,7 +217,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final CaseNode caseNode) { + public Node enterCaseNode(final CaseNode caseNode) { enterDefault(caseNode); type("SwitchCase"); @@ -238,7 +238,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final CatchNode catchNode) { + public Node enterCatchNode(final CatchNode catchNode) { enterDefault(catchNode); type("CatchClause"); @@ -264,7 +264,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final ContinueNode continueNode) { + public Node enterContinueNode(final ContinueNode continueNode) { enterDefault(continueNode); type("ContinueStatement"); @@ -282,7 +282,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final DoWhileNode doWhileNode) { + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { enterDefault(doWhileNode); type("DoWhileStatement"); @@ -299,7 +299,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final EmptyNode emptyNode) { + public Node enterEmptyNode(final EmptyNode emptyNode) { enterDefault(emptyNode); type("EmptyStatement"); @@ -308,7 +308,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final ExecuteNode executeNode) { + public Node enterExecuteNode(final ExecuteNode executeNode) { enterDefault(executeNode); type("ExpressionStatement"); @@ -321,7 +321,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final ForNode forNode) { + public Node enterForNode(final ForNode forNode) { enterDefault(forNode); if (forNode.isForIn() || (forNode.isForEach() && forNode.getInit() != null)) { @@ -384,14 +384,14 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { enterDefault(functionNode); - final boolean program = functionNode.isScript(); + final boolean program = functionNode.isProgram(); final String name; if (program) { name = "Program"; - } else if (functionNode.isStatement()) { + } else if (functionNode.isDeclared()) { name = "FunctionDeclaration"; } else { name = "FunctionExpression"; @@ -419,20 +419,11 @@ public final class JSONWriter extends NodeVisitor { } // body consists of nested functions and statements - final List funcs = functionNode.getFunctions(); final List stats = functionNode.getStatements(); - final int size = stats.size() + funcs.size(); + final int size = stats.size(); int idx = 0; arrayStart("body"); - for (final Node func : funcs) { - func.accept(this); - if (idx != (size - 1)) { - comma(); - } - idx++; - } - for (final Node stat : stats) { if (! stat.isDebug()) { stat.accept(this); @@ -448,7 +439,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final IdentNode identNode) { + public Node enterIdentNode(final IdentNode identNode) { enterDefault(identNode); final String name = identNode.getName(); @@ -464,7 +455,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final IfNode ifNode) { + public Node enterIfNode(final IfNode ifNode) { enterDefault(ifNode); type("IfStatement"); @@ -490,7 +481,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final IndexNode indexNode) { + public Node enterIndexNode(final IndexNode indexNode) { enterDefault(indexNode); type("MemberExpression"); @@ -510,7 +501,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final LabelNode labelNode) { + public Node enterLabelNode(final LabelNode labelNode) { enterDefault(labelNode); type("LabeledStatement"); @@ -527,13 +518,13 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final LineNumberNode lineNumberNode) { + public Node enterLineNumberNode(final LineNumberNode lineNumberNode) { return null; } @SuppressWarnings("rawtypes") @Override - public Node enter(final LiteralNode literalNode) { + public Node enterLiteralNode(final LiteralNode literalNode) { enterDefault(literalNode); if (literalNode instanceof LiteralNode.ArrayLiteralNode) { @@ -569,7 +560,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final ObjectNode objectNode) { + public Node enterObjectNode(final ObjectNode objectNode) { enterDefault(objectNode); type("ObjectExpression"); @@ -581,7 +572,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final PropertyNode propertyNode) { + public Node enterPropertyNode(final PropertyNode propertyNode) { final Node key = propertyNode.getKey(); final Node value = propertyNode.getValue(); @@ -647,7 +638,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final ReturnNode returnNode) { + public Node enterReturnNode(final ReturnNode returnNode) { enterDefault(returnNode); type("ReturnStatement"); @@ -665,7 +656,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final RuntimeNode runtimeNode) { + public Node enterRuntimeNode(final RuntimeNode runtimeNode) { final RuntimeNode.Request req = runtimeNode.getRequest(); if (req == RuntimeNode.Request.DEBUGGER) { @@ -680,12 +671,12 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final SplitNode splitNode) { + public Node enterSplitNode(final SplitNode splitNode) { return null; } @Override - public Node enter(final SwitchNode switchNode) { + public Node enterSwitchNode(final SwitchNode switchNode) { enterDefault(switchNode); type("SwitchStatement"); @@ -701,7 +692,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final TernaryNode ternaryNode) { + public Node enterTernaryNode(final TernaryNode ternaryNode) { enterDefault(ternaryNode); type("ConditionalExpression"); @@ -722,7 +713,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final ThrowNode throwNode) { + public Node enterThrowNode(final ThrowNode throwNode) { enterDefault(throwNode); type("ThrowStatement"); @@ -735,7 +726,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final TryNode tryNode) { + public Node enterTryNode(final TryNode tryNode) { enterDefault(tryNode); type("TryStatement"); @@ -760,7 +751,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final UnaryNode unaryNode) { + public Node enterUnaryNode(final UnaryNode unaryNode) { enterDefault(unaryNode); final TokenType tokenType = unaryNode.tokenType(); @@ -816,7 +807,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final VarNode varNode) { + public Node enterVarNode(final VarNode varNode) { enterDefault(varNode); type("VariableDeclaration"); @@ -852,7 +843,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final WhileNode whileNode) { + public Node enterWhileNode(final WhileNode whileNode) { enterDefault(whileNode); type("WhileStatement"); @@ -869,7 +860,7 @@ public final class JSONWriter extends NodeVisitor { } @Override - public Node enter(final WithNode withNode) { + public Node enterWithNode(final WithNode withNode) { enterDefault(withNode); type("WithStatement"); diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java index 11b8dbd54ed..d2f40d1ae95 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java @@ -42,7 +42,6 @@ import jdk.nashorn.internal.ir.IndexNode; import jdk.nashorn.internal.ir.LabelNode; import jdk.nashorn.internal.ir.LineNumberNode; import jdk.nashorn.internal.ir.Node; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.SplitNode; @@ -138,13 +137,13 @@ public final class PrintVisitor extends NodeVisitor { * Visits. */ @Override - public Node enter(final AccessNode accessNode) { + public Node enterAccessNode(final AccessNode accessNode) { accessNode.toString(sb); return null; } @Override - public Node enter(final Block block) { + public Node enterBlock(final Block block) { sb.append(' '); sb.append('{'); @@ -152,21 +151,6 @@ public final class PrintVisitor extends NodeVisitor { final boolean isFunction = block instanceof FunctionNode; - if (isFunction) { - final FunctionNode function = (FunctionNode)block; - final List functions = function.getFunctions(); - - for (final FunctionNode f : functions) { - sb.append(EOLN); - indent(); - f.accept(this); - } - - if (!functions.isEmpty()) { - sb.append(EOLN); - } - } - final List statements = block.getStatements(); boolean lastLineNumber = false; @@ -224,25 +208,25 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final BreakNode breakNode) { + public Node enterBreakNode(final BreakNode breakNode) { breakNode.toString(sb); return null; } @Override - public Node enter(final CallNode callNode) { + public Node enterCallNode(final CallNode callNode) { callNode.toString(sb); return null; } @Override - public Node enter(final ContinueNode continueNode) { + public Node enterContinueNode(final ContinueNode continueNode) { continueNode.toString(sb); return null; } @Override - public Node enter(final DoWhileNode doWhileNode) { + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { sb.append("do"); doWhileNode.getBody().accept(this); sb.append(' '); @@ -252,7 +236,7 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final ExecuteNode executeNode) { + public Node enterExecuteNode(final ExecuteNode executeNode) { final Node expression = executeNode.getExpression(); if (expression instanceof UnaryNode) { @@ -265,7 +249,7 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final ForNode forNode) { + public Node enterForNode(final ForNode forNode) { forNode.toString(sb); forNode.getBody().accept(this); @@ -273,15 +257,15 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { functionNode.toString(sb); - enter((Block)functionNode); + enterBlock(functionNode); return null; } @Override - public Node enter(final IfNode ifNode) { + public Node enterIfNode(final IfNode ifNode) { ifNode.toString(sb); ifNode.getPass().accept(this); @@ -296,13 +280,13 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final IndexNode indexNode) { + public Node enterIndexNode(final IndexNode indexNode) { indexNode.toString(sb); return null; } @Override - public Node enter(final LabelNode labeledNode) { + public Node enterLabelNode(final LabelNode labeledNode) { indent -= TABWIDTH; indent(); indent += TABWIDTH; @@ -313,7 +297,7 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final LineNumberNode lineNumberNode) { + public Node enterLineNumberNode(final LineNumberNode lineNumberNode) { if (printLineNumbers) { lineNumberNode.toString(sb); } @@ -323,25 +307,19 @@ public final class PrintVisitor extends NodeVisitor { @Override - public Node enter(final ReferenceNode referenceNode) { - referenceNode.toString(sb); - return null; - } - - @Override - public Node enter(final ReturnNode returnNode) { + public Node enterReturnNode(final ReturnNode returnNode) { returnNode.toString(sb); return null; } @Override - public Node enter(final RuntimeNode runtimeNode) { + public Node enterRuntimeNode(final RuntimeNode runtimeNode) { runtimeNode.toString(sb); return null; } @Override - public Node enter(final SplitNode splitNode) { + public Node enterSplitNode(final SplitNode splitNode) { splitNode.toString(sb); sb.append(EOLN); indent += TABWIDTH; @@ -350,7 +328,7 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node leave(final SplitNode splitNode) { + public Node leaveSplitNode(final SplitNode splitNode) { sb.append(""); sb.append(EOLN); indent -= TABWIDTH; @@ -359,7 +337,7 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final SwitchNode switchNode) { + public Node enterSwitchNode(final SwitchNode switchNode) { switchNode.toString(sb); sb.append(" {"); @@ -383,13 +361,13 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final ThrowNode throwNode) { + public Node enterThrowNode(final ThrowNode throwNode) { throwNode.toString(sb); return null; } @Override - public Node enter(final TryNode tryNode) { + public Node enterTryNode(final TryNode tryNode) { tryNode.toString(sb); tryNode.getBody().accept(this); @@ -412,13 +390,19 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final VarNode varNode) { - varNode.toString(sb); + public Node enterVarNode(final VarNode varNode) { + sb.append("var "); + varNode.getName().toString(sb); + final Node init = varNode.getInit(); + if(init != null) { + sb.append(" = "); + init.accept(this); + } return null; } @Override - public Node enter(final WhileNode whileNode) { + public Node enterWhileNode(final WhileNode whileNode) { whileNode.toString(sb); whileNode.getBody().accept(this); @@ -426,7 +410,7 @@ public final class PrintVisitor extends NodeVisitor { } @Override - public Node enter(final WithNode withNode) { + public Node enterWithNode(final WithNode withNode) { withNode.toString(sb); withNode.getBody().accept(this); diff --git a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java index 6856282e069..0021b7d2dfe 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeOperatorVisitor.java @@ -53,7 +53,7 @@ public class NodeOperatorVisitor extends NodeVisitor { } @Override - public final Node enter(final UnaryNode unaryNode) { + public final Node enterUnaryNode(final UnaryNode unaryNode) { switch (unaryNode.tokenType()) { case ADD: return enterADD(unaryNode); @@ -81,12 +81,12 @@ public class NodeOperatorVisitor extends NodeVisitor { case INCPOSTFIX: return enterDECINC(unaryNode); default: - return super.enter(unaryNode); + return super.enterUnaryNode(unaryNode); } } @Override - public final Node leave(final UnaryNode unaryNode) { + public final Node leaveUnaryNode(final UnaryNode unaryNode) { switch (unaryNode.tokenType()) { case ADD: return leaveADD(unaryNode); @@ -114,12 +114,12 @@ public class NodeOperatorVisitor extends NodeVisitor { case INCPOSTFIX: return leaveDECINC(unaryNode); default: - return super.leave(unaryNode); + return super.leaveUnaryNode(unaryNode); } } @Override - public final Node enter(final BinaryNode binaryNode) { + public final Node enterBinaryNode(final BinaryNode binaryNode) { switch (binaryNode.tokenType()) { case ADD: return enterADD(binaryNode); @@ -198,12 +198,12 @@ public class NodeOperatorVisitor extends NodeVisitor { case SUB: return enterSUB(binaryNode); default: - return super.enter(binaryNode); + return super.enterBinaryNode(binaryNode); } } @Override - public final Node leave(final BinaryNode binaryNode) { + public final Node leaveBinaryNode(final BinaryNode binaryNode) { switch (binaryNode.tokenType()) { case ADD: return leaveADD(binaryNode); @@ -282,7 +282,7 @@ public class NodeOperatorVisitor extends NodeVisitor { case SUB: return leaveSUB(binaryNode); default: - return super.leave(binaryNode); + return super.leaveBinaryNode(binaryNode); } } diff --git a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java index 9ce6fd02b3e..f10d8c036e6 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/visitor/NodeVisitor.java @@ -49,7 +49,6 @@ import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.ObjectNode; import jdk.nashorn.internal.ir.PropertyNode; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.SplitNode; @@ -153,7 +152,7 @@ public abstract class NodeVisitor { * @param accessNode the node * @return processed node, null if traversal should end, null if traversal should end */ - public Node enter(final AccessNode accessNode) { + public Node enterAccessNode(final AccessNode accessNode) { return enterDefault(accessNode); } @@ -163,7 +162,7 @@ public abstract class NodeVisitor { * @param accessNode the node * @return processed node, null if traversal should end */ - public Node leave(final AccessNode accessNode) { + public Node leaveAccessNode(final AccessNode accessNode) { return leaveDefault(accessNode); } @@ -173,7 +172,7 @@ public abstract class NodeVisitor { * @param block the node * @return processed node, null if traversal should end */ - public Node enter(final Block block) { + public Node enterBlock(final Block block) { return enterDefault(block); } @@ -183,7 +182,7 @@ public abstract class NodeVisitor { * @param block the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final Block block) { + public Node leaveBlock(final Block block) { return leaveDefault(block); } @@ -193,7 +192,7 @@ public abstract class NodeVisitor { * @param binaryNode the node * @return processed node */ - public Node enter(final BinaryNode binaryNode) { + public Node enterBinaryNode(final BinaryNode binaryNode) { return enterDefault(binaryNode); } @@ -203,7 +202,7 @@ public abstract class NodeVisitor { * @param binaryNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final BinaryNode binaryNode) { + public Node leaveBinaryNode(final BinaryNode binaryNode) { return leaveDefault(binaryNode); } @@ -213,7 +212,7 @@ public abstract class NodeVisitor { * @param breakNode the node * @return processed node, null if traversal should end */ - public Node enter(final BreakNode breakNode) { + public Node enterBreakNode(final BreakNode breakNode) { return enterDefault(breakNode); } @@ -223,7 +222,7 @@ public abstract class NodeVisitor { * @param breakNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final BreakNode breakNode) { + public Node leaveBreakNode(final BreakNode breakNode) { return leaveDefault(breakNode); } @@ -233,7 +232,7 @@ public abstract class NodeVisitor { * @param callNode the node * @return processed node, null if traversal should end */ - public Node enter(final CallNode callNode) { + public Node enterCallNode(final CallNode callNode) { return enterDefault(callNode); } @@ -243,7 +242,7 @@ public abstract class NodeVisitor { * @param callNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final CallNode callNode) { + public Node leaveCallNode(final CallNode callNode) { return leaveDefault(callNode); } @@ -253,7 +252,7 @@ public abstract class NodeVisitor { * @param caseNode the node * @return processed node, null if traversal should end */ - public Node enter(final CaseNode caseNode) { + public Node enterCaseNode(final CaseNode caseNode) { return enterDefault(caseNode); } @@ -263,7 +262,7 @@ public abstract class NodeVisitor { * @param caseNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final CaseNode caseNode) { + public Node leaveCaseNode(final CaseNode caseNode) { return leaveDefault(caseNode); } @@ -273,7 +272,7 @@ public abstract class NodeVisitor { * @param catchNode the node * @return processed node, null if traversal should end */ - public Node enter(final CatchNode catchNode) { + public Node enterCatchNode(final CatchNode catchNode) { return enterDefault(catchNode); } @@ -283,7 +282,7 @@ public abstract class NodeVisitor { * @param catchNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final CatchNode catchNode) { + public Node leaveCatchNode(final CatchNode catchNode) { return leaveDefault(catchNode); } @@ -293,7 +292,7 @@ public abstract class NodeVisitor { * @param continueNode the node * @return processed node, null if traversal should end */ - public Node enter(final ContinueNode continueNode) { + public Node enterContinueNode(final ContinueNode continueNode) { return enterDefault(continueNode); } @@ -303,7 +302,7 @@ public abstract class NodeVisitor { * @param continueNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final ContinueNode continueNode) { + public Node leaveContinueNode(final ContinueNode continueNode) { return leaveDefault(continueNode); } @@ -313,7 +312,7 @@ public abstract class NodeVisitor { * @param doWhileNode the node * @return processed node */ - public Node enter(final DoWhileNode doWhileNode) { + public Node enterDoWhileNode(final DoWhileNode doWhileNode) { return enterDefault(doWhileNode); } @@ -323,7 +322,7 @@ public abstract class NodeVisitor { * @param doWhileNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final DoWhileNode doWhileNode) { + public Node leaveDoWhileNode(final DoWhileNode doWhileNode) { return leaveDefault(doWhileNode); } @@ -333,7 +332,7 @@ public abstract class NodeVisitor { * @param emptyNode the node * @return processed node */ - public Node enter(final EmptyNode emptyNode) { + public Node enterEmptyNode(final EmptyNode emptyNode) { return enterDefault(emptyNode); } @@ -343,7 +342,7 @@ public abstract class NodeVisitor { * @param emptyNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final EmptyNode emptyNode) { + public Node leaveEmptyNode(final EmptyNode emptyNode) { return leaveDefault(emptyNode); } @@ -353,7 +352,7 @@ public abstract class NodeVisitor { * @param executeNode the node * @return processed node, null if traversal should end */ - public Node enter(final ExecuteNode executeNode) { + public Node enterExecuteNode(final ExecuteNode executeNode) { return enterDefault(executeNode); } @@ -363,7 +362,7 @@ public abstract class NodeVisitor { * @param executeNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final ExecuteNode executeNode) { + public Node leaveExecuteNode(final ExecuteNode executeNode) { return leaveDefault(executeNode); } @@ -373,7 +372,7 @@ public abstract class NodeVisitor { * @param forNode the node * @return processed node, null if traversal should end */ - public Node enter(final ForNode forNode) { + public Node enterForNode(final ForNode forNode) { return enterDefault(forNode); } @@ -383,7 +382,7 @@ public abstract class NodeVisitor { * @param forNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final ForNode forNode) { + public Node leaveForNode(final ForNode forNode) { return leaveDefault(forNode); } @@ -393,7 +392,7 @@ public abstract class NodeVisitor { * @param functionNode the node * @return processed node */ - public Node enter(final FunctionNode functionNode) { + public Node enterFunctionNode(final FunctionNode functionNode) { return enterDefault(functionNode); } @@ -403,7 +402,7 @@ public abstract class NodeVisitor { * @param functionNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final FunctionNode functionNode) { + public Node leaveFunctionNode(final FunctionNode functionNode) { return leaveDefault(functionNode); } @@ -413,7 +412,7 @@ public abstract class NodeVisitor { * @param identNode the node * @return processed node, null if traversal should end */ - public Node enter(final IdentNode identNode) { + public Node enterIdentNode(final IdentNode identNode) { return enterDefault(identNode); } @@ -423,7 +422,7 @@ public abstract class NodeVisitor { * @param identNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final IdentNode identNode) { + public Node leaveIdentNode(final IdentNode identNode) { return leaveDefault(identNode); } @@ -433,7 +432,7 @@ public abstract class NodeVisitor { * @param ifNode the node * @return processed node, null if traversal should end */ - public Node enter(final IfNode ifNode) { + public Node enterIfNode(final IfNode ifNode) { return enterDefault(ifNode); } @@ -443,7 +442,7 @@ public abstract class NodeVisitor { * @param ifNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final IfNode ifNode) { + public Node leaveIfNode(final IfNode ifNode) { return leaveDefault(ifNode); } @@ -453,7 +452,7 @@ public abstract class NodeVisitor { * @param indexNode the node * @return processed node, null if traversal should end */ - public Node enter(final IndexNode indexNode) { + public Node enterIndexNode(final IndexNode indexNode) { return enterDefault(indexNode); } @@ -463,7 +462,7 @@ public abstract class NodeVisitor { * @param indexNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final IndexNode indexNode) { + public Node leaveIndexNode(final IndexNode indexNode) { return leaveDefault(indexNode); } @@ -473,7 +472,7 @@ public abstract class NodeVisitor { * @param labelNode the node * @return processed node, null if traversal should end */ - public Node enter(final LabelNode labelNode) { + public Node enterLabelNode(final LabelNode labelNode) { return enterDefault(labelNode); } @@ -483,7 +482,7 @@ public abstract class NodeVisitor { * @param labelNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final LabelNode labelNode) { + public Node leaveLabelNode(final LabelNode labelNode) { return leaveDefault(labelNode); } @@ -493,7 +492,7 @@ public abstract class NodeVisitor { * @param lineNumberNode the node * @return processed node, null if traversal should end */ - public Node enter(final LineNumberNode lineNumberNode) { + public Node enterLineNumberNode(final LineNumberNode lineNumberNode) { return enterDefault(lineNumberNode); } @@ -503,7 +502,7 @@ public abstract class NodeVisitor { * @param lineNumberNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final LineNumberNode lineNumberNode) { + public Node leaveLineNumberNode(final LineNumberNode lineNumberNode) { return leaveDefault(lineNumberNode); } @@ -513,8 +512,7 @@ public abstract class NodeVisitor { * @param literalNode the node * @return processed node */ - @SuppressWarnings("rawtypes") - public Node enter(final LiteralNode literalNode) { + public Node enterLiteralNode(final LiteralNode literalNode) { return enterDefault(literalNode); } @@ -524,8 +522,7 @@ public abstract class NodeVisitor { * @param literalNode the node * @return processed node, which will replace the original one, or the original node */ - @SuppressWarnings("rawtypes") - public Node leave(final LiteralNode literalNode) { + public Node leaveLiteralNode(final LiteralNode literalNode) { return leaveDefault(literalNode); } @@ -535,7 +532,7 @@ public abstract class NodeVisitor { * @param objectNode the node * @return processed node */ - public Node enter(final ObjectNode objectNode) { + public Node enterObjectNode(final ObjectNode objectNode) { return enterDefault(objectNode); } @@ -545,7 +542,7 @@ public abstract class NodeVisitor { * @param objectNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final ObjectNode objectNode) { + public Node leaveObjectNode(final ObjectNode objectNode) { return leaveDefault(objectNode); } @@ -555,7 +552,7 @@ public abstract class NodeVisitor { * @param propertyNode the node * @return processed node, null if traversal should end */ - public Node enter(final PropertyNode propertyNode) { + public Node enterPropertyNode(final PropertyNode propertyNode) { return enterDefault(propertyNode); } @@ -565,37 +562,17 @@ public abstract class NodeVisitor { * @param propertyNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final PropertyNode propertyNode) { + public Node leavePropertyNode(final PropertyNode propertyNode) { return leaveDefault(propertyNode); } - /** - * Callback for entering a ReferenceNode - * - * @param referenceNode the node - * @return processed node, null if traversal should end - */ - public Node enter(final ReferenceNode referenceNode) { - return enterDefault(referenceNode); - } - - /** - * Callback for leaving a ReferenceNode - * - * @param referenceNode the node - * @return processed node, which will replace the original one, or the original node - */ - public Node leave(final ReferenceNode referenceNode) { - return leaveDefault(referenceNode); - } - /** * Callback for entering a ReturnNode * * @param returnNode the node * @return processed node, null if traversal should end */ - public Node enter(final ReturnNode returnNode) { + public Node enterReturnNode(final ReturnNode returnNode) { return enterDefault(returnNode); } @@ -605,7 +582,7 @@ public abstract class NodeVisitor { * @param returnNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final ReturnNode returnNode) { + public Node leaveReturnNode(final ReturnNode returnNode) { return leaveDefault(returnNode); } @@ -615,7 +592,7 @@ public abstract class NodeVisitor { * @param runtimeNode the node * @return processed node, null if traversal should end */ - public Node enter(final RuntimeNode runtimeNode) { + public Node enterRuntimeNode(final RuntimeNode runtimeNode) { return enterDefault(runtimeNode); } @@ -625,7 +602,7 @@ public abstract class NodeVisitor { * @param runtimeNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final RuntimeNode runtimeNode) { + public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { return leaveDefault(runtimeNode); } @@ -635,7 +612,7 @@ public abstract class NodeVisitor { * @param splitNode the node * @return processed node, null if traversal should end */ - public Node enter(final SplitNode splitNode) { + public Node enterSplitNode(final SplitNode splitNode) { return enterDefault(splitNode); } @@ -645,7 +622,7 @@ public abstract class NodeVisitor { * @param splitNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final SplitNode splitNode) { + public Node leaveSplitNode(final SplitNode splitNode) { return leaveDefault(splitNode); } @@ -655,7 +632,7 @@ public abstract class NodeVisitor { * @param switchNode the node * @return processed node, null if traversal should end */ - public Node enter(final SwitchNode switchNode) { + public Node enterSwitchNode(final SwitchNode switchNode) { return enterDefault(switchNode); } @@ -665,7 +642,7 @@ public abstract class NodeVisitor { * @param switchNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final SwitchNode switchNode) { + public Node leaveSwitchNode(final SwitchNode switchNode) { return leaveDefault(switchNode); } @@ -675,7 +652,7 @@ public abstract class NodeVisitor { * @param ternaryNode the node * @return processed node, null if traversal should end */ - public Node enter(final TernaryNode ternaryNode) { + public Node enterTernaryNode(final TernaryNode ternaryNode) { return enterDefault(ternaryNode); } @@ -685,7 +662,7 @@ public abstract class NodeVisitor { * @param ternaryNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final TernaryNode ternaryNode) { + public Node leaveTernaryNode(final TernaryNode ternaryNode) { return leaveDefault(ternaryNode); } @@ -695,7 +672,7 @@ public abstract class NodeVisitor { * @param throwNode the node * @return processed node, null if traversal should end */ - public Node enter(final ThrowNode throwNode) { + public Node enterThrowNode(final ThrowNode throwNode) { return enterDefault(throwNode); } @@ -705,7 +682,7 @@ public abstract class NodeVisitor { * @param throwNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final ThrowNode throwNode) { + public Node leaveThrowNode(final ThrowNode throwNode) { return leaveDefault(throwNode); } @@ -715,7 +692,7 @@ public abstract class NodeVisitor { * @param tryNode the node * @return processed node, null if traversal should end */ - public Node enter(final TryNode tryNode) { + public Node enterTryNode(final TryNode tryNode) { return enterDefault(tryNode); } @@ -725,7 +702,7 @@ public abstract class NodeVisitor { * @param tryNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final TryNode tryNode) { + public Node leaveTryNode(final TryNode tryNode) { return leaveDefault(tryNode); } @@ -735,7 +712,7 @@ public abstract class NodeVisitor { * @param unaryNode the node * @return processed node, null if traversal should end */ - public Node enter(final UnaryNode unaryNode) { + public Node enterUnaryNode(final UnaryNode unaryNode) { return enterDefault(unaryNode); } @@ -745,7 +722,7 @@ public abstract class NodeVisitor { * @param unaryNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final UnaryNode unaryNode) { + public Node leaveUnaryNode(final UnaryNode unaryNode) { return leaveDefault(unaryNode); } @@ -755,7 +732,7 @@ public abstract class NodeVisitor { * @param varNode the node * @return processed node, null if traversal should end */ - public Node enter(final VarNode varNode) { + public Node enterVarNode(final VarNode varNode) { return enterDefault(varNode); } @@ -765,7 +742,7 @@ public abstract class NodeVisitor { * @param varNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final VarNode varNode) { + public Node leaveVarNode(final VarNode varNode) { return leaveDefault(varNode); } @@ -775,7 +752,7 @@ public abstract class NodeVisitor { * @param whileNode the node * @return processed node, null if traversal should end */ - public Node enter(final WhileNode whileNode) { + public Node enterWhileNode(final WhileNode whileNode) { return enterDefault(whileNode); } @@ -785,7 +762,7 @@ public abstract class NodeVisitor { * @param whileNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final WhileNode whileNode) { + public Node leaveWhileNode(final WhileNode whileNode) { return leaveDefault(whileNode); } @@ -795,7 +772,7 @@ public abstract class NodeVisitor { * @param withNode the node * @return processed node, null if traversal should end */ - public Node enter(final WithNode withNode) { + public Node enterWithNode(final WithNode withNode) { return enterDefault(withNode); } @@ -805,7 +782,7 @@ public abstract class NodeVisitor { * @param withNode the node * @return processed node, which will replace the original one, or the original node */ - public Node leave(final WithNode withNode) { + public Node leaveWithNode(final WithNode withNode) { return leaveDefault(withNode); } diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index 166fed91f9e..b810043ebba 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -56,10 +56,10 @@ import static jdk.nashorn.internal.parser.TokenType.WHILE; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Stack; - import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.codegen.Namespace; import jdk.nashorn.internal.ir.AccessNode; @@ -76,17 +76,18 @@ import jdk.nashorn.internal.ir.EmptyNode; import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.FunctionNode; +import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IndexNode; import jdk.nashorn.internal.ir.LabelNode; +import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LineNumberNode; import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.Node; import jdk.nashorn.internal.ir.ObjectNode; import jdk.nashorn.internal.ir.PropertyKey; import jdk.nashorn.internal.ir.PropertyNode; -import jdk.nashorn.internal.ir.ReferenceNode; import jdk.nashorn.internal.ir.ReturnNode; import jdk.nashorn.internal.ir.RuntimeNode; import jdk.nashorn.internal.ir.SwitchNode; @@ -97,7 +98,6 @@ import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WhileNode; import jdk.nashorn.internal.ir.WithNode; -import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.ErrorManager; import jdk.nashorn.internal.runtime.JSErrorType; @@ -117,11 +117,8 @@ public class Parser extends AbstractParser { /** Is scripting mode. */ private final boolean scripting; - /** Current function being parsed. */ - private FunctionNode function; - - /** Current parsing block. */ - private Block block; + private final LexicalContext lexicalContext = new LexicalContext(); + private List functionDeclarations; /** Namespace for function names where not explicitly given */ private final Namespace namespace; @@ -277,7 +274,9 @@ loop: * @return New block. */ private Block newBlock() { - return block = new Block(source, token, Token.descPosition(token), block, function); + final Block block = new Block(source, token, Token.descPosition(token)); + lexicalContext.push(block); + return block; } /** @@ -290,19 +289,23 @@ loop: // Build function name. final StringBuilder sb = new StringBuilder(); - if (block != null) { - block.addParentName(sb); + final FunctionNode parentFunction = getFunction(); + if(parentFunction != null && !parentFunction.isProgram()) { + sb.append(parentFunction.getName()).append('$'); } sb.append(ident != null ? ident.getName() : FUNCTION_PREFIX.tag()); final String name = namespace.uniqueName(sb.toString()); - assert function != null || name.equals(RUN_SCRIPT.tag()) : "name = " + name;// must not rename runScript(). + assert parentFunction != null || name.equals(RUN_SCRIPT.tag()) : "name = " + name;// must not rename runScript(). // Start new block. - final FunctionNode functionBlock = new FunctionNode(source, token, Token.descPosition(token), namespace, block, ident, name); - block = function = functionBlock; - function.setStrictMode(isStrictMode); - function.setState(errors.hasErrors() ? CompilationState.PARSE_ERROR : CompilationState.PARSED); + final FunctionNode functionBlock = new FunctionNode(source, token, Token.descPosition(token), namespace, ident, name); + if(parentFunction == null) { + functionBlock.setProgram(); + } + functionBlock.setStrictMode(isStrictMode); + functionBlock.setState(errors.hasErrors() ? CompilationState.PARSE_ERROR : CompilationState.PARSED); + lexicalContext.push(functionBlock); return functionBlock; } @@ -310,9 +313,8 @@ loop: /** * Restore the current block. */ - private void restoreBlock() { - block = block.getParent(); - function = block.getFunction(); + private void restoreBlock(Block block) { + lexicalContext.pop(block); } /** @@ -322,19 +324,22 @@ loop: private Block getBlock(final boolean needsBraces) { // Set up new block. Captures LBRACE. final Block newBlock = newBlock(); - pushControlNode(newBlock); - - // Block opening brace. - if (needsBraces) { - expect(LBRACE); - } - try { - // Accumulate block statements. - statementList(); + pushControlNode(newBlock); + + // Block opening brace. + if (needsBraces) { + expect(LBRACE); + } + + try { + // Accumulate block statements. + statementList(); + } finally { + popControlNode(); + } } finally { - restoreBlock(); - popControlNode(); + restoreBlock(newBlock); } final int possibleEnd = Token.descPosition(token) + Token.descLength(token); @@ -364,7 +369,7 @@ loop: // Accumulate statements. statement(); } finally { - restoreBlock(); + restoreBlock(newBlock); } return newBlock; @@ -378,7 +383,10 @@ loop: final String name = ident.getName(); if (EVAL.tag().equals(name)) { - function.setHasEval(); + final Iterator it = lexicalContext.getFunctions(); + if(it.hasNext()) { + it.next().setHasEval(it); + } } } @@ -390,7 +398,7 @@ loop: final String name = ident.getName(); if (ARGUMENTS.tag().equals(name)) { - function.setUsesArguments(); + getFunction().setUsesArguments(); } } @@ -481,7 +489,7 @@ loop: * @return null or the found label node. */ private LabelNode findLabel(final IdentNode ident) { - for (final LabelNode labelNode : function.getLabelStack()) { + for (final LabelNode labelNode : getFunction().getLabelStack()) { if (labelNode.getLabel().equals(ident)) { return labelNode; } @@ -495,14 +503,14 @@ loop: * @param labelNode Label to add. */ private void pushLabel(final LabelNode labelNode) { - function.getLabelStack().push(labelNode); + getFunction().getLabelStack().push(labelNode); } /** * Remove a label from the label stack. */ private void popLabel() { - function.getLabelStack().pop(); + getFunction().getLabelStack().pop(); } /** @@ -512,6 +520,7 @@ loop: private void pushControlNode(final Node node) { final boolean isLoop = node instanceof WhileNode; final boolean isBreakable = node instanceof BreakableNode || node instanceof Block; + final FunctionNode function = getFunction(); function.getControlStack().push(node); for (final LabelNode labelNode : function.getLabelStack()) { @@ -530,7 +539,7 @@ loop: */ private void popControlNode() { // Get control stack. - final Stack controlStack = function.getControlStack(); + final Stack controlStack = getFunction().getControlStack(); // Can be empty if missing brace. if (!controlStack.isEmpty()) { @@ -540,7 +549,7 @@ loop: private void popControlNode(final Node node) { // Get control stack. - final Stack controlStack = function.getControlStack(); + final Stack controlStack = getFunction().getControlStack(); // Can be empty if missing brace. if (!controlStack.isEmpty() && controlStack.peek() == node) { @@ -549,7 +558,7 @@ loop: } private boolean isInWithBlock() { - final Stack controlStack = function.getControlStack(); + final Stack controlStack = getFunction().getControlStack(); for (int i = controlStack.size() - 1; i >= 0; i--) { final Node node = controlStack.get(i); @@ -562,7 +571,7 @@ loop: } private T findControl(final Class ctype) { - final Stack controlStack = function.getControlStack(); + final Stack controlStack = getFunction().getControlStack(); for (int i = controlStack.size() - 1; i >= 0; i--) { final Node node = controlStack.get(i); @@ -576,7 +585,7 @@ loop: private List findControls(final Class ctype, final Node to) { final List nodes = new ArrayList<>(); - final Stack controlStack = function.getControlStack(); + final Stack controlStack = getFunction().getControlStack(); for (int i = controlStack.size() - 1; i >= 0; i--) { final Node node = controlStack.get(i); @@ -625,7 +634,10 @@ loop: script.setKind(FunctionNode.Kind.SCRIPT); script.setFirstToken(functionToken); + functionDeclarations = new ArrayList<>(); sourceElements(); + script.prependStatements(functionDeclarations); + functionDeclarations = null; expect(EOF); script.setLastToken(token); script.setFinish(source.getLength() - 1); @@ -704,7 +716,7 @@ loop: // check for directive prologues if (checkDirective) { // skip any debug statement like line number to get actual first line - final Node lastStatement = lastStatement(block.getStatements()); + final Node lastStatement = lastStatement(getBlock().getStatements()); // get directive prologue, if any final String directive = getDirective(lastStatement); @@ -724,6 +736,7 @@ loop: // handle use strict directive if ("use strict".equals(directive)) { isStrictMode = true; + final FunctionNode function = getFunction(); function.setStrictMode(true); // We don't need to check these, if lexical environment is already strict @@ -796,11 +809,11 @@ loop: if (isStrictMode && !topLevel) { error(AbstractParser.message("strict.no.func.here"), token); } - functionExpression(true); + functionExpression(true, topLevel); return; } - block.addStatement(lineNumberNode); + getBlock().addStatement(lineNumberNode); switch (type) { case LBRACE: @@ -886,7 +899,7 @@ loop: // Force block execution. final ExecuteNode executeNode = new ExecuteNode(source, newBlock.getToken(), finish, newBlock); - block.addStatement(executeNode); + getBlock().addStatement(executeNode); } /** @@ -981,13 +994,9 @@ loop: // Allocate var node. final VarNode var = new VarNode(source, varToken, finish, name, init); - if (isStatement) { - function.addDeclaration(var); - } - vars.add(var); // Add to current block. - block.addStatement(var); + getBlock().addStatement(var); if (type != COMMARIGHT) { break; @@ -1000,7 +1009,7 @@ loop: boolean semicolon = type == SEMICOLON; endOfLine(); if (semicolon) { - block.setFinish(finish); + getBlock().setFinish(finish); } } @@ -1017,7 +1026,7 @@ loop: */ private void emptyStatement() { if (env._empty_statements) { - block.addStatement(new EmptyNode(source, token, + getBlock().addStatement(new EmptyNode(source, token, Token.descPosition(token) + Token.descLength(token))); } @@ -1043,7 +1052,7 @@ loop: ExecuteNode executeNode = null; if (expression != null) { executeNode = new ExecuteNode(source, expressionToken, finish, expression); - block.addStatement(executeNode); + getBlock().addStatement(executeNode); } else { expect(null); } @@ -1052,7 +1061,7 @@ loop: if (executeNode != null) { executeNode.setFinish(finish); - block.setFinish(finish); + getBlock().setFinish(finish); } } @@ -1094,7 +1103,7 @@ loop: // Construct and add new if node. final IfNode ifNode = new IfNode(source, ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail); - block.addStatement(ifNode); + getBlock().addStatement(ifNode); } /** @@ -1143,13 +1152,13 @@ loop: outer.setFinish(body.getFinish()); // Add for to current block. - block.addStatement(forNode); + getBlock().addStatement(forNode); } finally { - restoreBlock(); + restoreBlock(outer); popControlNode(); } - block.addStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer)); + getBlock().addStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer)); } /** @@ -1283,7 +1292,7 @@ loop: whileNode.setFinish(statements.getFinish()); // Add WHILE node. - block.addStatement(whileNode); + getBlock().addStatement(whileNode); } finally { popControlNode(); } @@ -1330,7 +1339,7 @@ loop: doWhileNode.setFinish(finish); // Add DO node. - block.addStatement(doWhileNode); + getBlock().addStatement(doWhileNode); } finally { popControlNode(); } @@ -1382,7 +1391,7 @@ loop: final ContinueNode continueNode = new ContinueNode(source, continueToken, finish, labelNode, targetNode, findControl(TryNode.class)); continueNode.setScopeNestingLevel(countControls(WithNode.class, targetNode)); - block.addStatement(continueNode); + getBlock().addStatement(continueNode); } /** @@ -1430,7 +1439,7 @@ loop: final BreakNode breakNode = new BreakNode(source, breakToken, finish, labelNode, targetNode, findControl(TryNode.class)); breakNode.setScopeNestingLevel(countControls(WithNode.class, targetNode)); - block.addStatement(breakNode); + getBlock().addStatement(breakNode); } /** @@ -1443,7 +1452,7 @@ loop: */ private void returnStatement() { // check for return outside function - if (function.getKind() == FunctionNode.Kind.SCRIPT) { + if (getFunction().getKind() == FunctionNode.Kind.SCRIPT) { error(AbstractParser.message("invalid.return")); } @@ -1470,7 +1479,7 @@ loop: // Construct and add RETURN node. final ReturnNode returnNode = new ReturnNode(source, returnToken, finish, expression, findControl(TryNode.class)); - block.addStatement(returnNode); + getBlock().addStatement(returnNode); } /** @@ -1505,7 +1514,7 @@ loop: // Construct and add YIELD node. final ReturnNode yieldNode = new ReturnNode(source, yieldToken, finish, expression, findControl(TryNode.class)); - block.addStatement(yieldNode); + getBlock().addStatement(yieldNode); } /** @@ -1529,7 +1538,10 @@ loop: // Get WITH expression. final WithNode withNode = new WithNode(source, withToken, finish, null, null); - function.setHasWith(); + final Iterator it = lexicalContext.getFunctions(); + if(it.hasNext()) { + it.next().setHasWith(it); + } try { pushControlNode(withNode); @@ -1549,7 +1561,7 @@ loop: popControlNode(withNode); } - block.addStatement(withNode); + getBlock().addStatement(withNode); } /** @@ -1649,7 +1661,7 @@ loop: switchNode.setFinish(finish); - block.addStatement(switchNode); + getBlock().addStatement(switchNode); } finally { popControlNode(); } @@ -1684,7 +1696,7 @@ loop: labelNode.setBody(statements); labelNode.setFinish(finish); - block.addStatement(labelNode); + getBlock().addStatement(labelNode); } finally { // Remove label. popLabel(); @@ -1727,7 +1739,7 @@ loop: // Construct and add THROW node. final ThrowNode throwNode = new ThrowNode(source, throwToken, finish, expression, findControl(TryNode.class)); - block.addStatement(throwNode); + getBlock().addStatement(throwNode); } /** @@ -1793,18 +1805,18 @@ loop: expect(RPAREN); + final Block catchBlock = newBlock(); try { - final Block catchBlock = newBlock(); // Get CATCH body. final Block catchBody = getBlock(true); // Create and add catch. final CatchNode catchNode = new CatchNode(source, catchToken, finish, exception, ifExpression, catchBody); - block.addStatement(catchNode); + getBlock().addStatement(catchNode); catchBlocks.add(catchBlock); } finally { - restoreBlock(); + restoreBlock(catchBlock); } // If unconditional catch then should to be the end. @@ -1840,11 +1852,11 @@ loop: outer.addStatement(tryNode); } finally { popControlNode(tryNode); - restoreBlock(); + restoreBlock(outer); popControlNode(outer); } - block.addStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer)); + getBlock().addStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer)); } /** @@ -1864,7 +1876,7 @@ loop: endOfLine(); final RuntimeNode runtimeNode = new RuntimeNode(source, debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList()); - block.addStatement(runtimeNode); + getBlock().addStatement(runtimeNode); } /** @@ -2244,7 +2256,7 @@ loop: parameters = new ArrayList<>(); functionNode = functionBody(getSetToken, getNameNode, parameters, FunctionNode.Kind.GETTER); propertyNode = new PropertyNode(source, propertyToken, finish, getIdent, null); - propertyNode.setGetter(new ReferenceNode(source, propertyToken, finish, functionNode)); + propertyNode.setGetter(functionNode); return propertyNode; case "set": @@ -2259,7 +2271,7 @@ loop: parameters.add(argIdent); functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER); propertyNode = new PropertyNode(source, propertyToken, finish, setIdent, null); - propertyNode.setSetter(new ReferenceNode(source, propertyToken, finish, functionNode)); + propertyNode.setSetter(functionNode); return propertyNode; default: @@ -2440,7 +2452,7 @@ loop: case FUNCTION: // Get function expression. - lhs = functionExpression(false); + lhs = functionExpression(false, false); break; default: @@ -2545,7 +2557,7 @@ loop: * * @return Expression node. */ - private Node functionExpression(final boolean isStatement) { + private Node functionExpression(final boolean isStatement, final boolean topLevel) { final LineNumberNode lineNumber = lineNumber(); final long functionToken = token; @@ -2580,10 +2592,12 @@ loop: final FunctionNode functionNode = functionBody(functionToken, name, parameters, FunctionNode.Kind.NORMAL); - if (isStatement && !isInWithBlock()) { - functionNode.setIsStatement(); + if (isStatement) { + if(topLevel) { + functionNode.setIsDeclared(); + } if(ARGUMENTS.tag().equals(name.getName())) { - functionNode.findParentFunction().setDefinesArguments(); + getFunction().setDefinesArguments(); } } @@ -2591,8 +2605,6 @@ loop: functionNode.setIsAnonymous(); } - final ReferenceNode referenceNode = new ReferenceNode(source, functionToken, finish, functionNode); - final int arity = parameters.size(); final boolean strict = functionNode.isStrictMode(); @@ -2628,17 +2640,18 @@ loop: } if (isStatement) { - final VarNode var = new VarNode(source, functionToken, finish, name, referenceNode); - if (isInWithBlock()) { - function.addDeclaration(var); - // Add to current block. - block.addStatement(var); + final VarNode varNode = new VarNode(source, functionToken, finish, name, functionNode, true); + if(topLevel) { + functionDeclarations.add(lineNumber); + functionDeclarations.add(varNode); } else { - functionNode.setFunctionVarNode(var, lineNumber); + final Block block = getBlock(); + block.addStatement(lineNumber); + block.addStatement(varNode); } } - return referenceNode; + return functionNode; } /** @@ -2721,7 +2734,14 @@ loop: expect(LBRACE); // Gather the function elements. - sourceElements(); + final List prevFunctionDecls = functionDeclarations; + functionDeclarations = new ArrayList<>(); + try { + sourceElements(); + functionNode.prependStatements(functionDeclarations); + } finally { + functionDeclarations = prevFunctionDecls; + } functionNode.setLastToken(token); expect(RBRACE); @@ -2729,12 +2749,9 @@ loop: } } finally { - restoreBlock(); + restoreBlock(functionNode); } - // Add the body of the function to the current block. - block.addFunction(functionNode); - return functionNode; } @@ -3069,4 +3086,12 @@ loop: public String toString() { return "[JavaScript Parsing]"; } + + private Block getBlock() { + return lexicalContext.getCurrentBlock(); + } + + private FunctionNode getFunction() { + return lexicalContext.getCurrentFunction(); + } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 0ca2c47a9ec..448df143c24 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -27,9 +27,9 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.codegen.CompilerConstants.RUN_SCRIPT; import static jdk.nashorn.internal.codegen.CompilerConstants.STRICT_MODE; +import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; -import static jdk.nashorn.internal.lookup.Lookup.MH; import java.io.File; import java.io.IOException; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties index 4547e444422..43a7ff62977 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties @@ -42,6 +42,8 @@ parser.error.expected.stmt=Expected statement but found {0} parser.error.expected.comma=Expected comma but found {0} parser.error.expected=Expected {0} but found {1} parser.error.invalid.return=Invalid return statement +parser.error.no.func.decl.here=Function declarations can only occur at program or function body level. You should use a function expression here instead. +parser.error.no.func.decl.here.warn=Function declarations should only occur at program or function body level. Function declaration in nested block was converted to a function expression. parser.error.property.redefinition=Property "{0}" already defined parser.error.unexpected.token=Unexpected token: {0} parser.error.many.vars.in.for.in.loop=Only one variable allowed in for..in loop @@ -57,7 +59,7 @@ parser.error.strict.name="{0}" cannot be used as {1} in strict mode parser.error.strict.cant.delete.ident=cannot delete identifier "{0}" in strict mode parser.error.strict.param.redefinition=strict mode function cannot have duplicate parameter name "{0}" parser.error.strict.no.octal=cannot use octal value in strict mode -parser.error.strict.no.func.here=In strict mode, functions can only be declared at top-level or immediately within a function +parser.error.strict.no.func.decl.here=In strict mode, function declarations can only occur at program or function body level. You should use a function expression here instead. type.error.strict.getter.setter.poison=In strict mode, "caller", "callee", and "arguments" properties can not be accessed on functions or the arguments object # not the expected type in a given context diff --git a/nashorn/test/script/basic/JDK-8006755.js b/nashorn/test/script/basic/JDK-8006755.js index 3012a4bed56..092434730b1 100644 --- a/nashorn/test/script/basic/JDK-8006755.js +++ b/nashorn/test/script/basic/JDK-8006755.js @@ -31,7 +31,7 @@ var scope = { x: "hello" }; with (scope) { - function main() { + var main = function() { if (x != "hello") { fail("x != 'hello'"); } diff --git a/nashorn/test/script/basic/NASHORN-837.js b/nashorn/test/script/basic/NASHORN-837.js index 0632fb39a31..ef9ec64d193 100644 --- a/nashorn/test/script/basic/NASHORN-837.js +++ b/nashorn/test/script/basic/NASHORN-837.js @@ -28,23 +28,13 @@ * @run */ -var failed = false; - try { - try { - throw new TypeError('error'); - } catch (iox) { - function f() { - print(iox.message); - } + throw new TypeError('error'); +} catch (iox) { + var f = function() { + if(iox.message != 'error') { + print("Failure! iox did not throw correct exception"); + } } - f(); -} catch (e) { - failed = (e instanceof ReferenceError); - //iox not defined should be thrown } - -if (!failed) { - print("Failure! iox did not throw correct exception"); -} - +f(); diff --git a/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java b/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java index adf361f4944..3cbe1ed4152 100644 --- a/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java @@ -44,6 +44,7 @@ public class CompilerTest { private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("compilertest.verbose")); private static final boolean TEST262 = Boolean.valueOf(System.getProperty("compilertest.test262")); private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir"); + private static final String TEST_NODE_DIR = System.getProperty("test.node.dir"); private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir"); interface TestFilter { @@ -81,21 +82,22 @@ public class CompilerTest { @Test public void compileAllTests() { if (TEST262) { - compileTestSet(TEST262_SUITE_DIR, new TestFilter() { + compileTestSet(new File(TEST262_SUITE_DIR), new TestFilter() { @Override public boolean exclude(final File file, final String content) { return content.indexOf("@negative") != -1; } }); } - compileTestSet(TEST_BASIC_DIR, null); + compileTestSet(new File(TEST_BASIC_DIR), null); + compileTestSet(new File(TEST_NODE_DIR, "node"), null); + compileTestSet(new File(TEST_NODE_DIR, "src"), null); } - private void compileTestSet(final String testSet, final TestFilter filter) { + private void compileTestSet(final File testSetDir, final TestFilter filter) { passed = 0; failed = 0; skipped = 0; - final File testSetDir = new File(testSet); if (! testSetDir.isDirectory()) { log("WARNING: " + testSetDir + " not found or not a directory"); return; @@ -103,7 +105,7 @@ public class CompilerTest { log(testSetDir.getAbsolutePath()); compileJSDirectory(testSetDir, filter); - log(testSet + " compile done!"); + log(testSetDir + " compile done!"); log("compile ok: " + passed); log("compile failed: " + failed); log("compile skipped: " + skipped); From 89120e782752b06fce36ec69737cf2f34f1c0cc2 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Thu, 28 Mar 2013 10:27:28 +0100 Subject: [PATCH 051/155] 7014552: gc/lock/jni/jnilockXXX works too slow on 1-processor machine Keep a counter of how many times we were stalled by the GC locker, add a diagnostic flag which sets the limit. Reviewed-by: brutisso, ehelin, johnc --- .../gc_implementation/g1/g1CollectedHeap.cpp | 30 +++++++++++++++---- .../gc_implementation/g1/g1CollectedHeap.hpp | 9 ++++-- .../g1/g1CollectedHeap.inline.hpp | 7 +++-- .../parallelScavenge/parallelScavengeHeap.cpp | 6 ++++ .../src/share/vm/memory/collectorPolicy.cpp | 7 ++++- hotspot/src/share/vm/runtime/globals.hpp | 4 +++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 64647979045..780e330b4f8 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -854,7 +854,8 @@ HeapWord* G1CollectedHeap::allocate_new_tlab(size_t word_size) { assert(!isHumongous(word_size), "we do not allow humongous TLABs"); unsigned int dummy_gc_count_before; - return attempt_allocation(word_size, &dummy_gc_count_before); + int dummy_gclocker_retry_count = 0; + return attempt_allocation(word_size, &dummy_gc_count_before, &dummy_gclocker_retry_count); } HeapWord* @@ -863,14 +864,14 @@ G1CollectedHeap::mem_allocate(size_t word_size, assert_heap_not_locked_and_not_at_safepoint(); // Loop until the allocation is satisified, or unsatisfied after GC. - for (int try_count = 1; /* we'll return */; try_count += 1) { + for (int try_count = 1, gclocker_retry_count = 0; /* we'll return */; try_count += 1) { unsigned int gc_count_before; HeapWord* result = NULL; if (!isHumongous(word_size)) { - result = attempt_allocation(word_size, &gc_count_before); + result = attempt_allocation(word_size, &gc_count_before, &gclocker_retry_count); } else { - result = attempt_allocation_humongous(word_size, &gc_count_before); + result = attempt_allocation_humongous(word_size, &gc_count_before, &gclocker_retry_count); } if (result != NULL) { return result; @@ -894,6 +895,9 @@ G1CollectedHeap::mem_allocate(size_t word_size, } return result; } else { + if (gclocker_retry_count > GCLockerRetryAllocationCount) { + return NULL; + } assert(op.result() == NULL, "the result should be NULL if the VM op did not succeed"); } @@ -910,7 +914,8 @@ G1CollectedHeap::mem_allocate(size_t word_size, } HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, - unsigned int *gc_count_before_ret) { + unsigned int *gc_count_before_ret, + int* gclocker_retry_count_ret) { // Make sure you read the note in attempt_allocation_humongous(). assert_heap_not_locked_and_not_at_safepoint(); @@ -986,10 +991,16 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, return NULL; } } else { + if (*gclocker_retry_count_ret > GCLockerRetryAllocationCount) { + MutexLockerEx x(Heap_lock); + *gc_count_before_ret = total_collections(); + return NULL; + } // The GCLocker is either active or the GCLocker initiated // GC has not yet been performed. Stall until it is and // then retry the allocation. GC_locker::stall_until_clear(); + (*gclocker_retry_count_ret) += 1; } // We can reach here if we were unsuccessul in scheduling a @@ -1019,7 +1030,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, } HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, - unsigned int * gc_count_before_ret) { + unsigned int * gc_count_before_ret, + int* gclocker_retry_count_ret) { // The structure of this method has a lot of similarities to // attempt_allocation_slow(). The reason these two were not merged // into a single one is that such a method would require several "if @@ -1104,10 +1116,16 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, return NULL; } } else { + if (*gclocker_retry_count_ret > GCLockerRetryAllocationCount) { + MutexLockerEx x(Heap_lock); + *gc_count_before_ret = total_collections(); + return NULL; + } // The GCLocker is either active or the GCLocker initiated // GC has not yet been performed. Stall until it is and // then retry the allocation. GC_locker::stall_until_clear(); + (*gclocker_retry_count_ret) += 1; } // We can reach here if we were unsuccessul in scheduling a diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 7dc5bd83047..557daf85eea 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -559,18 +559,21 @@ protected: // the mutator alloc region without taking the Heap_lock. This // should only be used for non-humongous allocations. inline HeapWord* attempt_allocation(size_t word_size, - unsigned int* gc_count_before_ret); + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret); // Second-level mutator allocation attempt: take the Heap_lock and // retry the allocation attempt, potentially scheduling a GC // pause. This should only be used for non-humongous allocations. HeapWord* attempt_allocation_slow(size_t word_size, - unsigned int* gc_count_before_ret); + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret); // Takes the Heap_lock and attempts a humongous allocation. It can // potentially schedule a GC pause. HeapWord* attempt_allocation_humongous(size_t word_size, - unsigned int* gc_count_before_ret); + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret); // Allocation attempt that should be called during safepoints (e.g., // at the end of a successful GC). expect_null_mutator_alloc_region diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp index 4f9c7726292..20eb1693c43 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @@ -60,7 +60,8 @@ inline bool G1CollectedHeap::obj_in_cs(oop obj) { inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size, - unsigned int* gc_count_before_ret) { + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret) { assert_heap_not_locked_and_not_at_safepoint(); assert(!isHumongous(word_size), "attempt_allocation() should not " "be called for humongous allocation requests"); @@ -68,7 +69,9 @@ G1CollectedHeap::attempt_allocation(size_t word_size, HeapWord* result = _mutator_alloc_region.attempt_allocation(word_size, false /* bot_updates */); if (result == NULL) { - result = attempt_allocation_slow(word_size, gc_count_before_ret); + result = attempt_allocation_slow(word_size, + gc_count_before_ret, + gclocker_retry_count_ret); } assert_heap_not_locked(); if (result != NULL) { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 0c39e69e1be..5d77e31b6c8 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -326,6 +326,7 @@ HeapWord* ParallelScavengeHeap::mem_allocate( uint loop_count = 0; uint gc_count = 0; + int gclocker_stalled_count = 0; while (result == NULL) { // We don't want to have multiple collections for a single filled generation. @@ -354,6 +355,10 @@ HeapWord* ParallelScavengeHeap::mem_allocate( return result; } + if (gclocker_stalled_count > GCLockerRetryAllocationCount) { + return NULL; + } + // Failed to allocate without a gc. if (GC_locker::is_active_and_needs_gc()) { // If this thread is not in a jni critical section, we stall @@ -366,6 +371,7 @@ HeapWord* ParallelScavengeHeap::mem_allocate( if (!jthr->in_critical()) { MutexUnlocker mul(Heap_lock); GC_locker::stall_until_clear(); + gclocker_stalled_count += 1; continue; } else { if (CheckJNICalls) { diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index d5eb387a04c..a2049597af7 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -532,7 +532,7 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, // Loop until the allocation is satisified, // or unsatisfied after GC. - for (int try_count = 1; /* return or throw */; try_count += 1) { + for (int try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) { HandleMark hm; // discard any handles allocated in each iteration // First allocation attempt is lock-free. @@ -576,6 +576,10 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, } } + if (gclocker_stalled_count > GCLockerRetryAllocationCount) { + return NULL; // we didn't get to do a GC and we didn't get any memory + } + // If this thread is not in a jni critical section, we stall // the requestor until the critical section has cleared and // GC allowed. When the critical section clears, a GC is @@ -587,6 +591,7 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, MutexUnlocker mul(Heap_lock); // Wait for JNI critical section to be exited GC_locker::stall_until_clear(); + gclocker_stalled_count += 1; continue; } else { if (CheckJNICalls) { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9645f625a85..d59bc735ed7 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1402,6 +1402,10 @@ class CommandLineFlags { "How much the GC can expand the eden by while the GC locker " \ "is active (as a percentage)") \ \ + diagnostic(intx, GCLockerRetryAllocationCount, 2, \ + "Number of times to retry allocations when" \ + " blocked by the GC locker") \ + \ develop(bool, UseCMSAdaptiveFreeLists, true, \ "Use Adaptive Free Lists in the CMS generation") \ \ From bb5bd507d76bc669919979d66c95f3427cb10e1c Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Wed, 27 Mar 2013 19:21:18 +0100 Subject: [PATCH 052/155] 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM Ergonomics now also takes available virtual memory into account when deciding for a heap size. The helper method to determine the maximum allocatable memory block now uses the appropriate OS specific calls to retrieve available virtual memory for the java process. In 32 bit environments this method now also searches for the maximum actually reservable amount of memory. Merge previously separate implementations for Linux/BSD/Solaris into a single method. Reviewed-by: jmasa, tamao --- hotspot/src/os/bsd/vm/os_bsd.cpp | 14 ----- hotspot/src/os/linux/vm/os_linux.cpp | 14 ----- hotspot/src/os/posix/vm/os_posix.cpp | 62 ++++++++++++++++++++++ hotspot/src/os/solaris/vm/os_solaris.cpp | 18 ------- hotspot/src/os/windows/vm/os_windows.cpp | 11 ++-- hotspot/src/share/vm/runtime/arguments.cpp | 21 +++++--- hotspot/src/share/vm/runtime/arguments.hpp | 3 ++ hotspot/src/share/vm/runtime/globals.hpp | 4 ++ hotspot/src/share/vm/runtime/os.hpp | 2 +- 9 files changed, 92 insertions(+), 57 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index a09db37288f..d062b048a46 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -167,20 +167,6 @@ julong os::physical_memory() { return Bsd::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { -#ifdef _LP64 - return size; -#else - julong result = MIN2(size, (julong)3800*M); - if (!is_allocatable(result)) { - // See comments under solaris for alignment considerations - julong reasonable_size = (julong)2*G - 2 * os::vm_page_size(); - result = MIN2(size, reasonable_size); - } - return result; -#endif // _LP64 -} - //////////////////////////////////////////////////////////////////////////////// // environment support diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 59cb59d6805..7e9250f3909 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -194,20 +194,6 @@ julong os::physical_memory() { return Linux::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { -#ifdef _LP64 - return size; -#else - julong result = MIN2(size, (julong)3800*M); - if (!is_allocatable(result)) { - // See comments under solaris for alignment considerations - julong reasonable_size = (julong)2*G - 2 * os::vm_page_size(); - result = MIN2(size, reasonable_size); - } - return result; -#endif // _LP64 -} - //////////////////////////////////////////////////////////////////////////////// // environment support diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index af75b3b362d..03302783688 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -188,4 +188,66 @@ void os::Posix::print_uname_info(outputStream* st) { st->cr(); } +bool os::has_allocatable_memory_limit(julong* limit) { + struct rlimit rlim; + int getrlimit_res = getrlimit(RLIMIT_AS, &rlim); + // if there was an error when calling getrlimit, assume that there is no limitation + // on virtual memory. + bool result; + if ((getrlimit_res != 0) || (rlim.rlim_cur == RLIM_INFINITY)) { + result = false; + } else { + *limit = (julong)rlim.rlim_cur; + result = true; + } +#ifdef _LP64 + return result; +#else + // arbitrary virtual space limit for 32 bit Unices found by testing. If + // getrlimit above returned a limit, bound it with this limit. Otherwise + // directly use it. + const julong max_virtual_limit = (julong)3800*M; + if (result) { + *limit = MIN2(*limit, max_virtual_limit); + } else { + *limit = max_virtual_limit; + } + // bound by actually allocatable memory. The algorithm uses two bounds, an + // upper and a lower limit. The upper limit is the current highest amount of + // memory that could not be allocated, the lower limit is the current highest + // amount of memory that could be allocated. + // The algorithm iteratively refines the result by halving the difference + // between these limits, updating either the upper limit (if that value could + // not be allocated) or the lower limit (if the that value could be allocated) + // until the difference between these limits is "small". + + // the minimum amount of memory we care about allocating. + const julong min_allocation_size = M; + + julong upper_limit = *limit; + + // first check a few trivial cases + if (is_allocatable(upper_limit) || (upper_limit <= min_allocation_size)) { + *limit = upper_limit; + } else if (!is_allocatable(min_allocation_size)) { + // we found that not even min_allocation_size is allocatable. Return it + // anyway. There is no point to search for a better value any more. + *limit = min_allocation_size; + } else { + // perform the binary search. + julong lower_limit = min_allocation_size; + while ((upper_limit - lower_limit) > min_allocation_size) { + julong temp_limit = ((upper_limit - lower_limit) / 2) + lower_limit; + temp_limit = align_size_down_(temp_limit, min_allocation_size); + if (is_allocatable(temp_limit)) { + lower_limit = temp_limit; + } else { + upper_limit = temp_limit; + } + } + *limit = lower_limit; + } + return true; +#endif +} diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index bdd78ad0218..5570195bb31 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -476,24 +476,6 @@ julong os::physical_memory() { return Solaris::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { -#ifdef _LP64 - return size; -#else - julong result = MIN2(size, (julong)3835*M); - if (!is_allocatable(result)) { - // Memory allocations will be aligned but the alignment - // is not known at this point. Alignments will - // be at most to LargePageSizeInBytes. Protect - // allocations from alignments up to illegal - // values. If at this point 2G is illegal. - julong reasonable_size = (julong)2*G - 2 * LargePageSizeInBytes; - result = MIN2(size, reasonable_size); - } - return result; -#endif -} - static hrtime_t first_hrtime = 0; static const hrtime_t hrtime_hz = 1000*1000*1000; const int LOCK_BUSY = 1; diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 4a99a1b3975..2b111029c4c 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -686,12 +686,17 @@ julong os::physical_memory() { return win32::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { +bool os::has_allocatable_memory_limit(julong* limit) { + MEMORYSTATUSEX ms; + ms.dwLength = sizeof(ms); + GlobalMemoryStatusEx(&ms); #ifdef _LP64 - return size; + *limit = (julong)ms.ullAvailVirtual; + return true; #else // Limit to 1400m because of the 2gb address space wall - return MIN2(size, (julong)1400*M); + *limit = MIN2((julong)1400*M, (julong)ms.ullAvailVirtual); + return true; #endif } diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 7fccf4be754..b662e5ae1a5 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1552,6 +1552,15 @@ void Arguments::set_g1_gc_flags() { } } +julong Arguments::limit_by_allocatable_memory(julong limit) { + julong max_allocatable; + julong result = limit; + if (os::has_allocatable_memory_limit(&max_allocatable)) { + result = MIN2(result, max_allocatable / MaxVirtMemFraction); + } + return result; +} + void Arguments::set_heap_size() { if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { // Deprecated flag @@ -1590,12 +1599,12 @@ void Arguments::set_heap_size() { } reasonable_max = MIN2(reasonable_max, max_coop_heap); } - reasonable_max = os::allocatable_physical_memory(reasonable_max); + reasonable_max = limit_by_allocatable_memory(reasonable_max); if (!FLAG_IS_DEFAULT(InitialHeapSize)) { // An initial heap size was specified on the command line, // so be sure that the maximum size is consistent. Done - // after call to allocatable_physical_memory because that + // after call to limit_by_allocatable_memory because that // method might reduce the allocation size. reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize); } @@ -1615,14 +1624,14 @@ void Arguments::set_heap_size() { reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); - reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum); + reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); julong reasonable_initial = phys_mem / InitialRAMFraction; reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); - reasonable_initial = os::allocatable_physical_memory(reasonable_initial); + reasonable_initial = limit_by_allocatable_memory(reasonable_initial); if (PrintGCDetails && Verbose) { // Cannot use gclog_or_tty yet. @@ -2608,9 +2617,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, initHeapSize = MIN2(total_memory / (julong)2, total_memory - (julong)160*M); - // Make sure that if we have a lot of memory we cap the 32 bit - // process space. The 64bit VM version of this function is a nop. - initHeapSize = os::allocatable_physical_memory(initHeapSize); + initHeapSize = limit_by_allocatable_memory(initHeapSize); if (FLAG_IS_DEFAULT(MaxHeapSize)) { FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize); diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index d75fc9a82bd..0a4350ee3c5 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -312,6 +312,9 @@ class Arguments : AllStatic { static void set_use_compressed_oops(); static void set_ergonomics_flags(); static void set_shared_spaces_flags(); + // limits the given memory size by the maximum amount of memory this process is + // currently allowed to allocate or reserve. + static julong limit_by_allocatable_memory(julong size); // Setup heap size static void set_heap_size(); // Based on automatic selection criteria, should the diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index d59bc735ed7..edfbcb9c2a7 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1962,6 +1962,10 @@ class CommandLineFlags { product(uintx, InitialRAMFraction, 64, \ "Fraction (1/n) of real memory used for initial heap size") \ \ + develop(uintx, MaxVirtMemFraction, 2, \ + "Maximum fraction (1/n) of virtual memory used for ergonomically" \ + "determining maximum heap size") \ + \ product(bool, UseAutoGCSelectPolicy, false, \ "Use automatic collection selection policy") \ \ diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index d061a0848c6..9bcf0c53174 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -184,7 +184,7 @@ class os: AllStatic { } static julong available_memory(); static julong physical_memory(); - static julong allocatable_physical_memory(julong size); + static bool has_allocatable_memory_limit(julong* limit); static bool is_server_class_machine(); // number of CPUs From 9c89e6d28aa8b723084f23efe4fe245f9874deda Mon Sep 17 00:00:00 2001 From: John Cuthbertson Date: Fri, 29 Mar 2013 13:49:37 -0700 Subject: [PATCH 053/155] 8010463: G1: Crashes with -UseTLAB and heap verification Some parts of the G1 heap can only be walked during a safepoint. Skip verifying these parts of the heap when verifying during JVM startup. Reviewed-by: brutisso, tschatzl --- .../gc_implementation/g1/g1CollectedHeap.cpp | 7 +-- hotspot/src/share/vm/memory/universe.cpp | 9 ---- hotspot/src/share/vm/runtime/init.cpp | 9 ---- hotspot/src/share/vm/runtime/thread.cpp | 11 +++-- .../gc/TestVerifyBeforeGCDuringStartup.java | 45 +++++++++++++++++++ 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 780e330b4f8..610942585e7 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3288,12 +3288,12 @@ void G1CollectedHeap::verify(bool silent) { void G1CollectedHeap::verify(bool silent, VerifyOption vo) { - if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) { + if (SafepointSynchronize::is_at_safepoint()) { if (!silent) { gclog_or_tty->print("Roots "); } VerifyRootsClosure rootsCl(vo); assert(Thread::current()->is_VM_thread(), - "Expected to be executed serially by the VM thread at this point"); + "Expected to be executed serially by the VM thread at this point"); CodeBlobToOopClosure blobsCl(&rootsCl, /*do_marking=*/ false); VerifyKlassClosure klassCl(this, &rootsCl); @@ -3378,7 +3378,8 @@ void G1CollectedHeap::verify(bool silent, } guarantee(!failures, "there should not have been any failures"); } else { - if (!silent) gclog_or_tty->print("(SKIPPING roots, heapRegions, remset) "); + if (!silent) + gclog_or_tty->print("(SKIPPING roots, heapRegionSets, heapRegions, remset) "); } } diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 79e092a3b19..d2bbf0175d2 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -953,15 +953,6 @@ void Universe::update_heap_info_at_gc() { void universe2_init() { EXCEPTION_MARK; Universe::genesis(CATCH); - // Although we'd like to verify here that the state of the heap - // is good, we can't because the main thread has not yet added - // itself to the threads list (so, using current interfaces - // we can't "fill" its TLAB), unless TLABs are disabled. - if (VerifyBeforeGC && !UseTLAB && - Universe::heap()->total_collections() >= VerifyGCStartAt) { - Universe::heap()->prepare_for_verify(); - Universe::verify(); // make sure we're starting with a clean slate - } } diff --git a/hotspot/src/share/vm/runtime/init.cpp b/hotspot/src/share/vm/runtime/init.cpp index 7ef17204bb2..62f295c7ec6 100644 --- a/hotspot/src/share/vm/runtime/init.cpp +++ b/hotspot/src/share/vm/runtime/init.cpp @@ -132,15 +132,6 @@ jint init_globals() { javaClasses_init(); // must happen after vtable initialization stubRoutines_init2(); // note: StubRoutines need 2-phase init - // Although we'd like to, we can't easily do a heap verify - // here because the main thread isn't yet a JavaThread, so - // its TLAB may not be made parseable from the usual interfaces. - if (VerifyBeforeGC && !UseTLAB && - Universe::heap()->total_collections() >= VerifyGCStartAt) { - Universe::heap()->prepare_for_verify(); - Universe::verify(); // make sure we're starting with a clean slate - } - // All the flags that get adjusted by VM_Version_init and os::init_2 // have been set so dump the flags now. if (PrintFlagsFinal) { diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 322597fe4cc..577901a2861 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -3423,12 +3423,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // real raw monitor. VM is setup enough here for raw monitor enter. JvmtiExport::transition_pending_onload_raw_monitors(); - if (VerifyBeforeGC && - Universe::heap()->total_collections() >= VerifyGCStartAt) { - Universe::heap()->prepare_for_verify(); - Universe::verify(); // make sure we're starting with a clean slate - } - // Fully start NMT MemTracker::start(); @@ -3452,6 +3446,11 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { } assert (Universe::is_fully_initialized(), "not initialized"); + if (VerifyBeforeGC && VerifyGCStartAt == 0) { + Universe::heap()->prepare_for_verify(); + Universe::verify(); // make sure we're starting with a clean slate + } + EXCEPTION_MARK; // At this point, the Universe is initialized, but we have not executed diff --git a/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java b/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java new file mode 100644 index 00000000000..109e45e4bd9 --- /dev/null +++ b/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 TestVerifyBeforeGCDuringStartup.java + * @key gc + * @bug 8010463 + * @summary Simple test run with -XX:+VerifyBeforeGC -XX:-UseTLAB to verify 8010463 + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +public class TestVerifyBeforeGCDuringStartup { + public static void main(String args[]) throws Exception { + ProcessBuilder pb = + ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"), + "-XX:-UseTLAB", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+VerifyBeforeGC", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("[Verifying"); + output.shouldHaveExitValue(0); + } +} From d67e393dd60d0afcd8cf992a7de182615fccd0d7 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Sat, 23 Mar 2013 09:16:37 +0100 Subject: [PATCH 054/155] 8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1" Reviewed-by: brutisso, sla, ctornqvi --- .../ClassMetaspaceSizeInJmapHeap.java | 6 +- .../java/testlibrary/JDKToolLauncher.java | 114 ++++++++++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java diff --git a/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java b/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java index 37a5f3a4c2c..b3258466a2d 100644 --- a/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java +++ b/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java @@ -39,8 +39,10 @@ public class ClassMetaspaceSizeInJmapHeap { public static void main(String[] args) throws Exception { String pid = Integer.toString(ProcessTools.getProcessId()); - ProcessBuilder pb = new ProcessBuilder(); - pb.command(JDKToolFinder.getJDKTool("jmap"), "-heap", pid); + JDKToolLauncher jmap = JDKToolLauncher.create("jmap") + .addToolArg("-heap") + .addToolArg(pid); + ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); File out = new File("ClassMetaspaceSizeInJmapHeap.stdout.txt"); pb.redirectOutput(out); diff --git a/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java b/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java new file mode 100644 index 00000000000..0f0c0a49d33 --- /dev/null +++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2013, 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. + */ + +package com.oracle.java.testlibrary; + +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; + +import com.oracle.java.testlibrary.JDKToolFinder; +import com.oracle.java.testlibrary.ProcessTools; + +/** + * A utility for constructing command lines for starting JDK tool processes. + * + * The JDKToolLauncher can in particular be combined with a + * java.lang.ProcessBuilder to easily run a JDK tool. For example, the + * following code run {@code jmap -heap} against a process with GC logging + * turned on for the {@code jmap} process: + * + *

    + * {@code
    + * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
    + *                                       .addVMArg("-XX:+PrintGC");
    + *                                       .addVMArg("-XX:+PrintGCDetails")
    + *                                       .addToolArg("-heap")
    + *                                       .addToolArg(pid);
    + * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
    + * Process p = pb.start();
    + * }
    + * 
    + */ +public class JDKToolLauncher { + private final String executable; + private final List vmArgs = new ArrayList(); + private final List toolArgs = new ArrayList(); + + private JDKToolLauncher(String tool) { + executable = JDKToolFinder.getJDKTool(tool); + vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs())); + } + + /** + * Creates a new JDKToolLauncher for the specified tool. + * + * @param tool The name of the tool + * @return A new JDKToolLauncher + */ + public static JDKToolLauncher create(String tool) { + return new JDKToolLauncher(tool); + } + + /** + * Adds an argument to the JVM running the tool. + * + * The JVM arguments are passed to the underlying JVM running the tool. + * Arguments will automatically be prepended with "-J". + * + * Any platform specific arguments required for running the tool are + * automatically added. + * + * + * @param arg The argument to VM running the tool + * @return The JDKToolLauncher instance + */ + public JDKToolLauncher addVMArg(String arg) { + vmArgs.add("-J" + arg); + return this; + } + + /** + * Adds an argument to the tool. + * + * @param arg The argument to the tool + * @return The JDKToolLauncher instance + */ + public JDKToolLauncher addToolArg(String arg) { + toolArgs.add(arg); + return this; + } + + /** + * Returns the command that can be used for running the tool. + * + * @return An array whose elements are the arguments of the command. + */ + public String[] getCommand() { + List command = new ArrayList(); + command.add(executable); + command.addAll(vmArgs); + command.addAll(toolArgs); + return command.toArray(new String[command.size()]); + } +} From 981e9c35c9371cf9eff83445c7027df69ed86aae Mon Sep 17 00:00:00 2001 From: Morris Meyer Date: Sat, 23 Mar 2013 06:22:07 -0700 Subject: [PATCH 055/155] 8009026: [parfait] Null pointer deference in hotspot/src/share/vm/code/nmethod.cpp Add guarantee() to nmethod constructor and checks to ensure CodeCache has space before allocation Reviewed-by: kvn --- hotspot/src/share/vm/code/codeCache.hpp | 5 +++ hotspot/src/share/vm/code/nmethod.cpp | 54 ++++++++++++++----------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/hotspot/src/share/vm/code/codeCache.hpp b/hotspot/src/share/vm/code/codeCache.hpp index 92ce241b938..e19aec61b79 100644 --- a/hotspot/src/share/vm/code/codeCache.hpp +++ b/hotspot/src/share/vm/code/codeCache.hpp @@ -156,6 +156,11 @@ class CodeCache : AllStatic { static address low_bound() { return (address) _heap->low_boundary(); } static address high_bound() { return (address) _heap->high_boundary(); } + static bool has_space(int size) { + // Always leave some room in the CodeCache for I2C/C2I adapters + return largest_free_block() > (CodeCacheMinimumFreeSpace + size); + } + // Profiling static address first_address(); // first address used for CodeBlobs static address last_address(); // last address used for CodeBlobs diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 157136edc0d..55a2c05f5ff 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -486,7 +486,6 @@ void nmethod::init_defaults() { #endif // def HAVE_DTRACE_H } - nmethod* nmethod::new_native_nmethod(methodHandle method, int compile_id, CodeBuffer *code_buffer, @@ -502,17 +501,19 @@ nmethod* nmethod::new_native_nmethod(methodHandle method, { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); - CodeOffsets offsets; - offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); - offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); - nm = new (native_nmethod_size) - nmethod(method(), native_nmethod_size, compile_id, &offsets, - code_buffer, frame_size, - basic_lock_owner_sp_offset, basic_lock_sp_offset, - oop_maps); - NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); - if (PrintAssembly && nm != NULL) - Disassembler::decode(nm); + if (CodeCache::has_space(native_nmethod_size)) { + CodeOffsets offsets; + offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); + offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); + nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, + compile_id, &offsets, + code_buffer, frame_size, + basic_lock_owner_sp_offset, + basic_lock_sp_offset, oop_maps); + NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); + if (PrintAssembly && nm != NULL) + Disassembler::decode(nm); + } } // verify nmethod debug_only(if (nm) nm->verify();) // might block @@ -537,16 +538,19 @@ nmethod* nmethod::new_dtrace_nmethod(methodHandle method, { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); - CodeOffsets offsets; - offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); - offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); - offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); + if (CodeCache::has_space(nmethod_size)) { + CodeOffsets offsets; + offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); + offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); + offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); - nm = new (nmethod_size) nmethod(method(), nmethod_size, &offsets, code_buffer, frame_size); + nm = new (nmethod_size) nmethod(method(), nmethod_size, + &offsets, code_buffer, frame_size); - NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); - if (PrintAssembly && nm != NULL) - Disassembler::decode(nm); + NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); + if (PrintAssembly && nm != NULL) + Disassembler::decode(nm); + } } // verify nmethod debug_only(if (nm) nm->verify();) // might block @@ -587,7 +591,8 @@ nmethod* nmethod::new_nmethod(methodHandle method, + round_to(handler_table->size_in_bytes(), oopSize) + round_to(nul_chk_table->size_in_bytes(), oopSize) + round_to(debug_info->data_size() , oopSize); - nm = new (nmethod_size) + if (CodeCache::has_space(nmethod_size)) { + nm = new (nmethod_size) nmethod(method(), nmethod_size, compile_id, entry_bci, offsets, orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, oop_maps, @@ -595,6 +600,7 @@ nmethod* nmethod::new_nmethod(methodHandle method, nul_chk_table, compiler, comp_level); + } if (nm != NULL) { // To make dependency checking during class loading fast, record // the nmethod dependencies in the classes it is dependent on. @@ -793,9 +799,9 @@ nmethod::nmethod( #endif // def HAVE_DTRACE_H void* nmethod::operator new(size_t size, int nmethod_size) { - // Always leave some room in the CodeCache for I2C/C2I adapters - if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) return NULL; - return CodeCache::allocate(nmethod_size); + void* alloc = CodeCache::allocate(nmethod_size); + guarantee(alloc != NULL, "CodeCache should have enough space"); + return alloc; } From 196cd6601b3631808f0a3c81914346262e3ab866 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Sat, 23 Mar 2013 10:06:34 -0700 Subject: [PATCH 056/155] 8010498: new hotspot build - hs25-b25 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 69b8ad849df..c6bad83dffd 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=24 +HS_BUILD_NUMBER=25 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From c458eb3fd6400ddf6988e21dbf9b5eb93f95328f Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Sun, 24 Mar 2013 09:11:55 +0100 Subject: [PATCH 057/155] 8008454: test/runtime/NMT/PrintNMTStatistics is broken Added @run tag so that it actually runs the test, also fixed broken command line and incorrect parsing. Also reviewed by gerard.ziemski@oracle.com Reviewed-by: mgerdin, zgu --- hotspot/test/runtime/NMT/PrintNMTStatistics.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hotspot/test/runtime/NMT/PrintNMTStatistics.java b/hotspot/test/runtime/NMT/PrintNMTStatistics.java index 084a81512d5..96bc2f3267f 100644 --- a/hotspot/test/runtime/NMT/PrintNMTStatistics.java +++ b/hotspot/test/runtime/NMT/PrintNMTStatistics.java @@ -27,7 +27,9 @@ * @bug 8005936 * @summary Make sure PrintNMTStatistics works on normal JVM exit * @library /testlibrary /testlibrary/whitebox - * @run compile PrintNMTStatistics.java + * @build PrintNMTStatistics + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main PrintNMTStatistics */ import com.oracle.java.testlibrary.*; @@ -52,13 +54,15 @@ public class PrintNMTStatistics { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", + "-Xbootclasspath/a:.", + "-XX:+WhiteBoxAPI", "-XX:NativeMemoryTracking=summary", - "+XX:+PrintNMTStatistics", + "-XX:+PrintNMTStatistics", "PrintNMTStatistics", "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Java Heap (reserved="); + output.shouldContain("Java Heap (reserved="); output.shouldNotContain("error"); output.shouldNotContain("warning"); output.shouldHaveExitValue(0); From 897aab045e7fef1438a523340501f2fe31826792 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Mon, 25 Mar 2013 12:01:06 +0100 Subject: [PATCH 058/155] 8017010: index evaluation to a temporary location for index operator much change temporaries to slots, but never scoped vars Reviewed-by: hannesw, sundar --- .../jdk/nashorn/internal/codegen/Attr.java | 9 ++- .../runtime/regexp/joni/ByteCodeMachine.java | 2 +- .../regexp/joni/encoding/AsciiTables.java | 2 +- nashorn/test/script/basic/JDK-8017010.js | 68 +++++++++++++++++++ .../test/script/basic/JDK-8017010.js.EXPECTED | 3 + nashorn/test/script/basic/NASHORN-258.js | 12 ++++ .../test/script/basic/NASHORN-258.js.EXPECTED | 1 + 7 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8017010.js create mode 100644 nashorn/test/script/basic/JDK-8017010.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java index 938055984cd..9ecf7c89a9c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Attr.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Attr.java @@ -577,7 +577,7 @@ final class Attr extends NodeOperatorVisitor { @Override public Node leaveIndexNode(final IndexNode indexNode) { - newTemporary(Type.OBJECT, indexNode); //TORO + newTemporary(Type.OBJECT, indexNode); //TODO return indexNode; } @@ -1470,8 +1470,13 @@ final class Attr extends NodeOperatorVisitor { assignmentDest.accept(new NodeVisitor() { @Override public Node leaveIndexNode(final IndexNode indexNode) { + assert indexNode.getSymbol().isTemp(); final Node index = indexNode.getIndex(); - index.getSymbol().setNeedsSlot(!index.getSymbol().isConstant()); + //only temps can be set as needing slots. the others will self resolve + //it is illegal to take a scope var and force it to be a slot, that breaks + if (index.getSymbol().isTemp() && !index.getSymbol().isConstant()) { + index.getSymbol().setNeedsSlot(true); + } return indexNode; } }); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java index 8aaabe2deca..43cc5188477 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java @@ -1459,4 +1459,4 @@ class ByteCodeMachine extends StackMachine { private int finish() { return bestLen; } -} \ No newline at end of file +} diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/AsciiTables.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/AsciiTables.java index 77eba2deb86..3dec4ba2547 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/AsciiTables.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/AsciiTables.java @@ -154,4 +154,4 @@ public class AsciiTables { {0x59, 0x79}, {0x5a, 0x7a} }; -} \ No newline at end of file +} diff --git a/nashorn/test/script/basic/JDK-8017010.js b/nashorn/test/script/basic/JDK-8017010.js new file mode 100644 index 00000000000..aa6e61a9328 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8017010.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * JDK-8010710 - slot/scope problem with temporary expressions + * as array index in self modifying assigns + * + * @test + * @run + */ +function zero() { + return 0; +} + +//try complex self modifying assignment and force slots to temporary value index operators +var a = [1, 2, 3, 4, 5]; +var b = [a, a]; +print(b[zero() + 1][2 + a[0]] += 10); + +//repro for NASHORN-258 that never made it +function AddRoundKey() { + var r=0; + state[r][1] &= 17; +} + +var srcFiles = []; +for(i=0;i<100;i++) { + srcFiles.push('dummy'); +} +var added = ''; + +//this broke the javafx build system. verify it works +function bouncingBall() { + for (j=0; j<100; j++) { + added += srcFiles[j]; + } +} +bouncingBall(); +print(added); + +//this is how they should have done it for speed, that works always, verify this too +function bouncingBall2() { + for (var k=0; k<100; k++) { + added += srcFiles[k]; + } +} +bouncingBall2(); +print(added); diff --git a/nashorn/test/script/basic/JDK-8017010.js.EXPECTED b/nashorn/test/script/basic/JDK-8017010.js.EXPECTED new file mode 100644 index 00000000000..296c81e57c4 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8017010.js.EXPECTED @@ -0,0 +1,3 @@ +14 +dummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummy +dummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummydummy diff --git a/nashorn/test/script/basic/NASHORN-258.js b/nashorn/test/script/basic/NASHORN-258.js index 0f4f674b6be..6d71266a3ad 100644 --- a/nashorn/test/script/basic/NASHORN-258.js +++ b/nashorn/test/script/basic/NASHORN-258.js @@ -29,6 +29,16 @@ */ function test3(a) { + for (i = 0; i < a.length ; i++) { + for (j = 0; j < a[i].length ; j++) { + for (k = 0; k < a[i][j].length ; k++) { + a[i][j][k] *= 8; + } + } + } +} + +function test3local(a) { for (var i = 0; i < a.length ; i++) { for (var j = 0; j < a[i].length ; j++) { for (var k = 0; k < a[i][j].length ; k++) { @@ -45,6 +55,8 @@ var array = [ [[1,1,1],[1,1,1],[1,1,1]], test3(array); print(array); +test3local(array); +print(array); function outer() { diff --git a/nashorn/test/script/basic/NASHORN-258.js.EXPECTED b/nashorn/test/script/basic/NASHORN-258.js.EXPECTED index 8c95c914b48..5986c471cd4 100644 --- a/nashorn/test/script/basic/NASHORN-258.js.EXPECTED +++ b/nashorn/test/script/basic/NASHORN-258.js.EXPECTED @@ -1,2 +1,3 @@ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 +64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64 1,1,8,1,1,8,1,1,8,1,1,8,1,1,8,1,1,8,1,1,8,1,1,8,1,1,8 From 41f0004e4ffc4c43ddaf45ea38c8008d837e0202 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Mon, 25 Mar 2013 08:37:28 -0400 Subject: [PATCH 059/155] 8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions Don't check the padding bits if class file version is >= 51. Reviewed-by: kvn, dholmes, coleenp --- hotspot/src/share/vm/classfile/verifier.cpp | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 071c835279e..4ff142a9200 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -61,8 +61,9 @@ # include "bytes_ppc.hpp" #endif -#define NOFAILOVER_MAJOR_VERSION 51 -#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52 +#define NOFAILOVER_MAJOR_VERSION 51 +#define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION 51 +#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52 // Access to external entry for VerifyClassCodes - old byte code verifier @@ -2027,16 +2028,19 @@ void ClassVerifier::verify_switch( address bcp = bcs->bcp(); address aligned_bcp = (address) round_to((intptr_t)(bcp + 1), jintSize); - // 4639449 & 4647081: padding bytes must be 0 - u2 padding_offset = 1; - while ((bcp + padding_offset) < aligned_bcp) { - if(*(bcp + padding_offset) != 0) { - verify_error(ErrorContext::bad_code(bci), - "Nonzero padding byte in lookswitch or tableswitch"); - return; + if (_klass->major_version() < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) { + // 4639449 & 4647081: padding bytes must be 0 + u2 padding_offset = 1; + while ((bcp + padding_offset) < aligned_bcp) { + if(*(bcp + padding_offset) != 0) { + verify_error(ErrorContext::bad_code(bci), + "Nonzero padding byte in lookswitch or tableswitch"); + return; + } + padding_offset++; } - padding_offset++; } + int default_offset = (int) Bytes::get_Java_u4(aligned_bcp); int keys, delta; current_frame->pop_stack( From a9423b7ebf4e22b42c4382cbfd946ed5a2034386 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 25 Mar 2013 18:20:16 +0530 Subject: [PATCH 060/155] 8010709: org on the top level doesn't resolve Reviewed-by: lagergren, hannesw --- .../jdk/nashorn/internal/objects/Global.java | 30 +++++++++++- nashorn/test/script/basic/JDK-8010709.js | 46 +++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/script/basic/JDK-8010709.js diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index e0bb9ecefd2..e079248b577 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -259,13 +259,29 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { @Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE) public volatile Object packages; + /** Nashorn extension: Java access - global.com */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public volatile Object com; + + /** Nashorn extension: Java access - global.edu */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public volatile Object edu; + /** Nashorn extension: Java access - global.java */ @Property(attributes = Attribute.NOT_ENUMERABLE) public volatile Object java; + /** Nashorn extension: Java access - global.javafx */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public volatile Object javafx; + /** Nashorn extension: Java access - global.javax */ @Property(attributes = Attribute.NOT_ENUMERABLE) - public Object javax; + public volatile Object javax; + + /** Nashorn extension: Java access - global.org */ + @Property(attributes = Attribute.NOT_ENUMERABLE) + public volatile Object org; /** Nashorn extension: Java access - global.javaImporter */ @Property(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE) @@ -320,8 +336,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { private ScriptFunction builtinTypeError; private ScriptFunction builtinURIError; private ScriptObject builtinPackages; + private ScriptObject builtinCom; + private ScriptObject builtinEdu; private ScriptObject builtinJava; + private ScriptObject builtinJavafx; private ScriptObject builtinJavax; + private ScriptObject builtinOrg; private ScriptObject builtinJavaImporter; private ScriptObject builtinJavaApi; private ScriptObject builtinArrayBuffer; @@ -1482,8 +1502,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { private void initJavaAccess() { final ScriptObject objectProto = getObjectPrototype(); this.builtinPackages = new NativeJavaPackage("", objectProto); + this.builtinCom = new NativeJavaPackage("com", objectProto); + this.builtinEdu = new NativeJavaPackage("edu", objectProto); this.builtinJava = new NativeJavaPackage("java", objectProto); + this.builtinJavafx = new NativeJavaPackage("javafx", objectProto); this.builtinJavax = new NativeJavaPackage("javax", objectProto); + this.builtinOrg = new NativeJavaPackage("org", objectProto); this.builtinJavaImporter = initConstructor("JavaImporter"); this.builtinJavaApi = initConstructor("Java"); } @@ -1566,8 +1590,12 @@ public final class Global extends ScriptObject implements GlobalObject, Scope { this.function = this.builtinFunction; this.jsadapter = this.builtinJSAdapter; this.json = this.builtinJSON; + this.com = this.builtinCom; + this.edu = this.builtinEdu; this.java = this.builtinJava; + this.javafx = this.builtinJavafx; this.javax = this.builtinJavax; + this.org = this.builtinOrg; this.javaImporter = this.builtinJavaImporter; this.javaApi = this.builtinJavaApi; this.math = this.builtinMath; diff --git a/nashorn/test/script/basic/JDK-8010709.js b/nashorn/test/script/basic/JDK-8010709.js new file mode 100644 index 00000000000..d2ec87aeb7d --- /dev/null +++ b/nashorn/test/script/basic/JDK-8010709.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * JDK-8010709 org on the top level doesn't resolve + * + * @test + * @run + */ + +function check(pkgName) { + if (typeof this[pkgName] != 'object') { + fail(pkgName + " not defined"); + } + + if (String(this[pkgName]) != '[JavaPackage ' + pkgName + ']') { + fail(pkgName + " is not a JavaPackage"); + } +} + +check("com"); +check("edu"); +check("java"); +check("javafx"); +check("javax"); +check("org"); From 0e9d409036892e67fb0d3928e7845692cd58459a Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Mon, 25 Mar 2013 09:36:15 -0700 Subject: [PATCH 061/155] 8009552: test/vm/verifier/TestStaticIF.java failing with hs25.0-b Remove support for verification of class files with version 52 and above from type inference verifier. Reviewed-by: acorn, hseigel --- hotspot/src/share/vm/classfile/verifier.cpp | 6 --- .../test/runtime/8007736/TestStaticIF.java | 44 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 hotspot/test/runtime/8007736/TestStaticIF.java diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 4ff142a9200..96912df1971 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -63,7 +63,6 @@ #define NOFAILOVER_MAJOR_VERSION 51 #define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION 51 -#define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52 // Access to external entry for VerifyClassCodes - old byte code verifier @@ -2322,11 +2321,6 @@ void ClassVerifier::verify_invoke_instructions( types = (1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref); break; - case Bytecodes::_invokestatic: - types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ? - (1 << JVM_CONSTANT_Methodref) : - ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref)); - break; default: types = 1 << JVM_CONSTANT_Methodref; } diff --git a/hotspot/test/runtime/8007736/TestStaticIF.java b/hotspot/test/runtime/8007736/TestStaticIF.java deleted file mode 100644 index d3c3239e816..00000000000 --- a/hotspot/test/runtime/8007736/TestStaticIF.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013, 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 8007736 - * @summary Test static interface method. - * @run main/othervm -Xverify:all TestStaticIF - */ - -public class TestStaticIF implements StaticMethodInInterface { - - public static void main(String[] args) { - System.out.printf("main: %s%n", StaticMethodInInterface.get()); - } -} - -interface StaticMethodInInterface { - - public static String get() { - return "Hello from StaticMethodInInterface.get()"; - } -} From 9309aac6971c4ab58f370e5513e15a2e1f1bd4ad Mon Sep 17 00:00:00 2001 From: Michael Fang Date: Mon, 25 Mar 2013 16:53:02 -0700 Subject: [PATCH 062/155] 8010521: jdk8 l10n resource file translation update 2 Reviewed-by: naoto, yhuang --- .../se/impl/orbutil/resources/sunorb_de.properties | 2 +- .../se/impl/orbutil/resources/sunorb_es.properties | 2 +- .../se/impl/orbutil/resources/sunorb_fr.properties | 2 +- .../se/impl/orbutil/resources/sunorb_it.properties | 10 +++++----- .../se/impl/orbutil/resources/sunorb_ja.properties | 10 +++++----- .../se/impl/orbutil/resources/sunorb_ko.properties | 2 +- .../se/impl/orbutil/resources/sunorb_pt_BR.properties | 2 +- .../se/impl/orbutil/resources/sunorb_sv.properties | 2 +- .../se/impl/orbutil/resources/sunorb_zh_CN.properties | 2 +- .../se/impl/orbutil/resources/sunorb_zh_TW.properties | 2 +- .../classes/com/sun/tools/corba/se/idl/idl_ja.prp | 8 ++++---- .../classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp | 2 +- .../corba/se/idl/toJavaPortable/toJavaPortable_ja.prp | 4 ++-- .../se/idl/toJavaPortable/toJavaPortable_zh_CN.prp | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties index 3343f1fb225..b33670ea62f 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties index 96707e40f75..12562891caa 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_es.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties index b46f46cd619..b1b64f1f9f3 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_fr.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties index 7d39881dddf..908f7a4e2cb 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_it.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 @@ -23,9 +23,9 @@ # questions. # -orbd.usage=Utilizzo: {0} \n\ndove include:\n -port Porta di attivazione da cui avviare ORBD, valore predefinito 1049 (opzionale)\n -defaultdb Directory per i file ORBD, valore predefinito "./orb.db" (opzionale)\n -serverid ID server per ORBD, valore predefinito 1 (opzionale)\n -ORBInitialPort Porta iniziale (richiesta)\n -ORBInitialHost HostName iniziale (richiesto)\n +orbd.usage=Uso: {0} \n\ndove include:\n -port Porta di attivazione da cui avviare ORBD, valore predefinito 1049 (opzionale)\n -defaultdb Directory per i file ORBD, valore predefinito "./orb.db" (opzionale)\n -serverid ID server per ORBD, valore predefinito 1 (opzionale)\n -ORBInitialPort Porta iniziale (richiesta)\n -ORBInitialHost HostName iniziale (richiesto)\n -servertool.usage=Utilizzo: {0} \n\ndove include:\n -ORBInitialPort Porta iniziale (richiesta)\n -ORBInitialHost HostName iniziale (richiesto)\n +servertool.usage=Uso: {0} \n\ndove include:\n -ORBInitialPort Porta iniziale (richiesta)\n -ORBInitialHost HostName iniziale (richiesto)\n servertool.banner=\n\nBenvenuti in Java IDL Server Tool \nimmettere i comandi quando richiesto \n servertool.shorthelp=\n\n\tComandi disponibili:\n\t-------------------- \n servertool.baddef=Definizione server errata: {0} @@ -82,13 +82,13 @@ servertool.quit1=esci dall'applicazione corrente servertool.help=\thelp\n\tOR\n\thelp \n servertool.help1=Guida -servertool.orbidmap=\tUtilizzo: orblist [ -serverid | -applicationName ]\n +servertool.orbidmap=\tUso: orblist [ -serverid | -applicationName ]\n servertool.orbidmap1=lista nomi orb e relativa mappatura servertool.orbidmap2=\n\tId ORB\t\tNome ORB\n\t------\t\t--------\n pnameserv.success=NameServer persistente avviato correttamente -bootstrap.usage=Utilizzo: {0} \n\ndove include:\n -ORBInitialPort Porta iniziale (richiesta)\n -InitialServicesFile File contenente la lista dei servizi iniziali (richiesto)\n +bootstrap.usage=Uso: {0} \n\ndove include:\n -ORBInitialPort Porta iniziale (richiesta)\n -InitialServicesFile File contenente la lista dei servizi iniziali (richiesto)\n bootstrap.success=impostazione porta su {0} e lettura servizi da {1} in corso bootstrap.filenotreadable=il file {0} non \u00E8 leggibile bootstrap.filenotfound=impossibile trovare il file {0} diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties index 8911bd177f1..f067fd9de63 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 @@ -60,12 +60,12 @@ servertool.getserverid=\n\tgetserverid [ -applicationName ]\n servertool.getserverid1=applicationName\u306E\u30B5\u30FC\u30D0\u30FCID\u3092\u8FD4\u3057\u307E\u3059 servertool.getserverid2=\tapplicationName {0}\u306E\u30B5\u30FC\u30D0\u30FCID\u306F{1}\u3067\u3059 -servertool.list=\n\t\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059\n +servertool.list=\n\tlist\n servertool.list1=\u767B\u9332\u3055\u308C\u305F\u3059\u3079\u3066\u306E\u30B5\u30FC\u30D0\u30FC\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059 servertool.list2=\n\t\u30B5\u30FC\u30D0\u30FCID\t\u30B5\u30FC\u30D0\u30FC\u306E\u30AF\u30E9\u30B9\u540D\t\t\u30B5\u30FC\u30D0\u30FC\u30FB\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\n\t---------\t----------------\t\t----------------------\n -servertool.listactive=\n\t\u30A2\u30AF\u30C6\u30A3\u30D6\u306A\u30B5\u30FC\u30D0\u30FC\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059 +servertool.listactive=\n\tlistactive servertool.listactive1=\u73FE\u5728\u30A2\u30AF\u30C6\u30A3\u30D6\u306A\u30B5\u30FC\u30D0\u30FC\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059 -servertool.listappnames=\tapplicationNames\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059\n +servertool.listappnames=\tlistappnames\n servertool.listappnames1=\u73FE\u5728\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u308BapplicationNames\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059 servertool.listappnames2=\u73FE\u5728\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u308B\u30B5\u30FC\u30D0\u30FCapplicationNames: @@ -76,7 +76,7 @@ servertool.startserver=\n\tstartup [ -serverid | -applicationName \n diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties index 7d58921d36f..7be6158a9f5 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_ko.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties index 1c5dbce8243..81ca99db3d8 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_pt_BR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties index eaf5b45f79a..c11488e9f48 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_sv.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties index e03e66b400f..6dce9e6e827 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties index 075fa02a2ba..db797522663 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties +++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2005, 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 diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp index ab409ba6fa5..80fbd04f9d8 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp @@ -68,7 +68,7 @@ Compile.parsing=%0\u306E\u89E3\u6790\u4E2D Compile.parseDone=\u5B8C\u4E86 - %0 Compile.generating=%0\u306E\u751F\u6210\u4E2D Compile.genDone=\u5B8C\u4E86 - %0 -Deprecated.keyword=\u8B66\u544A: \u30AD\u30FC\u30EF\u30FC\u30C9`%0'\u306F\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 +Deprecated.keyword=\u8B66\u544A: \u30AD\u30FC\u30EF\u30FC\u30C9`%0'\u306F\u975E\u63A8\u5968\u3067\u3059\u3002 EvaluationException.1=%0\u6F14\u7B97\u5B50\u306E\u30AA\u30DA\u30E9\u30F3\u30C9\u306B\u4E00\u8CAB\u6027\u304C\u3042\u308A\u307E\u305B\u3093: %1\u304A\u3088\u3073%2\u3002 EvaluationException.2=%0\u6F14\u7B97\u5B50\u306E\u30AA\u30DA\u30E9\u30F3\u30C9\u306F\u3001%1\u3067\u306F\u306A\u304F\u6570\u5024\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002 EvaluationException.or=\u30D3\u30C3\u30C8\u5358\u4F4D\u306EOR\u6F14\u7B97 @@ -114,7 +114,7 @@ ParseException.badRepIDPrefix=%0 (\u884C%1): \u30A4\u30F3\u30BF\u30D5\u30A7\u30F ParseException.badState=%0 (\u884C%1): %2\u306F\u30B9\u30C6\u30FC\u30C8\u30D5\u30EB\u30FB\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u3067\u304D\u307E\u305B\u3093\u3002\u8907\u6570\u306E\u30B9\u30C6\u30FC\u30C8\u30D5\u30EB\u89AA\u304C\u3042\u308A\u307E\u3059\u3002\n%3\n%4 ParseException.branchLabel=%0 (\u884C%1): case %2\u306F\u3059\u3067\u306B\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u3059\u3002\n%3\n%4 ParseException.branchName=%0 (\u884C%1): %2\u3068\u3044\u3046\u540D\u524D\u306E\u5206\u5C90\u306F\u3059\u3067\u306B\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u3059\u3002\n%3\n%4 -ParseException.duplicateInit=%0 (\u884C%1): \u521D\u671F\u5316\u5B50\u306B\u306F\u524D\u306E\u521D\u671F\u5316\u5B50\u3068\u540C\u3058\u7F72\u540D\u304C\u3042\u308A\u307E\u3059\u3002\n%2\n%3 +ParseException.duplicateInit=%0 (\u884C%1): \u521D\u671F\u5316\u5B50\u306B\u306F\u524D\u306E\u521D\u671F\u5316\u5B50\u3068\u540C\u3058\u30B7\u30B0\u30CD\u30C1\u30E3\u304C\u3042\u308A\u307E\u3059\u3002\n%2\n%3 ParseException.duplicateState=%0 (\u884C%1): \u30C7\u30FC\u30BF\u30FB\u30E1\u30F3\u30D0\u30FC%2\u306E\u540D\u524D\u304C\u524D\u306E\u30C7\u30FC\u30BF\u30FB\u30E1\u30F3\u30D0\u30FC\u3068\u540C\u3058\u3067\u3059\u3002\n%3\n%4 ParseException.elseNoIf=%0 (\u884C%1): \u4E00\u81F4\u3059\u308B#if\u304C\u306A\u3044#else\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n%2\n%3 ParseException.endNoIf=%0 (\u884C%1): \u4E00\u81F4\u3059\u308B#if\u304C\u306A\u3044#endif\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n%2\n%3 @@ -146,7 +146,7 @@ ParseException.selfInherit=%0 (\u884C%1): %2\u3092\u305D\u308C\u81EA\u4F53\u304B ParseException.stringTooLong=%0 (\u884C%1): "%2"\u306F%3\u6587\u5B57\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n%4\n%5 ParseException.syntax1=%0 (\u884C%1): `%2'\u304C\u5FC5\u8981\u3067\u3059\u304C\u3001`%3'\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n%4\n%5 ParseException.syntax2=%0 (\u884C%1): %2\u306E1\u3064\u304C\u5FC5\u8981\u3067\u3059\u304C\u3001`%3'\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n%4\n%5 -ParseException.unclosed=%0: \u30B3\u30E1\u30F3\u30C8\u3067\u4E88\u671F\u3057\u306A\u3044EOF\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002 +ParseException.unclosed=%0: \u30B3\u30E1\u30F3\u30C8\u3067\u4E88\u671F\u3057\u306A\u3044\u30D5\u30A1\u30A4\u30EB\u306E\u7D42\u308F\u308A\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002 ParseException.undeclaredType=%0 (\u884C%1): %2\u306F\u5BA3\u8A00\u3055\u308C\u3066\u3044\u306A\u3044\u578B\u3067\u3059\u3002\n%3\n%4 ParseException.warning=%0 (\u884C%1): %2\n%3\n%4 ParseException.constExprType=%0 (\u884C%1): \u5B9A\u6570\u5F0F\u306E\u578B\u306F%2\u3067\u3059\u304C\u3001%3\u306B\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n%4\n%5 @@ -173,5 +173,5 @@ default=\u30A8\u30E9\u30FC\u3002\u5B58\u5728\u3057\u306A\u3044\u30E1\u30C3\u30BB # -i, -d, -keep, -emitAll, -noWarn, -v, -verbose, -version, #define # Do not translate the string "java com.sun.tools.corba.se.idl.Compile" -usage=\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u4F7F\u7528\u65B9\u6CD5:\n\ java com.sun.tools.corba.se.idl.Compile [options] \n\u306FIDL\u5B9A\u7FA9\u3092\u542B\u3080\u30D5\u30A1\u30A4\u30EB\u306E\u540D\u524D\u3067\u3001\n[options]\u306F\u6B21\u306B\u30EA\u30B9\u30C8\u3059\u308B\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u3067\u3059\u3002\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\n\u7701\u7565\u53EF\u80FD\u3067\u3001\u4EFB\u610F\u306E\u9806\u5E8F\u3067\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u306F\u5FC5\u9808\u3067\u3001\n\u6700\u5F8C\u306B\u8868\u793A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n\ \n\u30AA\u30D7\u30B7\u30E7\u30F3:\n-d IDL\u30D5\u30A1\u30A4\u30EB\u306E\u6B21\u306E\u884C\u3068\n\ \u540C\u3058\u3067\u3059: #define \n-emitAll #included\u30D5\u30A1\u30A4\u30EB\u3067\u898B\u3064\u304B\u3063\u305F\u30BF\u30A4\u30D7\u3092\u542B\u3080\u3001\u3059\u3079\u3066\u306E\u30BF\u30A4\u30D7\u3092\n\ \u767A\u884C\u3057\u307E\u3059\u3002\n-i \u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001\u73FE\u5728\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u304C\n\ \u30B9\u30AD\u30E3\u30F3\u3055\u308C\u307E\u3059\u3002\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u5225\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u8FFD\u52A0\u3057\u307E\u3059\u3002\n-keep \u751F\u6210\u3055\u308C\u308B\u30D5\u30A1\u30A4\u30EB\u304C\u3059\u3067\u306B\u5B58\u5728\u3059\u308B\u5834\u5408\u306F\u3001\u4E0A\u66F8\u304D\n\ \u3057\u307E\u305B\u3093\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u4E0A\u66F8\u304D\u3055\u308C\u307E\u3059\u3002\n-noWarn \u8B66\u544A\u3092\u51FA\u3055\u306A\u3044\u3088\u3046\u306B\u3057\u307E\u3059\u3002\n-v, -verbose \u8A73\u7D30\u30E2\u30FC\u30C9\u3002\n-version \u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7\u3092\u8868\u793A\u3057\u307E\u3059\u3002\n +usage=\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u4F7F\u7528\u65B9\u6CD5:\n java com.sun.tools.corba.se.idl.Compile [options] \n\u306FIDL\u5B9A\u7FA9\u3092\u542B\u3080\u30D5\u30A1\u30A4\u30EB\u306E\u540D\u524D\u3067\u3001\n[options]\u306F\u6B21\u306B\u30EA\u30B9\u30C8\u3059\u308B\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u3067\u3059\u3002\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\n\u7701\u7565\u53EF\u80FD\u3067\u3001\u4EFB\u610F\u306E\u9806\u5E8F\u3067\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u306F\u5FC5\u9808\u3067\u3001\n\u6700\u5F8C\u306B\u8868\u793A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n \n\u30AA\u30D7\u30B7\u30E7\u30F3:\n-d IDL\u30D5\u30A1\u30A4\u30EB\u306E\u6B21\u306E\u884C\u3068\n \u540C\u3058\u3067\u3059: #define \n-emitAll #included\u30D5\u30A1\u30A4\u30EB\u3067\u898B\u3064\u304B\u3063\u305F\u30BF\u30A4\u30D7\u3092\u542B\u3080\u3001\u3059\u3079\u3066\u306E\u30BF\u30A4\u30D7\u3092\n \u767A\u884C\u3057\u307E\u3059\u3002\n-i \u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001\u73FE\u5728\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u304C\n \u30B9\u30AD\u30E3\u30F3\u3055\u308C\u307E\u3059\u3002\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u5225\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u8FFD\u52A0\u3057\u307E\u3059\u3002\n-keep \u751F\u6210\u3055\u308C\u308B\u30D5\u30A1\u30A4\u30EB\u304C\u3059\u3067\u306B\u5B58\u5728\u3059\u308B\u5834\u5408\u306F\u3001\u4E0A\u66F8\u304D\n \u3057\u307E\u305B\u3093\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u4E0A\u66F8\u304D\u3055\u308C\u307E\u3059\u3002\n-noWarn \u8B66\u544A\u3092\u51FA\u3055\u306A\u3044\u3088\u3046\u306B\u3057\u307E\u3059\u3002\n-v, -verbose \u8A73\u7D30\u30E2\u30FC\u30C9\u3002\n-version \u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7\u3092\u8868\u793A\u3057\u307E\u3059\u3002\n diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp index ed66b727a78..630b55d0d7f 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp @@ -173,5 +173,5 @@ default=\u9519\u8BEF! \u8BF7\u6C42\u4E86\u4E0D\u5B58\u5728\u7684\u6D88\u606F\u30 # -i, -d, -keep, -emitAll, -noWarn, -v, -verbose, -version, #define # Do not translate the string "java com.sun.tools.corba.se.idl.Compile" -usage=\u7F16\u8BD1\u5668\u7528\u6CD5:\n\ java com.sun.tools.corba.se.idl.Compile [\u9009\u9879] \n\u5176\u4E2D, \u662F\u5305\u542B IDL \u5B9A\u4E49\u7684\u6587\u4EF6\u7684\u540D\u79F0, \u800C\n[\u9009\u9879] \u662F\u4E0B\u5217\u9009\u9879\u7684\u4EFB\u610F\u7EC4\u5408\u3002\u8FD9\u4E9B\u9009\u9879\n\u662F\u53EF\u9009\u7684, \u5E76\u4E14\u663E\u793A\u987A\u5E8F\u5E76\u4E0D\u56FA\u5B9A; \u662F\u5FC5\u9700\u7684\n\u5E76\u4E14\u5FC5\u987B\u663E\u793A\u5728\u6700\u540E\u3002\n\ \n\u9009\u9879:\n-d <\u7B26\u53F7> \u8FD9\u7B49\u540C\u4E8E IDL \u6587\u4EF6\u4E2D\u7684\n\ \u4E0B\u9762\u4E00\u884C: #define <\u7B26\u53F7>\n-emitAll \u53D1\u51FA\u6240\u6709\u7C7B\u578B, \u5305\u62EC\u5728 #included\n\ \u6587\u4EF6\u4E2D\u627E\u5230\u7684\u7C7B\u578B\u3002\n-i <\u5305\u542B\u8DEF\u5F84> \u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5C06\u5728\u5F53\u524D\u76EE\u5F55\u4E2D\u626B\u63CF\n\ \u5305\u542B\u7684\u6587\u4EF6\u3002\u6B64\u9009\u9879\u5C06\u6DFB\u52A0\u53E6\u4E00\u4E2A\u76EE\u5F55\u3002\n-keep \u5982\u679C\u8981\u751F\u6210\u7684\u6587\u4EF6\u5DF2\u5B58\u5728, \u8BF7\u4E0D\u8981\n\ \u8986\u76D6\u5B83\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u4F1A\u8986\u76D6\u5B83\u3002\n-noWarn \u9690\u85CF\u8B66\u544A\u3002\n-v, -verbose \u8BE6\u7EC6\u6A21\u5F0F\u3002\n-version \u663E\u793A\u7248\u672C\u53F7\u3002\n +usage=\u7F16\u8BD1\u5668\u7528\u6CD5:\n java com.sun.tools.corba.se.idl.Compile [\u9009\u9879] \n\u5176\u4E2D, \u662F\u5305\u542B IDL \u5B9A\u4E49\u7684\u6587\u4EF6\u7684\u540D\u79F0, \u800C\n[\u9009\u9879] \u662F\u4E0B\u5217\u9009\u9879\u7684\u4EFB\u610F\u7EC4\u5408\u3002\u8FD9\u4E9B\u9009\u9879\n\u662F\u53EF\u9009\u7684, \u5E76\u4E14\u663E\u793A\u987A\u5E8F\u5E76\u4E0D\u56FA\u5B9A; \u662F\u5FC5\u9700\u7684\n\u5E76\u4E14\u5FC5\u987B\u663E\u793A\u5728\u6700\u540E\u3002\n \n\u9009\u9879:\n-d <\u7B26\u53F7> \u8FD9\u7B49\u540C\u4E8E IDL \u6587\u4EF6\u4E2D\u7684\n \u4E0B\u9762\u4E00\u884C: #define <\u7B26\u53F7>\n-emitAll \u53D1\u51FA\u6240\u6709\u7C7B\u578B, \u5305\u62EC\u5728 #included\n \u6587\u4EF6\u4E2D\u627E\u5230\u7684\u7C7B\u578B\u3002\n-i <\u5305\u542B\u8DEF\u5F84> \u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5C06\u5728\u5F53\u524D\u76EE\u5F55\u4E2D\u626B\u63CF\n \u5305\u542B\u7684\u6587\u4EF6\u3002\u6B64\u9009\u9879\u5C06\u6DFB\u52A0\u53E6\u4E00\u4E2A\u76EE\u5F55\u3002\n-keep \u5982\u679C\u8981\u751F\u6210\u7684\u6587\u4EF6\u5DF2\u5B58\u5728, \u8BF7\u4E0D\u8981\n \u8986\u76D6\u5B83\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u4F1A\u8986\u76D6\u5B83\u3002\n-noWarn \u9690\u85CF\u8B66\u544A\u3002\n-v, -verbose \u8BE6\u7EC6\u6A21\u5F0F\u3002\n-version \u663E\u793A\u7248\u672C\u53F7\u3002\n diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp index 1171c88b7f2..35cee81cd2d 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp @@ -53,7 +53,7 @@ # toJavaProlog1=%0\u306B\u3088\u3063\u3066\u751F\u6210\u3055\u308C\u307E\u3057\u305F toJavaProlog2=%0\u304B\u3089 -PreEmit.indeterminateTypeInfo=%0\u306E\u30BF\u30A4\u30D7\u60C5\u5831\u3092\u5224\u65AD\u3067\u304D\u307E\u305B\u3093\u3002 +PreEmit.indeterminateTypeInfo=%0\u306E\u30BF\u30A4\u30D7\u60C5\u5831\u3092\u5224\u5225\u3067\u304D\u307E\u305B\u3093\u3002 InterfaceGen.noImpl=%0\u306E\u30ED\u30FC\u30AB\u30EB\u5B9F\u88C5\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 Version.product=IDL-to-Java\u30B3\u30F3\u30D1\u30A4\u30E9(\u30DD\u30FC\u30BF\u30D6\u30EB)\u3001\u30D0\u30FC\u30B8\u30E7\u30F3"%0" Version.number=3.2 @@ -65,4 +65,4 @@ NameModifier.InvalidChar=\u30D1\u30BF\u30FC\u30F3\u306B\u7121\u52B9\u306A\u6587\ # -d, -emitAll, -f, -i, -keep, -m, -sep, -pkgPrefix, -td, -v, -verbose, -version, -implbase # Do not translate the string "java com.sun.tools.corba.se.idl.toJavaPortable.Compile" # -usage=\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u4F7F\u7528\u65B9\u6CD5:\n\n\ java com.sun.tools.corba.se.idl.toJavaPortable.Compile [options] \n\n\u306FIDL\u5B9A\u7FA9\u3092\u542B\u3080\u30D5\u30A1\u30A4\u30EB\u306E\u540D\u524D\u3067\u3001\n[options]\u306F\u6B21\u306B\u30EA\u30B9\u30C8\u3059\u308B\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u3067\u3059\u3002\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\n\u7701\u7565\u53EF\u80FD\u3067\u3001\u4EFB\u610F\u306E\u9806\u5E8F\u3067\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u306F\u5FC5\u9808\u3067\u3001\n\u6700\u5F8C\u306B\u8868\u793A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n\ \n\u30AA\u30D7\u30B7\u30E7\u30F3:\n-d IDL\u30D5\u30A1\u30A4\u30EB\u306E\u6B21\u306E\u884C\u3068\n\ \u540C\u3058\u3067\u3059: #define \n-emitAll #included\u30D5\u30A1\u30A4\u30EB\u3067\u898B\u3064\u304B\u3063\u305F\u30BF\u30A4\u30D7\u3092\u542B\u3080\u3001\u3059\u3079\u3066\u306E\u30BF\u30A4\u30D7\u3092\u767A\u884C\u3057\u307E\u3059\u3002\n-f \u767A\u884C\u3059\u308B\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0\u3092\u5B9A\u7FA9\u3057\u307E\u3059\u3002\u306Fclient\u3001\n\ server\u3001all\u3001serverTIE\u3001allTIE\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002serverTIE\u3068allTIE\u306F\n\ \u59D4\u4EFB\u30E2\u30C7\u30EB\u30FB\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u767A\u884C\u3057\u307E\u3059\u3002\u3053\u306E\u30D5\u30E9\u30B0\u3092\n\ \u4F7F\u7528\u3057\u306A\u3044\u5834\u5408\u306F\u3001-fclient\u3068\u307F\u306A\u3055\u308C\u307E\u3059\u3002\n-i \u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001\u73FE\u5728\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u304C\n\ \u30B9\u30AD\u30E3\u30F3\u3055\u308C\u307E\u3059\u3002\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u5225\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u8FFD\u52A0\u3057\u307E\u3059\u3002\n-keep \u751F\u6210\u3055\u308C\u308B\u30D5\u30A1\u30A4\u30EB\u304C\u3059\u3067\u306B\u5B58\u5728\u3059\u308B\u5834\u5408\u306F\u3001\u4E0A\u66F8\u304D\n\ \u3057\u307E\u305B\u3093\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u4E0A\u66F8\u304D\u3055\u308C\u307E\u3059\u3002\n-noWarn \u8B66\u544A\u3092\u51FA\u3055\u306A\u3044\u3088\u3046\u306B\u3057\u307E\u3059\u3002\n-oldImplBase \u53E4\u3044(1.4\u4EE5\u524D) JDK ORB\u3068\u4E92\u63DB\u6027\u306E\u3042\u308B\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u751F\u6210\u3057\u307E\u3059\u3002\n-pkgPrefix \u30D5\u30A1\u30A4\u30EB\u30FB\u30B9\u30B3\u30FC\u30D7\u3067\u30BF\u30A4\u30D7\u307E\u305F\u306F\u30E2\u30B8\u30E5\u30FC\u30EB\u540D\u304C\u691C\u51FA\u3055\u308C\u305F\u5834\u5408\u3001\n\ \u306B\u5BFE\u3057\u3066\u751F\u6210\u3055\u308C\u305F\u3059\u3079\u3066\u306E\u30D5\u30A1\u30A4\u30EB\u306EJava\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u3092\n\ \u3067\u59CB\u3081\u307E\u3059\u3002\n-pkgTranslate \u30BF\u30A4\u30D7\u307E\u305F\u306F\u30E2\u30B8\u30E5\u30FC\u30EB\u540D\u304C\u691C\u51FA\u3055\u308C\u305F\u5834\u5408\u3001\n\ \u751F\u6210\u3055\u308C\u305FJava\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u3067\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002pkgPrefix\u306E\n\ \u5909\u66F4\u304C\u5148\u306B\u884C\u308F\u308C\u308B\u3053\u3068\u306B\u6CE8\u610F\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u306F\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\n\ \u6B63\u5F0F\u540D\u3068\u5B8C\u5168\u306B\u4E00\u81F4\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u307E\u305F\u3001\u3092\n\ org\u3001org.omg\u307E\u305F\u306Forg.omg\u306E\u30B5\u30D6\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\n-skeletonName \u30D1\u30BF\u30FC\u30F3\u306B\u5F93\u3063\u3066\u30B9\u30B1\u30EB\u30C8\u30F3\u306B\u540D\u524D\u3092\u4ED8\u3051\u307E\u3059\u3002\n\ \u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:\n\ POA\u30D9\u30FC\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u5834\u5408\u306F%POA (-fserver\u307E\u305F\u306F-fall) \n\ oldImplBase\u30D9\u30FC\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u5834\u5408\u306F_%ImplBase\n\ (-oldImplBase\u304A\u3088\u3073(-fserver\u307E\u305F\u306F-fall))\u3002\n-td \u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u306F\u3001\u73FE\u5728\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u304B\u308F\u308A\u306B\u3092\n\ \u4F7F\u7528\u3057\u307E\u3059\u3002\n-tieName \u30D1\u30BF\u30FC\u30F3\u306B\u5F93\u3063\u3066tie\u306B\u540D\u524D\u3092\u4ED8\u3051\u307E\u3059\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:\n\ POA tie\u306E\u5834\u5408\u306F%POATie (-fserverTie\u307E\u305F\u306F-fallTie) \n\ oldImplBase tie\u306E\u5834\u5408\u306F%_Tie\n\ (-oldImplBase\u304A\u3088\u3073(-fserverTie\u307E\u305F\u306F-fallTie))\u3002\n-v, -verbose \u8A73\u7D30\u30E2\u30FC\u30C9\u3002\n-version \u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3057\u307E\u3059\u3002\n +usage=\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u4F7F\u7528\u65B9\u6CD5:\n\n java com.sun.tools.corba.se.idl.toJavaPortable.Compile [options] \n\n\u306FIDL\u5B9A\u7FA9\u3092\u542B\u3080\u30D5\u30A1\u30A4\u30EB\u306E\u540D\u524D\u3067\u3001\n[options]\u306F\u6B21\u306B\u30EA\u30B9\u30C8\u3059\u308B\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u3067\u3059\u3002\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\n\u7701\u7565\u53EF\u80FD\u3067\u3001\u4EFB\u610F\u306E\u9806\u5E8F\u3067\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u306F\u5FC5\u9808\u3067\u3001\n\u6700\u5F8C\u306B\u8868\u793A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n \n\u30AA\u30D7\u30B7\u30E7\u30F3:\n-d IDL\u30D5\u30A1\u30A4\u30EB\u306E\u6B21\u306E\u884C\u3068\n \u540C\u3058\u3067\u3059: #define \n-emitAll #included\u30D5\u30A1\u30A4\u30EB\u3067\u898B\u3064\u304B\u3063\u305F\u30BF\u30A4\u30D7\u3092\u542B\u3080\u3001\u3059\u3079\u3066\u306E\u30BF\u30A4\u30D7\u3092\u767A\u884C\u3057\u307E\u3059\u3002\n-f \u767A\u884C\u3059\u308B\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0\u3092\u5B9A\u7FA9\u3057\u307E\u3059\u3002\u306Fclient\u3001\n server\u3001all\u3001serverTIE\u3001allTIE\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002serverTIE\u3068allTIE\u306F\n \u59D4\u4EFB\u30E2\u30C7\u30EB\u30FB\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u767A\u884C\u3057\u307E\u3059\u3002\u3053\u306E\u30D5\u30E9\u30B0\u3092\n \u4F7F\u7528\u3057\u306A\u3044\u5834\u5408\u306F\u3001-fclient\u3068\u307F\u306A\u3055\u308C\u307E\u3059\u3002\n-i \u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u3001\u73FE\u5728\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u304C\n \u30B9\u30AD\u30E3\u30F3\u3055\u308C\u307E\u3059\u3002\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u5225\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u8FFD\u52A0\u3057\u307E\u3059\u3002\n-keep \u751F\u6210\u3055\u308C\u308B\u30D5\u30A1\u30A4\u30EB\u304C\u3059\u3067\u306B\u5B58\u5728\u3059\u308B\u5834\u5408\u306F\u3001\u4E0A\u66F8\u304D\n \u3057\u307E\u305B\u3093\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u306F\u4E0A\u66F8\u304D\u3055\u308C\u307E\u3059\u3002\n-noWarn \u8B66\u544A\u3092\u51FA\u3055\u306A\u3044\u3088\u3046\u306B\u3057\u307E\u3059\u3002\n-oldImplBase \u53E4\u3044(1.4\u4EE5\u524D) JDK ORB\u3068\u4E92\u63DB\u6027\u306E\u3042\u308B\u30B9\u30B1\u30EB\u30C8\u30F3\u3092\u751F\u6210\u3057\u307E\u3059\u3002\n-pkgPrefix \u30D5\u30A1\u30A4\u30EB\u30FB\u30B9\u30B3\u30FC\u30D7\u3067\u30BF\u30A4\u30D7\u307E\u305F\u306F\u30E2\u30B8\u30E5\u30FC\u30EB\u540D\u304C\u691C\u51FA\u3055\u308C\u305F\u5834\u5408\u3001\n \u306B\u5BFE\u3057\u3066\u751F\u6210\u3055\u308C\u305F\u3059\u3079\u3066\u306E\u30D5\u30A1\u30A4\u30EB\u306EJava\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u3092\n \u3067\u59CB\u3081\u307E\u3059\u3002\n-pkgTranslate \u30BF\u30A4\u30D7\u307E\u305F\u306F\u30E2\u30B8\u30E5\u30FC\u30EB\u540D\u304C\u691C\u51FA\u3055\u308C\u305F\u5834\u5408\u3001\n \u751F\u6210\u3055\u308C\u305FJava\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u3067\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002pkgPrefix\u306E\n \u5909\u66F4\u304C\u5148\u306B\u884C\u308F\u308C\u308B\u3053\u3068\u306B\u6CE8\u610F\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u306F\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\n \u6B63\u5F0F\u540D\u3068\u5B8C\u5168\u306B\u4E00\u81F4\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u307E\u305F\u3001\u3092\n org\u3001org.omg\u307E\u305F\u306Forg.omg\u306E\u30B5\u30D6\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\n-skeletonName \u30D1\u30BF\u30FC\u30F3\u306B\u5F93\u3063\u3066\u30B9\u30B1\u30EB\u30C8\u30F3\u306B\u540D\u524D\u3092\u4ED8\u3051\u307E\u3059\u3002\n \u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:\n POA\u30D9\u30FC\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u5834\u5408\u306F%POA (-fserver\u307E\u305F\u306F-fall) \n oldImplBase\u30D9\u30FC\u30B9\u30FB\u30AF\u30E9\u30B9\u306E\u5834\u5408\u306F_%ImplBase\n (-oldImplBase\u304A\u3088\u3073(-fserver\u307E\u305F\u306F-fall))\u3002\n-td \u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u306F\u3001\u73FE\u5728\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u304B\u308F\u308A\u306B\u3092\n \u4F7F\u7528\u3057\u307E\u3059\u3002\n-tieName \u30D1\u30BF\u30FC\u30F3\u306B\u5F93\u3063\u3066tie\u306B\u540D\u524D\u3092\u4ED8\u3051\u307E\u3059\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:\n POA tie\u306E\u5834\u5408\u306F%POATie (-fserverTie\u307E\u305F\u306F-fallTie) \n oldImplBase tie\u306E\u5834\u5408\u306F%_Tie\n (-oldImplBase\u304A\u3088\u3073(-fserverTie\u307E\u305F\u306F-fallTie))\u3002\n-v, -verbose \u8A73\u7D30\u30E2\u30FC\u30C9\u3002\n-version \u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3057\u307E\u3059\u3002\n diff --git a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp index dd385beab8f..ee77a65bb3c 100644 --- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp +++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp @@ -65,4 +65,4 @@ NameModifier.InvalidChar=\u6A21\u5F0F\u4E2D\u5305\u542B\u65E0\u6548\u5B57\u7B26 # -d, -emitAll, -f, -i, -keep, -m, -sep, -pkgPrefix, -td, -v, -verbose, -version, -implbase # Do not translate the string "java com.sun.tools.corba.se.idl.toJavaPortable.Compile" # -usage=\u7F16\u8BD1\u5668\u7528\u6CD5:\n\n\ java com.sun.tools.corba.se.idl.toJavaPortable.Compile [\u9009\u9879] \n\n\u5176\u4E2D, \u662F\u5305\u542B IDL \u5B9A\u4E49\u7684\u6587\u4EF6\u7684\u540D\u79F0, \u800C\n[\u9009\u9879] \u662F\u4E0B\u5217\u9009\u9879\u7684\u4EFB\u610F\u7EC4\u5408\u3002\u9009\u9879\n\u662F\u53EF\u9009\u7684, \u5E76\u4E14\u663E\u793A\u987A\u5E8F\u5E76\u4E0D\u56FA\u5B9A; \u662F\u5FC5\u9700\u7684,\n\u5E76\u4E14\u5FC5\u987B\u663E\u793A\u5728\u6700\u540E\u3002\n\ \n\u9009\u9879:\n-d <\u7B26\u53F7> \u8FD9\u7B49\u540C\u4E8E IDL \u6587\u4EF6\u4E2D\u7684\n\ \u4E0B\u9762\u4E00\u884C: #define <\u7B26\u53F7>\n-emitAll \u53D1\u51FA\u6240\u6709\u7C7B\u578B, \u5305\u62EC\u5728 #included \u6587\u4EF6\u4E2D\u627E\u5230\u7684\u7C7B\u578B\u3002\n-f \u5B9A\u4E49\u8981\u53D1\u51FA\u54EA\u4E9B\u7ED1\u5B9A\u3002 \u662F client,\n\ server, all, serverTIE, allTIE \u4E4B\u4E00\u3002serverTIE \u548C allTIE\n\ \u5BFC\u81F4\u53D1\u51FA\u59D4\u6D3E\u6A21\u578B\u9AA8\u67B6\u3002\u5982\u679C\u672A\u4F7F\u7528\n\ \u6B64\u6807\u8BB0, \u5C06\u5047\u5B9A\u4E3A -fclient\u3002\n-i <\u5305\u542B\u8DEF\u5F84> \u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5C06\u5728\u5F53\u524D\u76EE\u5F55\u4E2D\u626B\u63CF\n\ \u5305\u542B\u7684\u6587\u4EF6\u3002\u6B64\u9009\u9879\u5C06\u6DFB\u52A0\u53E6\u4E00\u4E2A\u76EE\u5F55\u3002\n-keep \u5982\u679C\u8981\u751F\u6210\u7684\u6587\u4EF6\u5DF2\u5B58\u5728, \u8BF7\u4E0D\u8981\n\ \u8986\u76D6\u5B83\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u4F1A\u8986\u76D6\u5B83\u3002\n-noWarn \u9690\u85CF\u8B66\u544A\u3002\n-oldImplBase \u751F\u6210\u4E0E\u65E7\u7248 (1.4 \u7248\u4E4B\u524D) JDK ORB \u517C\u5BB9\u7684\u9AA8\u67B6\u3002\n-pkgPrefix <\u524D\u7F00> \u5F53\u5728\u6587\u4EF6\u8303\u56F4\u5185\u9047\u5230\u7C7B\u578B\u6216\u6A21\u5757\u540D \u65F6,\n\ \u5728\u4E3A \u751F\u6210\u7684\u6240\u6709\u6587\u4EF6\u7684 Java \u7A0B\u5E8F\u5305\u540D\u524D\n\ \u6DFB\u52A0 <\u524D\u7F00>\u3002\n-pkgTranslate \u5F53\u9047\u5230\u7C7B\u578B\u6216\u6A21\u5757\u540D \u65F6, \u5728\n\ \u751F\u6210\u7684 Java \u7A0B\u5E8F\u5305\u4E2D\u5C06\u5176\u66FF\u6362\u4E3A \u3002\u8BF7\u6CE8\u610F, \n\ \u5C06\u9996\u5148\u8FDB\u884C pkgPrefix \u66F4\u6539\u3002 \u5FC5\u987B\u4E0E\n\ \u5B8C\u6574\u7A0B\u5E8F\u5305\u540D\u5B8C\u5168\u5339\u914D\u3002\u53E6\u5916, \u4E0D\u80FD\u4E3A\n\ org, org.omg \u6216 org.omg \u7684\u4EFB\u4F55\u5B50\u7A0B\u5E8F\u5305\u3002\n-skeletonName \u6839\u636E\u6A21\u5F0F\u547D\u540D\u9AA8\u67B6\u3002\n\ \u9ED8\u8BA4\u503C\u4E3A:\n\ %POA \u8868\u793A POA \u57FA\u7C7B (-fserver \u6216 -fall) \n\ _%ImplBase \u8868\u793A oldImplBase \u57FA\u7C7B\n\ (-oldImplBase \u548C (-fserver \u6216 -fall))\u3002\n-td \u4F7F\u7528 \u8868\u793A\u8F93\u51FA\u76EE\u5F55\u4EE5\u4EE3\u66FF\n\ \u5F53\u524D\u76EE\u5F55\u3002\n-tieName \u6839\u636E\u6A21\u5F0F\u547D\u540D tie\u3002\u9ED8\u8BA4\u503C\u4E3A:\n\ %POATie \u8868\u793A POA tie (-fserverTie \u6216 -fallTie) \n\ %_Tie \u8868\u793A oldImplBase tie\n\ (-oldImplBase \u548C (-fserverTie \u6216 -fallTie))\u3002\n-v, -verbose \u8BE6\u7EC6\u6A21\u5F0F\u3002\n-version \u663E\u793A\u7248\u672C\u53F7\u5E76\u9000\u51FA\u3002\n +usage=\u7F16\u8BD1\u5668\u7528\u6CD5:\n\n java com.sun.tools.corba.se.idl.toJavaPortable.Compile [\u9009\u9879] \n\n\u5176\u4E2D, \u662F\u5305\u542B IDL \u5B9A\u4E49\u7684\u6587\u4EF6\u7684\u540D\u79F0, \u800C\n[\u9009\u9879] \u662F\u4E0B\u5217\u9009\u9879\u7684\u4EFB\u610F\u7EC4\u5408\u3002\u9009\u9879\n\u662F\u53EF\u9009\u7684, \u5E76\u4E14\u663E\u793A\u987A\u5E8F\u5E76\u4E0D\u56FA\u5B9A; \u662F\u5FC5\u9700\u7684,\n\u5E76\u4E14\u5FC5\u987B\u663E\u793A\u5728\u6700\u540E\u3002\n \n\u9009\u9879:\n-d <\u7B26\u53F7> \u8FD9\u7B49\u540C\u4E8E IDL \u6587\u4EF6\u4E2D\u7684\n \u4E0B\u9762\u4E00\u884C: #define <\u7B26\u53F7>\n-emitAll \u53D1\u51FA\u6240\u6709\u7C7B\u578B, \u5305\u62EC\u5728 #included \u6587\u4EF6\u4E2D\u627E\u5230\u7684\u7C7B\u578B\u3002\n-f \u5B9A\u4E49\u8981\u53D1\u51FA\u54EA\u4E9B\u7ED1\u5B9A\u3002 \u662F client,\n server, all, serverTIE, allTIE \u4E4B\u4E00\u3002serverTIE \u548C allTIE\n \u5BFC\u81F4\u53D1\u51FA\u59D4\u6D3E\u6A21\u578B\u9AA8\u67B6\u3002\u5982\u679C\u672A\u4F7F\u7528\n \u6B64\u6807\u8BB0, \u5C06\u5047\u5B9A\u4E3A -fclient\u3002\n-i <\u5305\u542B\u8DEF\u5F84> \u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u5C06\u5728\u5F53\u524D\u76EE\u5F55\u4E2D\u626B\u63CF\n \u5305\u542B\u7684\u6587\u4EF6\u3002\u6B64\u9009\u9879\u5C06\u6DFB\u52A0\u53E6\u4E00\u4E2A\u76EE\u5F55\u3002\n-keep \u5982\u679C\u8981\u751F\u6210\u7684\u6587\u4EF6\u5DF2\u5B58\u5728, \u8BF7\u4E0D\u8981\n \u8986\u76D6\u5B83\u3002\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u4F1A\u8986\u76D6\u5B83\u3002\n-noWarn \u9690\u85CF\u8B66\u544A\u3002\n-oldImplBase \u751F\u6210\u4E0E\u65E7\u7248 (1.4 \u7248\u4E4B\u524D) JDK ORB \u517C\u5BB9\u7684\u9AA8\u67B6\u3002\n-pkgPrefix <\u524D\u7F00> \u5F53\u5728\u6587\u4EF6\u8303\u56F4\u5185\u9047\u5230\u7C7B\u578B\u6216\u6A21\u5757\u540D \u65F6,\n \u5728\u4E3A \u751F\u6210\u7684\u6240\u6709\u6587\u4EF6\u7684 Java \u7A0B\u5E8F\u5305\u540D\u524D\n \u6DFB\u52A0 <\u524D\u7F00>\u3002\n-pkgTranslate \u5F53\u9047\u5230\u7C7B\u578B\u6216\u6A21\u5757\u540D \u65F6, \u5728\n \u751F\u6210\u7684 Java \u7A0B\u5E8F\u5305\u4E2D\u5C06\u5176\u66FF\u6362\u4E3A \u3002\u8BF7\u6CE8\u610F, \n \u5C06\u9996\u5148\u8FDB\u884C pkgPrefix \u66F4\u6539\u3002 \u5FC5\u987B\u4E0E\n \u5B8C\u6574\u7A0B\u5E8F\u5305\u540D\u5B8C\u5168\u5339\u914D\u3002\u53E6\u5916, \u4E0D\u80FD\u4E3A\n org, org.omg \u6216 org.omg \u7684\u4EFB\u4F55\u5B50\u7A0B\u5E8F\u5305\u3002\n-skeletonName \u6839\u636E\u6A21\u5F0F\u547D\u540D\u9AA8\u67B6\u3002\n \u9ED8\u8BA4\u503C\u4E3A:\n %POA \u8868\u793A POA \u57FA\u7C7B (-fserver \u6216 -fall) \n _%ImplBase \u8868\u793A oldImplBase \u57FA\u7C7B\n (-oldImplBase \u548C (-fserver \u6216 -fall))\u3002\n-td \u4F7F\u7528 \u8868\u793A\u8F93\u51FA\u76EE\u5F55\u4EE5\u4EE3\u66FF\n \u5F53\u524D\u76EE\u5F55\u3002\n-tieName \u6839\u636E\u6A21\u5F0F\u547D\u540D tie\u3002\u9ED8\u8BA4\u503C\u4E3A:\n %POATie \u8868\u793A POA tie (-fserverTie \u6216 -fallTie) \n %_Tie \u8868\u793A oldImplBase tie\n (-oldImplBase \u548C (-fserverTie \u6216 -fallTie))\u3002\n-v, -verbose \u8BE6\u7EC6\u6A21\u5F0F\u3002\n-version \u663E\u793A\u7248\u672C\u53F7\u5E76\u9000\u51FA\u3002\n From fa35aeb6eb0fc9709955a303b80600b94fd54d41 Mon Sep 17 00:00:00 2001 From: Michael Fang Date: Mon, 25 Mar 2013 16:55:14 -0700 Subject: [PATCH 063/155] 8010521: jdk8 l10n resource file translation update 2 Reviewed-by: naoto, yhuang --- .../html/resources/standard_ja.properties | 103 ++-- .../html/resources/standard_zh_CN.properties | 49 +- .../toolkit/resources/doclets_ja.properties | 22 +- .../resources/doclets_zh_CN.properties | 14 +- .../javac/resources/compiler_ja.properties | 466 ++++++++++++++---- .../javac/resources/compiler_zh_CN.properties | 426 +++++++++++++--- .../tools/javac/resources/javac_ja.properties | 20 +- .../javac/resources/javac_zh_CN.properties | 12 +- .../javadoc/resources/javadoc_ja.properties | 12 +- .../resources/javadoc_zh_CN.properties | 12 +- .../tools/javah/resources/l10n_ja.properties | 8 +- .../javah/resources/l10n_zh_CN.properties | 4 +- 12 files changed, 819 insertions(+), 329 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties index 1e020b6d965..fc635cc7d32 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties @@ -32,7 +32,7 @@ doclet.navAnnotationTypeOptionalMember=\u30AA\u30D7\u30B7\u30E7\u30F3 doclet.navAnnotationTypeRequiredMember=\u5FC5\u9808 doclet.navAnnotationTypeMember=\u8981\u7D20 doclet.navField=\u30D5\u30A3\u30FC\u30EB\u30C9 -doclet.navEnum=\u5217\u6319\u5B9A\u6570 +doclet.navEnum=\u5217\u6319\u578B\u5B9A\u6570 doclet.navConstructor=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF doclet.navMethod=\u30E1\u30BD\u30C3\u30C9 doclet.Index=\u7D22\u5F15 @@ -41,59 +41,47 @@ doclet.Window_Split_Index={0}\u306E\u7D22\u5F15 doclet.Help=\u30D8\u30EB\u30D7 doclet.Skip_navigation_links=\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30EA\u30F3\u30AF\u3092\u30B9\u30AD\u30C3\u30D7 doclet.New_Page=NewPage -doclet.None=\u306A\u3057 -doclet.Factory_Method_Detail=static\u30D5\u30A1\u30AF\u30C8\u30EA\u30FB\u30E1\u30BD\u30C3\u30C9\u306E\u8A73\u7D30 doclet.navDeprecated=\u975E\u63A8\u5968 -doclet.Deprecated_List=\u975E\u63A8\u5968API\u306E\u30EA\u30B9\u30C8 -doclet.Window_Deprecated_List=\u975E\u63A8\u5968API\u306E\u30EA\u30B9\u30C8 -doclet.Note_0_is_deprecated=\u6CE8\u610F: {0}\u306F\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 +doclet.Window_Deprecated_List=\u975E\u63A8\u5968\u306E\u30EA\u30B9\u30C8 doclet.Overrides=\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9: doclet.in_class=\u30AF\u30E9\u30B9\u5185 -doclet.0_Fields_and_Methods="{0}"\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u30E1\u30BD\u30C3\u30C9 -doclet.Index_of_Fields_and_Methods=\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u30E1\u30BD\u30C3\u30C9\u306E\u7D22\u5F15 doclet.Static_variable_in={0}\u306Estatic\u5909\u6570 doclet.Variable_in={0}\u306E\u5909\u6570 doclet.Constructor_for={0}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF doclet.Static_method_in={0}\u306Estatic\u30E1\u30BD\u30C3\u30C9 doclet.Method_in={0}\u306E\u30E1\u30BD\u30C3\u30C9 -doclet.throws=\u30B9\u30ED\u30FC doclet.package=\u30D1\u30C3\u30B1\u30FC\u30B8 doclet.MalformedURL=\u4E0D\u6B63\u306AURL: {0} doclet.File_error=\u30D5\u30A1\u30A4\u30EB\u8AAD\u8FBC\u307F\u30A8\u30E9\u30FC: {0} doclet.URL_error=URL\u53D6\u51FA\u3057\u30A8\u30E9\u30FC: {0} -doclet.No_Package_Comment_File=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306EPackage.Comment\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 -doclet.No_Source_For_Class=\u30AF\u30E9\u30B9{0}\u306E\u30BD\u30FC\u30B9\u60C5\u5831\u304C\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002 doclet.see.class_or_package_not_found=\u30BF\u30B0{0}: \u53C2\u7167\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {1} doclet.see.class_or_package_not_accessible=\u30BF\u30B0{0}: \u53C2\u7167\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093: {1} -doclet.see.malformed_tag={0}\u30BF\u30B0: \u4E0D\u6B63\u306A{1}\u30BF\u30B0 -doclet.Inherited_API_Summary=\u7D99\u627F\u3055\u308C\u305FAPI\u306E\u6982\u8981 -doclet.Deprecated_API=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044API -doclet.Deprecated_Classes=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30AF\u30E9\u30B9 -doclet.Deprecated_Enums=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B -doclet.Deprecated_Interfaces=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 -doclet.Deprecated_Exceptions=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u4F8B\u5916 -doclet.Deprecated_Annotation_Types=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B -doclet.Deprecated_Errors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A8\u30E9\u30FC -doclet.Deprecated_Fields=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30D5\u30A3\u30FC\u30EB\u30C9 -doclet.Deprecated_Constructors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF -doclet.Deprecated_Methods=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30E1\u30BD\u30C3\u30C9 -doclet.Deprecated_Enum_Constants=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B\u5B9A\u6570 -doclet.Deprecated_Annotation_Type_Members=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B\u306E\u8981\u7D20 -doclet.deprecated_classes=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30AF\u30E9\u30B9 -doclet.deprecated_enums=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B -doclet.deprecated_interfaces=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 -doclet.deprecated_exceptions=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u4F8B\u5916 -doclet.deprecated_annotation_types=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B -doclet.deprecated_errors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A8\u30E9\u30FC -doclet.deprecated_fields=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30D5\u30A3\u30FC\u30EB\u30C9 -doclet.deprecated_constructors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF -doclet.deprecated_methods=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30E1\u30BD\u30C3\u30C9 -doclet.deprecated_enum_constants=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B\u5B9A\u6570 -doclet.deprecated_annotation_type_members=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B\u306E\u8981\u7D20 -doclet.Frame_Output=\u30D5\u30EC\u30FC\u30E0\u51FA\u529B -doclet.Docs_generated_by_Javadoc=\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306Fjavadoc\u3067\u751F\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002 +doclet.Deprecated_API=\u975E\u63A8\u5968\u306EAPI +doclet.Deprecated_Packages=\u975E\u63A8\u5968\u306E\u30D1\u30C3\u30B1\u30FC\u30B8 +doclet.Deprecated_Classes=\u975E\u63A8\u5968\u306E\u30AF\u30E9\u30B9 +doclet.Deprecated_Enums=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B +doclet.Deprecated_Interfaces=\u975E\u63A8\u5968\u306E\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 +doclet.Deprecated_Exceptions=\u975E\u63A8\u5968\u306E\u4F8B\u5916 +doclet.Deprecated_Annotation_Types=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B +doclet.Deprecated_Errors=\u975E\u63A8\u5968\u306E\u30A8\u30E9\u30FC +doclet.Deprecated_Fields=\u975E\u63A8\u5968\u306E\u30D5\u30A3\u30FC\u30EB\u30C9 +doclet.Deprecated_Constructors=\u975E\u63A8\u5968\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF +doclet.Deprecated_Methods=\u975E\u63A8\u5968\u306E\u30E1\u30BD\u30C3\u30C9 +doclet.Deprecated_Enum_Constants=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B\u5B9A\u6570 +doclet.Deprecated_Annotation_Type_Members=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B\u306E\u8981\u7D20 +doclet.deprecated_packages=\u975E\u63A8\u5968\u306E\u30D1\u30C3\u30B1\u30FC\u30B8 +doclet.deprecated_classes=\u975E\u63A8\u5968\u306E\u30AF\u30E9\u30B9 +doclet.deprecated_enums=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B +doclet.deprecated_interfaces=\u975E\u63A8\u5968\u306E\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 +doclet.deprecated_exceptions=\u975E\u63A8\u5968\u306E\u4F8B\u5916 +doclet.deprecated_annotation_types=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B +doclet.deprecated_errors=\u975E\u63A8\u5968\u306E\u30A8\u30E9\u30FC +doclet.deprecated_fields=\u975E\u63A8\u5968\u306E\u30D5\u30A3\u30FC\u30EB\u30C9 +doclet.deprecated_constructors=\u975E\u63A8\u5968\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF +doclet.deprecated_methods=\u975E\u63A8\u5968\u306E\u30E1\u30BD\u30C3\u30C9 +doclet.deprecated_enum_constants=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B\u5B9A\u6570 +doclet.deprecated_annotation_type_members=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B\u306E\u8981\u7D20 doclet.Generated_Docs_Untitled=\u751F\u6210\u3055\u308C\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8(\u30BF\u30A4\u30C8\u30EB\u306A\u3057) -doclet.Blank=\u30D6\u30E9\u30F3\u30AF doclet.Other_Packages=\u305D\u306E\u4ED6\u306E\u30D1\u30C3\u30B1\u30FC\u30B8 doclet.Package_Description=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u8AAC\u660E doclet.Description=\u8AAC\u660E @@ -102,33 +90,25 @@ doclet.in_interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u5185 doclet.Subclasses=\u76F4\u7CFB\u306E\u65E2\u77E5\u306E\u30B5\u30D6\u30AF\u30E9\u30B9: doclet.Subinterfaces=\u65E2\u77E5\u306E\u30B5\u30D6\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8: doclet.Implementing_Classes=\u65E2\u77E5\u306E\u5B9F\u88C5\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8: +doclet.Functional_Interface=\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 +doclet.Functional_Interface_Message=\u3053\u308C\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306A\u306E\u3067\u3001\u30E9\u30E0\u30C0\u5F0F\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u5272\u5F53\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002 doclet.also=\u540C\u69D8\u306B -doclet.Option=\u30AA\u30D7\u30B7\u30E7\u30F3 -doclet.Or=\u307E\u305F\u306F doclet.Frames=\u30D5\u30EC\u30FC\u30E0 doclet.No_Frames=\u30D5\u30EC\u30FC\u30E0\u306A\u3057 doclet.Package_Hierarchies=\u30D1\u30C3\u30B1\u30FC\u30B8\u968E\u5C64: doclet.Hierarchy_For_Package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u968E\u5C64 -doclet.Source_Code=\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9: doclet.Hierarchy_For_All_Packages=\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64 -doclet.Cannot_handle_no_packages=\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u51E6\u7406\u3067\u304D\u307E\u305B\u3093\u3002 doclet.Frame_Alert=\u30D5\u30EC\u30FC\u30E0\u95A2\u9023\u306E\u30A2\u30E9\u30FC\u30C8 -doclet.Overview-Member-Frame=\u6982\u8981\u30E1\u30F3\u30D0\u30FC\u30FB\u30D5\u30EC\u30FC\u30E0 doclet.Frame_Warning_Message=\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306F\u30D5\u30EC\u30FC\u30E0\u6A5F\u80FD\u3092\u4F7F\u7528\u3057\u3066\u8868\u793A\u3059\u308B\u3088\u3046\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30D5\u30EC\u30FC\u30E0\u3092\u8868\u793A\u3067\u304D\u306A\u3044Web\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u306E\u5834\u5408\u306B\u3053\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002{0}\u306B\u30EA\u30F3\u30AF\u3057\u307E\u3059\u3002 doclet.No_Script_Message=\u30D6\u30E9\u30A6\u30B6\u306EJavaScript\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002 doclet.Non_Frame_Version=\u30D5\u30EC\u30FC\u30E0\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u306A\u3044\u30D0\u30FC\u30B8\u30E7\u30F3 -doclet.Frame_Version=\u30D5\u30EC\u30FC\u30E0\u3042\u308A\u306E\u30D0\u30FC\u30B8\u30E7\u30F3 -doclet.Following_From_Class=\u30AF\u30E9\u30B9{0}\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u30BF\u30B0: -doclet.Following_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9{0}\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u30BF\u30B0: doclet.Description_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u8AAC\u660E: doclet.Description_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u8AAC\u660E: -doclet.Standard_doclet_invoked=\u6A19\u6E96\u306Edoclet\u304C\u8D77\u52D5\u3055\u308C\u307E\u3057\u305F... -doclet.No_Non_Deprecated_Classes_To_Document=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3059\u308B\u975E\u63A8\u5968\u4EE5\u5916\u306E\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 +doclet.No_Non_Deprecated_Classes_To_Document=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3059\u308B\u975E\u63A8\u5968\u3067\u306A\u3044\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 doclet.Interfaces_Italic=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9(\u30A4\u30BF\u30EA\u30C3\u30AF) doclet.Enclosing_Class=\u542B\u307E\u308C\u3066\u3044\u308B\u30AF\u30E9\u30B9: doclet.Enclosing_Interface=\u542B\u307E\u308C\u3066\u3044\u308B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9: doclet.Window_Source_title=\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9 -doclet.Help_title=API\u30D8\u30EB\u30D7 doclet.Window_Help_title=API\u30D8\u30EB\u30D7 doclet.Help_line_1=API\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u69CB\u6210 doclet.Help_line_2=\u3053\u306EAPI(Application Programming Interface)\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u306F\u3001\u6B21\u306B\u8AAC\u660E\u3059\u308B\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306B\u3042\u308B\u9805\u76EE\u306B\u5BFE\u5FDC\u3059\u308B\u30DA\u30FC\u30B8\u304C\u542B\u307E\u308C\u307E\u3059\u3002 @@ -149,7 +129,7 @@ doclet.Help_line_16=\u968E\u5C64\u30C4\u30EA\u30FC(\u30AF\u30E9\u30B9\u968E\u5C6 doclet.Help_line_17_with_tree_link=\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u306F{0}\u30DA\u30FC\u30B8\u304C\u3042\u308A\u3001\u3055\u3089\u306B\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64\u304C\u3042\u308A\u307E\u3059\u3002\u5404\u968E\u5C64\u30DA\u30FC\u30B8\u306F\u3001\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8\u3068\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8\u3092\u542B\u307F\u307E\u3059\u3002\u30AF\u30E9\u30B9\u306F java.lang.Object \u3092\u958B\u59CB\u70B9\u3068\u3059\u308B\u7D99\u627F\u69CB\u9020\u3067\u7DE8\u6210\u3055\u308C\u307E\u3059\u3002\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306F\u3001java.lang.Object \u304B\u3089\u306F\u7D99\u627F\u3057\u307E\u305B\u3093\u3002 doclet.Help_line_18=\u6982\u8981\u30DA\u30FC\u30B8\u3092\u8868\u793A\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u300C\u968E\u5C64\u30C4\u30EA\u30FC\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u3068\u3001\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002 doclet.Help_line_19=\u7279\u5B9A\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u8868\u793A\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u300C\u968E\u5C64\u30C4\u30EA\u30FC\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u3068\u3001\u8A72\u5F53\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u307F\u306E\u968E\u5C64\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002 -doclet.Help_line_20_with_deprecated_api_link={0}\u30DA\u30FC\u30B8\u306F\u3001\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u3059\u3079\u3066\u306EAPI\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059\u3002\u975E\u63A8\u5968API\u3068\u306F\u3001\u6A5F\u80FD\u6539\u826F\u306A\u3069\u306E\u7406\u7531\u304B\u3089\u4F7F\u7528\u3092\u304A\u85A6\u3081\u3067\u304D\u306A\u304F\u306A\u3063\u305FAPI\u306E\u3053\u3068\u3067\u3001\u901A\u5E38\u306F\u305D\u308C\u306B\u4EE3\u308F\u308BAPI\u304C\u63D0\u4F9B\u3055\u308C\u307E\u3059\u3002\u975E\u63A8\u5968API\u306F\u4ECA\u5F8C\u306E\u5B9F\u88C5\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002 +doclet.Help_line_20_with_deprecated_api_link={0}\u30DA\u30FC\u30B8\u306F\u3001\u975E\u63A8\u5968\u306EAPI\u3092\u3059\u3079\u3066\u30EA\u30B9\u30C8\u3057\u307E\u3059\u3002\u975E\u63A8\u5968\u306EAPI\u3068\u306F\u3001\u6A5F\u80FD\u6539\u826F\u306A\u3069\u306E\u7406\u7531\u304B\u3089\u4F7F\u7528\u3092\u304A\u85A6\u3081\u3067\u304D\u306A\u304F\u306A\u3063\u305FAPI\u306E\u3053\u3068\u3067\u3001\u901A\u5E38\u306F\u305D\u308C\u306B\u4EE3\u308F\u308BAPI\u304C\u63D0\u4F9B\u3055\u308C\u307E\u3059\u3002\u975E\u63A8\u5968\u306EAPI\u306F\u4ECA\u5F8C\u306E\u5B9F\u88C5\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002 doclet.Help_line_21=\u7D22\u5F15 doclet.Help_line_22={0}\u306B\u306F\u3001\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3001\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u3001\u30E1\u30BD\u30C3\u30C9\u304A\u3088\u3073\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8\u9806\u306E\u30EA\u30B9\u30C8\u304C\u542B\u307E\u308C\u307E\u3059\u3002 doclet.Help_line_23=\u524D/\u6B21 @@ -158,7 +138,7 @@ doclet.Help_line_25=\u30D5\u30EC\u30FC\u30E0/\u30D5\u30EC\u30FC\u30E0\u306A\u305 doclet.Help_line_26=\u3053\u308C\u3089\u306E\u30EA\u30F3\u30AF\u306FHTML\u30D5\u30EC\u30FC\u30E0\u306E\u8868\u793A\u3068\u975E\u8868\u793A\u3092\u5207\u308A\u66FF\u3048\u307E\u3059\u3002\u3059\u3079\u3066\u306E\u30DA\u30FC\u30B8\u306F\u30D5\u30EC\u30FC\u30E0\u3042\u308A\u3067\u3082\u3001\u30D5\u30EC\u30FC\u30E0\u306A\u3057\u3067\u3082\u8868\u793A\u3067\u304D\u307E\u3059\u3002 doclet.Help_line_27={0}\u30EA\u30F3\u30AF\u306B\u306F\u3001\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9(\u975Estatic\u306E\u30CD\u30B9\u30C8\u3055\u308C\u305F\u578B\u3092\u9664\u304F)\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002 doclet.Help_line_28=\u76F4\u5217\u5316\u53EF\u80FD\u307E\u305F\u306F\u5916\u90E8\u5316\u53EF\u80FD\u306A\u5404\u30AF\u30E9\u30B9\u306F\u3001\u76F4\u5217\u5316\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u30E1\u30BD\u30C3\u30C9\u306E\u8AAC\u660E\u3092\u542B\u307F\u307E\u3059\u3002\u3053\u306E\u60C5\u5831\u306F\u3001API\u3092\u4F7F\u7528\u3059\u308B\u958B\u767A\u8005\u3067\u306F\u306A\u304F\u3001\u518D\u5B9F\u88C5\u3092\u884C\u3046\u62C5\u5F53\u8005\u306B\u5F79\u7ACB\u3061\u307E\u3059\u3002\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306B\u30EA\u30F3\u30AF\u304C\u306A\u3044\u5834\u5408\u3001\u76F4\u5217\u5316\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306B\u79FB\u52D5\u3057\u3066\u3001\u30AF\u30E9\u30B9\u8A18\u8FF0\u306E\u300C\u95A2\u9023\u9805\u76EE\u300D\u30BB\u30AF\u30B7\u30E7\u30F3\u306B\u3042\u308B\u300C\u76F4\u5217\u5316\u3055\u308C\u305F\u5F62\u5F0F\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u3053\u3068\u306B\u3088\u308A\u3001\u3053\u306E\u60C5\u5831\u3092\u8868\u793A\u3067\u304D\u307E\u3059\u3002 -doclet.Help_line_29=\u300C\u5B9A\u6570\u30D5\u30A3\u30FC\u30EB\u30C9\u5024\u300D \u30DA\u30FC\u30B8\u306B\u306F\u3001static final\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u305D\u306E\u5024\u306E\u30EA\u30B9\u30C8\u304C\u3042\u308A\u307E\u3059\u3002 +doclet.Help_line_29={0}\u30DA\u30FC\u30B8\u306B\u306F\u3001static final\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u305D\u306E\u5024\u306E\u30EA\u30B9\u30C8\u304C\u3042\u308A\u307E\u3059\u3002 doclet.Help_line_30=\u3053\u306E\u30D8\u30EB\u30D7\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3001\u6A19\u6E96doclet\u3092\u4F7F\u7528\u3057\u3066\u751F\u6210\u3055\u308C\u305FAPI\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u9069\u7528\u3055\u308C\u307E\u3059\u3002 doclet.Help_enum_line_1=\u5404\u5217\u6319\u578B\u306B\u306F\u3001\u305D\u308C\u81EA\u8EAB\u306E\u500B\u5225\u306E\u30DA\u30FC\u30B8\u3068\u6B21\u306E\u30BB\u30AF\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059: doclet.Help_enum_line_2=\u5217\u6319\u578B\u306E\u5BA3\u8A00 @@ -166,19 +146,6 @@ doclet.Help_enum_line_3=\u5217\u6319\u578B\u306E\u8AAC\u660E doclet.Help_annotation_type_line_1=\u5404\u6CE8\u91C8\u578B\u306B\u306F\u3001\u305D\u308C\u81EA\u8EAB\u306E\u500B\u5225\u306E\u30DA\u30FC\u30B8\u3068\u6B21\u306E\u30BB\u30AF\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059: doclet.Help_annotation_type_line_2=\u6CE8\u91C8\u578B\u306E\u5BA3\u8A00 doclet.Help_annotation_type_line_3=\u6CE8\u91C8\u578B\u306E\u8AAC\u660E -doclet.Style_line_1=javadoc\u30B9\u30BF\u30A4\u30EB\u30FB\u30B7\u30FC\u30C8 -doclet.Style_line_2=\u8272\u3084\u30D5\u30A9\u30F3\u30C8\u306A\u3069\u306E\u30B9\u30BF\u30A4\u30EB\u5C5E\u6027\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\u306B\u306F\u3001\u3053\u3053\u3067\u5B9A\u7FA9\u3057\u307E\u3059 -doclet.Style_line_3=\u30DA\u30FC\u30B8\u306E\u30D0\u30C3\u30AF\u30B0\u30E9\u30A6\u30F3\u30C9\u306E\u8272 -doclet.Style_Headings=\u898B\u51FA\u3057 -doclet.Style_line_4=\u8868\u306E\u8272 -doclet.Style_line_5=\u6FC3\u3044\u85E4\u8272 -doclet.Style_line_6=\u8584\u3044\u85E4\u8272 -doclet.Style_line_7=\u767D -doclet.Style_line_8=\u5DE6\u5074\u306E\u30D5\u30EC\u30FC\u30E0\u306E\u30EA\u30B9\u30C8\u306B\u4F7F\u7528\u3059\u308B\u30D5\u30A9\u30F3\u30C8 -doclet.Style_line_9=\u30D5\u30EC\u30FC\u30E0\u306B\u304A\u3051\u308B\u3001\u3088\u308A\u5C0F\u3055\u3044sans-serif\u30D5\u30A9\u30F3\u30C8\u306E\u4F8B -doclet.Style_line_10=\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306E\u30D5\u30A9\u30F3\u30C8\u3068\u8272 -doclet.Style_line_11=\u6FC3\u3044\u9752 -doclet.Style_line_12=\u8868\u306E\u30AD\u30E3\u30D7\u30B7\u30E7\u30F3\u30FB\u30B9\u30BF\u30A4\u30EB doclet.ClassUse_Packages.that.use.0={0}\u3092\u4F7F\u7528\u3057\u3066\u3044\u308B\u30D1\u30C3\u30B1\u30FC\u30B8 doclet.ClassUse_Uses.of.0.in.1={1}\u3067\u306E{0}\u306E\u4F7F\u7528 doclet.ClassUse_Classes.in.0.used.by.1={1}\u306B\u3088\u308A\u4F7F\u7528\u3055\u308C\u308B{0}\u306E\u30AF\u30E9\u30B9 @@ -208,13 +175,11 @@ doclet.ClassUse_No.usage.of.0={0}\u306F\u3069\u3053\u304B\u3089\u3082\u4F7F\u752 doclet.Window_ClassUse_Header={0} {1}\u306E\u4F7F\u7528 doclet.ClassUse_Title={0}
    {1}\u306E\u4F7F\u7528 doclet.navClassUse=\u4F7F\u7528 -doclet.link_option_twice=\u5916\u90E8URL\u30EA\u30F3\u30AF\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3(link\u307E\u305F\u306Flinkoffline)\u304C2\u56DE\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059\u3002 doclet.Error_in_packagelist=-group\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u4F7F\u7528\u65B9\u6CD5\u306E\u30A8\u30E9\u30FC: {0} {1} doclet.Groupname_already_used=-group\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u304A\u3044\u3066\u3001\u3059\u3067\u306B\u30B0\u30EB\u30FC\u30D7\u540D\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0} doclet.Same_package_name_used=\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u5F62\u5F0F\u304C2\u56DE\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0} -doclet.Serialization.Excluded_Class=\u5E38\u99D0\u30D5\u30A3\u30FC\u30EB\u30C9{1}\u306F\u3001\u9664\u5916\u3055\u308C\u305F\u30AF\u30E9\u30B9{0}\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002 -doclet.Serialization.Nonexcluded_Class=\u5E38\u99D0\u30D5\u30A3\u30FC\u30EB\u30C9{1}\u306F\u3001\u975E\u8868\u793A\u306E\u3001\u542B\u307E\u308C\u306A\u3044\u30AF\u30E9\u30B9{0}\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002 -doclet.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n-d \u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u306E\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\n-use \u30AF\u30E9\u30B9\u3068\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u4F7F\u7528\u30DA\u30FC\u30B8\u3092\u4F5C\u6210\u3059\u308B\n-version @version\u30D1\u30E9\u30B0\u30E9\u30D5\u3092\u542B\u3081\u308B\n-author @author\u30D1\u30E9\u30B0\u30E9\u30D5\u3092\u542B\u3081\u308B\n-docfilessubdirs doc-file\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u518D\u5E30\u7684\u306B\u30B3\u30D4\u30FC\u3059\u308B\n-splitindex 1\u5B57\u3054\u3068\u306B1\u30D5\u30A1\u30A4\u30EB\u306B\u7D22\u5F15\u3092\u5206\u5272\u3059\u308B\n-windowtitle \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u7528\u306E\u30D6\u30E9\u30A6\u30B6\u30FB\u30A6\u30A3\u30F3\u30C9\u30A6\u30FB\u30BF\u30A4\u30C8\u30EB\n-doctitle \u6982\u8981\u30DA\u30FC\u30B8\u306B\u30BF\u30A4\u30C8\u30EB\u3092\u542B\u3081\u308B\n-header \u5404\u30DA\u30FC\u30B8\u306B\u30D8\u30C3\u30C0\u30FC\u3092\u542B\u3081\u308B\n-footer \u5404\u30DA\u30FC\u30B8\u306B\u30D5\u30C3\u30BF\u30FC\u3092\u542B\u3081\u308B\n-top \u5404\u30DA\u30FC\u30B8\u306B\u4E0A\u90E8\u30C6\u30AD\u30B9\u30C8\u3092\u542B\u3081\u308B\n-bottom \u5404\u30DA\u30FC\u30B8\u306B\u4E0B\u90E8\u30C6\u30AD\u30B9\u30C8\u3092\u542B\u3081\u308B\n-link \u306Bjavadoc\u51FA\u529B\u3078\u306E\u30EA\u30F3\u30AF\u3092\u4F5C\u6210\u3059\u308B\n-linkoffline \u306B\u3042\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EA\u30B9\u30C8\u3092\u4F7F\u7528\u3057\u3066\u306Edocs\u306B\u30EA\u30F3\u30AF\u3059\u308B\n-excludedocfilessubdir :.. \u6307\u5B9A\u3055\u308C\u305F\u540D\u524D\u306Edoc-files\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u3059\u3079\u3066\u9664\u5916\u3059\u308B\n-group :.. \u6307\u5B9A\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u6982\u8981\u30DA\u30FC\u30B8\u306B\u304A\u3044\u3066\u30B0\u30EB\u30FC\u30D7\u5316\u3059\u308B\n-nocomment \u8A18\u8FF0\u304A\u3088\u3073\u30BF\u30B0\u3092\u6291\u5236\u3057\u3066\u5BA3\u8A00\u306E\u307F\u3092\u751F\u6210\u3059\u308B\n-nodeprecated @deprecated\u60C5\u5831\u3092\u9664\u5916\u3059\u308B\n-noqualifier ::... \u51FA\u529B\u304B\u3089\u4FEE\u98FE\u5B50\u306E\u30EA\u30B9\u30C8\u3092\u9664\u5916\u3059\u308B\n-nosince @since\u60C5\u5831\u3092\u9664\u5916\u3059\u308B\n-notimestamp \u975E\u8868\u793A\u306E\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u9664\u5916\u3059\u308B\n-nodeprecatedlist \u975E\u63A8\u5968\u306E\u30EA\u30B9\u30C8\u3092\u751F\u6210\u3057\u306A\u3044\n-notree \u30AF\u30E9\u30B9\u968E\u5C64\u3092\u751F\u6210\u3057\u306A\u3044\n-noindex \u7D22\u5F15\u3092\u751F\u6210\u3057\u306A\u3044\n-nohelp \u30D8\u30EB\u30D7\u30FB\u30EA\u30F3\u30AF\u3092\u751F\u6210\u3057\u306A\u3044\n-nonavbar \u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u3092\u751F\u6210\u3057\u306A\u3044\n-serialwarn @serial\u30BF\u30B0\u306B\u95A2\u3059\u308B\u8B66\u544A\u3092\u751F\u6210\u3059\u308B\n-tag ::
    \u5358\u4E00\u306E\u5F15\u6570\u3092\u6301\u3064\u30AB\u30B9\u30BF\u30E0\u30FB\u30BF\u30B0\u3092\u6307\u5B9A\u3059\u308B\n-taglet \u30BF\u30B0\u30EC\u30C3\u30C8\u306E\u5B8C\u5168\u4FEE\u98FE\u540D\u3092\u767B\u9332\u3059\u308B\n-tagletpath \u30BF\u30B0\u30EC\u30C3\u30C8\u306E\u30D1\u30B9\n-charset \u751F\u6210\u3055\u308C\u308B\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30AF\u30ED\u30B9\u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u3067\u306E\u6587\u5B57\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\n-helpfile \u30D8\u30EB\u30D7\u30FB\u30EA\u30F3\u30AF\u306E\u30EA\u30F3\u30AF\u5148\u30D5\u30A1\u30A4\u30EB\u3092\u542B\u3081\u308B\n-linksource HTML\u5F62\u5F0F\u3067\u30BD\u30FC\u30B9\u3092\u751F\u6210\u3059\u308B\n-sourcetab \u30BD\u30FC\u30B9\u5185\u306E\u30BF\u30D6\u306E\u7A7A\u767D\u6587\u5B57\u306E\u6570\u3092\u6307\u5B9A\u3059\u308B\n-keywords HTML\u306Emeta\u30BF\u30B0\u306B\u3001\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30E1\u30F3\u30D0\u30FC\u306E\u60C5\u5831\u3092\u542B\u3081\u308B\n-stylesheetfile \u751F\u6210\u3055\u308C\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30B9\u30BF\u30A4\u30EB\u5909\u66F4\u7528\u30D5\u30A1\u30A4\u30EB\n-docencoding \u51FA\u529B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u540D +doclet.exception_encountered={1}\u306E\u51E6\u7406\u4E2D\u306B\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n{0} +doclet.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n-d \u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u306E\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\n-use \u30AF\u30E9\u30B9\u3068\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u4F7F\u7528\u30DA\u30FC\u30B8\u3092\u4F5C\u6210\u3059\u308B\n-version @version\u30D1\u30E9\u30B0\u30E9\u30D5\u3092\u542B\u3081\u308B\n-author @author\u30D1\u30E9\u30B0\u30E9\u30D5\u3092\u542B\u3081\u308B\n-docfilessubdirs doc-file\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u518D\u5E30\u7684\u306B\u30B3\u30D4\u30FC\u3059\u308B\n-splitindex 1\u5B57\u3054\u3068\u306B1\u30D5\u30A1\u30A4\u30EB\u306B\u7D22\u5F15\u3092\u5206\u5272\u3059\u308B\n-windowtitle \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u7528\u306E\u30D6\u30E9\u30A6\u30B6\u30FB\u30A6\u30A3\u30F3\u30C9\u30A6\u30FB\u30BF\u30A4\u30C8\u30EB\n-doctitle \u6982\u8981\u30DA\u30FC\u30B8\u306B\u30BF\u30A4\u30C8\u30EB\u3092\u542B\u3081\u308B\n-header \u5404\u30DA\u30FC\u30B8\u306B\u30D8\u30C3\u30C0\u30FC\u3092\u542B\u3081\u308B\n-footer \u5404\u30DA\u30FC\u30B8\u306B\u30D5\u30C3\u30BF\u30FC\u3092\u542B\u3081\u308B\n-top \u5404\u30DA\u30FC\u30B8\u306B\u4E0A\u90E8\u30C6\u30AD\u30B9\u30C8\u3092\u542B\u3081\u308B\n-bottom \u5404\u30DA\u30FC\u30B8\u306B\u4E0B\u90E8\u30C6\u30AD\u30B9\u30C8\u3092\u542B\u3081\u308B\n-link \u306Bjavadoc\u51FA\u529B\u3078\u306E\u30EA\u30F3\u30AF\u3092\u4F5C\u6210\u3059\u308B\n-linkoffline \u306B\u3042\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EA\u30B9\u30C8\u3092\u4F7F\u7528\u3057\u3066\u306Edocs\u306B\u30EA\u30F3\u30AF\u3059\u308B\n-excludedocfilessubdir :.. \u6307\u5B9A\u3055\u308C\u305F\u540D\u524D\u306Edoc-files\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u3059\u3079\u3066\u9664\u5916\u3059\u308B\n-group :.. \u6307\u5B9A\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u6982\u8981\u30DA\u30FC\u30B8\u306B\u304A\u3044\u3066\u30B0\u30EB\u30FC\u30D7\u5316\u3059\u308B\n-nocomment \u8A18\u8FF0\u304A\u3088\u3073\u30BF\u30B0\u3092\u6291\u5236\u3057\u3066\u5BA3\u8A00\u306E\u307F\u3092\u751F\u6210\u3059\u308B\n-nodeprecated @deprecated\u60C5\u5831\u3092\u9664\u5916\u3059\u308B\n-noqualifier ::... \u51FA\u529B\u304B\u3089\u4FEE\u98FE\u5B50\u306E\u30EA\u30B9\u30C8\u3092\u9664\u5916\u3059\u308B\n-nosince @since\u60C5\u5831\u3092\u9664\u5916\u3059\u308B\n-notimestamp \u975E\u8868\u793A\u306E\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u9664\u5916\u3059\u308B\n-nodeprecatedlist \u975E\u63A8\u5968\u306E\u30EA\u30B9\u30C8\u3092\u751F\u6210\u3057\u306A\u3044\n-notree \u30AF\u30E9\u30B9\u968E\u5C64\u3092\u751F\u6210\u3057\u306A\u3044\n-noindex \u7D22\u5F15\u3092\u751F\u6210\u3057\u306A\u3044\n-nohelp \u30D8\u30EB\u30D7\u30FB\u30EA\u30F3\u30AF\u3092\u751F\u6210\u3057\u306A\u3044\n-nonavbar \u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u3092\u751F\u6210\u3057\u306A\u3044\n-serialwarn @serial\u30BF\u30B0\u306B\u95A2\u3059\u308B\u8B66\u544A\u3092\u751F\u6210\u3059\u308B\n-tag ::
    \u5358\u4E00\u306E\u5F15\u6570\u3092\u6301\u3064\u30AB\u30B9\u30BF\u30E0\u30FB\u30BF\u30B0\u3092\u6307\u5B9A\u3059\u308B\n-taglet \u30BF\u30B0\u30EC\u30C3\u30C8\u306E\u5B8C\u5168\u4FEE\u98FE\u540D\u3092\u767B\u9332\u3059\u308B\n-tagletpath \u30BF\u30B0\u30EC\u30C3\u30C8\u306E\u30D1\u30B9\n-Xdocrootparent \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30B3\u30E1\u30F3\u30C8\u5185\u306E@docRoot(\u3053\u306E\u5F8C\u306B\u306F/..\u304C\u7D9A\u304F)\u306E\u3059\u3079\u3066\u306E\u51FA\u73FE\u7B87\u6240\u3092\u3067\u7F6E\u63DB\u3059\u308B\n-charset \u751F\u6210\u3055\u308C\u308B\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30AF\u30ED\u30B9\u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u3067\u306E\u6587\u5B57\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\n-helpfile \u30D8\u30EB\u30D7\u30FB\u30EA\u30F3\u30AF\u306E\u30EA\u30F3\u30AF\u5148\u30D5\u30A1\u30A4\u30EB\u3092\u542B\u3081\u308B\n-linksource HTML\u5F62\u5F0F\u3067\u30BD\u30FC\u30B9\u3092\u751F\u6210\u3059\u308B\n-sourcetab \u30BD\u30FC\u30B9\u5185\u306E\u30BF\u30D6\u306E\u7A7A\u767D\u6587\u5B57\u306E\u6570\u3092\u6307\u5B9A\u3059\u308B\n-keywords HTML\u306Emeta\u30BF\u30B0\u306B\u3001\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30E1\u30F3\u30D0\u30FC\u306E\u60C5\u5831\u3092\u542B\u3081\u308B\n-stylesheetfile \u751F\u6210\u3055\u308C\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30B9\u30BF\u30A4\u30EB\u5909\u66F4\u7528\u30D5\u30A1\u30A4\u30EB\n-docencoding \u51FA\u529B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u540D diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties index 4198bd9c8d9..76f0abe8add 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties @@ -41,33 +41,23 @@ doclet.Window_Split_Index={0} - \u7D22\u5F15 doclet.Help=\u5E2E\u52A9 doclet.Skip_navigation_links=\u8DF3\u8FC7\u5BFC\u822A\u94FE\u63A5 doclet.New_Page=NewPage -doclet.None=\u65E0 -doclet.Factory_Method_Detail=\u9759\u6001\u5DE5\u5382\u65B9\u6CD5\u8BE6\u7EC6\u8D44\u6599 doclet.navDeprecated=\u5DF2\u8FC7\u65F6 -doclet.Deprecated_List=\u5DF2\u8FC7\u65F6\u7684\u5217\u8868 doclet.Window_Deprecated_List=\u5DF2\u8FC7\u65F6\u7684\u5217\u8868 -doclet.Note_0_is_deprecated=\u6CE8: {0}\u5DF2\u8FC7\u65F6\u3002 doclet.Overrides=\u8986\u76D6: doclet.in_class=\u5728\u7C7B\u4E2D -doclet.0_Fields_and_Methods="{0}" \u5B57\u6BB5\u548C\u65B9\u6CD5 -doclet.Index_of_Fields_and_Methods=\u5B57\u6BB5\u548C\u65B9\u6CD5\u7684\u7D22\u5F15 doclet.Static_variable_in={0}\u4E2D\u7684\u9759\u6001\u53D8\u91CF doclet.Variable_in={0}\u4E2D\u7684\u53D8\u91CF doclet.Constructor_for={0}\u7684\u6784\u9020\u5668 doclet.Static_method_in={0}\u4E2D\u7684\u9759\u6001\u65B9\u6CD5 doclet.Method_in={0}\u4E2D\u7684\u65B9\u6CD5 -doclet.throws=\u629B\u51FA doclet.package=\u7A0B\u5E8F\u5305 doclet.MalformedURL=\u683C\u5F0F\u9519\u8BEF\u7684 URL: {0} doclet.File_error=\u8BFB\u53D6\u6587\u4EF6\u65F6\u51FA\u9519: {0} doclet.URL_error=\u83B7\u53D6 URL \u65F6\u51FA\u9519: {0} -doclet.No_Package_Comment_File=\u5BF9\u4E8E\u7A0B\u5E8F\u5305{0}, \u627E\u4E0D\u5230 Package.Comment \u6587\u4EF6 -doclet.No_Source_For_Class=\u7C7B{0}\u7684\u6E90\u4FE1\u606F\u4E0D\u53EF\u7528\u3002 doclet.see.class_or_package_not_found=\u6807\u8BB0{0}: \u627E\u4E0D\u5230\u5F15\u7528: {1} doclet.see.class_or_package_not_accessible=\u6807\u8BB0{0}: \u65E0\u6CD5\u8BBF\u95EE\u5F15\u7528: {1} -doclet.see.malformed_tag=\u6807\u8BB0{0}: \u683C\u5F0F\u9519\u8BEF: {1} -doclet.Inherited_API_Summary=\u7EE7\u627F\u7684 API \u6982\u8981 doclet.Deprecated_API=\u5DF2\u8FC7\u65F6\u7684 API +doclet.Deprecated_Packages=\u5DF2\u8FC7\u65F6\u7A0B\u5E8F\u5305 doclet.Deprecated_Classes=\u5DF2\u8FC7\u65F6\u7684\u7C7B doclet.Deprecated_Enums=\u5DF2\u8FC7\u65F6\u7684\u679A\u4E3E doclet.Deprecated_Interfaces=\u5DF2\u8FC7\u65F6\u7684\u63A5\u53E3 @@ -79,6 +69,7 @@ doclet.Deprecated_Constructors=\u5DF2\u8FC7\u65F6\u7684\u6784\u9020\u5668 doclet.Deprecated_Methods=\u5DF2\u8FC7\u65F6\u7684\u65B9\u6CD5 doclet.Deprecated_Enum_Constants=\u5DF2\u8FC7\u65F6\u7684\u679A\u4E3E\u5E38\u91CF doclet.Deprecated_Annotation_Type_Members=\u5DF2\u8FC7\u65F6\u7684\u6CE8\u91CA\u7C7B\u578B\u5143\u7D20 +doclet.deprecated_packages=\u5DF2\u8FC7\u65F6\u7A0B\u5E8F\u5305 doclet.deprecated_classes=\u5DF2\u8FC7\u65F6\u7684\u7C7B doclet.deprecated_enums=\u5DF2\u8FC7\u65F6\u7684\u679A\u4E3E doclet.deprecated_interfaces=\u5DF2\u8FC7\u65F6\u7684\u63A5\u53E3 @@ -90,10 +81,7 @@ doclet.deprecated_constructors=\u5DF2\u8FC7\u65F6\u7684\u6784\u9020\u5668 doclet.deprecated_methods=\u5DF2\u8FC7\u65F6\u7684\u65B9\u6CD5 doclet.deprecated_enum_constants=\u5DF2\u8FC7\u65F6\u7684\u679A\u4E3E\u5E38\u91CF doclet.deprecated_annotation_type_members=\u5DF2\u8FC7\u65F6\u7684\u6CE8\u91CA\u7C7B\u578B\u5143\u7D20 -doclet.Frame_Output=\u6846\u67B6\u8F93\u51FA -doclet.Docs_generated_by_Javadoc=\u7531 Javadoc \u751F\u6210\u7684\u6587\u6863\u3002 doclet.Generated_Docs_Untitled=\u751F\u6210\u7684\u6587\u6863 (\u65E0\u6807\u9898) -doclet.Blank=\u7A7A\u767D doclet.Other_Packages=\u5176\u4ED6\u7A0B\u5E8F\u5305 doclet.Package_Description=\u7A0B\u5E8F\u5305{0}\u7684\u8BF4\u660E doclet.Description=\u8BF4\u660E @@ -102,33 +90,25 @@ doclet.in_interface=\u5728\u63A5\u53E3\u4E2D doclet.Subclasses=\u76F4\u63A5\u5DF2\u77E5\u5B50\u7C7B: doclet.Subinterfaces=\u6240\u6709\u5DF2\u77E5\u5B50\u63A5\u53E3: doclet.Implementing_Classes=\u6240\u6709\u5DF2\u77E5\u5B9E\u73B0\u7C7B: +doclet.Functional_Interface=\u51FD\u6570\u63A5\u53E3: +doclet.Functional_Interface_Message=\u8FD9\u662F\u4E00\u4E2A\u51FD\u6570\u63A5\u53E3, \u56E0\u6B64\u53EF\u7528\u4F5C lambda \u8868\u8FBE\u5F0F\u6216\u65B9\u6CD5\u5F15\u7528\u7684\u8D4B\u503C\u76EE\u6807\u3002 doclet.also=\u5E76 -doclet.Option=\u9009\u9879 -doclet.Or=\u6216 doclet.Frames=\u6846\u67B6 doclet.No_Frames=\u65E0\u6846\u67B6 doclet.Package_Hierarchies=\u7A0B\u5E8F\u5305\u5206\u5C42\u7ED3\u6784: doclet.Hierarchy_For_Package=\u7A0B\u5E8F\u5305{0}\u7684\u5206\u5C42\u7ED3\u6784 -doclet.Source_Code=\u6E90\u4EE3\u7801: doclet.Hierarchy_For_All_Packages=\u6240\u6709\u7A0B\u5E8F\u5305\u7684\u5206\u5C42\u7ED3\u6784 -doclet.Cannot_handle_no_packages=\u65E0\u6CD5\u5904\u7406\u6CA1\u6709\u7A0B\u5E8F\u5305\u7684\u60C5\u51B5\u3002 doclet.Frame_Alert=\u6846\u67B6\u9884\u8B66 -doclet.Overview-Member-Frame=\u6210\u5458\u6846\u67B6\u6982\u89C8 doclet.Frame_Warning_Message=\u8BF7\u4F7F\u7528\u6846\u67B6\u529F\u80FD\u67E5\u770B\u6B64\u6587\u6863\u3002\u5982\u679C\u770B\u5230\u6B64\u6D88\u606F, \u5219\u8868\u660E\u60A8\u4F7F\u7528\u7684\u662F\u4E0D\u652F\u6301\u6846\u67B6\u7684 Web \u5BA2\u6237\u673A\u3002\u94FE\u63A5\u5230{0}\u3002 doclet.No_Script_Message=\u60A8\u7684\u6D4F\u89C8\u5668\u5DF2\u7981\u7528 JavaScript\u3002 doclet.Non_Frame_Version=\u975E\u6846\u67B6\u7248\u672C -doclet.Frame_Version=\u6846\u67B6\u7248\u672C -doclet.Following_From_Class=\u4EE5\u4E0B\u5185\u5BB9\u662F\u4ECE\u7C7B{0}\u590D\u5236\u7684 -doclet.Following_From_Interface=\u4EE5\u4E0B\u5185\u5BB9\u662F\u4ECE\u63A5\u53E3{0}\u590D\u5236\u7684 doclet.Description_From_Interface=\u4ECE\u63A5\u53E3\u590D\u5236\u7684\u8BF4\u660E: doclet.Description_From_Class=\u4ECE\u7C7B\u590D\u5236\u7684\u8BF4\u660E: -doclet.Standard_doclet_invoked=\u5DF2\u8C03\u7528\u7684\u6807\u51C6 doclet... doclet.No_Non_Deprecated_Classes_To_Document=\u627E\u4E0D\u5230\u53EF\u4EE5\u6587\u6863\u5316\u7684\u672A\u8FC7\u65F6\u7684\u7C7B\u3002 doclet.Interfaces_Italic=\u63A5\u53E3 (\u659C\u4F53) doclet.Enclosing_Class=\u5C01\u95ED\u7C7B: doclet.Enclosing_Interface=\u5C01\u95ED\u63A5\u53E3: doclet.Window_Source_title=\u6E90\u4EE3\u7801 -doclet.Help_title=API \u5E2E\u52A9 doclet.Window_Help_title=API \u5E2E\u52A9 doclet.Help_line_1=\u6B64 API \u6587\u6863\u7684\u7EC4\u7EC7\u65B9\u5F0F doclet.Help_line_2=\u6B64 API (\u5E94\u7528\u7A0B\u5E8F\u7F16\u7A0B\u63A5\u53E3) \u6587\u6863\u5305\u542B\u5BF9\u5E94\u4E8E\u5BFC\u822A\u680F\u4E2D\u7684\u9879\u76EE\u7684\u9875\u9762, \u5982\u4E0B\u6240\u8FF0\u3002 @@ -158,7 +138,7 @@ doclet.Help_line_25=\u6846\u67B6/\u65E0\u6846\u67B6 doclet.Help_line_26=\u8FD9\u4E9B\u94FE\u63A5\u7528\u4E8E\u663E\u793A\u548C\u9690\u85CF HTML \u6846\u67B6\u3002\u6240\u6709\u9875\u9762\u5747\u5177\u6709\u6709\u6846\u67B6\u548C\u65E0\u6846\u67B6\u4E24\u79CD\u663E\u793A\u65B9\u5F0F\u3002 doclet.Help_line_27={0}\u94FE\u63A5\u663E\u793A\u6240\u6709\u7C7B\u548C\u63A5\u53E3 (\u9664\u4E86\u975E\u9759\u6001\u5D4C\u5957\u7C7B\u578B)\u3002 doclet.Help_line_28=\u6BCF\u4E2A\u53EF\u5E8F\u5217\u5316\u6216\u53EF\u5916\u90E8\u5316\u7684\u7C7B\u90FD\u6709\u5176\u5E8F\u5217\u5316\u5B57\u6BB5\u548C\u65B9\u6CD5\u7684\u8BF4\u660E\u3002\u6B64\u4FE1\u606F\u5BF9\u91CD\u65B0\u5B9E\u73B0\u8005\u6709\u7528, \u800C\u5BF9\u4F7F\u7528 API \u7684\u5F00\u53D1\u8005\u5219\u6CA1\u6709\u4EC0\u4E48\u7528\u5904\u3002\u5C3D\u7BA1\u5BFC\u822A\u680F\u4E2D\u6CA1\u6709\u94FE\u63A5, \u4F46\u60A8\u53EF\u4EE5\u901A\u8FC7\u4E0B\u5217\u65B9\u5F0F\u83B7\u53D6\u6B64\u4FE1\u606F: \u8F6C\u81F3\u4EFB\u4F55\u5E8F\u5217\u5316\u7C7B, \u7136\u540E\u5355\u51FB\u7C7B\u8BF4\u660E\u7684 "\u53E6\u8BF7\u53C2\u9605" \u90E8\u5206\u4E2D\u7684 "\u5E8F\u5217\u5316\u8868\u683C"\u3002 -doclet.Help_line_29=\u5E38\u91CF\u5B57\u6BB5\u503C\u9875\u9762\u5217\u51FA\u4E86\u9759\u6001\u6700\u7EC8\u5B57\u6BB5\u53CA\u5176\u503C\u3002 +doclet.Help_line_29={0}\u9875\u9762\u5217\u51FA\u4E86\u9759\u6001\u6700\u7EC8\u5B57\u6BB5\u53CA\u5176\u503C\u3002 doclet.Help_line_30=\u6B64\u5E2E\u52A9\u6587\u4EF6\u9002\u7528\u4E8E\u4F7F\u7528\u6807\u51C6 doclet \u751F\u6210\u7684 API \u6587\u6863\u3002 doclet.Help_enum_line_1=\u6BCF\u4E2A\u679A\u4E3E\u90FD\u6709\u5404\u81EA\u7684\u9875\u9762, \u5176\u4E2D\u5305\u542B\u4EE5\u4E0B\u90E8\u5206: doclet.Help_enum_line_2=\u679A\u4E3E\u58F0\u660E @@ -166,19 +146,6 @@ doclet.Help_enum_line_3=\u679A\u4E3E\u8BF4\u660E doclet.Help_annotation_type_line_1=\u6BCF\u4E2A\u6CE8\u91CA\u7C7B\u578B\u90FD\u6709\u5404\u81EA\u7684\u9875\u9762, \u5176\u4E2D\u5305\u542B\u4EE5\u4E0B\u90E8\u5206: doclet.Help_annotation_type_line_2=\u6CE8\u91CA\u7C7B\u578B\u58F0\u660E doclet.Help_annotation_type_line_3=\u6CE8\u91CA\u7C7B\u578B\u8BF4\u660E -doclet.Style_line_1=Javadoc \u6837\u5F0F\u8868 -doclet.Style_line_2=\u5728\u6B64\u5904\u5B9A\u4E49\u989C\u8272, \u5B57\u4F53\u548C\u5176\u4ED6\u6837\u5F0F\u5C5E\u6027\u4EE5\u8986\u76D6\u9ED8\u8BA4\u503C -doclet.Style_line_3=\u9875\u9762\u80CC\u666F\u989C\u8272 -doclet.Style_Headings=\u6807\u9898 -doclet.Style_line_4=\u8868\u683C\u989C\u8272 -doclet.Style_line_5=\u6DF1\u7D2B\u8272 -doclet.Style_line_6=\u6DE1\u7D2B\u8272 -doclet.Style_line_7=\u767D\u8272 -doclet.Style_line_8=\u5DE6\u4FA7\u7684\u6846\u67B6\u5217\u8868\u4E2D\u4F7F\u7528\u7684\u5B57\u4F53 -doclet.Style_line_9=\u6846\u67B6\u4E2D\u5C0F\u53F7 sans-serif \u5B57\u4F53\u7684\u793A\u4F8B -doclet.Style_line_10=\u5BFC\u822A\u680F\u5B57\u4F53\u548C\u989C\u8272 -doclet.Style_line_11=\u6DF1\u84DD\u8272 -doclet.Style_line_12=\u8868\u6807\u9898\u6837\u5F0F doclet.ClassUse_Packages.that.use.0=\u4F7F\u7528{0}\u7684\u7A0B\u5E8F\u5305 doclet.ClassUse_Uses.of.0.in.1={1}\u4E2D{0}\u7684\u4F7F\u7528 doclet.ClassUse_Classes.in.0.used.by.1={1}\u4F7F\u7528\u7684{0}\u4E2D\u7684\u7C7B @@ -208,13 +175,11 @@ doclet.ClassUse_No.usage.of.0=\u6CA1\u6709{0}\u7684\u7528\u6CD5 doclet.Window_ClassUse_Header={0} {1}\u7684\u4F7F\u7528 doclet.ClassUse_Title={0} {1}
    \u7684\u4F7F\u7528 doclet.navClassUse=\u4F7F\u7528 -doclet.link_option_twice=\u5916\u90E8 URL \u94FE\u63A5\u9009\u9879 (link \u6216 linkoffline) \u4F7F\u7528\u4E86\u4E24\u6B21\u3002 doclet.Error_in_packagelist=\u4F7F\u7528 -group \u9009\u9879\u65F6\u51FA\u9519: {0} {1} doclet.Groupname_already_used=\u5728 -group \u9009\u9879\u4E2D, groupname \u5DF2\u4F7F\u7528: {0} doclet.Same_package_name_used=\u7A0B\u5E8F\u5305\u540D\u79F0\u5F62\u5F0F\u4F7F\u7528\u4E86\u4E24\u6B21: {0} -doclet.Serialization.Excluded_Class=\u975E\u77AC\u6001\u5B57\u6BB5{1}\u4F7F\u7528\u4E86\u6392\u9664\u7684\u7C7B{0}\u3002 -doclet.Serialization.Nonexcluded_Class=\u975E\u77AC\u6001\u5B57\u6BB5{1}\u4F7F\u7528\u4E86\u9690\u85CF\u7684, \u672A\u5305\u542B\u7684\u7C7B{0}\u3002 -doclet.usage=\u901A\u8FC7\u6807\u51C6 doclet \u63D0\u4F9B:\n-d \u8F93\u51FA\u6587\u4EF6\u7684\u76EE\u6807\u76EE\u5F55\n-use \u521B\u5EFA\u7C7B\u548C\u7A0B\u5E8F\u5305\u7528\u6CD5\u9875\u9762\n-version \u5305\u542B @version \u6BB5\n-author \u5305\u542B @author \u6BB5\n-docfilessubdirs \u9012\u5F52\u590D\u5236\u6587\u6863\u6587\u4EF6\u5B50\u76EE\u5F55\n-splitindex \u5C06\u7D22\u5F15\u5206\u4E3A\u6BCF\u4E2A\u5B57\u6BCD\u5BF9\u5E94\u4E00\u4E2A\u6587\u4EF6\n-windowtitle \u6587\u6863\u7684\u6D4F\u89C8\u5668\u7A97\u53E3\u6807\u9898\n-doctitle \u5305\u542B\u6982\u89C8\u9875\u9762\u7684\u6807\u9898\n-header \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u9875\u7709\u6587\u672C\n-footer \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u9875\u811A\u6587\u672C\n-top \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u9876\u90E8\u6587\u672C\n-bottom \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u5E95\u90E8\u6587\u672C\n-link \u521B\u5EFA\u6307\u5411\u4F4D\u4E8E \u7684 javadoc \u8F93\u51FA\u7684\u94FE\u63A5\n-linkoffline \u5229\u7528\u4F4D\u4E8E \u7684\u7A0B\u5E8F\u5305\u5217\u8868\u94FE\u63A5\u81F3\u4F4D\u4E8E \u7684\u6587\u6863\n-excludedocfilessubdir :..\u6392\u9664\u5177\u6709\u7ED9\u5B9A\u540D\u79F0\u7684\u6240\u6709\u6587\u6863\u6587\u4EF6\u5B50\u76EE\u5F55\u3002\n-group :..\u5728\u6982\u89C8\u9875\u9762\u4E2D, \u5C06\u6307\u5B9A\u7684\u7A0B\u5E8F\u5305\u5206\u7EC4\n-nocomment \u4E0D\u751F\u6210\u8BF4\u660E\u548C\u6807\u8BB0, \u53EA\u751F\u6210\u58F0\u660E\u3002\n-nodeprecated \u4E0D\u5305\u542B @deprecated \u4FE1\u606F\n-noqualifier ::...\u8F93\u51FA\u4E2D\u4E0D\u5305\u62EC\u6307\u5B9A\u9650\u5B9A\u7B26\u7684\u5217\u8868\u3002\n-nosince \u4E0D\u5305\u542B @since \u4FE1\u606F\n-notimestamp \u4E0D\u5305\u542B\u9690\u85CF\u65F6\u95F4\u6233\n-nodeprecatedlist \u4E0D\u751F\u6210\u5DF2\u8FC7\u65F6\u7684\u5217\u8868\n-notree \u4E0D\u751F\u6210\u7C7B\u5206\u5C42\u7ED3\u6784\n-noindex \u4E0D\u751F\u6210\u7D22\u5F15\n-nohelp \u4E0D\u751F\u6210\u5E2E\u52A9\u94FE\u63A5\n-nonavbar \u4E0D\u751F\u6210\u5BFC\u822A\u680F\n-serialwarn \u751F\u6210\u6709\u5173 @serial \u6807\u8BB0\u7684\u8B66\u544A\n-tag ::
    \u6307\u5B9A\u5355\u4E2A\u53C2\u6570\u5B9A\u5236\u6807\u8BB0\n-taglet \u8981\u6CE8\u518C\u7684 Taglet \u7684\u5168\u9650\u5B9A\u540D\u79F0\n-tagletpath Taglet \u7684\u8DEF\u5F84\n-charset \u7528\u4E8E\u8DE8\u5E73\u53F0\u67E5\u770B\u751F\u6210\u7684\u6587\u6863\u7684\u5B57\u7B26\u96C6\u3002\n-helpfile \u5305\u542B\u5E2E\u52A9\u94FE\u63A5\u6240\u94FE\u63A5\u5230\u7684\u6587\u4EF6\n-linksource \u4EE5 HTML \u683C\u5F0F\u751F\u6210\u6E90\u6587\u4EF6\n-sourcetab \u6307\u5B9A\u6E90\u4E2D\u6BCF\u4E2A\u5236\u8868\u7B26\u5360\u636E\u7684\u7A7A\u683C\u6570\n-keywords \u4F7F\u7A0B\u5E8F\u5305, \u7C7B\u548C\u6210\u5458\u4FE1\u606F\u9644\u5E26 HTML \u5143\u6807\u8BB0\n-stylesheetfile \u7528\u4E8E\u66F4\u6539\u751F\u6210\u6587\u6863\u7684\u6837\u5F0F\u7684\u6587\u4EF6\n-docencoding \u8F93\u51FA\u7F16\u7801\u540D\u79F0 +doclet.exception_encountered=\u5904\u7406{1}\u65F6\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\n{0} +doclet.usage=\u901A\u8FC7\u6807\u51C6 doclet \u63D0\u4F9B:\n-d \u8F93\u51FA\u6587\u4EF6\u7684\u76EE\u6807\u76EE\u5F55\n-use \u521B\u5EFA\u7C7B\u548C\u7A0B\u5E8F\u5305\u7528\u6CD5\u9875\u9762\n-version \u5305\u542B @version \u6BB5\n-author \u5305\u542B @author \u6BB5\n-docfilessubdirs \u9012\u5F52\u590D\u5236\u6587\u6863\u6587\u4EF6\u5B50\u76EE\u5F55\n-splitindex \u5C06\u7D22\u5F15\u5206\u4E3A\u6BCF\u4E2A\u5B57\u6BCD\u5BF9\u5E94\u4E00\u4E2A\u6587\u4EF6\n-windowtitle \u6587\u6863\u7684\u6D4F\u89C8\u5668\u7A97\u53E3\u6807\u9898\n-doctitle \u5305\u542B\u6982\u89C8\u9875\u9762\u7684\u6807\u9898\n-header \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u9875\u7709\u6587\u672C\n-footer \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u9875\u811A\u6587\u672C\n-top \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u9876\u90E8\u6587\u672C\n-bottom \u5305\u542B\u6BCF\u4E2A\u9875\u9762\u7684\u5E95\u90E8\u6587\u672C\n-link \u521B\u5EFA\u6307\u5411\u4F4D\u4E8E \u7684 javadoc \u8F93\u51FA\u7684\u94FE\u63A5\n-linkoffline \u5229\u7528\u4F4D\u4E8E \u7684\u7A0B\u5E8F\u5305\u5217\u8868\u94FE\u63A5\u81F3\u4F4D\u4E8E \u7684\u6587\u6863\n-excludedocfilessubdir :.. \u6392\u9664\u5177\u6709\u7ED9\u5B9A\u540D\u79F0\u7684\u6240\u6709\u6587\u6863\u6587\u4EF6\u5B50\u76EE\u5F55\u3002\n-group :.. \u5728\u6982\u89C8\u9875\u9762\u4E2D, \u5C06\u6307\u5B9A\u7684\u7A0B\u5E8F\u5305\u5206\u7EC4\n-nocomment \u4E0D\u751F\u6210\u8BF4\u660E\u548C\u6807\u8BB0, \u53EA\u751F\u6210\u58F0\u660E\u3002\n-nodeprecated \u4E0D\u5305\u542B @deprecated \u4FE1\u606F\n-noqualifier ::... \u8F93\u51FA\u4E2D\u4E0D\u5305\u62EC\u9650\u5B9A\u7B26\u7684\u5217\u8868\u3002\n-nosince \u4E0D\u5305\u542B @since \u4FE1\u606F\n-notimestamp \u4E0D\u5305\u542B\u9690\u85CF\u65F6\u95F4\u6233\n-nodeprecatedlist \u4E0D\u751F\u6210\u5DF2\u8FC7\u65F6\u7684\u5217\u8868\n-notree \u4E0D\u751F\u6210\u7C7B\u5206\u5C42\u7ED3\u6784\n-noindex \u4E0D\u751F\u6210\u7D22\u5F15\n-nohelp \u4E0D\u751F\u6210\u5E2E\u52A9\u94FE\u63A5\n-nonavbar \u4E0D\u751F\u6210\u5BFC\u822A\u680F\n-serialwarn \u751F\u6210\u6709\u5173 @serial \u6807\u8BB0\u7684\u8B66\u544A\n-tag ::
    \u6307\u5B9A\u5355\u4E2A\u53C2\u6570\u5B9A\u5236\u6807\u8BB0\n-taglet \u8981\u6CE8\u518C\u7684 Taglet \u7684\u5168\u9650\u5B9A\u540D\u79F0\n-tagletpath Taglet \u7684\u8DEF\u5F84\n-Xdocrootparent \u5C06\u6587\u6863\u6CE8\u91CA\u4E2D\u51FA\u73B0\u7684\u6240\u6709\u540E\u8DDF /.. \u7684 @docRoot \u66FF\u6362\u4E3A \n-charset \u7528\u4E8E\u8DE8\u5E73\u53F0\u67E5\u770B\u751F\u6210\u7684\u6587\u6863\u7684\u5B57\u7B26\u96C6\u3002\n-helpfile \u5305\u542B\u5E2E\u52A9\u94FE\u63A5\u6240\u94FE\u63A5\u5230\u7684\u6587\u4EF6\n-linksource \u4EE5 HTML \u683C\u5F0F\u751F\u6210\u6E90\u6587\u4EF6\n-sourcetab \u6307\u5B9A\u6E90\u4E2D\u6BCF\u4E2A\u5236\u8868\u7B26\u5360\u636E\u7684\u7A7A\u683C\u6570\n-keywords \u4F7F\u7A0B\u5E8F\u5305, \u7C7B\u548C\u6210\u5458\u4FE1\u606F\u9644\u5E26 HTML \u5143\u6807\u8BB0\n-stylesheetfile \u7528\u4E8E\u66F4\u6539\u751F\u6210\u6587\u6863\u7684\u6837\u5F0F\u7684\u6587\u4EF6\n-docencoding \u8F93\u51FA\u7F16\u7801\u540D\u79F0 diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties index 0ca792933b9..75202520a3c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties @@ -11,6 +11,8 @@ doclet.Class_0_implements_serializable=Class {0} implements Serializable doclet.Class_0_extends_implements_serializable=Class {0} extends {1} implements Serializable doclet.Option_conflict=\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u304C{1}\u3068\u77DB\u76FE\u3057\u307E\u3059 doclet.Option_reuse=\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u518D\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0} +doclet.Option_doclint_no_qualifiers=\u30A2\u30AF\u30BB\u30B9\u4FEE\u98FE\u5B50\u306F-Xdoclint\u306E\u5F15\u6570\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 +doclet.Option_doclint_invalid_arg=-Xdoclint\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059 doclet.exception_encountered= {0}\u3092\u691C\u51FA\n\t\u30D5\u30A1\u30A4\u30EB\u306E\u4F5C\u6210\u4E2D: {1} doclet.perform_copy_exception_encountered= \u30B3\u30D4\u30FC\u5B9F\u884C\u4E2D\u306B{0}\u3092\n\u691C\u51FA\u3057\u307E\u3057\u305F\u3002 doclet.File_not_found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} @@ -19,10 +21,8 @@ doclet.Copying_File_0_To_Dir_1=\u30D5\u30A1\u30A4\u30EB{0}\u3092\u30C7\u30A3\u30 doclet.Copying_File_0_To_File_1=\u30D5\u30A1\u30A4\u30EB{0}\u3092\u30D5\u30A1\u30A4\u30EB{1}\u306B\u30B3\u30D4\u30FC\u4E2D... doclet.No_Public_Classes_To_Document=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3059\u308Bpublic\u307E\u305F\u306Fprotected\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 doclet.Unable_to_create_directory_0=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093 -doclet.destination_directory_not_found_0=\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 doclet.destination_directory_not_directory_0=\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u306F\u3042\u308A\u307E\u305B\u3093 doclet.destination_directory_not_writable_0=\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u66F8\u8FBC\u307F\u53EF\u80FD\u3067\u306F\u3042\u308A\u307E\u305B\u3093 -doclet.Error_creating_tmp_file=\u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u4F7F\u7528\u3057\u3066\u4E00\u6642\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002 doclet.Encoding_not_supported=\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093 doclet.Building_Tree=\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u3068\u30AF\u30E9\u30B9\u306E\u968E\u5C64\u30C4\u30EA\u30FC\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059... doclet.Building_Index=\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u3068\u30AF\u30E9\u30B9\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059... @@ -72,7 +72,6 @@ doclet.Field_Summary=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u6982\u8981 doclet.Enum_Constant_Summary=\u5217\u6319\u578B\u5B9A\u6570\u306E\u6982\u8981 doclet.Constructor_Summary=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u6982\u8981 doclet.Method_Summary=\u30E1\u30BD\u30C3\u30C9\u306E\u6982\u8981 -doclet.Factory_Method_Summary=static\u30D5\u30A1\u30AF\u30C8\u30EA\u30FB\u30E1\u30BD\u30C3\u30C9\u306E\u6982\u8981 doclet.Interfaces=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.Enums=\u5217\u6319\u578B doclet.AnnotationTypes=\u6CE8\u91C8\u578B @@ -86,15 +85,14 @@ doclet.All_Superinterfaces=\u3059\u3079\u3066\u306E\u30B9\u30FC\u30D1\u30FC\u30A doclet.All_Implemented_Interfaces=\u3059\u3079\u3066\u306E\u5B9F\u88C5\u3055\u308C\u305F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9: doclet.All_classes_and_interfaces=\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9(\u975Estatic\u306E\u30CD\u30B9\u30C8\u3055\u308C\u305F\u578B\u3092\u9664\u304F) doclet.Package_class_and_interface_descriptions=\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u8AAC\u660E -doclet.Members=\u30E1\u30F3\u30D0\u30FC doclet.Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.Class=\u30AF\u30E9\u30B9 doclet.AnnotationType=\u6CE8\u91C8\u578B doclet.annotationtype=\u6CE8\u91C8\u578B doclet.annotationtypes=\u6CE8\u91C8\u578B doclet.Enum=\u5217\u6319\u578B -doclet.enum=\u5217\u6319 -doclet.enums=\u5217\u6319 +doclet.enum=\u5217\u6319\u578B +doclet.enums=\u5217\u6319\u578B doclet.interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.interfaces=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.class=\u30AF\u30E9\u30B9 @@ -105,26 +103,20 @@ doclet.errors=\u30A8\u30E9\u30FC doclet.Exception=\u4F8B\u5916 doclet.exception=\u4F8B\u5916 doclet.exceptions=\u4F8B\u5916 -doclet.extended_by=\u4E0A\u4F4D\u3092\u62E1\u5F35 -doclet.extends=extends doclet.Package_private=(package private) -doclet.implements=implementsdoclet.Same_package_name_used=\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u5F62\u5F0F\u304C2\u56DE\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0} doclet.Nested_Classes_Interfaces_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9/\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.Nested_Classes_Interface_Inherited_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9/\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.Methods_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9 doclet.Methods_Inherited_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9 doclet.Fields_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30D5\u30A3\u30FC\u30EB\u30C9 doclet.Fields_Inherited_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30D5\u30A3\u30FC\u30EB\u30C9 -doclet.Serializable=\u76F4\u5217\u5316\u53EF\u80FD -doclet.Externalizable=\u5916\u90E8\u5316\u53EF\u80FD doclet.Annotation_Type_Member_Detail=\u8981\u7D20\u306E\u8A73\u7D30 doclet.Enum_Constant_Detail=\u5217\u6319\u578B\u5B9A\u6570\u306E\u8A73\u7D30 doclet.Constants_Summary=\u5B9A\u6570\u30D5\u30A3\u30FC\u30EB\u30C9\u5024 doclet.Field_Detail=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u8A73\u7D30 doclet.Method_Detail=\u30E1\u30BD\u30C3\u30C9\u306E\u8A73\u7D30 doclet.Constructor_Detail=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u8A73\u7D30 -doclet.Deprecated=\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 -doclet.Deprecated_class=\u3053\u306E\u30AF\u30E9\u30B9\u306F\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 +doclet.Deprecated=\u975E\u63A8\u5968\u3067\u3059\u3002 doclet.Groupname_already_used=-group\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u304A\u3044\u3066\u3001\u3059\u3067\u306B\u30B0\u30EB\u30FC\u30D7\u540D\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0} doclet.value_tag_invalid_reference={0}(@value\u30BF\u30B0\u306B\u3088\u308A\u53C2\u7167\u3055\u308C\u3066\u3044\u308B)\u306F\u4E0D\u660E\u306A\u53C2\u7167\u3067\u3059\u3002 doclet.value_tag_invalid_constant=@value\u30BF\u30B0({0}\u3092\u53C2\u7167\u3057\u3066\u3044\u308B)\u306F\u5B9A\u6570\u5185\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002 @@ -144,7 +136,7 @@ doclet.Annotation_Type_Optional_Members=\u4EFB\u610F\u8981\u7D20 doclet.annotation_type_required_members=\u5FC5\u9808\u8981\u7D20 doclet.Annotation_Type_Required_Members=\u5FC5\u9808\u8981\u7D20 doclet.enum_constants=\u5217\u6319\u578B\u5B9A\u6570 -doclet.Enum_Constants=\u5217\u6319\u5B9A\u6570 +doclet.Enum_Constants=\u5217\u6319\u578B\u5B9A\u6570 doclet.nested_classes=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9 doclet.Nested_Classes=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9 doclet.subclasses=\u30B5\u30D6\u30AF\u30E9\u30B9 @@ -167,4 +159,4 @@ doclet.0_and_1={0}\u3068{1} #Documentation for Enums doclet.enum_values_doc=\n\u3053\u306E\u5217\u6319\u578B\u306E\u5B9A\u6570\u3092\u542B\u3080\u914D\u5217\u3092\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B\u9806\u5E8F\u3067\u8FD4\u3057\u307E\u3059\u3002\n\u3053\u306E\u30E1\u30BD\u30C3\u30C9\u306F\u6B21\u306E\u3088\u3046\u306B\u3057\u3066\u5B9A\u6570\u3092\u53CD\u5FA9\u3059\u308B\u305F\u3081\u306B\n\u4F7F\u7528\u3067\u304D\u307E\u3059:\n
    \nfor({0} c: {0}.values())\n  System.out.println(c);\n
    \n@return\u3053\u306E\u5217\u6319\u578B\u306E\u5B9A\u6570\u3092\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B\u9806\u5E8F\u3067\n\u542B\u3080\u914D\u5217 -doclet.enum_valueof_doc=\n\u6307\u5B9A\u3057\u305F\u540D\u524D\u3092\u6301\u3064\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u8FD4\u3057\u307E\u3059\u3002\n\u6587\u5B57\u5217\u306F\u3001\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u5BA3\u8A00\u3059\u308B\u306E\u306B\u4F7F\u7528\u3057\u305F\u8B58\u5225\u5B50\u3068\u53B3\u5BC6\u306B\n\u4E00\u81F4\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n(\u4F59\u5206\u306A\u7A7A\u767D\u6587\u5B57\u3092\u542B\u3081\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002)\n\n@param name\u8FD4\u3055\u308C\u308B\u5217\u6319\u578B\u5B9A\u6570\u306E\u540D\u524D\n@return\u6307\u5B9A\u3055\u308C\u305F\u540D\u524D\u3092\u6301\u3064\u5217\u6319\u578B\u5B9A\u6570\n@throws IllegalArgumentException\u6307\u5B9A\u3055\u308C\u305F\u540D\u524D\u3092\u6301\u3064\u5B9A\u6570\u3092\n\u3053\u306E\u5217\u6319\u578B\u304C\u6301\u3063\u3066\u3044\u306A\u3044\u5834\u5408\n@throws NullPointerException\u5F15\u6570\u304Cnull\u306E\u5834\u5408 +doclet.enum_valueof_doc=\n\u6307\u5B9A\u3057\u305F\u540D\u524D\u3092\u6301\u3064\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u8FD4\u3057\u307E\u3059\u3002\n\u6587\u5B57\u5217\u306F\u3001\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u5BA3\u8A00\u3059\u308B\u306E\u306B\u4F7F\u7528\u3057\u305F\u8B58\u5225\u5B50\u3068\u6B63\u78BA\u306B\n\u4E00\u81F4\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n(\u4F59\u5206\u306A\u7A7A\u767D\u6587\u5B57\u3092\u542B\u3081\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002)\n\n@param name\u8FD4\u3055\u308C\u308B\u5217\u6319\u578B\u5B9A\u6570\u306E\u540D\u524D\n@return\u6307\u5B9A\u3055\u308C\u305F\u540D\u524D\u3092\u6301\u3064\u5217\u6319\u578B\u5B9A\u6570\n@throws IllegalArgumentException\u6307\u5B9A\u3055\u308C\u305F\u540D\u524D\u3092\u6301\u3064\u5B9A\u6570\u3092\n\u3053\u306E\u5217\u6319\u578B\u304C\u6301\u3063\u3066\u3044\u306A\u3044\u5834\u5408\n@throws NullPointerException\u5F15\u6570\u304Cnull\u306E\u5834\u5408 diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties index 3e1fa628b73..121350f25c0 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties @@ -11,6 +11,8 @@ doclet.Class_0_implements_serializable=\u7C7B{0}\u5B9E\u73B0\u53EF\u5E8F\u5217\u doclet.Class_0_extends_implements_serializable=\u7C7B{0}\u6269\u5C55{1}\u5B9E\u73B0\u53EF\u5E8F\u5217\u5316 doclet.Option_conflict=\u9009\u9879{0}\u4E0E{1}\u51B2\u7A81 doclet.Option_reuse=\u91CD\u590D\u4F7F\u7528\u7684\u9009\u9879: {0} +doclet.Option_doclint_no_qualifiers=-Xdoclint \u53C2\u6570\u4E0D\u5141\u8BB8\u4F7F\u7528\u8BBF\u95EE\u9650\u5B9A\u7B26 +doclet.Option_doclint_invalid_arg=-Xdoclint \u9009\u9879\u7684\u53C2\u6570\u65E0\u6548 doclet.exception_encountered= \u5C1D\u8BD5\u521B\u5EFA\u6587\u4EF6{1}\u65F6 \n\t\u9047\u5230{0} doclet.perform_copy_exception_encountered= \u6267\u884C\u590D\u5236\u65F6 \n\u9047\u5230{0}\u3002 doclet.File_not_found=\u627E\u4E0D\u5230\u6587\u4EF6: {0} @@ -19,10 +21,8 @@ doclet.Copying_File_0_To_Dir_1=\u6B63\u5728\u5C06\u6587\u4EF6{0}\u590D\u5236\u52 doclet.Copying_File_0_To_File_1=\u6B63\u5728\u5C06\u6587\u4EF6{0}\u590D\u5236\u5230\u6587\u4EF6{1}... doclet.No_Public_Classes_To_Document=\u627E\u4E0D\u5230\u53EF\u4EE5\u6587\u6863\u5316\u7684\u516C\u5171\u6216\u53D7\u4FDD\u62A4\u7684\u7C7B\u3002 doclet.Unable_to_create_directory_0=\u65E0\u6CD5\u521B\u5EFA\u76EE\u5F55 {0} -doclet.destination_directory_not_found_0=\u627E\u4E0D\u5230\u76EE\u6807\u76EE\u5F55 {0} doclet.destination_directory_not_directory_0=\u76EE\u6807\u76EE\u5F55\u4E0D\u662F\u76EE\u5F55 {0} doclet.destination_directory_not_writable_0=\u76EE\u6807\u76EE\u5F55\u4E0D\u53EF\u5199\u5165 {0} -doclet.Error_creating_tmp_file=\u4F7F\u7528\u9ED8\u8BA4\u5E73\u53F0\u7F16\u7801\u521B\u5EFA\u4E34\u65F6\u6587\u4EF6\u65F6\u51FA\u9519\u3002 doclet.Encoding_not_supported=\u4E0D\u652F\u6301\u7F16\u7801: {0} doclet.Building_Tree=\u6B63\u5728\u6784\u5EFA\u6240\u6709\u7A0B\u5E8F\u5305\u548C\u7C7B\u7684\u6811... doclet.Building_Index=\u6B63\u5728\u6784\u5EFA\u6240\u6709\u7A0B\u5E8F\u5305\u548C\u7C7B\u7684\u7D22\u5F15... @@ -72,7 +72,6 @@ doclet.Field_Summary=\u5B57\u6BB5\u6982\u8981 doclet.Enum_Constant_Summary=\u679A\u4E3E\u5E38\u91CF\u6982\u8981 doclet.Constructor_Summary=\u6784\u9020\u5668\u6982\u8981 doclet.Method_Summary=\u65B9\u6CD5\u6982\u8981 -doclet.Factory_Method_Summary=\u9759\u6001\u5DE5\u5382\u65B9\u6CD5\u6982\u8981 doclet.Interfaces=\u63A5\u53E3 doclet.Enums=\u679A\u4E3E doclet.AnnotationTypes=\u6CE8\u91CA\u7C7B\u578B @@ -86,7 +85,6 @@ doclet.All_Superinterfaces=\u6240\u6709\u8D85\u7EA7\u63A5\u53E3: doclet.All_Implemented_Interfaces=\u6240\u6709\u5DF2\u5B9E\u73B0\u7684\u63A5\u53E3: doclet.All_classes_and_interfaces=\u6240\u6709\u7C7B\u548C\u63A5\u53E3 (\u9664\u4E86\u975E\u9759\u6001\u5D4C\u5957\u7C7B\u578B) doclet.Package_class_and_interface_descriptions=\u7A0B\u5E8F\u5305, \u7C7B\u548C\u63A5\u53E3\u8BF4\u660E -doclet.Members=\u6210\u5458 doclet.Interface=\u63A5\u53E3 doclet.Class=\u7C7B doclet.AnnotationType=\u6CE8\u91CA\u7C7B\u578B @@ -105,18 +103,13 @@ doclet.errors=\u9519\u8BEF doclet.Exception=\u5F02\u5E38\u9519\u8BEF doclet.exception=\u5F02\u5E38\u9519\u8BEF doclet.exceptions=\u5F02\u5E38\u9519\u8BEF -doclet.extended_by=\u6269\u5C55\u8005 -doclet.extends=\u6269\u5C55 doclet.Package_private=(\u4E13\u7528\u7A0B\u5E8F\u5305) -doclet.implements=implementsdoclet.Same_package_name_used=\u7A0B\u5E8F\u5305\u540D\u79F0\u5F62\u5F0F\u4F7F\u7528\u4E86\u4E24\u6B21: {0} doclet.Nested_Classes_Interfaces_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u5D4C\u5957\u7C7B/\u63A5\u53E3 doclet.Nested_Classes_Interface_Inherited_From_Interface=\u4ECE\u63A5\u53E3\u7EE7\u627F\u7684\u5D4C\u5957\u7C7B/\u63A5\u53E3 doclet.Methods_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u65B9\u6CD5 doclet.Methods_Inherited_From_Interface=\u4ECE\u63A5\u53E3\u7EE7\u627F\u7684\u65B9\u6CD5 doclet.Fields_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u5B57\u6BB5 doclet.Fields_Inherited_From_Interface=\u4ECE\u63A5\u53E3\u7EE7\u627F\u7684\u5B57\u6BB5 -doclet.Serializable=\u53EF\u5E8F\u5217\u5316 -doclet.Externalizable=\u53EF\u5916\u90E8\u5316 doclet.Annotation_Type_Member_Detail=\u5143\u7D20\u8BE6\u7EC6\u8D44\u6599 doclet.Enum_Constant_Detail=\u679A\u4E3E\u5E38\u91CF\u8BE6\u7EC6\u8D44\u6599 doclet.Constants_Summary=\u5E38\u91CF\u5B57\u6BB5\u503C @@ -124,7 +117,6 @@ doclet.Field_Detail=\u5B57\u6BB5\u8BE6\u7EC6\u8D44\u6599 doclet.Method_Detail=\u65B9\u6CD5\u8BE6\u7EC6\u8D44\u6599 doclet.Constructor_Detail=\u6784\u9020\u5668\u8BE6\u7EC6\u8D44\u6599 doclet.Deprecated=\u5DF2\u8FC7\u65F6\u3002 -doclet.Deprecated_class=\u8BE5\u7C7B\u5DF2\u8FC7\u65F6\u3002 doclet.Groupname_already_used=\u5728 -group \u9009\u9879\u4E2D, groupname \u5DF2\u4F7F\u7528: {0} doclet.value_tag_invalid_reference={0} (\u7531 @value \u6807\u8BB0\u5F15\u7528) \u4E3A\u672A\u77E5\u5F15\u7528\u3002 doclet.value_tag_invalid_constant=@value \u6807\u8BB0 (\u5F15\u7528{0}) \u53EA\u80FD\u5728\u5E38\u91CF\u4E2D\u4F7F\u7528\u3002 @@ -167,4 +159,4 @@ doclet.0_and_1={0}\u548C{1} #Documentation for Enums doclet.enum_values_doc=\n\u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u4E9B\u5E38\u91CF\u7684\u6570\u7EC4\u3002\u8BE5\u65B9\u6CD5\u53EF\u7528\u4E8E\u8FED\u4EE3\n\u5E38\u91CF, \u5982\u4E0B\u6240\u793A:\n
    \nfor ({0} c : {0}.values())\n    System.out.println(c);\n
    \n@\u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u4E9B\u5E38\u91CF\u7684\u6570\u7EC4 -doclet.enum_valueof_doc=\n\u8FD4\u56DE\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u3002\n\u5B57\u7B26\u4E32\u5FC5\u987B\u4E0E\u7528\u4E8E\u58F0\u660E\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u7684\n\u6807\u8BC6\u7B26\u5B8C\u5168\u5339\u914D\u3002(\u4E0D\u5141\u8BB8\u6709\u591A\u4F59\n\u7684\u7A7A\u683C\u5B57\u7B26\u3002)\n\n@param name \u8981\u8FD4\u56DE\u7684\u679A\u4E3E\u5E38\u91CF\u7684\u540D\u79F0\u3002\n@return \u8FD4\u56DE\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u679A\u4E3E\u5E38\u91CF\n@throws \u5982\u679C\u8BE5\u679A\u4E3E\u7C7B\u578B\u6CA1\u6709\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u5E38\u91CF, \n\u5219\u629B\u51FA IllegalArgumentException\n@throws \u5982\u679C\u53C2\u6570\u4E3A\u7A7A\u503C, \u5219\u629B\u51FA NullPointerException +doclet.enum_valueof_doc=\n\u8FD4\u56DE\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u3002\n\u5B57\u7B26\u4E32\u5FC5\u987B\u4E0E\u7528\u4E8E\u58F0\u660E\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u7684\n\u6807\u8BC6\u7B26\u5B8C\u5168\u5339\u914D\u3002(\u4E0D\u5141\u8BB8\u6709\u591A\u4F59\n\u7684\u7A7A\u683C\u5B57\u7B26\u3002)\n\n@param name \u8981\u8FD4\u56DE\u7684\u679A\u4E3E\u5E38\u91CF\u7684\u540D\u79F0\u3002\n@\u8FD4\u56DE\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u679A\u4E3E\u5E38\u91CF\n@\u5982\u679C\u8BE5\u679A\u4E3E\u7C7B\u578B\u6CA1\u6709\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u5E38\u91CF, \n\u5219\u629B\u51FA IllegalArgumentException\n@\u5982\u679C\u53C2\u6570\u4E3A\u7A7A\u503C, \u5219\u629B\u51FA NullPointerException diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties index 6f1096aeab2..dc6c03fbe25 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties @@ -65,8 +65,11 @@ compiler.err.abstract.meth.cant.have.body=abstract\u30E1\u30BD\u30C3\u30C9\u304C compiler.err.already.annotated={0} {1}\u306F\u6CE8\u91C8\u304C\u4ED8\u3044\u3066\u3044\u307E\u3059 -# 0: symbol, 1: symbol -compiler.err.already.defined={0}\u306F{1}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 +# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol +compiler.err.already.defined={0} {1}\u306F\u3059\u3067\u306B{2} {3}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 + +# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol kind, 4: symbol +compiler.err.already.defined.in.clinit={0} {1}\u306F\u3059\u3067\u306B{3} {4}\u306E{2}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 # 0: string compiler.err.already.defined.single.import={0}\u306F\u5358\u4E00\u306E\u578B\u30A4\u30F3\u30DD\u30FC\u30C8\u5BA3\u8A00\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 @@ -109,28 +112,84 @@ compiler.err.array.dimension.missing=\u914D\u5217\u306E\u5927\u304D\u3055\u304C\ # 0: type compiler.err.array.req.but.found=\u914D\u5217\u304C\u8981\u6C42\u3055\u308C\u307E\u3057\u305F\u304C\u3001{0}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F -compiler.err.assignment.from.super-bound=\u30EF\u30A4\u30EB\u30C9\u30AB\u30FC\u30C9{0}\u304B\u3089\u4EE3\u5165\u3057\u3066\u3044\u307E\u3059 - -compiler.err.assignment.to.extends-bound=\u30EF\u30A4\u30EB\u30C9\u30AB\u30FC\u30C9{0}\u3078\u4EE3\u5165\u3057\u3066\u3044\u307E\u3059 - compiler.err.attribute.value.must.be.constant=\u5C5E\u6027\u306E\u5024\u306F\u5B9A\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 +# 0: statement type +compiler.err.bad.initializer={0}\u306E\u4E0D\u6B63\u306A\u521D\u671F\u5316\u5B50 + compiler.err.break.outside.switch.loop=break\u304Cswitch\u6587\u307E\u305F\u306F\u30EB\u30FC\u30D7\u306E\u5916\u306B\u3042\u308A\u307E\u3059 # 0: name compiler.err.call.must.be.first.stmt.in.ctor={0}\u306E\u547C\u51FA\u3057\u306F\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u5148\u982D\u6587\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 -compiler.err.cant.apply.symbol={4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3} - # 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment -compiler.err.cant.apply.symbol.1={4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093\u3002\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3}\n\u7406\u7531: {6} +compiler.err.cant.apply.symbol={4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093\u3002\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3}\n\u7406\u7531: {6} # 0: symbol kind, 1: name, 2: list of type compiler.err.cant.apply.symbols={1}\u306B\u9069\u5207\u306A{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093({2}) +# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment +compiler.misc.cant.apply.symbol={4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3}\n\u7406\u7531: {6} + +# 0: symbol kind, 1: name, 2: list of type +compiler.misc.cant.apply.symbols={1}\u306B\u9069\u5207\u306A{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093({2}) + +# 0: symbol kind, 1: symbol +compiler.misc.no.abstracts={0} {1}\u3067\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 + +# 0: symbol kind, 1: symbol +compiler.misc.incompatible.abstracts={0} {1}\u3067\u8907\u6570\u306E\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u306A\u3044\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F + +compiler.err.bad.functional.intf.anno=\u4E88\u671F\u3057\u306A\u3044@FunctionalInterface\u6CE8\u91C8 + +# 0: message segment +compiler.err.bad.functional.intf.anno.1=\u4E88\u671F\u3057\u306A\u3044@FunctionalInterface\u6CE8\u91C8\n{0} + +# 0: symbol +compiler.misc.not.a.functional.intf={0}\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093 + +# 0: symbol, 1: message segment +compiler.misc.not.a.functional.intf.1={0}\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093\n{1} + +# 0: symbol, 1: symbol kind, 2: symbol +compiler.misc.invalid.generic.lambda.target=\u30E9\u30E0\u30C0\u5F0F\u306E\u6A5F\u80FD\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u304C\u7121\u52B9\u3067\u3059\n{1} {2}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u306F\u6C4E\u7528\u3067\u3059 + +# 0: symbol kind, 1: symbol +compiler.misc.incompatible.descs.in.functional.intf={0} {1}\u3067\u4E0D\u9069\u5408\u306A\u6A5F\u80FD\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F + +# 0: name, 1: list of type, 2: type, 3: list of type +compiler.misc.descriptor=\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF: {2} {0}({1}) + +# 0: name, 1: list of type, 2: type, 3: list of type +compiler.misc.descriptor.throws=\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF: {2} {0}({1})\u3067{3}\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3059 + +# 0: type +compiler.misc.no.suitable.functional.intf.inst={0}\u306E\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093 + +# 0: type +compiler.misc.secondary.bound.must.be.marker.intf=\u30BB\u30AB\u30F3\u30C0\u30EA\u30FB\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0{0}\u306F\u30DE\u30FC\u30AB\u30FC\u30FB\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 + +# 0: symbol kind, 1: message segment +compiler.err.invalid.mref={0}\u53C2\u7167\u304C\u7121\u52B9\u3067\u3059\u3002{1} + +# 0: symbol kind, 1: message segment +compiler.misc.invalid.mref={0}\u53C2\u7167\u304C\u7121\u52B9\u3067\u3059\u3002{1} + +compiler.misc.static.mref.with.targs=static\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u5316\u3055\u308C\u305F\u4FEE\u98FE\u5B50 + +compiler.misc.static.bound.mref=static\u306E\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167 + # 0: symbol compiler.err.cant.assign.val.to.final.var=final\u5909\u6570{0}\u306B\u5024\u3092\u4EE3\u5165\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 +# 0: symbol, 1: message segment +compiler.err.cant.ref.non.effectively.final.var={1}\u304B\u3089\u53C2\u7167\u3055\u308C\u308B\u30ED\u30FC\u30AB\u30EB\u5909\u6570\u306F\u3001final\u307E\u305F\u306F\u4E8B\u5B9F\u4E0A\u306Efinal\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 + + +compiler.misc.lambda=\u30E9\u30E0\u30C0\u5F0F + +compiler.misc.inner.cls=\u5185\u90E8\u30AF\u30E9\u30B9 + # 0: type compiler.err.cant.deref={0}\u306F\u9593\u63A5\u53C2\u7167\u3067\u304D\u307E\u305B\u3093 @@ -142,8 +201,6 @@ compiler.err.cant.inherit.from.final=final {0}\u304B\u3089\u306F\u7D99\u627F\u30 # 0: symbol compiler.err.cant.ref.before.ctor.called=\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u547C\u51FA\u3057\u524D\u306F{0}\u3092\u53C2\u7167\u3067\u304D\u307E\u305B\u3093 -compiler.err.cant.ret.val.from.meth.decl.void=\u623B\u308A\u5024\u306E\u578B\u304Cvoid\u306E\u30E1\u30BD\u30C3\u30C9\u304B\u3089\u306F\u5024\u3092\u8FD4\u305B\u307E\u305B\u3093 - compiler.err.cant.select.static.class.from.param.type=\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3055\u308C\u305F\u578B\u304B\u3089static\u30AF\u30E9\u30B9\u3092\u9078\u629E\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 # 0: symbol, 1: string, 2: string @@ -154,6 +211,8 @@ compiler.err.catch.without.try=''catch''\u3078\u306E''try''\u304C\u3042\u308A\u3 # 0: symbol kind, 1: symbol compiler.err.clash.with.pkg.of.same.name={0} {1}\u306F\u540C\u540D\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u3068\u7AF6\u5408\u3057\u307E\u3059 +compiler.err.class.not.allowed=\u30AF\u30E9\u30B9\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u307E\u305F\u306F\u5217\u6319\u578B\u306E\u5BA3\u8A00\u3092\u3053\u3053\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 + compiler.err.const.expr.req=\u5B9A\u6570\u5F0F\u304C\u5FC5\u8981\u3067\u3059 compiler.err.cont.outside.loop=continue\u304C\u30EB\u30FC\u30D7\u306E\u5916\u306B\u3042\u308A\u307E\u3059 @@ -169,10 +228,8 @@ compiler.err.call.to.super.not.allowed.in.enum.ctor=\u5217\u6319\u578B\u30B3\u30 # 0: type compiler.err.no.superclass={0}\u306B\u306F\u30B9\u30FC\u30D1\u30FC\u30AF\u30E9\u30B9\u304C\u3042\u308A\u307E\u305B\u3093 -compiler.err.wrong.target.for.polymorphic.signature.definition=MethodHandle API\u306E\u4F5C\u6210\u306B\u306F-target 7\u30E9\u30F3\u30BF\u30A4\u30E0\u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059\u3002\u73FE\u5728\u306F-target {0}\u3067\u3059 - # 0: symbol, 1: type, 2: symbol, 3: type, 4: unused -compiler.err.concrete.inheritance.conflict={1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u3068{3}\u306E{2}\u306F\u540C\u3058\u30B7\u30B0\u30CB\u30C1\u30E3\u304B\u3089\u7D99\u627F\u3055\u308C\u3066\u3044\u307E\u3059 +compiler.err.concrete.inheritance.conflict={1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u3068{3}\u306E{2}\u306F\u540C\u3058\u30B7\u30B0\u30CD\u30C1\u30E3\u304B\u3089\u7D99\u627F\u3055\u308C\u3066\u3044\u307E\u3059 compiler.err.default.allowed.in.intf.annotation.member=\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u306F@interface\u30E1\u30F3\u30D0\u30FC\u5185\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059 @@ -181,9 +238,48 @@ compiler.err.doesnt.exist=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306F\u5B58\u5728\u3 compiler.err.duplicate.annotation=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059 +# 0: type +compiler.err.duplicate.annotation.invalid.repeated=\u6CE8\u91C8{0}\u3092\u7E70\u308A\u8FD4\u305B\u307E\u305B\u3093\n\u6709\u52B9\u306A\u5305\u542B\u3059\u308B\u6CE8\u91C8\u304C\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 + # 0: name, 1: type compiler.err.duplicate.annotation.member.value={1}\u306E\u6CE8\u91C8\u30E1\u30F3\u30D0\u30FC\u306E\u5024{0}\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059 +# 0: type, 1: type +compiler.err.duplicate.annotation.missing.container=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002{0}\u306E\u5BA3\u8A00\u306B\u306F\u6709\u52B9\u306A{1}\u6CE8\u91C8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 + +# 0: type +compiler.err.invalid.repeatable.annotation=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002{0}\u306F\u7121\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u6CE8\u91C8\u3067\u6CE8\u91C8\u4ED8\u3051\u3055\u308C\u3066\u3044\u307E\u3059 + +# 0: type +compiler.err.invalid.repeatable.annotation.no.value=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002{0}\u306F\u6709\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u306A\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u5024\u8981\u7D20\u30E1\u30BD\u30C3\u30C9\u304C\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u305B\u3093 + +# 0: type, 1: number +compiler.err.invalid.repeatable.annotation.multiple.values=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002{0}\u306F\u6709\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u306A\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002{1}\u5024\u8981\u7D20\u30E1\u30BD\u30C3\u30C9\u304C\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u3059 + +# 0: type +compiler.err.invalid.repeatable.annotation.invalid.value=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002{0}\u306F\u6709\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u306A\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u5024\u8981\u7D20\u304C\u7121\u52B9\u3067\u3059\u3002\u30E1\u30BD\u30C3\u30C9\u304C\u5FC5\u8981\u3067\u3059 + +# 0: type, 1: type, 2: type +compiler.err.invalid.repeatable.annotation.value.return=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059\u3002\u5305\u542B\u3059\u308B\u6CE8\u91C8{0}\u306E\u5024\u8981\u7D20\u306B\u306F\u578B{2}\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002{1}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F + +# 0: type, 1: symbol +compiler.err.invalid.repeatable.annotation.elem.nondefault=\u5305\u542B\u3059\u308B\u6CE8\u91C8{0}\u306B\u306F\u8981\u7D20{1}\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 + +# 0: symbol, 1: type, 2: symbol, 3: type +compiler.err.invalid.repeatable.annotation.retention=\u5305\u542B\u3059\u308B\u6CE8\u91C8{0}\u306B\u306F\u3001\u4FDD\u6709{3}\u3092\u542B\u3080\u5305\u542B\u3055\u308C\u305F\u6CE8\u91C8{2}\u3088\u308A\u77ED\u3044\u4FDD\u6709({1})\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059 + +# 0: symbol, 1: symbol +compiler.err.invalid.repeatable.annotation.not.documented=\u7E70\u308A\u8FD4\u3055\u308C\u305F\u6CE8\u91C8{1}\u306F@Documented\u3067\u3059\u304C\u3001\u5305\u542B\u3059\u308B\u6CE8\u91C8\u30BF\u30A4\u30D7{0}\u306F\u9055\u3044\u307E\u3059 + +# 0: symbol, 1: symbol +compiler.err.invalid.repeatable.annotation.not.inherited=\u308A\u8FD4\u3055\u308C\u305F\u6CE8\u91C8\u30BF\u30A4\u30D7{1}\u306F@Inherited\u3067\u3059\u304C\u3001\u5305\u542B\u3059\u308B\u6CE8\u91C8\u30BF\u30A4\u30D7{0}\u306F\u9055\u3044\u307E\u3059 + +# 0: symbol, 1: symbol +compiler.err.invalid.repeatable.annotation.incompatible.target=\u30B3\u30F3\u30C6\u30CA\u6CE8\u91C8{0}\u306E\u30BF\u30FC\u30B2\u30C3\u30C8\u306F\u3001\u7E70\u308A\u8FD4\u3055\u308C\u305F\u6CE8\u91C8{1}\u306E\u30BF\u30FC\u30B2\u30C3\u30C8\u306E\u30B5\u30D6\u30BB\u30C3\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 + +# 0: symbol +compiler.err.invalid.repeatable.annotation.repeated.and.container.present=\u30B3\u30F3\u30C6\u30CA{0}\u306F\u542B\u307E\u308C\u3066\u3044\u308B\u8981\u7D20\u3068\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093 + # 0: name compiler.err.duplicate.class=\u30AF\u30E9\u30B9{0}\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059 @@ -245,10 +341,10 @@ compiler.err.generic.array.creation=\u6C4E\u7528\u914D\u5217\u3092\u4F5C\u6210\u compiler.err.generic.throwable=\u6C4E\u7528\u30AF\u30E9\u30B9\u306Fjava.lang.Throwable\u3092\u62E1\u5F35\u3067\u304D\u307E\u305B\u3093 # 0: symbol -compiler.err.icls.cant.have.static.decl=\u5185\u90E8\u30AF\u30E9\u30B9{0}\u306E\u9759\u7684\u5BA3\u8A00\u304C\u4E0D\u6B63\u3067\u3059\n\u4FEE\u98FE\u5B50\''static\''\u306F\u5B9A\u6570\u304A\u3088\u3073\u5909\u6570\u306E\u5BA3\u8A00\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059 +compiler.err.icls.cant.have.static.decl=\u5185\u90E8\u30AF\u30E9\u30B9{0}\u306E\u9759\u7684\u5BA3\u8A00\u304C\u4E0D\u6B63\u3067\u3059\n\u4FEE\u98FE\u5B50''static''\u306F\u5B9A\u6570\u304A\u3088\u3073\u5909\u6570\u306E\u5BA3\u8A00\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059 # 0: string -compiler.err.illegal.char=\\{0}\u306F\u4E0D\u6B63\u306A\u6587\u5B57\u3067\u3059 +compiler.err.illegal.char=''{0}''\u306F\u4E0D\u6B63\u306A\u6587\u5B57\u3067\u3059 compiler.err.illegal.char.for.encoding=\u3053\u306E\u6587\u5B57\u306F\u3001\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306B\u30DE\u30C3\u30D7\u3067\u304D\u307E\u305B\u3093 @@ -280,11 +376,15 @@ compiler.err.illegal.nonascii.digit=\u4E0D\u6B63\u306A\u975EASCII\u6570\u5B57\u3 compiler.err.illegal.underscore=\u4E0D\u6B63\u306A\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u3067\u3059 +compiler.err.illegal.dot=\u4E0D\u6B63\u306A''.''\u3067\u3059 + # 0: symbol compiler.err.illegal.qual.not.icls=\u4FEE\u98FE\u5B50\u304C\u4E0D\u6B63\u3067\u3059\u3002{0}\u306F\u5185\u90E8\u30AF\u30E9\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093 compiler.err.illegal.start.of.expr=\u5F0F\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059 +compiler.err.illegal.start.of.stmt=\u6587\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059 + compiler.err.illegal.start.of.type=\u578B\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059 compiler.err.illegal.unicode.esc=Unicode\u30A8\u30B9\u30B1\u30FC\u30D7\u304C\u4E0D\u6B63\u3067\u3059 @@ -302,8 +402,6 @@ compiler.err.incomparable.types=\u578B{0}\u3068{1}\u306F\u6BD4\u8F03\u3067\u304D # 0: number compiler.err.int.number.too.large=\u6574\u6570{0}\u304C\u5927\u304D\u3059\u304E\u307E\u3059 -compiler.err.internal.error.cant.instantiate=\u5185\u90E8\u30A8\u30E9\u30FC\u3067\u3059\u3002{0}\u3092{1}\u3067({2})\u306B\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u751F\u6210\u3067\u304D\u307E\u305B\u3093 - compiler.err.intf.annotation.members.cant.have.params=@interface\u30E1\u30F3\u30D0\u30FC\u304C\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 compiler.err.intf.annotation.cant.have.type.params=@interface\u304C\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 @@ -315,7 +413,7 @@ compiler.err.intf.annotation.member.clash=@interface\u30E1\u30F3\u30D0\u30FC\u30 compiler.err.intf.expected.here=\u3053\u3053\u306B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304C\u5FC5\u8981\u3067\u3059 -compiler.err.intf.meth.cant.have.body=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 +compiler.err.intf.meth.cant.have.body=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 compiler.err.invalid.annotation.member.type=\u6CE8\u91C8\u30E1\u30F3\u30D0\u30FC\u306E\u578B\u304C\u4E0D\u6B63\u3067\u3059 @@ -327,6 +425,8 @@ compiler.err.invalid.meth.decl.ret.type.req=\u7121\u52B9\u306A\u30E1\u30BD\u30C3 compiler.err.varargs.and.old.array.syntax=\u65E7\u5F0F\u306E\u914D\u5217\u8868\u8A18\u6CD5\u306F\u53EF\u5909\u5F15\u6570\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 +compiler.err.variable.not.allowed=\u5909\u6570\u306E\u5BA3\u8A00\u3092\u3053\u3053\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 + # 0: name compiler.err.label.already.in.use=\u30E9\u30D9\u30EB{0}\u306F\u3059\u3067\u306B\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059 @@ -337,6 +437,8 @@ compiler.err.local.enum=\u5217\u6319\u578B\u306F\u30ED\u30FC\u30AB\u30EB\u306B\u compiler.err.cannot.create.array.with.type.arguments=\u578B\u5F15\u6570\u3092\u6301\u3064\u914D\u5217\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093 +compiler.err.cannot.create.array.with.diamond=''<>''\u3092\u6301\u3064\u914D\u5217\u306F\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093 + # # limits. We don't give the limits in the diagnostic because we expect # them to change, yet we want to use the same diagnostic. These are all @@ -360,7 +462,7 @@ compiler.err.limit.stack=\u30B3\u30FC\u30C9\u304C\u8981\u6C42\u3059\u308B\u30B9\ compiler.err.limit.string=\u5B9A\u6570\u6587\u5B57\u5217\u304C\u9577\u3059\u304E\u307E\u3059 -compiler.err.limit.string.overflow=\u6587\u5B57\u5217\"{0}...\"\u306EUTF8\u8868\u73FE\u304C\u3001\u5B9A\u6570\u30D7\u30FC\u30EB\u306B\u5BFE\u3057\u3066\u9577\u3059\u304E\u307E\u3059 +compiler.err.limit.string.overflow=\u6587\u5B57\u5217"{0}..."\u306EUTF8\u8868\u73FE\u304C\u3001\u5B9A\u6570\u30D7\u30FC\u30EB\u306B\u5BFE\u3057\u3066\u9577\u3059\u304E\u307E\u3059 compiler.err.malformed.fp.lit=\u6D6E\u52D5\u5C0F\u6570\u70B9\u30EA\u30C6\u30E9\u30EB\u304C\u4E0D\u6B63\u3067\u3059 @@ -370,7 +472,9 @@ compiler.err.missing.meth.body.or.decl.abstract=\u30E1\u30BD\u30C3\u30C9\u672C\u compiler.err.missing.ret.stmt=return\u6587\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -compiler.err.missing.ret.val=\u623B\u308A\u5024\u304C\u3042\u308A\u307E\u305B\u3093 +compiler.misc.missing.ret.val=\u623B\u308A\u5024\u304C\u3042\u308A\u307E\u305B\u3093 + +compiler.misc.unexpected.ret.val=\u4E88\u671F\u3057\u306A\u3044\u623B\u308A\u5024 # 0: set of modifier compiler.err.mod.not.allowed.here=\u4FEE\u98FE\u5B50{0}\u3092\u3053\u3053\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 @@ -396,7 +500,26 @@ compiler.err.name.reserved.for.internal.use={0}\u306F\u5185\u90E8\u3067\u306E\u4 compiler.err.native.meth.cant.have.body=native\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 # 0: type, 1: type -compiler.err.neither.conditional.subtype=?\u306B\u5BFE\u3059\u308B\u4E92\u63DB\u6027\u306E\u306A\u3044\u578B : \u3069\u3061\u3089\u3082\u4ED6\u65B9\u306E\u30B5\u30D6\u30BF\u30A4\u30D7\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\n2\u756A\u76EE\u306E\u30AA\u30DA\u30E9\u30F3\u30C9 : {0}\n3\u756A\u76EE\u306E\u30AA\u30DA\u30E9\u30F3\u30C9 : {1} +compiler.err.neither.conditional.subtype=?\u306B\u5BFE\u3059\u308B\u4E0D\u9069\u5408\u306A\u578B : \u3069\u3061\u3089\u3082\u4ED6\u65B9\u306E\u30B5\u30D6\u30BF\u30A4\u30D7\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\n2\u756A\u76EE\u306E\u30AA\u30DA\u30E9\u30F3\u30C9 : {0}\n3\u756A\u76EE\u306E\u30AA\u30DA\u30E9\u30F3\u30C9 : {1} + +# 0: message segment +compiler.misc.incompatible.type.in.conditional=\u6761\u4EF6\u5F0F\u306E\u578B\u304C\u4E0D\u6B63\u3067\u3059\u3002{0} + +compiler.misc.conditional.target.cant.be.void=\u6761\u4EF6\u5F0F\u306E\u30BF\u30FC\u30B2\u30C3\u30C8\u578B\u306Fvoid\u306B\u3067\u304D\u307E\u305B\u3093 + +# 0: type +compiler.misc.incompatible.ret.type.in.lambda=\u30E9\u30E0\u30C0\u5F0F\u306E\u623B\u308A\u578B\u304C\u4E0D\u6B63\u3067\u3059\n{0} + +# 0: type +compiler.misc.incompatible.ret.type.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u623B\u308A\u578B\u304C\u4E0D\u6B63\u3067\u3059\n{0} + +# 0: list of type +compiler.err.incompatible.thrown.types.in.lambda=\u30E9\u30E0\u30C0\u5F0F\u3067\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u4E0D\u9069\u5408\u3067\u3059 + +# 0: list of type +compiler.err.incompatible.thrown.types.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u4E0D\u9069\u5408\u3067\u3059 + +compiler.misc.incompatible.arg.types.in.lambda=\u30E9\u30E0\u30C0\u5F0F\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u578B\u306F\u4E0D\u9069\u5408\u3067\u3059 compiler.err.new.not.allowed.in.annotation=''new''\u306F\u6CE8\u91C8\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 @@ -413,6 +536,12 @@ compiler.err.not.annotation.type={0}\u306F\u6CE8\u91C8\u578B\u3067\u306F\u3042\u # 0: symbol, 1: symbol compiler.err.not.def.access.class.intf.cant.access={1}\u306E{0}\u304C\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u306A\u3044\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 +# 0: symbol, 1: symbol +compiler.misc.not.def.access.class.intf.cant.access={1}\u306E{0}\u304C\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u306A\u3044\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059 + +# 0: symbol, 1: list of type, 2: type +compiler.misc.cant.access.inner.cls.constr=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF{0}({1})\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n\u5185\u90E8\u30AF\u30E9\u30B9\u3092\u56F2\u3080\u578B{2}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u3042\u308A\u307E\u305B\u3093 + # 0: symbol, 1: symbol compiler.err.not.def.public.cant.access={1}\u306E{0}\u306Fpublic\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u30D1\u30C3\u30B1\u30FC\u30B8\u5916\u304B\u3089\u306F\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093 @@ -440,7 +569,7 @@ compiler.err.warnings.and.werror=\u8B66\u544A\u304C\u898B\u3064\u304B\u308A-Werr # Errors related to annotation processing # 0: symbol, 1: string, 2: stack-trace -compiler.err.proc.cant.access={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1}\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n{2} +compiler.err.proc.cant.access={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1}\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n{2} # 0: symbol, 1: string compiler.err.proc.cant.access.1={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1} @@ -455,15 +584,13 @@ compiler.err.proc.messager={0} # 0: list of string compiler.err.proc.no.explicit.annotation.processing.requested=\u30AF\u30E9\u30B9\u540D''{0}''\u304C\u53D7\u3051\u5165\u308C\u3089\u308C\u308B\u306E\u306F\u3001\u6CE8\u91C8\u51E6\u7406\u304C\u660E\u793A\u7684\u306B\u30EA\u30AF\u30A8\u30B9\u30C8\u3055\u308C\u305F\u5834\u5408\u306E\u307F\u3067\u3059 -compiler.err.proc.no.service=\u30B5\u30FC\u30D3\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u30FB\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\njava.util.ServiceLoader\u304Bsun.misc.Service\u304C\u4F7F\u7528\u3067\u304D\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002 +compiler.err.proc.no.service=\u30B5\u30FC\u30D3\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u304C\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u304C\u3001\u6CE8\u91C8\u51E6\u7406\u306B\u5FC5\u8981\u3067\u3059\u3002 compiler.err.proc.processor.bad.option.name=\u30D7\u30ED\u30BB\u30C3\u30B5''{1}''\u306B\u3088\u3063\u3066\u6307\u5B9A\u3055\u308C\u305F\u30AA\u30D7\u30B7\u30E7\u30F3\u540D''{0}''\u304C\u4E0D\u6B63\u3067\u3059 # 0: string compiler.err.proc.processor.cant.instantiate=\u30D7\u30ED\u30BB\u30C3\u30B5''{0}''\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F -compiler.err.proc.processor.constructor.error=\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u69CB\u7BC9\u4E2D\u306B\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F: {0} - # 0: string compiler.err.proc.processor.not.found=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5''{0}''\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 @@ -482,7 +609,10 @@ compiler.err.qualified.new.of.static.class=static\u30AF\u30E9\u30B9\u306Enew\u30 compiler.err.recursive.ctor.invocation=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u547C\u51FA\u3057\u304C\u518D\u5E30\u7684\u3067\u3059 # 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol -compiler.err.ref.ambiguous={0}\u306E\u53C2\u7167\u306F\u3042\u3044\u307E\u3044\u3067\u3059\u3002{3}\u306E{1} {2}\u3068{6}\u306E{4} {5}\u304C\u4E21\u65B9\u9069\u5408\u3057\u307E\u3059 +compiler.err.ref.ambiguous={0}\u306E\u53C2\u7167\u306F\u3042\u3044\u307E\u3044\u3067\u3059\n{3}\u306E{1} {2}\u3068{6}\u306E{4} {5}\u306E\u4E21\u65B9\u304C\u4E00\u81F4\u3057\u307E\u3059 + +# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol +compiler.misc.ref.ambiguous={0}\u306E\u53C2\u7167\u306F\u3042\u3044\u307E\u3044\u3067\u3059\n{3}\u306E{1} {2}\u3068{6}\u306E{4} {5}\u306E\u4E21\u65B9\u304C\u4E00\u81F4\u3057\u307E\u3059 compiler.err.repeated.annotation.target=\u6CE8\u91C8\u30BF\u30FC\u30B2\u30C3\u30C8\u304C\u7E70\u308A\u8FD4\u3055\u308C\u3066\u3044\u307E\u3059 @@ -495,9 +625,9 @@ compiler.err.report.access={0}\u306F{2}\u3067{1}\u30A2\u30AF\u30BB\u30B9\u3055\u compiler.err.ret.outside.meth=\u30E1\u30BD\u30C3\u30C9\u306E\u5916\u306Ereturn\u6587\u3067\u3059 -compiler.err.signature.doesnt.match.supertype=\u30B7\u30B0\u30CB\u30C1\u30E3\u304C{0}\u306B\u9069\u5408\u3057\u307E\u305B\u3093\u3002\u4E92\u63DB\u6027\u306E\u306A\u3044\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7\u3067\u3059 +compiler.err.signature.doesnt.match.supertype=\u30B7\u30B0\u30CD\u30C1\u30E3\u304C{0}\u306B\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u4E0D\u9069\u5408\u306A\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7\u3067\u3059 -compiler.err.signature.doesnt.match.intf=\u30B7\u30B0\u30CB\u30C1\u30E3\u304C{0}\u306B\u9069\u5408\u3057\u307E\u305B\u3093\u3002\u4E92\u63DB\u6027\u306E\u306A\u3044\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3059 +compiler.err.signature.doesnt.match.intf=\u30B7\u30B0\u30CD\u30C1\u30E3\u304C{0}\u306B\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u4E0D\u9069\u5408\u306A\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3059 # 0: symbol, 1: symbol, 2: symbol compiler.err.does.not.override.abstract={0}\u306Fabstract\u3067\u306A\u304F\u3001{2}\u5185\u306Eabstract\u30E1\u30BD\u30C3\u30C9{1}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u305B\u3093 @@ -534,7 +664,28 @@ compiler.err.type.var.more.than.once=\u578B\u5909\u6570{0}\u306F{1}\u306E\u623B\ compiler.err.type.var.more.than.once.in.result=\u578B\u5909\u6570{0}\u306F{1}\u306E\u578B\u30672\u56DE\u4EE5\u4E0A\u51FA\u73FE\u3057\u307E\u3059\u3002\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u751F\u6210\u3055\u308C\u306A\u3044\u307E\u307E\u306B\u306F\u3067\u304D\u307E\u305B\u3093 # 0: type, 1: type, 2: string -compiler.err.types.incompatible.diff.ret=\u578B{0}\u3068\u578B{1}\u306E\u4E92\u63DB\u6027\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u4E21\u65B9\u3068\u3082{2}\u3092\u5B9A\u7FA9\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u623B\u308A\u5024\u306E\u578B\u304C\u7121\u95A2\u4FC2\u3067\u3059 +compiler.err.types.incompatible.diff.ret=\u578B{0}\u3068\u578B{1}\u304C\u9069\u5408\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u4E21\u65B9\u3068\u3082{2}\u3092\u5B9A\u7FA9\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u623B\u308A\u5024\u306E\u578B\u304C\u7121\u95A2\u4FC2\u3067\u3059 + +# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol +compiler.err.types.incompatible.unrelated.defaults={0} {1}\u306F\u578B{4}\u3068{5}\u304B\u3089{2}({3})\u306E\u95A2\u9023\u3057\u306A\u3044\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u7D99\u627F\u3057\u307E\u3059 + +# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol +compiler.err.types.incompatible.abstract.default={0} {1}\u306F\u578B{4}\u3068{5}\u304B\u3089{2}({3})\u306E\u62BD\u8C61\u3068\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u7D99\u627F\u3057\u307E\u3059 + +# 0: name, 1: kind, 2: symbol +compiler.err.default.overrides.object.member={1} {2}\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9{0}\u306Fjava.lang.Object\u306E\u30E1\u30F3\u30D0\u30FC\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059 + +# 0: type +compiler.err.illegal.static.intf.meth.call=static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u30FB\u30B3\u30FC\u30EB\u304C\u4E0D\u6B63\u3067\u3059\n\u53D7\u4FE1\u5F0F\u306F\u578B\u4FEE\u98FE\u5B50''{0}''\u3067\u7F6E\u63DB\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 + +# 0: type, 1: message segment +compiler.err.illegal.default.super.call=\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30B9\u30FC\u30D1\u30FC\u30FB\u30B3\u30FC\u30EB\u306E\u578B\u4FEE\u98FE\u5B50{0}\u304C\u4E0D\u6B63\u3067\u3059\n{1} + +# 0: symbol, 1: type +compiler.misc.overridden.default={1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u307E\u3059 + +# 0: symbol, 1: symbol +compiler.misc.redundant.supertype=\u5197\u9577\u306A\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9{0}\u306F{1}\u306B\u3088\u3063\u3066\u62E1\u5F35\u3055\u308C\u307E\u3057\u305F compiler.err.unclosed.char.lit=\u6587\u5B57\u30EA\u30C6\u30E9\u30EB\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093 @@ -550,19 +701,14 @@ compiler.err.io.exception=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E # 0: name compiler.err.undef.label=\u30E9\u30D9\u30EB{0}\u306F\u672A\u5B9A\u7FA9\u3067\u3059 -compiler.err.undetermined.type={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u5B9A\u3067\u304D\u307E\u305B\u3093 - -# 0: type, 1: message segment -compiler.err.undetermined.type.1={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002\n\u7406\u7531: {1} - -# 0: list of type, 1: message segment -compiler.err.invalid.inferred.types={0}\u306E\u63A8\u5B9A\u578B\u304C\u7121\u52B9\u3067\u3059\u3002{1} - # 0: message segment, 1: unused -compiler.err.cant.apply.diamond={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u5B9A\u3067\u304D\u307E\u305B\u3093 +compiler.err.cant.apply.diamond={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093 -# 0: message segment, 1: message segment -compiler.err.cant.apply.diamond.1={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002\n\u7406\u7531: {1} +# 0: message segment or type, 1: message segment +compiler.err.cant.apply.diamond.1={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n\u7406\u7531: {1} + +# 0: message segment or type, 1: message segment +compiler.misc.cant.apply.diamond.1={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n\u7406\u7531: {1} compiler.err.unreachable.stmt=\u3053\u306E\u6587\u306B\u5236\u5FA1\u304C\u79FB\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093 @@ -605,7 +751,7 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\u30E1\u30BD\u30C3\u30C9{0}\u3 # 0: symbol compiler.misc.varargs.trustme.on.virtual.varargs=\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9{0}\u306Ffinal\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 -# 0: type, 1: kind, 2: symbol +# 0: type, 1: symbol kind, 2: symbol compiler.misc.inaccessible.varargs.type=\u4EEE\u53EF\u5909\u5F15\u6570\u8981\u7D20\u578B{0}\u306F{1} {2}\u304B\u3089\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093 # In the following string, {1} will always be the detail message from @@ -620,7 +766,7 @@ compiler.err.class.public.should.be.in.file=\u30AF\u30E9\u30B9{0}\u306Fpublic\u3 ## All errors which do not refer to a particular line in the source code are ## preceded by this string. -compiler.err.error=\u30A8\u30E9\u30FC:\u0020 +compiler.err.error=\u30A8\u30E9\u30FC: # The following error messages do not refer to a line in the source code. compiler.err.cant.read.file={0}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093 @@ -637,7 +783,7 @@ compiler.misc.fatal.err.cant.locate.field=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: compiler.misc.fatal.err.cant.locate.ctor=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: {0}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u3092\u691C\u51FA\u3067\u304D\u307E\u305B\u3093 -compiler.misc.fatal.err.cant.close.loader=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: \u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306E\u30AF\u30E9\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u3092\u9589\u3058\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093 +compiler.misc.fatal.err.cant.close=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: \u30B3\u30F3\u30D1\u30A4\u30E9\u30FB\u30EA\u30BD\u30FC\u30B9\u3092\u9589\u3058\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093 ##### @@ -659,21 +805,24 @@ compiler.misc.x.print.rounds=\u5F80\u5FA9{0}:\n\t\u5165\u529B\u30D5\u30A1\u30A4\ ## The following string will appear before all messages keyed as: ## "compiler.note". + +compiler.note.potential.lambda.found=\u3053\u306E\u533F\u540D\u5185\u90E8\u30AF\u30E9\u30B9\u3092\u30E9\u30E0\u30C0\u5F0F\u306B\u5909\u63DB\u3067\u304D\u307E\u3059\u3002 + compiler.note.note=\u6CE8\u610F: # 0: file name -compiler.note.deprecated.filename={0}\u306F\u63A8\u5968\u3055\u308C\u306A\u3044API\u3092\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002 +compiler.note.deprecated.filename={0}\u306F\u975E\u63A8\u5968\u306EAPI\u3092\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002 -compiler.note.deprecated.plural=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u63A8\u5968\u3055\u308C\u306A\u3044API\u3092\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002 +compiler.note.deprecated.plural=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u975E\u63A8\u5968\u306EAPI\u3092\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002 # The following string may appear after one of the above deprecation # messages. compiler.note.deprecated.recompile=\u8A73\u7D30\u306F\u3001-Xlint:deprecation\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3057\u3066\u518D\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044\u3002 # 0: file name -compiler.note.deprecated.filename.additional={0}\u306B\u63A8\u5968\u3055\u308C\u306A\u3044API\u306E\u8FFD\u52A0\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u304C\u3042\u308A\u307E\u3059\u3002 +compiler.note.deprecated.filename.additional={0}\u306B\u975E\u63A8\u5968\u306EAPI\u306E\u8FFD\u52A0\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u304C\u3042\u308A\u307E\u3059\u3002 -compiler.note.deprecated.plural.additional=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u63A8\u5968\u3055\u308C\u306A\u3044API\u3092\u8FFD\u52A0\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002 +compiler.note.deprecated.plural.additional=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u975E\u63A8\u5968\u306EAPI\u3092\u8FFD\u52A0\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002 # 0: file name compiler.note.unchecked.filename={0}\u306E\u64CD\u4F5C\u306F\u3001\u672A\u30C1\u30A7\u30C3\u30AF\u307E\u305F\u306F\u5B89\u5168\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 @@ -773,12 +922,12 @@ compiler.misc.resume.abort=R)\u518D\u958B,A)\u4E2D\u6B62> ## ## All warning messages are preceded by the following string. -compiler.warn.warning=\u8B66\u544A: +compiler.warn.warning=\u8B66\u544A: ## Warning messages may also include the following prefix to identify a ## lint option # 0: option name -compiler.warn.lintOption=[{0}]\u0020 +compiler.warn.lintOption=[{0}] # 0: symbol compiler.warn.constant.SVUID=serialVersionUID\u306F\u30AF\u30E9\u30B9{0}\u306E\u5B9A\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 @@ -789,7 +938,7 @@ compiler.warn.dir.path.element.not.found=\u4E0D\u6B63\u306A\u30D1\u30B9\u8981\u7 compiler.warn.finally.cannot.complete=finally\u7BC0\u304C\u6B63\u5E38\u306B\u5B8C\u4E86\u3067\u304D\u307E\u305B\u3093 # 0: symbol, 1: symbol -compiler.warn.has.been.deprecated={1}\u306E{0}\u306F\u63A8\u5968\u3055\u308C\u307E\u305B\u3093 +compiler.warn.has.been.deprecated={1}\u306E{0}\u306F\u975E\u63A8\u5968\u306B\u306A\u308A\u307E\u3057\u305F # 0: symbol compiler.warn.sun.proprietary={0}\u306F\u5185\u90E8\u6240\u6709\u306EAPI\u3067\u3042\u308A\u3001\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059 @@ -925,7 +1074,7 @@ compiler.warn.unchecked.varargs.non.reifiable.type=\u30D1\u30E9\u30E1\u30FC\u30B # 0: symbol compiler.warn.varargs.unsafe.use.varargs.param=\u53EF\u5909\u5F15\u6570\u30E1\u30BD\u30C3\u30C9\u306F\u3001\u578B\u60C5\u5831\u4FDD\u6301\u53EF\u80FD\u3067\u306A\u3044\u53EF\u5909\u5F15\u6570\u30D1\u30E9\u30E1\u30FC\u30BF{0}\u304B\u3089\u306E\u30D2\u30FC\u30D7\u6C5A\u67D3\u306E\u539F\u56E0\u3068\u306A\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059 -compiler.warn.missing.deprecated.annotation=\u63A8\u5968\u3055\u308C\u306A\u3044\u9805\u76EE\u306F@Deprecated\u3067\u6CE8\u91C8\u304C\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093 +compiler.warn.missing.deprecated.annotation=\u975E\u63A8\u5968\u306E\u9805\u76EE\u306F@Deprecated\u3067\u6CE8\u91C8\u304C\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093 compiler.warn.invalid.archive.file=\u30D1\u30B9\u4E0A\u306E\u4E88\u671F\u3057\u306A\u3044\u30D5\u30A1\u30A4\u30EB: {0} @@ -952,7 +1101,7 @@ compiler.warn.raw.class.use=raw\u578B\u304C\u898B\u3064\u304B\u308A\u307E\u3057\ compiler.warn.diamond.redundant.args=\u65B0\u3057\u3044\u5F0F\u306E\u578B\u5F15\u6570\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059(\u304B\u308F\u308A\u306B\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u3092\u4F7F\u7528\u3057\u307E\u3059)\u3002 # 0: type, 1: type -compiler.warn.diamond.redundant.args.1=\u65B0\u3057\u3044\u5F0F\u306E\u578B\u5F15\u6570\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059(\u304B\u308F\u308A\u306B\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u3092\u4F7F\u7528\u3057\u307E\u3059)\u3002\n\u660E\u793A\u7684: {0}\n\u63A8\u5B9A: {1} +compiler.warn.diamond.redundant.args.1=\u65B0\u3057\u3044\u5F0F\u306E\u578B\u5F15\u6570\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059(\u304B\u308F\u308A\u306B\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u3092\u4F7F\u7528\u3057\u307E\u3059)\u3002\n\u660E\u793A\u7684: {0}\n\u63A8\u8AD6: {1} # 0: symbol, 1: message segment compiler.warn.varargs.redundant.trustme.anno={0}\u6CE8\u91C8\u304C\u5197\u9577\u3067\u3059\u3002{1} @@ -1030,7 +1179,7 @@ compiler.misc.bad.source.file.header=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\ ## The following are all possible strings for the second argument ({1}) of the ## above strings. -compiler.misc.bad.class.signature=\u30AF\u30E9\u30B9{0}\u306E\u30B7\u30B0\u30CB\u30C1\u30E3\u304C\u4E0D\u6B63\u3067\u3059 +compiler.misc.bad.class.signature=\u30AF\u30E9\u30B9{0}\u306E\u30B7\u30B0\u30CD\u30C1\u30E3\u304C\u4E0D\u6B63\u3067\u3059 #0: symbol, 1: symbol compiler.misc.bad.enclosing.class={0}\u306E\u5185\u90E8\u30AF\u30E9\u30B9\u304C\u4E0D\u6B63\u3067\u3059: {1} @@ -1044,7 +1193,9 @@ compiler.misc.bad.const.pool.tag=\u5B9A\u6570\u30D7\u30FC\u30EB\u30FB\u30BF\u30B compiler.misc.bad.const.pool.tag.at=\u5B9A\u6570\u30D7\u30FC\u30EB\u30FB\u30BF\u30B0{1}\u3067\u306E{0}\u304C\u4E0D\u6B63\u3067\u3059 -compiler.misc.bad.signature=\u30B7\u30B0\u30CB\u30C1\u30E3{0}\u304C\u4E0D\u6B63\u3067\u3059 +compiler.misc.bad.signature=\u30B7\u30B0\u30CD\u30C1\u30E3{0}\u304C\u4E0D\u6B63\u3067\u3059 + +compiler.misc.bad.type.annotation.value=\u6CE8\u91C8\u30BF\u30FC\u30B2\u30C3\u30C8\u578B\u306E\u5024\u306E\u578B\u304C\u4E0D\u6B63\u3067\u3059: {0} compiler.misc.class.file.wrong.class=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306B\u4E0D\u6B63\u306A\u30AF\u30E9\u30B9\u304C\u3042\u308A\u307E\u3059 @@ -1077,24 +1228,17 @@ compiler.err.not.within.bounds=\u578B\u5F15\u6570{0}\u306F\u578B\u5909\u6570{1}\ ##### -# 0: message segment, 1: type, 2: type -compiler.err.prob.found.req={0}\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {1} +# 0: message segment +compiler.err.prob.found.req=\u4E0D\u9069\u5408\u306A\u578B: {0} # 0: message segment, 1: type, 2: type compiler.warn.prob.found.req={0}\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {1} -compiler.err.prob.found.req.1={0} {3}\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {1} +# 0: type, 1: type +compiler.misc.inconvertible.types={0}\u3092{1}\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093: -## The following are all possible strings for the first argument ({0}) of the -## above strings. -compiler.misc.incompatible.types=\u4E92\u63DB\u6027\u306E\u306A\u3044\u578B - -# 0: message segment -compiler.misc.incompatible.types.1=\u4E92\u63DB\u6027\u306E\u306A\u3044\u578B\u3002{0} - -compiler.misc.inconvertible.types=\u5909\u63DB\u3067\u304D\u306A\u3044\u578B - -compiler.misc.possible.loss.of.precision=\u7CBE\u5EA6\u304C\u4F4E\u4E0B\u3057\u3066\u3044\u308B\u53EF\u80FD\u6027 +# 0: type, 1: type +compiler.misc.possible.loss.of.precision=\u7CBE\u5EA6\u304C\u5931\u308F\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B{0}\u304B\u3089{1}\u3078\u306E\u5909\u63DB compiler.misc.unchecked.assign=\u7121\u691C\u67FB\u5909\u63DB @@ -1104,16 +1248,13 @@ compiler.misc.unchecked.assign=\u7121\u691C\u67FB\u5909\u63DB # assigned array cannot dynamically check its stores compiler.misc.unchecked.cast.to.type=\u7121\u691C\u67FB\u30AD\u30E3\u30B9\u30C8 -compiler.misc.assignment.from.super-bound=\u30B9\u30FC\u30D1\u30FC\u30D0\u30A6\u30F3\u30C9\u578B{0}\u304B\u3089\u306E\u4EE3\u5165 - -compiler.misc.assignment.to.extends-bound=\u62E1\u5F35\u30D0\u30A6\u30F3\u30C9\u578B{0}\u3078\u306E\u4EE3\u5165 - # compiler.err.star.expected=\ # ''*'' expected # compiler.err.no.elem.type=\ # \[\*\] cannot have a type -compiler.misc.try.not.applicable.to.type=try-with-resource\u306F\u5909\u6570\u578B\u306B\u9069\u7528\u3055\u308C\u307E\u305B\u3093 +# 0: type +compiler.misc.try.not.applicable.to.type=try-with-resource\u306F\u5909\u6570\u578B\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\n({0}) ##### @@ -1139,25 +1280,44 @@ compiler.misc.type.parameter=\u578B\u30D1\u30E9\u30E1\u30FC\u30BF{0} ## The following are all possible strings for the last argument of all those ## diagnostics whose key ends in ".1" -compiler.misc.undetermined.type=\u672A\u5B9A\u578B - -compiler.misc.type.variable.has.undetermined.type=\u578B\u5909\u6570{0}\u306F\u672A\u5B9A\u578B\u3067\u3059 # 0: type, 1: list of type compiler.misc.no.unique.maximal.instance.exists=\u578B\u5909\u6570{0}(\u4E0A\u9650{1})\u306E\u56FA\u6709\u306E\u6700\u5927\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u307E\u305B\u3093 compiler.misc.no.unique.minimal.instance.exists=\u578B\u5909\u6570{0}(\u4E0B\u9650{1})\u306E\u56FA\u6709\u306E\u6700\u5C0F\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u307E\u305B\u3093 +# 0: type, 1: list of type +compiler.misc.incompatible.upper.bounds=\u63A8\u8AD6\u5909\u6570{0}\u306B\u306F\u3001\u4E0D\u9069\u5408\u306A\u4E0A\u9650{1}\u304C\u3042\u308A\u307E\u3059 + +# 0: type, 1: list of type, 2: list of type +compiler.misc.incompatible.eq.upper.bounds=\u63A8\u8AD6\u5909\u6570{0}\u306B\u306F\u3001\u4E0D\u9069\u5408\u306A\u5883\u754C\u304C\u3042\u308A\u307E\u3059\n\u7B49\u4FA1\u5236\u7D04: {1}\n\u4E0A\u9650: {2} + +# 0: type, 1: list of type, 2: list of type +compiler.misc.incompatible.eq.lower.bounds=\u63A8\u8AD6\u5909\u6570{0}\u306B\u306F\u3001\u4E0D\u9069\u5408\u306A\u5883\u754C\u304C\u3042\u308A\u307E\u3059\n\u7B49\u4FA1\u5236\u7D04: {1}\n\u4E0B\u9650: {2} + # 0: list of type, 1: type, 2: type compiler.misc.infer.no.conforming.instance.exists=\u578B\u5909\u6570{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u306A\u3044\u306E\u3067\u3001{1}\u306F{2}\u306B\u9069\u5408\u3057\u307E\u305B\u3093 -# 0: list of type, 1: type, 2: type -compiler.misc.infer.no.conforming.assignment.exists=\u578B\u5909\u6570{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u306A\u3044\u306E\u3067\u3001\u5F15\u6570\u578B{1}\u306F\u4EEE\u30D1\u30E9\u30E1\u30FC\u30BF\u578B{2}\u306B\u9069\u5408\u3057\u307E\u305B\u3093 +# 0: list of type, 1: message segment +compiler.misc.infer.no.conforming.assignment.exists=\u578B\u5909\u6570{0}\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n(\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {1}) -compiler.misc.infer.arg.length.mismatch=\u5B9F\u5F15\u6570\u30EA\u30B9\u30C8\u3068\u4EEE\u5F15\u6570\u30EA\u30B9\u30C8\u306E\u9577\u3055\u304C\u7570\u306A\u308B\u305F\u3081\u3001\u5F15\u6570\u304B\u3089\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093 +# 0: list of type +compiler.misc.infer.arg.length.mismatch=\u578B\u5909\u6570{0}\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n(\u5B9F\u5F15\u6570\u30EA\u30B9\u30C8\u3068\u4EEE\u5F15\u6570\u30EA\u30B9\u30C8\u306E\u9577\u3055\u304C\u7570\u306A\u308A\u307E\u3059) + +# 0: list of type, 1: message segment +compiler.misc.infer.varargs.argument.mismatch=\u578B\u5909\u6570{0}\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n(\u53EF\u5909\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {1}) # 0: type, 1: list of type -compiler.misc.inferred.do.not.conform.to.bounds=\u63A8\u5B9A\u578B\u306F\u5BA3\u8A00\u3055\u308C\u305F\u5883\u754C\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u5B9A: {0}\n\u5883\u754C: {1} +compiler.misc.inferred.do.not.conform.to.upper.bounds=\u63A8\u8AD6\u578B\u304C\u4E0A\u9650\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u8AD6: {0}\n\u4E0A\u9650: {1} + +# 0: type, 1: list of type +compiler.misc.inferred.do.not.conform.to.lower.bounds=\u63A8\u8AD6\u578B\u304C\u4E0B\u9650\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u8AD6: {0}\n\u4E0B\u9650: {1} + +# 0: type, 1: list of type +compiler.misc.inferred.do.not.conform.to.eq.bounds=\u63A8\u8AD6\u578B\u304C\u7B49\u4FA1\u5236\u7D04\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u8AD6: {0}\n\u7B49\u4FA1\u5236\u7D04: {1} + +# 0: list of type +compiler.misc.cyclic.inference=\u63A8\u8AD6\u306E\u30EB\u30FC\u30D7\u306E\u305F\u3081\u3001\u63A8\u8AD6\u5909\u6570{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u751F\u6210\u3067\u304D\u307E\u305B\u3093 # 0: symbol compiler.misc.diamond={0}<> @@ -1165,6 +1325,7 @@ compiler.misc.diamond={0}<> # 0: type compiler.misc.diamond.non.generic=\u975E\u6C4E\u7528\u30AF\u30E9\u30B9{0}\u3067''<>''\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 +# 0: unused compiler.misc.diamond.and.explicit.params=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u660E\u793A\u7684\u306A\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u306F''<>''\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 # 0: type, 1: list of type @@ -1172,14 +1333,18 @@ compiler.misc.explicit.param.do.not.conform.to.bounds=\u660E\u793A\u7684\u306A\u compiler.misc.arg.length.mismatch=\u5B9F\u5F15\u6570\u30EA\u30B9\u30C8\u3068\u4EEE\u5F15\u6570\u30EA\u30B9\u30C8\u306E\u9577\u3055\u304C\u7570\u306A\u308A\u307E\u3059 -# 0: type, 1: type -compiler.misc.no.conforming.assignment.exists=\u5B9F\u5F15\u6570{0}\u306F\u30E1\u30BD\u30C3\u30C9\u547C\u51FA\u5909\u63DB\u306B\u3088\u3063\u3066{1}\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093 +# 0: message segment +compiler.misc.no.conforming.assignment.exists=\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {0} -# 0: type, 1: type -compiler.misc.varargs.argument.mismatch=\u5F15\u6570\u578B{0}\u306F\u53EF\u5909\u5F15\u6570\u8981\u7D20\u578B{1}\u306B\u9069\u5408\u3057\u307E\u305B\u3093 +# 0: message segment +compiler.misc.varargs.argument.mismatch=\u53EF\u5909\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {0} ##### +# 0: type, 1: file name +compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file={1}\u306E\u88DC\u52A9\u30AF\u30E9\u30B9{0}\u306B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u5916\u304B\u3089\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093 + + ## The first argument ({0}) is a "kindname". # 0: symbol kind, 1: symbol, 2: symbol compiler.err.abstract.cant.be.accessed.directly=\u62BD\u8C61{0}\u3067\u3042\u308B{1}({2}\u5185)\u306B\u76F4\u63A5\u30A2\u30AF\u30BB\u30B9\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 @@ -1188,10 +1353,17 @@ compiler.err.abstract.cant.be.accessed.directly=\u62BD\u8C61{0}\u3067\u3042\u308 # 0: symbol kind, 1: symbol compiler.err.non-static.cant.be.ref=static\u3067\u306A\u3044{0} {1}\u3092static\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u304B\u3089\u53C2\u7167\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 +# 0: symbol kind, 1: symbol +compiler.misc.non-static.cant.be.ref=static\u3067\u306A\u3044{0} {1}\u3092static\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u304B\u3089\u53C2\u7167\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 + ## Both arguments ({0}, {1}) are "kindname"s. {0} is a comma-separated list ## of kindnames (the list should be identical to that provided in source. compiler.err.unexpected.type=\u4E88\u671F\u3057\u306A\u3044\u578B\n\u671F\u5F85\u5024: {0}\n\u691C\u51FA\u5024: {1} +compiler.err.unexpected.lambda=\u3053\u3053\u3067\u306F\u30E9\u30E0\u30C0\u5F0F\u306F\u4E88\u671F\u3055\u308C\u3066\u3044\u307E\u305B\u3093 + +compiler.err.unexpected.mref=\u3053\u3053\u3067\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306F\u4E88\u671F\u3055\u308C\u3066\u3044\u307E\u305B\u3093 + ## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.) ## The second argument {1} is the non-resolved symbol ## The third argument {2} is a list of type parameters (non-empty if {1} is a method) @@ -1216,12 +1388,20 @@ compiler.err.cant.resolve.location.args=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u30 # 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment compiler.err.cant.resolve.location.args.params=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB: {0} <{2}>{1}({3})\n\u5834\u6240: {4} +### Following are replicated/used for method reference diagnostics + +# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment +compiler.misc.cant.resolve.location.args=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB: {0} {1}({3})\n\u5834\u6240: {4} + +# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment +compiler.misc.cant.resolve.location.args.params=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB: {0} <{2}>{1}({3})\n\u5834\u6240: {4} + ##a location subdiagnostic is composed as follows: ## The first argument {0} is the location "kindname" (e.g. 'constructor', 'field', etc.) ## The second argument {1} is the location name ## The third argument {2} is the location type (only when {1} is a variable name) -# 0: symbol kind, 1: symbol, 2: unused +# 0: symbol kind, 1: type or symbol, 2: unused compiler.misc.location={0} {1} # 0: symbol kind, 1: symbol, 2: type @@ -1236,7 +1416,7 @@ compiler.misc.kindname.annotation=@interface compiler.misc.kindname.constructor=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF -compiler.misc.kindname.enum=\u5217\u6319 +compiler.misc.kindname.enum=\u5217\u6319\u578B compiler.misc.kindname.interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 @@ -1256,6 +1436,10 @@ compiler.misc.kindname.class=\u30AF\u30E9\u30B9 compiler.misc.kindname.package=\u30D1\u30C3\u30B1\u30FC\u30B8 +compiler.misc.kindname.static.init=static\u521D\u671F\u5316\u5B50 + +compiler.misc.kindname.instance.init=\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u521D\u671F\u5316\u5B50 + ##### compiler.misc.no.args=\u5F15\u6570\u304C\u3042\u308A\u307E\u305B\u3093 @@ -1312,6 +1496,7 @@ compiler.misc.varargs.implement={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u5B9F\u88C5 # 0: symbol, 1: symbol, 2: symbol, 3: symbol compiler.misc.varargs.clash.with={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059 +# 0: unused compiler.misc.diamond.and.anon.class=\u533F\u540D\u5185\u90E8\u30AF\u30E9\u30B9\u3067\u306F''<>''\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 # 0: symbol kind, 1: symbol, 2: symbol, 3: message segment @@ -1336,13 +1521,23 @@ compiler.warn.enum.as.identifier=\u30EA\u30EA\u30FC\u30B95\u304B\u3089''enum''\u compiler.warn.assert.as.identifier=\u30EA\u30EA\u30FC\u30B91.4\u304B\u3089''assert''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u3001\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''assert''\u3092\u30AD\u30FC\u30EF\u30FC\u30C9\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F\u3001-source 1.4\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) +compiler.warn.underscore.as.identifier=\u8B58\u5225\u5B50\u3068\u3057\u3066''_''\u304C\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F\n(\u8B58\u5225\u5B50\u3068\u3057\u3066\u306E''_''\u306E\u4F7F\u7528\u306F\u3001\u5C06\u6765\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u306A\u3044\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059) + compiler.err.enum.as.identifier=\u30EA\u30EA\u30FC\u30B95\u304B\u3089''enum''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''enum''\u3092\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F-source 1.4\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) compiler.err.assert.as.identifier=\u30EA\u30EA\u30FC\u30B91.4\u304B\u3089''assert''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u3001\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''assert''\u3092\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F\u3001-source 1.3\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) # TODO 308: make a better error message -# compiler.err.this.as.identifier=\ -# as of release 8, ''this'' is allowed as the parameter name for the receiver type only, which has to be the first parameter +compiler.err.this.as.identifier=\u30EA\u30EA\u30FC\u30B98\u304B\u3089''this''\u306F\u53D7\u4FE1\u30BF\u30A4\u30D7\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u540D\u3068\u3057\u3066\u306E\u307F\u8A31\u53EF\u3055\u308C\u3001\u6700\u521D\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 + +# TODO 308: make a better error message +compiler.err.cant.annotate.static.class=\u5305\u542B\u3059\u308Bstatic\u306E\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306F\u6CE8\u91C8\u4ED8\u3051\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 +# TODO 308: make a better error message +compiler.err.cant.annotate.nested.type=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30BF\u30A4\u30D7\u306F\u6CE8\u91C8\u4ED8\u3051\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 + +compiler.err.incorrect.receiver.type=\u53D7\u4FE1\u30BF\u30A4\u30D7\u304C\u3001\u5305\u542B\u3059\u308B\u30AF\u30E9\u30B9\u30FB\u30BF\u30A4\u30D7\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093 + +compiler.err.no.annotations.on.dot.class=\u6CE8\u91C8\u306F\u30AF\u30E9\u30B9\u30FB\u30EA\u30C6\u30E9\u30EB\u306E\u30BF\u30A4\u30D7\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093 # 0: string compiler.err.generics.not.supported.in.source=\u7DCF\u79F0\u578B\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u7DCF\u79F0\u578B\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) @@ -1353,9 +1548,8 @@ compiler.err.varargs.not.supported.in.source=\u53EF\u5909\u5F15\u6570\u30E1\u30B # 0: string compiler.err.annotations.not.supported.in.source=\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) -#308 compiler.err.type.annotations.not.supported.in.source=\ -#308 type annotations are not supported in -source {0}\n\ -#308 (use -source 8 or higher to enable type annotations) +# 0: string +compiler.err.type.annotations.not.supported.in.source=\u30BF\u30A4\u30D7\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30BF\u30A4\u30D7\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) # 0: string compiler.err.foreach.not.supported.in.source=for-each\u30EB\u30FC\u30D7\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(for-each\u30EB\u30FC\u30D7\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) @@ -1375,6 +1569,47 @@ compiler.err.multicatch.not.supported.in.source=\u8907\u6570catch\u6587\u306F-so # 0: string compiler.err.string.switch.not.supported.in.source=switch\u5185\u306E\u6587\u5B57\u5217\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(switch\u5185\u306E\u6587\u5B57\u5217\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) +# 0: string +compiler.err.lambda.not.supported.in.source=\u30E9\u30E0\u30C0\u5F0F\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30E9\u30E0\u30C0\u5F0F\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + +# 0: string +compiler.err.method.references.not.supported.in.source=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + +# 0: string +compiler.err.default.methods.not.supported.in.source=\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + +# 0: string +compiler.err.intersection.types.in.cast.not.supported.in.source=\u30AD\u30E3\u30B9\u30C8\u5185\u306Eintersection\u578B\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + +# 0: string +compiler.err.static.intf.methods.not.supported.in.source=static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + +######################################## +# Diagnostics for verbose resolution +# used by Resolve (debug only) +######################################## + +# 0: number, 1: symbol, 2: unused +compiler.misc.applicable.method.found=#{0}\u500B\u306E\u4F7F\u7528\u53EF\u80FD\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {1} + +# 0: number, 1: symbol, 2: message segment +compiler.misc.applicable.method.found.1=#{0}\u500B\u306E\u4F7F\u7528\u53EF\u80FD\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {1}\n({2}) + +# 0: number, 1: symbol, 2: message segment +compiler.misc.not.applicable.method.found=#{0}\u500B\u306E\u4F7F\u7528\u3067\u304D\u306A\u3044\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {1}\n({2}) + +# 0: type +compiler.misc.partial.inst.sig=\u90E8\u5206\u7684\u306B\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3055\u308C\u307E\u3057\u305F: {0} + +# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment +compiler.note.verbose.resolve.multi=\u578B{1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u3092\u5019\u88DC{2}\u306B\u89E3\u6C7A\u3057\u3066\u3044\u307E\u3059\n\u30D5\u30A7\u30FC\u30BA: {3}\n\u5B9F\u969B\u306E\u578B: {4}\n\u578B\u5F15\u6570: {5}\n\u5019\u88DC: + +# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment +compiler.note.verbose.resolve.multi.1=\u578B{1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u306E\u89E3\u6C7A\u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\n\u30D5\u30A7\u30FC\u30BA: {3}\n\u5B9F\u969B\u306E\u578B: {4}\n\u578B\u5F15\u6570: {5}\n\u5019\u88DC: + +# 0: symbol, 1: type, 2: type +compiler.note.deferred.method.inst=\u30E1\u30BD\u30C3\u30C9{0}\u306E\u9045\u5EF6\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\n\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3055\u308C\u305F\u30B7\u30B0\u30CD\u30C1\u30E3: {1}\n\u30BF\u30FC\u30B2\u30C3\u30C8\u578B: {2} + ######################################## # Diagnostics for where clause implementation # used by the RichDiagnosticFormatter. @@ -1397,26 +1632,32 @@ compiler.misc.intersection.type=INT#{0} # where clause for captured type: contains upper ('extends {1}') and lower # ('super {2}') bound along with the wildcard that generated this captured type ({3}) # 0: type, 1: type, 2: type, 3: type -compiler.misc.where.captured={3}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3\u304B\u3089\u306E{0} extends {1} super: {2} +compiler.misc.where.captured={0}\u306F{3}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3\u304B\u3089{1}\u3092\u62E1\u5F35\u3057{2}\u3092\u30B9\u30FC\u30D1\u30FC\u3057\u307E\u3059 # compact where clause for captured type: contains upper ('extends {1}') along # with the wildcard that generated this captured type ({3}) # 0: type, 1: type, 2: unused, 3: type -compiler.misc.where.captured.1={3}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3\u304B\u3089\u306E{0} extends {1} +compiler.misc.where.captured.1={0}\u306F{3}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3\u304B\u3089{1}\u3092\u62E1\u5F35\u3057\u307E\u3059 # where clause for type variable: contains upper bound(s) ('extends {1}') along with # the kindname ({2}) and location ({3}) in which the typevar has been declared # 0: type, 1: list of type, 2: symbol kind, 3: symbol -compiler.misc.where.typevar={2} {3}\u3067\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B{0} extends {1} +compiler.misc.where.typevar={2} {3}\u3067\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B{0}\u306F{1}\u3092\u62E1\u5F35\u3057\u307E\u3059 # compact where clause for type variable: contains the kindname ({2}) and location ({3}) # in which the typevar has been declared +# 0: type, 1: list of type, 2: symbol kind, 3: symbol compiler.misc.where.typevar.1={2} {3}\u3067\u5BA3\u8A00\u3055\u308C\u305F{0} +# where clause for fresh type variable: contains upper bound(s) ('extends {1}'). +# Since a fresh type-variable is synthetic - there's no location/kindname here. +# 0: type, 1: list of type +compiler.misc.where.fresh.typevar={0}\u306F{1}\u3092\u62E1\u5F35\u3057\u307E\u3059 + # where clause for type variable: contains all the upper bound(s) ('extends {1}') # of this intersection type # 0: type, 1: list of type -compiler.misc.where.intersection={0} extends {1} +compiler.misc.where.intersection={0}\u306F{1}\u3092\u62E1\u5F35\u3057\u307E\u3059 ### Where clause headers ### compiler.misc.where.description.captured={0}\u304C\u65B0\u3057\u3044\u578B\u5909\u6570\u306E\u5834\u5408: @@ -1435,4 +1676,39 @@ compiler.misc.where.description.typevar.1={0}\u304C\u578B\u5909\u6570\u306E\u583 compiler.misc.where.description.intersection.1={0}\u304Cintersection\u578B\u306E\u5834\u5408: +### +# errors related to doc comments + +compiler.err.dc.bad.entity=HTML\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u304C\u4E0D\u6B63\u3067\u3059 + +compiler.err.dc.bad.gt=''>''\u306E\u4F7F\u7528\u304C\u4E0D\u6B63\u3067\u3059 + +compiler.err.dc.bad.inline.tag=\u30A4\u30F3\u30E9\u30A4\u30F3\u30FB\u30BF\u30B0\u306E\u4F7F\u7528\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093 + +compiler.err.dc.identifier.expected=\u8B58\u5225\u5B50\u304C\u5FC5\u8981\u3067\u3059 + +compiler.err.dc.malformed.html=HTML\u304C\u4E0D\u6B63\u3067\u3059 + +compiler.err.dc.missing.semicolon=\u30BB\u30DF\u30B3\u30ED\u30F3\u304C\u3042\u308A\u307E\u305B\u3093 + +compiler.err.dc.no.content=\u30B3\u30F3\u30C6\u30F3\u30C4\u306A\u3057 + +compiler.err.dc.no.tag.name='@'\u306E\u5F8C\u306B\u30BF\u30B0\u540D\u304C\u3042\u308A\u307E\u305B\u3093 + +compiler.err.dc.gt.expected=''>''\u304C\u5FC5\u8981\u3067\u3059 + +compiler.err.dc.ref.bad.parens=\u53C2\u7167\u306B'')''\u304C\u3042\u308A\u307E\u305B\u3093 + +compiler.err.dc.ref.syntax.error=\u53C2\u7167\u306B\u69CB\u6587\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059 + +compiler.err.dc.ref.unexpected.input=\u4E88\u671F\u3057\u306A\u3044\u30C6\u30AD\u30B9\u30C8\u3067\u3059 + +compiler.err.dc.unexpected.content=\u4E88\u671F\u3057\u306A\u3044\u30B3\u30F3\u30C6\u30F3\u30C4\u3067\u3059 + +compiler.err.dc.unterminated.inline.tag=\u30A4\u30F3\u30E9\u30A4\u30F3\u30FB\u30BF\u30B0\u304C\u7D42\u4E86\u3057\u3066\u3044\u307E\u305B\u3093 + +compiler.err.dc.unterminated.signature=\u30B7\u30B0\u30CD\u30C1\u30E3\u304C\u7D42\u4E86\u3057\u3066\u3044\u307E\u305B\u3093 + +compiler.err.dc.unterminated.string=\u6587\u5B57\u5217\u304C\u7D42\u4E86\u3057\u3066\u3044\u307E\u305B\u3093 + diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties index 005bc3b3e69..af6298e1b48 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties @@ -65,8 +65,11 @@ compiler.err.abstract.meth.cant.have.body=\u62BD\u8C61\u65B9\u6CD5\u4E0D\u80FD\u compiler.err.already.annotated={0} {1}\u5DF2\u8FDB\u884C\u6CE8\u91CA -# 0: symbol, 1: symbol -compiler.err.already.defined=\u5DF2\u5728{1}\u4E2D\u5B9A\u4E49{0} +# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol +compiler.err.already.defined=\u5DF2\u5728{2} {3}\u4E2D\u5B9A\u4E49\u4E86{0} {1} + +# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol kind, 4: symbol +compiler.err.already.defined.in.clinit=\u5DF2\u5728{3} {4}\u7684{2}\u4E2D\u5B9A\u4E49\u4E86{0} {1} # 0: string compiler.err.already.defined.single.import=\u5DF2\u5728 single-type \u5BFC\u5165\u4E2D\u5B9A\u4E49{0} @@ -109,28 +112,84 @@ compiler.err.array.dimension.missing=\u7F3A\u5C11\u6570\u7EC4\u7EF4 # 0: type compiler.err.array.req.but.found=\u9700\u8981\u6570\u7EC4, \u4F46\u627E\u5230{0} -compiler.err.assignment.from.super-bound=\u901A\u8FC7\u901A\u914D\u7B26 {0} \u5206\u914D - -compiler.err.assignment.to.extends-bound=\u5206\u914D\u7ED9\u901A\u914D\u7B26 {0} - compiler.err.attribute.value.must.be.constant=\u5C5E\u6027\u503C\u5FC5\u987B\u4E3A\u5E38\u91CF +# 0: statement type +compiler.err.bad.initializer={0}\u7684\u521D\u59CB\u5316\u7A0B\u5E8F\u9519\u8BEF + compiler.err.break.outside.switch.loop=\u5728 switch \u6216 loop \u5916\u90E8\u4E2D\u65AD # 0: name compiler.err.call.must.be.first.stmt.in.ctor=\u5BF9{0}\u7684\u8C03\u7528\u5FC5\u987B\u662F\u6784\u9020\u5668\u4E2D\u7684\u7B2C\u4E00\u4E2A\u8BED\u53E5 -compiler.err.cant.apply.symbol=\u65E0\u6CD5\u5C06{4} {5}\u4E2D\u7684{0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7C7B\u578B\n\u9700\u8981: {2}\n\u627E\u5230: {3} - # 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment -compiler.err.cant.apply.symbol.1=\u65E0\u6CD5\u5C06{4} {5}\u4E2D\u7684{0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7C7B\u578B;\n\u9700\u8981: {2}\n\u627E\u5230: {3}\n\u539F\u56E0: {6} +compiler.err.cant.apply.symbol=\u65E0\u6CD5\u5C06{4} {5}\u4E2D\u7684{0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7C7B\u578B;\n\u9700\u8981: {2}\n\u627E\u5230: {3}\n\u539F\u56E0: {6} # 0: symbol kind, 1: name, 2: list of type compiler.err.cant.apply.symbols=\u5BF9\u4E8E{1}({2}), \u627E\u4E0D\u5230\u5408\u9002\u7684{0} +# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment +compiler.misc.cant.apply.symbol=\u65E0\u6CD5\u5C06 {4} {5}\u4E2D\u7684 {0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7C7B\u578B\n\u9700\u8981: {2}\n\u627E\u5230: {3}\n\u539F\u56E0: {6} + +# 0: symbol kind, 1: name, 2: list of type +compiler.misc.cant.apply.symbols=\u5BF9\u4E8E{1}({2}), \u627E\u4E0D\u5230\u5408\u9002\u7684{0} + +# 0: symbol kind, 1: symbol +compiler.misc.no.abstracts=\u5728 {0} {1} \u4E2D\u627E\u4E0D\u5230\u62BD\u8C61\u65B9\u6CD5 + +# 0: symbol kind, 1: symbol +compiler.misc.incompatible.abstracts=\u5728 {0} {1} \u4E2D\u627E\u5230\u591A\u4E2A\u975E\u8986\u76D6\u62BD\u8C61\u65B9\u6CD5 + +compiler.err.bad.functional.intf.anno=\u610F\u5916\u7684 @FunctionalInterface \u6CE8\u91CA + +# 0: message segment +compiler.err.bad.functional.intf.anno.1=\u610F\u5916\u7684 @FunctionalInterface \u6CE8\u91CA\n{0} + +# 0: symbol +compiler.misc.not.a.functional.intf={0} \u4E0D\u662F\u51FD\u6570\u63A5\u53E3 + +# 0: symbol, 1: message segment +compiler.misc.not.a.functional.intf.1={0} \u4E0D\u662F\u51FD\u6570\u63A5\u53E3\n{1} + +# 0: symbol, 1: symbol kind, 2: symbol +compiler.misc.invalid.generic.lambda.target=lambda \u8868\u8FBE\u5F0F\u7684\u51FD\u6570\u63CF\u8FF0\u7B26\u65E0\u6548\n{1} {2} \u4E2D\u7684\u65B9\u6CD5 {0} \u4E3A\u6CDB\u578B\u65B9\u6CD5 + +# 0: symbol kind, 1: symbol +compiler.misc.incompatible.descs.in.functional.intf=\u5728 {0} {1} \u4E2D\u627E\u5230\u4E0D\u517C\u5BB9\u7684\u51FD\u6570\u63CF\u8FF0\u7B26 + +# 0: name, 1: list of type, 2: type, 3: list of type +compiler.misc.descriptor=\u63CF\u8FF0\u7B26: {2} {0}({1}) + +# 0: name, 1: list of type, 2: type, 3: list of type +compiler.misc.descriptor.throws=\u63CF\u8FF0\u7B26: {2} {0}({1}) \u629B\u51FA{3} + +# 0: type +compiler.misc.no.suitable.functional.intf.inst=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u51FD\u6570\u63A5\u53E3\u63CF\u8FF0\u7B26 + +# 0: type +compiler.misc.secondary.bound.must.be.marker.intf=\u6B21\u7EA7\u9650\u5236\u8303\u56F4{0}\u5FC5\u987B\u4E3A\u6807\u8BB0\u63A5\u53E3 + +# 0: symbol kind, 1: message segment +compiler.err.invalid.mref={0} \u5F15\u7528\u65E0\u6548; {1} + +# 0: symbol kind, 1: message segment +compiler.misc.invalid.mref={0} \u5F15\u7528\u65E0\u6548; {1} + +compiler.misc.static.mref.with.targs=\u6709\u5173\u9759\u6001\u65B9\u6CD5\u5F15\u7528\u7684\u53C2\u6570\u5316\u9650\u5B9A\u7B26 + +compiler.misc.static.bound.mref=\u9759\u6001\u9650\u5236\u8303\u56F4\u65B9\u6CD5\u5F15\u7528 + # 0: symbol compiler.err.cant.assign.val.to.final.var=\u65E0\u6CD5\u4E3A\u6700\u7EC8\u53D8\u91CF{0}\u5206\u914D\u503C +# 0: symbol, 1: message segment +compiler.err.cant.ref.non.effectively.final.var=\u4ECE{1}\u5F15\u7528\u7684\u672C\u5730\u53D8\u91CF\u5FC5\u987B\u662F\u6700\u7EC8\u53D8\u91CF\u6216\u5B9E\u9645\u4E0A\u7684\u6700\u7EC8\u53D8\u91CF + + +compiler.misc.lambda=lambda \u8868\u8FBE\u5F0F + +compiler.misc.inner.cls=\u5185\u90E8\u7C7B + # 0: type compiler.err.cant.deref=\u65E0\u6CD5\u53D6\u6D88\u5F15\u7528{0} @@ -142,8 +201,6 @@ compiler.err.cant.inherit.from.final=\u65E0\u6CD5\u4ECE\u6700\u7EC8{0}\u8FDB\u88 # 0: symbol compiler.err.cant.ref.before.ctor.called=\u65E0\u6CD5\u5728\u8C03\u7528\u8D85\u7C7B\u578B\u6784\u9020\u5668\u4E4B\u524D\u5F15\u7528{0} -compiler.err.cant.ret.val.from.meth.decl.void=\u5BF9\u4E8E\u7ED3\u679C\u7C7B\u578B\u4E3A\u7A7A\u7684\u65B9\u6CD5, \u65E0\u6CD5\u8FD4\u56DE\u503C - compiler.err.cant.select.static.class.from.param.type=\u65E0\u6CD5\u4ECE\u53C2\u6570\u5316\u7684\u7C7B\u578B\u4E2D\u9009\u62E9\u9759\u6001\u7C7B # 0: symbol, 1: string, 2: string @@ -154,6 +211,8 @@ compiler.err.catch.without.try=\u6709 ''catch'', \u4F46\u662F\u6CA1\u6709 ''try' # 0: symbol kind, 1: symbol compiler.err.clash.with.pkg.of.same.name={0} {1}\u4E0E\u5E26\u6709\u76F8\u540C\u540D\u79F0\u7684\u7A0B\u5E8F\u5305\u51B2\u7A81 +compiler.err.class.not.allowed=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u7C7B, \u63A5\u53E3\u6216\u679A\u4E3E\u58F0\u660E + compiler.err.const.expr.req=\u9700\u8981\u5E38\u91CF\u8868\u8FBE\u5F0F compiler.err.cont.outside.loop=continue \u5728 loop \u5916\u90E8 @@ -169,8 +228,6 @@ compiler.err.call.to.super.not.allowed.in.enum.ctor=\u5728\u679A\u4E3E\u6784\u90 # 0: type compiler.err.no.superclass={0}\u4E0D\u5177\u6709\u8D85\u7C7B -compiler.err.wrong.target.for.polymorphic.signature.definition=MethodHandle API \u6784\u5EFA\u9700\u8981 -target 7 \u8FD0\u884C\u65F6\u6216\u66F4\u9AD8; \u5F53\u524D\u4E3A -target {0} - # 0: symbol, 1: type, 2: symbol, 3: type, 4: unused compiler.err.concrete.inheritance.conflict={1}\u4E2D\u7684\u65B9\u6CD5{0}\u548C{3}\u4E2D\u7684\u65B9\u6CD5{2}\u662F\u4F7F\u7528\u76F8\u540C\u7684\u7B7E\u540D\u7EE7\u627F\u7684 @@ -181,9 +238,48 @@ compiler.err.doesnt.exist=\u7A0B\u5E8F\u5305{0}\u4E0D\u5B58\u5728 compiler.err.duplicate.annotation=\u6CE8\u91CA\u91CD\u590D +# 0: type +compiler.err.duplicate.annotation.invalid.repeated=\u65E0\u6CD5\u91CD\u590D\u6CE8\u91CA{0}\n\u5B83\u6CA1\u6709\u5B9A\u4E49\u6709\u6548\u7684\u5305\u542B\u6CE8\u91CA\u3002 + # 0: name, 1: type compiler.err.duplicate.annotation.member.value={1}\u4E2D\u7684\u6CE8\u91CA\u6210\u5458\u503C{0}\u91CD\u590D +# 0: type, 1: type +compiler.err.duplicate.annotation.missing.container=\u6CE8\u91CA\u91CD\u590D, {0}\u7684\u58F0\u660E\u6CA1\u6709\u6709\u6548\u7684{1}\u6CE8\u91CA + +# 0: type +compiler.err.invalid.repeatable.annotation=\u6CE8\u91CA\u91CD\u590D, \u4F7F\u7528\u65E0\u6548\u7684\u53EF\u91CD\u590D\u6CE8\u91CA\u5BF9{0}\u8FDB\u884C\u4E86\u6CE8\u91CA + +# 0: type +compiler.err.invalid.repeatable.annotation.no.value=\u6CE8\u91CA\u91CD\u590D, {0}\u4E0D\u662F\u6709\u6548\u7684\u53EF\u91CD\u590D\u7C7B\u578B, \u672A\u58F0\u660E\u4EFB\u4F55\u503C\u5143\u7D20\u65B9\u6CD5 + +# 0: type, 1: number +compiler.err.invalid.repeatable.annotation.multiple.values=\u6CE8\u91CA\u91CD\u590D, {0}\u4E0D\u662F\u6709\u6548\u7684\u53EF\u91CD\u590D\u7C7B\u578B, \u5DF2\u58F0\u660E {1} \u4E2A\u503C\u5143\u7D20\u65B9\u6CD5 + +# 0: type +compiler.err.invalid.repeatable.annotation.invalid.value=\u6CE8\u91CA\u91CD\u590D, {0}\u4E0D\u662F\u6709\u6548\u7684\u53EF\u91CD\u590D\u7C7B\u578B, \u503C\u5143\u7D20\u65E0\u6548, \u9700\u8981\u65B9\u6CD5 + +# 0: type, 1: type, 2: type +compiler.err.invalid.repeatable.annotation.value.return=\u6CE8\u91CA\u91CD\u590D, \u5305\u542B\u6CE8\u91CA{0}\u7684\u503C\u5143\u7D20\u5E94\u5177\u6709\u7C7B\u578B{2}, \u4F46\u627E\u5230\u7684\u662F{1} + +# 0: type, 1: symbol +compiler.err.invalid.repeatable.annotation.elem.nondefault=\u5305\u542B\u6CE8\u91CA{0}\u6CA1\u6709\u5143\u7D20 {1} \u7684\u9ED8\u8BA4\u503C + +# 0: symbol, 1: type, 2: symbol, 3: type +compiler.err.invalid.repeatable.annotation.retention=\u5305\u542B\u6CE8\u91CA {0} \u7684\u4FDD\u7559\u671F ({1}) \u77ED\u4E8E\u5DF2\u5305\u542B\u6CE8\u91CA {2} \u7684\u4FDD\u7559\u671F ({3}) + +# 0: symbol, 1: symbol +compiler.err.invalid.repeatable.annotation.not.documented=\u5305\u542B\u6CE8\u91CA\u7C7B\u578B {0} \u4E0D\u662F @Documented, \u800C\u91CD\u590D\u7684\u6CE8\u91CA\u7C7B\u578B {1} \u4E3A + +# 0: symbol, 1: symbol +compiler.err.invalid.repeatable.annotation.not.inherited=\u5305\u542B\u6CE8\u91CA\u7C7B\u578B {0} \u4E0D\u662F @Inherited, \u800C\u91CD\u590D\u7684\u6CE8\u91CA\u7C7B\u578B {1} \u4E3A + +# 0: symbol, 1: symbol +compiler.err.invalid.repeatable.annotation.incompatible.target=\u5BB9\u5668\u6CE8\u91CA {0} \u7684\u76EE\u6807\u4E0D\u662F\u91CD\u590D\u6CE8\u91CA {1} \u7684\u76EE\u6807\u5B50\u96C6 + +# 0: symbol +compiler.err.invalid.repeatable.annotation.repeated.and.container.present=\u5BB9\u5668 {0} \u4E0D\u5F97\u4E0E\u5176\u5305\u542B\u7684\u5143\u7D20\u540C\u65F6\u5B58\u5728 + # 0: name compiler.err.duplicate.class=\u7C7B\u91CD\u590D: {0} @@ -245,10 +341,10 @@ compiler.err.generic.array.creation=\u521B\u5EFA\u6CDB\u578B\u6570\u7EC4 compiler.err.generic.throwable=\u6CDB\u578B\u7C7B\u4E0D\u80FD\u6269\u5C55 java.lang.Throwable # 0: symbol -compiler.err.icls.cant.have.static.decl=\u5185\u90E8\u7C7B{0}\u4E2D\u7684\u9759\u6001\u58F0\u660E\u975E\u6CD5\n\u4FEE\u9970\u7B26 \''static\'' \u4EC5\u5141\u8BB8\u5728\u5E38\u91CF\u53D8\u91CF\u58F0\u660E\u4E2D\u4F7F\u7528 +compiler.err.icls.cant.have.static.decl=\u5185\u90E8\u7C7B{0}\u4E2D\u7684\u9759\u6001\u58F0\u660E\u975E\u6CD5\n\u4FEE\u9970\u7B26 ''static'' \u4EC5\u5141\u8BB8\u5728\u5E38\u91CF\u53D8\u91CF\u58F0\u660E\u4E2D\u4F7F\u7528 # 0: string -compiler.err.illegal.char=\u975E\u6CD5\u5B57\u7B26: \\{0} +compiler.err.illegal.char=\u975E\u6CD5\u5B57\u7B26: ''{0}'' compiler.err.illegal.char.for.encoding=\u7F16\u7801{0}\u7684\u4E0D\u53EF\u6620\u5C04\u5B57\u7B26 @@ -280,11 +376,15 @@ compiler.err.illegal.nonascii.digit=\u975E\u6CD5\u7684\u975E ASCII \u6570\u5B57 compiler.err.illegal.underscore=\u975E\u6CD5\u4E0B\u5212\u7EBF +compiler.err.illegal.dot=\u975E\u6CD5 ''.'' + # 0: symbol compiler.err.illegal.qual.not.icls=\u975E\u6CD5\u9650\u5B9A\u7B26; {0}\u4E0D\u662F\u5185\u90E8\u7C7B compiler.err.illegal.start.of.expr=\u975E\u6CD5\u7684\u8868\u8FBE\u5F0F\u5F00\u59CB +compiler.err.illegal.start.of.stmt=\u975E\u6CD5\u7684\u8BED\u53E5\u5F00\u59CB + compiler.err.illegal.start.of.type=\u975E\u6CD5\u7684\u7C7B\u578B\u5F00\u59CB compiler.err.illegal.unicode.esc=\u975E\u6CD5\u7684 Unicode \u8F6C\u4E49 @@ -302,8 +402,6 @@ compiler.err.incomparable.types=\u4E0D\u53EF\u6BD4\u8F83\u7684\u7C7B\u578B: {0}\ # 0: number compiler.err.int.number.too.large=\u8FC7\u5927\u7684\u6574\u6570: {0} -compiler.err.internal.error.cant.instantiate=\u5185\u90E8\u9519\u8BEF; \u65E0\u6CD5\u5C06\u4F4D\u4E8E{1}\u7684{0}\u5B9E\u4F8B\u5316\u4E3A ({2}) - compiler.err.intf.annotation.members.cant.have.params=@interface \u6210\u5458\u4E0D\u80FD\u5E26\u6709\u53C2\u6570 compiler.err.intf.annotation.cant.have.type.params=@interface \u4E0D\u80FD\u5E26\u6709\u7C7B\u578B\u53C2\u6570 @@ -315,7 +413,7 @@ compiler.err.intf.annotation.member.clash=@interface \u6210\u5458\u4E0E{1}\u4E2D compiler.err.intf.expected.here=\u6B64\u5904\u9700\u8981\u63A5\u53E3 -compiler.err.intf.meth.cant.have.body=\u63A5\u53E3\u65B9\u6CD5\u4E0D\u80FD\u5E26\u6709\u4E3B\u4F53 +compiler.err.intf.meth.cant.have.body=\u63A5\u53E3\u62BD\u8C61\u65B9\u6CD5\u4E0D\u80FD\u5E26\u6709\u4E3B\u4F53 compiler.err.invalid.annotation.member.type=\u6CE8\u91CA\u6210\u5458\u7684\u7C7B\u578B\u65E0\u6548 @@ -327,6 +425,8 @@ compiler.err.invalid.meth.decl.ret.type.req=\u65B9\u6CD5\u58F0\u660E\u65E0\u6548 compiler.err.varargs.and.old.array.syntax=variable-arity \u53C2\u6570\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u4F20\u7EDF\u6570\u7EC4\u8BB0\u53F7 +compiler.err.variable.not.allowed=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u53D8\u91CF\u58F0\u660E + # 0: name compiler.err.label.already.in.use=\u6807\u7B7E{0}\u5DF2\u4F7F\u7528 @@ -337,6 +437,8 @@ compiler.err.local.enum=\u679A\u4E3E\u7C7B\u578B\u4E0D\u80FD\u4E3A\u672C\u5730\u compiler.err.cannot.create.array.with.type.arguments=\u65E0\u6CD5\u521B\u5EFA\u5177\u6709\u7C7B\u578B\u53D8\u91CF\u7684\u6570\u7EC4 +compiler.err.cannot.create.array.with.diamond=\u65E0\u6CD5\u521B\u5EFA\u5177\u6709 ''<>'' \u7684\u6570\u7EC4 + # # limits. We don't give the limits in the diagnostic because we expect # them to change, yet we want to use the same diagnostic. These are all @@ -360,7 +462,7 @@ compiler.err.limit.stack=\u4EE3\u7801\u9700\u8981\u8FC7\u591A\u5806\u6808 compiler.err.limit.string=\u5E38\u91CF\u5B57\u7B26\u4E32\u8FC7\u957F -compiler.err.limit.string.overflow=\u5BF9\u4E8E\u5E38\u91CF\u6C60\u6765\u8BF4, \u5B57\u7B26\u4E32 \"{0}...\" \u7684 UTF8 \u8868\u793A\u8FC7\u957F +compiler.err.limit.string.overflow=\u5BF9\u4E8E\u5E38\u91CF\u6C60\u6765\u8BF4, \u5B57\u7B26\u4E32 "{0}..." \u7684 UTF8 \u8868\u793A\u8FC7\u957F compiler.err.malformed.fp.lit=\u6D6E\u70B9\u6587\u5B57\u7684\u683C\u5F0F\u9519\u8BEF @@ -370,7 +472,9 @@ compiler.err.missing.meth.body.or.decl.abstract=\u7F3A\u5C11\u65B9\u6CD5\u4E3B\u compiler.err.missing.ret.stmt=\u7F3A\u5C11\u8FD4\u56DE\u8BED\u53E5 -compiler.err.missing.ret.val=\u7F3A\u5C11\u8FD4\u56DE\u503C +compiler.misc.missing.ret.val=\u7F3A\u5C11\u8FD4\u56DE\u503C + +compiler.misc.unexpected.ret.val=\u610F\u5916\u7684\u8FD4\u56DE\u503C # 0: set of modifier compiler.err.mod.not.allowed.here=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u4FEE\u9970\u7B26{0} @@ -398,6 +502,25 @@ compiler.err.native.meth.cant.have.body=\u672C\u673A\u65B9\u6CD5\u4E0D\u80FD\u5E # 0: type, 1: type compiler.err.neither.conditional.subtype=? \u7684\u4E0D\u517C\u5BB9\u7C7B\u578B: \u4E24\u8005\u90FD\u4E0D\u662F\u5BF9\u65B9\u7684\u5B50\u7C7B\u578B\n\u7B2C\u4E8C\u4E2A\u64CD\u4F5C\u6570: {0}\n\u7B2C\u4E09\u4E2A\u64CD\u4F5C\u6570: {1} +# 0: message segment +compiler.misc.incompatible.type.in.conditional=\u6761\u4EF6\u8868\u8FBE\u5F0F\u4E2D\u7684\u7C7B\u578B\u9519\u8BEF; {0} + +compiler.misc.conditional.target.cant.be.void=\u6761\u4EF6\u8868\u8FBE\u5F0F\u7684\u76EE\u6807\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A + +# 0: type +compiler.misc.incompatible.ret.type.in.lambda=lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u8FD4\u56DE\u7C7B\u578B\u9519\u8BEF\n{0} + +# 0: type +compiler.misc.incompatible.ret.type.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u7684\u8FD4\u56DE\u7C7B\u578B\u9519\u8BEF\n{0} + +# 0: list of type +compiler.err.incompatible.thrown.types.in.lambda=lambda \u8868\u8FBE\u5F0F\u4E2D\u629B\u51FA\u7684\u7C7B\u578B{0}\u4E0D\u517C\u5BB9 + +# 0: list of type +compiler.err.incompatible.thrown.types.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u629B\u51FA\u7684\u7C7B\u578B{0}\u4E0D\u517C\u5BB9 + +compiler.misc.incompatible.arg.types.in.lambda=lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u53C2\u6570\u7C7B\u578B\u4E0D\u517C\u5BB9 + compiler.err.new.not.allowed.in.annotation=\u6CE8\u91CA\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 ''new'' compiler.err.no.annotation.member={1}\u4E2D\u6CA1\u6709\u6CE8\u91CA\u6210\u5458{0} @@ -413,6 +536,12 @@ compiler.err.not.annotation.type={0}\u4E0D\u662F\u6CE8\u91CA\u7C7B\u578B # 0: symbol, 1: symbol compiler.err.not.def.access.class.intf.cant.access={1}\u4E2D\u7684{0}\u662F\u5728\u4E0D\u53EF\u8BBF\u95EE\u7684\u7C7B\u6216\u63A5\u53E3\u4E2D\u5B9A\u4E49\u7684 +# 0: symbol, 1: symbol +compiler.misc.not.def.access.class.intf.cant.access={1}\u4E2D\u7684{0}\u662F\u5728\u4E0D\u53EF\u8BBF\u95EE\u7684\u7C7B\u6216\u63A5\u53E3\u4E2D\u5B9A\u4E49\u7684 + +# 0: symbol, 1: list of type, 2: type +compiler.misc.cant.access.inner.cls.constr=\u65E0\u6CD5\u8BBF\u95EE\u6784\u9020\u5668 {0}({1})\n\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u7C7B\u578B\u4E3A{2}\u7684\u5C01\u95ED\u5B9E\u4F8B + # 0: symbol, 1: symbol compiler.err.not.def.public.cant.access={0}\u5728{1}\u4E2D\u4E0D\u662F\u516C\u5171\u7684; \u65E0\u6CD5\u4ECE\u5916\u90E8\u7A0B\u5E8F\u5305\u4E2D\u5BF9\u5176\u8FDB\u884C\u8BBF\u95EE @@ -455,15 +584,13 @@ compiler.err.proc.messager={0} # 0: list of string compiler.err.proc.no.explicit.annotation.processing.requested=\u4EC5\u5F53\u663E\u5F0F\u8BF7\u6C42\u6CE8\u91CA\u5904\u7406\u65F6\u624D\u63A5\u53D7\u7C7B\u540D\u79F0 ''{0}'' -compiler.err.proc.no.service=\u627E\u4E0D\u5230\u670D\u52A1\u52A0\u8F7D\u5668\u7C7B\u3002\njava.util.ServiceLoader \u6216 sun.misc.Service \u5FC5\u987B\u53EF\u7528\u3002 +compiler.err.proc.no.service=ServiceLoader \u4E0D\u53EF\u7528, \u4F46\u5B83\u662F\u6CE8\u91CA\u5904\u7406\u6240\u5FC5\u9700\u7684\u3002 compiler.err.proc.processor.bad.option.name=\u5904\u7406\u7A0B\u5E8F ''{1}'' \u63D0\u4F9B\u7684\u9009\u9879\u540D\u79F0 ''{0}'' \u9519\u8BEF # 0: string compiler.err.proc.processor.cant.instantiate=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u5904\u7406\u7A0B\u5E8F ''{0}'' \u7684\u5B9E\u4F8B -compiler.err.proc.processor.constructor.error=\u6784\u9020\u5904\u7406\u7A0B\u5E8F\u5BF9\u8C61{0}\u65F6\u629B\u51FA\u5F02\u5E38\u9519\u8BEF - # 0: string compiler.err.proc.processor.not.found=\u627E\u4E0D\u5230\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F ''{0}'' @@ -482,7 +609,10 @@ compiler.err.qualified.new.of.static.class=\u9650\u5B9A\u7684\u65B0\u9759\u6001\ compiler.err.recursive.ctor.invocation=\u9012\u5F52\u6784\u9020\u5668\u8C03\u7528 # 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol -compiler.err.ref.ambiguous=\u5BF9{0}\u7684\u5F15\u7528\u4E0D\u660E\u786E, {3}\u4E2D\u7684{1} {2}\u548C{6}\u4E2D\u7684{4} {5}\u90FD\u5339\u914D +compiler.err.ref.ambiguous=\u5BF9{0}\u7684\u5F15\u7528\u4E0D\u660E\u786E\n{3} \u4E2D\u7684{1} {2} \u548C {6} \u4E2D\u7684{4} {5} \u90FD\u5339\u914D + +# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol +compiler.misc.ref.ambiguous=\u5BF9{0}\u7684\u5F15\u7528\u4E0D\u660E\u786E\n{3} \u4E2D\u7684{1} {2} \u548C {6} \u4E2D\u7684{4} {5} \u90FD\u5339\u914D compiler.err.repeated.annotation.target=\u6CE8\u91CA\u76EE\u6807\u91CD\u590D @@ -536,6 +666,27 @@ compiler.err.type.var.more.than.once.in.result=\u7C7B\u578B\u53D8\u91CF{0}\u5728 # 0: type, 1: type, 2: string compiler.err.types.incompatible.diff.ret=\u7C7B\u578B{0}\u548C{1}\u4E0D\u517C\u5BB9; \u4E24\u8005\u90FD\u5B9A\u4E49\u4E86{2}, \u4F46\u5374\u5E26\u6709\u4E0D\u76F8\u5173\u7684\u8FD4\u56DE\u7C7B\u578B +# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol +compiler.err.types.incompatible.unrelated.defaults={0} {1}\u4ECE\u7C7B\u578B {4} \u548C {5} \u4E2D\u7EE7\u627F\u4E86{2}({3}) \u7684\u4E0D\u76F8\u5173\u9ED8\u8BA4\u503C + +# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol +compiler.err.types.incompatible.abstract.default={0} {1}\u4ECE\u7C7B\u578B {4} \u548C {5} \u4E2D\u7EE7\u627F\u4E86{2}({3}) \u7684\u62BD\u8C61\u548C\u9ED8\u8BA4\u503C + +# 0: name, 1: kind, 2: symbol +compiler.err.default.overrides.object.member={1} {2} \u4E2D\u7684\u9ED8\u8BA4\u65B9\u6CD5{0}\u8986\u76D6\u4E86 java.lang.Object \u7684\u6210\u5458 + +# 0: type +compiler.err.illegal.static.intf.meth.call=\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\u8C03\u7528\u975E\u6CD5\n\u5E94\u5C06\u63A5\u6536\u65B9\u8868\u8FBE\u5F0F\u66FF\u6362\u4E3A\u7C7B\u578B\u9650\u5B9A\u7B26 ''{0}'' + +# 0: type, 1: message segment +compiler.err.illegal.default.super.call=\u9ED8\u8BA4\u8D85\u7EA7\u8C03\u7528\u4E2D\u7684\u7C7B\u578B\u9650\u5B9A\u7B26{0}\u9519\u8BEF\n{1} + +# 0: symbol, 1: type +compiler.misc.overridden.default=\u8986\u76D6\u4E86{1}\u4E2D\u7684\u65B9\u6CD5 {0} + +# 0: symbol, 1: symbol +compiler.misc.redundant.supertype=\u5197\u4F59\u63A5\u53E3 {0} \u5DF2\u7531 {1} \u6269\u5C55 + compiler.err.unclosed.char.lit=\u672A\u7ED3\u675F\u7684\u5B57\u7B26\u6587\u5B57 compiler.err.unclosed.comment=\u672A\u7ED3\u675F\u7684\u6CE8\u91CA @@ -550,19 +701,14 @@ compiler.err.io.exception=\u8BFB\u53D6\u6E90\u6587\u4EF6\u65F6\u51FA\u9519: {0} # 0: name compiler.err.undef.label=\u672A\u5B9A\u4E49\u7684\u6807\u7B7E: {0} -compiler.err.undetermined.type=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570 - -# 0: type, 1: message segment -compiler.err.undetermined.type.1=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570;\n\u539F\u56E0: {1} - -# 0: list of type, 1: message segment -compiler.err.invalid.inferred.types={0}\u7684\u63A8\u65AD\u7C7B\u578B\u65E0\u6548; {1} - # 0: message segment, 1: unused compiler.err.cant.apply.diamond=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570 -# 0: message segment, 1: message segment -compiler.err.cant.apply.diamond.1=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570;\n\u539F\u56E0: {1} +# 0: message segment or type, 1: message segment +compiler.err.cant.apply.diamond.1=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570\n\u539F\u56E0: {1} + +# 0: message segment or type, 1: message segment +compiler.misc.cant.apply.diamond.1=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570\n\u539F\u56E0: {1} compiler.err.unreachable.stmt=\u65E0\u6CD5\u8BBF\u95EE\u7684\u8BED\u53E5 @@ -605,7 +751,7 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\u65B9\u6CD5 {0} \u4E0D\u662F # 0: symbol compiler.misc.varargs.trustme.on.virtual.varargs=\u5B9E\u4F8B\u65B9\u6CD5 {0} \u4E0D\u662F\u6700\u7EC8\u7684\u3002 -# 0: type, 1: kind, 2: symbol +# 0: type, 1: symbol kind, 2: symbol compiler.misc.inaccessible.varargs.type=\u5F62\u5F0F varargs \u5143\u7D20\u7C7B\u578B{0}\u65E0\u6CD5\u4ECE {1} {2} \u8FDB\u884C\u8BBF\u95EE # In the following string, {1} will always be the detail message from @@ -620,7 +766,7 @@ compiler.err.class.public.should.be.in.file=\u7C7B{0}\u662F\u516C\u5171\u7684, \ ## All errors which do not refer to a particular line in the source code are ## preceded by this string. -compiler.err.error=\u9519\u8BEF:\u0020 +compiler.err.error=\u9519\u8BEF: # The following error messages do not refer to a line in the source code. compiler.err.cant.read.file=\u65E0\u6CD5\u8BFB\u53D6: {0} @@ -637,7 +783,7 @@ compiler.misc.fatal.err.cant.locate.field=\u81F4\u547D\u9519\u8BEF: \u627E\u4E0D compiler.misc.fatal.err.cant.locate.ctor=\u81F4\u547D\u9519\u8BEF: \u627E\u4E0D\u5230{0}\u7684\u6784\u9020\u5668 -compiler.misc.fatal.err.cant.close.loader=\u81F4\u547D\u9519\u8BEF: \u65E0\u6CD5\u5173\u95ED\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u7C7B\u52A0\u8F7D\u5668 +compiler.misc.fatal.err.cant.close=\u81F4\u547D\u9519\u8BEF: \u65E0\u6CD5\u5173\u95ED\u7F16\u8BD1\u5668\u8D44\u6E90 ##### @@ -659,7 +805,10 @@ compiler.misc.x.print.rounds=\u5FAA\u73AF {0}:\n\t\u8F93\u5165\u6587\u4EF6: {1}\ ## The following string will appear before all messages keyed as: ## "compiler.note". -compiler.note.note=\u6CE8:\u0020 + +compiler.note.potential.lambda.found=\u53EF\u5C06\u6B64\u533F\u540D\u5185\u90E8\u7C7B\u521B\u5EFA\u8F6C\u6362\u4E3A lambda \u8868\u8FBE\u5F0F\u3002 + +compiler.note.note=\u6CE8: # 0: file name compiler.note.deprecated.filename={0}\u4F7F\u7528\u6216\u8986\u76D6\u4E86\u5DF2\u8FC7\u65F6\u7684 API\u3002 @@ -773,12 +922,12 @@ compiler.misc.resume.abort=\u7EE7\u7EED(R), \u653E\u5F03(A)> ## ## All warning messages are preceded by the following string. -compiler.warn.warning=\u8B66\u544A:\u0020 +compiler.warn.warning=\u8B66\u544A: ## Warning messages may also include the following prefix to identify a ## lint option # 0: option name -compiler.warn.lintOption=[{0}]\u0020 +compiler.warn.lintOption=[{0}] # 0: symbol compiler.warn.constant.SVUID=serialVersionUID \u5728\u7C7B{0}\u4E2D\u5FC5\u987B\u662F\u5E38\u91CF @@ -1046,6 +1195,8 @@ compiler.misc.bad.const.pool.tag.at=\u9519\u8BEF\u7684\u5E38\u91CF\u6C60\u6807\u compiler.misc.bad.signature=\u9519\u8BEF\u7684\u7B7E\u540D: {0} +compiler.misc.bad.type.annotation.value=\u9519\u8BEF\u7684\u7C7B\u578B\u6CE8\u91CA\u76EE\u6807\u7C7B\u578B\u503C: {0} + compiler.misc.class.file.wrong.class=\u7C7B\u6587\u4EF6\u5305\u542B\u9519\u8BEF\u7684\u7C7B: {0} compiler.misc.class.file.not.found=\u627E\u4E0D\u5230{0}\u7684\u7C7B\u6587\u4EF6 @@ -1077,24 +1228,17 @@ compiler.err.not.within.bounds=\u7C7B\u578B\u53C2\u6570{0}\u4E0D\u5728\u7C7B\u57 ##### -# 0: message segment, 1: type, 2: type -compiler.err.prob.found.req={0}\n\u9700\u8981: {2}\n\u627E\u5230: {1} +# 0: message segment +compiler.err.prob.found.req=\u4E0D\u517C\u5BB9\u7684\u7C7B\u578B: {0} # 0: message segment, 1: type, 2: type compiler.warn.prob.found.req={0}\n\u9700\u8981: {2}\n\u627E\u5230: {1} -compiler.err.prob.found.req.1={0} {3}\n\u9700\u8981: {2}\n\u627E\u5230: {1} +# 0: type, 1: type +compiler.misc.inconvertible.types={0}\u65E0\u6CD5\u8F6C\u6362\u4E3A{1} -## The following are all possible strings for the first argument ({0}) of the -## above strings. -compiler.misc.incompatible.types=\u4E0D\u517C\u5BB9\u7684\u7C7B\u578B - -# 0: message segment -compiler.misc.incompatible.types.1=\u4E0D\u517C\u5BB9\u7684\u7C7B\u578B; {0} - -compiler.misc.inconvertible.types=\u4E0D\u53EF\u8F6C\u6362\u7684\u7C7B\u578B - -compiler.misc.possible.loss.of.precision=\u53EF\u80FD\u635F\u5931\u7CBE\u5EA6 +# 0: type, 1: type +compiler.misc.possible.loss.of.precision=\u4ECE{0}\u8F6C\u6362\u5230{1}\u53EF\u80FD\u4F1A\u6709\u635F\u5931 compiler.misc.unchecked.assign=\u672A\u7ECF\u68C0\u67E5\u7684\u8F6C\u6362 @@ -1104,16 +1248,13 @@ compiler.misc.unchecked.assign=\u672A\u7ECF\u68C0\u67E5\u7684\u8F6C\u6362 # assigned array cannot dynamically check its stores compiler.misc.unchecked.cast.to.type=\u672A\u7ECF\u68C0\u67E5\u7684\u8F6C\u6362 -compiler.misc.assignment.from.super-bound=\u4ECE super-bound \u7C7B\u578B{0}\u8FDB\u884C\u5206\u914D - -compiler.misc.assignment.to.extends-bound=\u5230 extends-bound \u7C7B\u578B{0}\u7684\u5206\u914D - # compiler.err.star.expected=\ # ''*'' expected # compiler.err.no.elem.type=\ # \[\*\] cannot have a type -compiler.misc.try.not.applicable.to.type=try-with-resources \u4E0D\u9002\u7528\u4E8E\u53D8\u91CF\u7C7B\u578B +# 0: type +compiler.misc.try.not.applicable.to.type=try-with-resources \u4E0D\u9002\u7528\u4E8E\u53D8\u91CF\u7C7B\u578B\n({0}) ##### @@ -1139,25 +1280,44 @@ compiler.misc.type.parameter=\u7C7B\u578B\u53C2\u6570{0} ## The following are all possible strings for the last argument of all those ## diagnostics whose key ends in ".1" -compiler.misc.undetermined.type=\u672A\u786E\u5B9A\u7684\u7C7B\u578B - -compiler.misc.type.variable.has.undetermined.type=\u7C7B\u578B\u53D8\u91CF{0}\u5E26\u6709\u672A\u786E\u5B9A\u7684\u7C7B\u578B # 0: type, 1: list of type compiler.misc.no.unique.maximal.instance.exists=\u5BF9\u4E8E\u4E0A\u9650\u4E3A{1}\u7684\u7C7B\u578B\u53D8\u91CF{0}, \u4E0D\u5B58\u5728\u552F\u4E00\u6700\u5927\u5B9E\u4F8B compiler.misc.no.unique.minimal.instance.exists=\u5BF9\u4E8E\u4E0B\u9650\u4E3A{1}\u7684\u7C7B\u578B\u53D8\u91CF{0}, \u4E0D\u5B58\u5728\u552F\u4E00\u6700\u5C0F\u5B9E\u4F8B +# 0: type, 1: list of type +compiler.misc.incompatible.upper.bounds=\u63A8\u8BBA\u53D8\u91CF {0} \u5177\u6709\u4E0D\u517C\u5BB9\u7684\u4E0A\u9650 {1} + +# 0: type, 1: list of type, 2: list of type +compiler.misc.incompatible.eq.upper.bounds=\u63A8\u8BBA\u53D8\u91CF {0} \u5177\u6709\u4E0D\u517C\u5BB9\u7684\u9650\u5236\u8303\u56F4\n\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6: {1}\n\u4E0A\u9650: {2} + +# 0: type, 1: list of type, 2: list of type +compiler.misc.incompatible.eq.lower.bounds=\u63A8\u8BBA\u53D8\u91CF{0}\u5177\u6709\u4E0D\u517C\u5BB9\u7684\u9650\u5236\u8303\u56F4\n\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6: {1}\n\u4E0B\u9650: {2} + # 0: list of type, 1: type, 2: type compiler.misc.infer.no.conforming.instance.exists=\u4E0D\u5B58\u5728\u7C7B\u578B\u53D8\u91CF{0}\u7684\u5B9E\u4F8B, \u4EE5\u4F7F{1}\u4E0E{2}\u4E00\u81F4 -# 0: list of type, 1: type, 2: type -compiler.misc.infer.no.conforming.assignment.exists=\u4E0D\u5B58\u5728\u7C7B\u578B\u53D8\u91CF{0}\u7684\u5B9E\u4F8B, \u4EE5\u4F7F\u53C2\u6570\u7C7B\u578B{1}\u4E0E\u5F62\u5F0F\u53C2\u6570\u7C7B\u578B{2}\u4E00\u81F4 +# 0: list of type, 1: message segment +compiler.misc.infer.no.conforming.assignment.exists=\u65E0\u6CD5\u63A8\u65AD\u7C7B\u578B\u53D8\u91CF {0}\n(\u53C2\u6570\u4E0D\u5339\u914D; {1}) -compiler.misc.infer.arg.length.mismatch=\u65E0\u6CD5\u4ECE\u53C2\u6570\u8FDB\u884C\u5B9E\u4F8B\u5316, \u56E0\u4E3A\u5B9E\u9645\u53C2\u6570\u5217\u8868\u548C\u5F62\u5F0F\u53C2\u6570\u5217\u8868\u957F\u5EA6\u4E0D\u540C +# 0: list of type +compiler.misc.infer.arg.length.mismatch=\u65E0\u6CD5\u63A8\u65AD\u7C7B\u578B\u53D8\u91CF {0}\n(\u5B9E\u9645\u53C2\u6570\u5217\u8868\u548C\u5F62\u5F0F\u53C2\u6570\u5217\u8868\u957F\u5EA6\u4E0D\u540C) + +# 0: list of type, 1: message segment +compiler.misc.infer.varargs.argument.mismatch=\u65E0\u6CD5\u63A8\u65AD\u7C7B\u578B\u53D8\u91CF {0}\n(varargs \u4E0D\u5339\u914D; {1}) # 0: type, 1: list of type -compiler.misc.inferred.do.not.conform.to.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u58F0\u660E\u7684\u8303\u56F4\n\u63A8\u65AD: {0}\n\u8303\u56F4: {1} +compiler.misc.inferred.do.not.conform.to.upper.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u4E0A\u9650\n\u63A8\u65AD: {0}\n\u4E0A\u9650: {1} + +# 0: type, 1: list of type +compiler.misc.inferred.do.not.conform.to.lower.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u4E0B\u9650\n\u63A8\u65AD: {0}\n\u4E0B\u9650: {1} + +# 0: type, 1: list of type +compiler.misc.inferred.do.not.conform.to.eq.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6\n\u63A8\u65AD: {0}\n\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6: {1} + +# 0: list of type +compiler.misc.cyclic.inference=\u7531\u4E8E\u63A8\u8BBA\u5FAA\u73AF, \u65E0\u6CD5\u5B9E\u4F8B\u5316\u63A8\u8BBA\u53D8\u91CF{0} # 0: symbol compiler.misc.diamond={0}<> @@ -1165,6 +1325,7 @@ compiler.misc.diamond={0}<> # 0: type compiler.misc.diamond.non.generic=\u65E0\u6CD5\u5C06 ''<>'' \u4E0E\u975E\u6CDB\u578B\u7C7B{0}\u4E00\u8D77\u4F7F\u7528 +# 0: unused compiler.misc.diamond.and.explicit.params=\u4E0D\u80FD\u5C06 ''<>'' \u4E0E\u6784\u9020\u5668\u7684\u663E\u5F0F\u7C7B\u578B\u53C2\u6570\u4E00\u8D77\u4F7F\u7528 # 0: type, 1: list of type @@ -1172,14 +1333,18 @@ compiler.misc.explicit.param.do.not.conform.to.bounds=\u663E\u5F0F\u7C7B\u578B\u compiler.misc.arg.length.mismatch=\u5B9E\u9645\u53C2\u6570\u5217\u8868\u548C\u5F62\u5F0F\u53C2\u6570\u5217\u8868\u957F\u5EA6\u4E0D\u540C -# 0: type, 1: type -compiler.misc.no.conforming.assignment.exists=\u65E0\u6CD5\u901A\u8FC7\u65B9\u6CD5\u8C03\u7528\u8F6C\u6362\u5C06\u5B9E\u9645\u53C2\u6570{0}\u8F6C\u6362\u4E3A{1} +# 0: message segment +compiler.misc.no.conforming.assignment.exists=\u53C2\u6570\u4E0D\u5339\u914D; {0} -# 0: type, 1: type -compiler.misc.varargs.argument.mismatch=\u53C2\u6570\u7C7B\u578B{0}\u4E0D\u7B26\u5408 vararg \u5143\u7D20\u7C7B\u578B{1} +# 0: message segment +compiler.misc.varargs.argument.mismatch=varargs \u4E0D\u5339\u914D; {0} ##### +# 0: type, 1: file name +compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file={1} \u4E2D\u7684\u8F85\u52A9\u7C7B{0}\u4E0D\u5E94\u4ECE\u5176\u81EA\u8EAB\u7684\u6E90\u6587\u4EF6\u4EE5\u5916\u8BBF\u95EE + + ## The first argument ({0}) is a "kindname". # 0: symbol kind, 1: symbol, 2: symbol compiler.err.abstract.cant.be.accessed.directly=\u65E0\u6CD5\u76F4\u63A5\u8BBF\u95EE{2}\u4E2D\u7684\u62BD\u8C61{0} {1} @@ -1188,10 +1353,17 @@ compiler.err.abstract.cant.be.accessed.directly=\u65E0\u6CD5\u76F4\u63A5\u8BBF\u # 0: symbol kind, 1: symbol compiler.err.non-static.cant.be.ref=\u65E0\u6CD5\u4ECE\u9759\u6001\u4E0A\u4E0B\u6587\u4E2D\u5F15\u7528\u975E\u9759\u6001 {0} {1} +# 0: symbol kind, 1: symbol +compiler.misc.non-static.cant.be.ref=\u65E0\u6CD5\u4ECE\u9759\u6001\u4E0A\u4E0B\u6587\u4E2D\u5F15\u7528\u975E\u9759\u6001 {0} {1} + ## Both arguments ({0}, {1}) are "kindname"s. {0} is a comma-separated list ## of kindnames (the list should be identical to that provided in source. compiler.err.unexpected.type=\u610F\u5916\u7684\u7C7B\u578B\n\u9700\u8981: {0}\n\u627E\u5230: {1} +compiler.err.unexpected.lambda=\u6B64\u5904\u4E0D\u5E94\u4E3A lambda \u8868\u8FBE\u5F0F + +compiler.err.unexpected.mref=\u6B64\u5904\u4E0D\u5E94\u4E3A\u65B9\u6CD5\u5F15\u7528 + ## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.) ## The second argument {1} is the non-resolved symbol ## The third argument {2} is a list of type parameters (non-empty if {1} is a method) @@ -1216,12 +1388,20 @@ compiler.err.cant.resolve.location.args=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u # 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment compiler.err.cant.resolve.location.args.params=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7: {0} <{2}>{1}({3})\n\u4F4D\u7F6E: {4} +### Following are replicated/used for method reference diagnostics + +# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment +compiler.misc.cant.resolve.location.args=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7: {0} {1}({3})\n\u4F4D\u7F6E: {4} + +# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment +compiler.misc.cant.resolve.location.args.params=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7: {0} <{2}>{1}({3})\n\u4F4D\u7F6E: {4} + ##a location subdiagnostic is composed as follows: ## The first argument {0} is the location "kindname" (e.g. 'constructor', 'field', etc.) ## The second argument {1} is the location name ## The third argument {2} is the location type (only when {1} is a variable name) -# 0: symbol kind, 1: symbol, 2: unused +# 0: symbol kind, 1: type or symbol, 2: unused compiler.misc.location={0} {1} # 0: symbol kind, 1: symbol, 2: type @@ -1256,6 +1436,10 @@ compiler.misc.kindname.class=\u7C7B compiler.misc.kindname.package=\u7A0B\u5E8F\u5305 +compiler.misc.kindname.static.init=\u9759\u6001\u521D\u59CB\u5316\u7A0B\u5E8F + +compiler.misc.kindname.instance.init=\u5B9E\u4F8B\u521D\u59CB\u5316\u7A0B\u5E8F + ##### compiler.misc.no.args=\u6CA1\u6709\u53C2\u6570 @@ -1312,6 +1496,7 @@ compiler.misc.varargs.implement={1}\u4E2D\u7684{0}\u5B9E\u73B0\u4E86{3}\u4E2D\u7 # 0: symbol, 1: symbol, 2: symbol, 3: symbol compiler.misc.varargs.clash.with={1}\u4E2D\u7684{0}\u8986\u76D6\u4E86{3}\u4E2D\u7684{2} +# 0: unused compiler.misc.diamond.and.anon.class=\u65E0\u6CD5\u5C06 ''<>'' \u4E0E\u533F\u540D\u5185\u90E8\u7C7B\u4E00\u8D77\u4F7F\u7528 # 0: symbol kind, 1: symbol, 2: symbol, 3: message segment @@ -1336,13 +1521,23 @@ compiler.warn.enum.as.identifier=\u4ECE\u53D1\u884C\u7248 5 \u5F00\u59CB, ''enum compiler.warn.assert.as.identifier=\u4ECE\u53D1\u884C\u7248 1.4 \u5F00\u59CB, ''assert'' \u662F\u4E00\u4E2A\u5173\u952E\u5B57, \u4F46\u4E0D\u80FD\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 1.4 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u5C06 ''assert'' \u7528\u4F5C\u5173\u952E\u5B57) +compiler.warn.underscore.as.identifier=''_'' \u5DF2\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u4EE5\u540E\u7684\u53D1\u884C\u7248\u53EF\u80FD\u4E0D\u652F\u6301\u5C06 ''_'' \u7528\u4F5C\u6807\u8BC6\u7B26) + compiler.err.enum.as.identifier=\u4ECE\u53D1\u884C\u7248 5 \u5F00\u59CB, ''enum'' \u4E3A\u5173\u952E\u5B57, \u800C\u4E0D\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 1.4 \u6216\u66F4\u4F4E\u7248\u672C\u4EE5\u5C06 ''enum'' \u7528\u4F5C\u6807\u8BC6\u7B26) compiler.err.assert.as.identifier=\u4ECE\u53D1\u884C\u7248 1.4 \u5F00\u59CB, ''assert'' \u662F\u4E00\u4E2A\u5173\u952E\u5B57, \u4F46\u4E0D\u80FD\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 1.3 \u6216\u66F4\u4F4E\u7248\u672C\u4EE5\u5C06 ''assert'' \u7528\u4F5C\u6807\u8BC6\u7B26) # TODO 308: make a better error message -# compiler.err.this.as.identifier=\ -# as of release 8, ''this'' is allowed as the parameter name for the receiver type only, which has to be the first parameter +compiler.err.this.as.identifier=\u4ECE\u53D1\u884C\u7248 8 \u5F00\u59CB, ''this'' \u53EA\u80FD\u4F5C\u4E3A\u63A5\u6536\u65B9\u7C7B\u578B\u7684\u53C2\u6570\u540D, \u8BE5\u53C2\u6570\u5FC5\u987B\u4E3A\u7B2C\u4E00\u4E2A\u53C2\u6570 + +# TODO 308: make a better error message +compiler.err.cant.annotate.static.class=\u65E0\u6CD5\u5BF9\u5C01\u95ED\u9759\u6001\u5D4C\u5957\u7C7B\u8FDB\u884C\u6CE8\u91CA +# TODO 308: make a better error message +compiler.err.cant.annotate.nested.type=\u65E0\u6CD5\u5BF9\u5D4C\u5957\u7C7B\u578B\u8FDB\u884C\u6CE8\u91CA + +compiler.err.incorrect.receiver.type=\u63A5\u6536\u65B9\u7C7B\u578B\u4E0E\u5C01\u95ED\u7C7B\u7C7B\u578B\u4E0D\u5339\u914D + +compiler.err.no.annotations.on.dot.class=\u7C7B\u6587\u5B57\u7C7B\u578B\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u4EFB\u4F55\u6CE8\u91CA # 0: string compiler.err.generics.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u6CDB\u578B\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u6CDB\u578B) @@ -1353,9 +1548,8 @@ compiler.err.varargs.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u630 # 0: string compiler.err.annotations.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u6CE8\u91CA) -#308 compiler.err.type.annotations.not.supported.in.source=\ -#308 type annotations are not supported in -source {0}\n\ -#308 (use -source 8 or higher to enable type annotations) +# 0: string +compiler.err.type.annotations.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u7C7B\u578B\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u7C7B\u578B\u6CE8\u91CA) # 0: string compiler.err.foreach.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 for-each \u5FAA\u73AF\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 for-each \u5FAA\u73AF) @@ -1375,6 +1569,47 @@ compiler.err.multicatch.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u # 0: string compiler.err.string.switch.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 switch \u4E2D\u5B58\u5728\u5B57\u7B26\u4E32\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u5141\u8BB8 switch \u4E2D\u5B58\u5728\u5B57\u7B26\u4E32) +# 0: string +compiler.err.lambda.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 lambda \u8868\u8FBE\u5F0F\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 lambda \u8868\u8FBE\u5F0F) + +# 0: string +compiler.err.method.references.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u65B9\u6CD5\u5F15\u7528\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u65B9\u6CD5\u5F15\u7528) + +# 0: string +compiler.err.default.methods.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9ED8\u8BA4\u65B9\u6CD5\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9ED8\u8BA4\u65B9\u6CD5) + +# 0: string +compiler.err.intersection.types.in.cast.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u8F6C\u6362\u4E2D\u7684\u4EA4\u53C9\u7C7B\u578B\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9ED8\u8BA4\u65B9\u6CD5) + +# 0: string +compiler.err.static.intf.methods.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9759\u6001\u63A5\u53E3\u65B9\u6CD5) + +######################################## +# Diagnostics for verbose resolution +# used by Resolve (debug only) +######################################## + +# 0: number, 1: symbol, 2: unused +compiler.misc.applicable.method.found=\u627E\u5230\u7B2C {0} \u4E2A\u9002\u7528\u65B9\u6CD5: {1} + +# 0: number, 1: symbol, 2: message segment +compiler.misc.applicable.method.found.1=\u627E\u5230\u7B2C {0} \u4E2A\u9002\u7528\u65B9\u6CD5: {1}\n({2}) + +# 0: number, 1: symbol, 2: message segment +compiler.misc.not.applicable.method.found=\u627E\u5230\u7B2C {0} \u4E2A\u4E0D\u9002\u7528\u7684\u65B9\u6CD5: {1}\n({2}) + +# 0: type +compiler.misc.partial.inst.sig=\u90E8\u5206\u5B9E\u4F8B\u5316\u4E3A: {0} + +# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment +compiler.note.verbose.resolve.multi=\u5C06\u7C7B\u578B {1} \u7684\u65B9\u6CD5 {0} \u89E3\u6790\u4E3A\u5019\u9009\u9879 {2}\n\u9636\u6BB5: {3}\n\u5177\u6709\u5B9E\u9645\u503C: {4}\n\u5177\u6709\u7C7B\u578B\u53C2\u6570: {5}\n\u5019\u9009\u9879: + +# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment +compiler.note.verbose.resolve.multi.1=\u7C7B\u578B {1} \u7684\u65B9\u6CD5 {0} \u89E3\u6790\u9519\u8BEF\n\u9636\u6BB5: {3}\n\u5177\u6709\u5B9E\u9645\u503C: {4}\n\u5177\u6709\u7C7B\u578B\u53C2\u6570: {5}\n\u5019\u9009\u9879: + +# 0: symbol, 1: type, 2: type +compiler.note.deferred.method.inst=\u65B9\u6CD5 {0} \u7684\u5EF6\u8FDF\u5B9E\u4F8B\u5316\n\u5B9E\u4F8B\u5316\u7B7E\u540D: {1}\n\u76EE\u6807\u7C7B\u578B: {2} + ######################################## # Diagnostics for where clause implementation # used by the RichDiagnosticFormatter. @@ -1411,8 +1646,14 @@ compiler.misc.where.typevar={0}\u6269\u5C55\u5DF2\u5728{2} {3}\u4E2D\u58F0\u660E # compact where clause for type variable: contains the kindname ({2}) and location ({3}) # in which the typevar has been declared +# 0: type, 1: list of type, 2: symbol kind, 3: symbol compiler.misc.where.typevar.1={0}\u5DF2\u5728{2} {3}\u4E2D\u58F0\u660E +# where clause for fresh type variable: contains upper bound(s) ('extends {1}'). +# Since a fresh type-variable is synthetic - there's no location/kindname here. +# 0: type, 1: list of type +compiler.misc.where.fresh.typevar={0}\u6269\u5C55{1} + # where clause for type variable: contains all the upper bound(s) ('extends {1}') # of this intersection type # 0: type, 1: list of type @@ -1435,4 +1676,39 @@ compiler.misc.where.description.typevar.1=\u5176\u4E2D, {0}\u662F\u7C7B\u578B\u5 compiler.misc.where.description.intersection.1=\u5176\u4E2D, {0}\u662F\u4EA4\u53C9\u7C7B\u578B: +### +# errors related to doc comments + +compiler.err.dc.bad.entity=HTML \u5B9E\u4F53\u9519\u8BEF + +compiler.err.dc.bad.gt=''>'' \u7684\u7528\u6CD5\u9519\u8BEF + +compiler.err.dc.bad.inline.tag=\u5185\u5D4C\u6807\u8BB0\u7684\u7528\u6CD5\u4E0D\u6B63\u786E + +compiler.err.dc.identifier.expected=\u9700\u8981\u6807\u8BC6\u7B26 + +compiler.err.dc.malformed.html=\u683C\u5F0F\u9519\u8BEF\u7684 HTML + +compiler.err.dc.missing.semicolon=\u7F3A\u5C11\u5206\u53F7 + +compiler.err.dc.no.content=\u65E0\u5185\u5BB9 + +compiler.err.dc.no.tag.name='@' \u540E\u6CA1\u6709\u6807\u8BB0\u540D + +compiler.err.dc.gt.expected=\u9700\u8981 ''>'' + +compiler.err.dc.ref.bad.parens=\u5F15\u7528\u4E2D\u7F3A\u5C11 '')'' + +compiler.err.dc.ref.syntax.error=\u5F15\u7528\u4E2D\u51FA\u73B0\u8BED\u6CD5\u9519\u8BEF + +compiler.err.dc.ref.unexpected.input=\u610F\u5916\u7684\u6587\u672C + +compiler.err.dc.unexpected.content=\u610F\u5916\u7684\u5185\u5BB9 + +compiler.err.dc.unterminated.inline.tag=\u672A\u7EC8\u6B62\u7684\u5185\u5D4C\u6807\u8BB0 + +compiler.err.dc.unterminated.signature=\u672A\u7EC8\u6B62\u7684\u7B7E\u540D + +compiler.err.dc.unterminated.string=\u672A\u7EC8\u6B62\u7684\u5B57\u7B26\u4E32 + diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties index a368f250376..7396add6c89 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ javac.opt.g.none=\u30C7\u30D0\u30C3\u30B0\u60C5\u5831\u3092\u751F\u6210\u3057\u3 javac.opt.g.lines.vars.source=\u3044\u304F\u3064\u304B\u306E\u30C7\u30D0\u30C3\u30B0\u60C5\u5831\u306E\u307F\u3092\u751F\u6210\u3059\u308B javac.opt.nowarn=\u8B66\u544A\u3092\u767A\u751F\u3055\u305B\u306A\u3044 javac.opt.verbose=\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u52D5\u4F5C\u306B\u3064\u3044\u3066\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B -javac.opt.deprecation=\u63A8\u5968\u3055\u308C\u306A\u3044API\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u30BD\u30FC\u30B9\u306E\u4F4D\u7F6E\u3092\u51FA\u529B\u3059\u308B +javac.opt.deprecation=\u975E\u63A8\u5968\u306EAPI\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u30BD\u30FC\u30B9\u306E\u4F4D\u7F6E\u3092\u51FA\u529B\u3059\u308B javac.opt.classpath=\u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304A\u3088\u3073\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B javac.opt.sourcepath=\u5165\u529B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B javac.opt.bootclasspath=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B @@ -40,9 +40,11 @@ javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u4F4D\u7F6E\u3 javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u307F\u62E1\u5F35\u6A5F\u80FD\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B javac.opt.processorpath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B javac.opt.processor=\u5B9F\u884C\u3059\u308B\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9 +javac.opt.parameters=\u30E1\u30BD\u30C3\u30C9\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u30EA\u30D5\u30EC\u30AF\u30B7\u30E7\u30F3\u7528\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u751F\u6210\u3057\u307E\u3059 javac.opt.proc.none.only=\u6CE8\u91C8\u51E6\u7406\u3084\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u5B9F\u884C\u3059\u308B\u304B\u3069\u3046\u304B\u3092\u5236\u5FA1\u3057\u307E\u3059\u3002 javac.opt.d=\u751F\u6210\u3055\u308C\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u683C\u7D0D\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B javac.opt.sourceDest=\u751F\u6210\u3055\u308C\u305F\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u683C\u7D0D\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B +javac.opt.headerDest=\u751F\u6210\u3055\u308C\u305F\u30CD\u30A4\u30C6\u30A3\u30D6\u30FB\u30D8\u30C3\u30C0\u30FC\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u683C\u7D0D\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B javac.opt.J=\u3092\u5B9F\u884C\u30B7\u30B9\u30C6\u30E0\u306B\u76F4\u63A5\u6E21\u3059 javac.opt.encoding=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u4F7F\u7528\u3059\u308B\u6587\u5B57\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3059\u308B javac.opt.target=\u7279\u5B9A\u306EVM\u30D0\u30FC\u30B8\u30E7\u30F3\u7528\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3059\u308B @@ -61,6 +63,8 @@ javac.opt.arg.directory= javac.opt.arg.encoding= javac.opt.arg.release= javac.opt.arg.number= +javac.opt.plugin=\u5B9F\u884C\u3055\u308C\u308B\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u540D\u524D\u3068\u30AA\u30D7\u30B7\u30E7\u30F3\u5F15\u6570 +javac.opt.arg.plugin="name args" ## extended options @@ -80,6 +84,9 @@ javac.opt.arg.pathname= javac.opt.arg.file= javac.opt.Xlint=\u63A8\u5968\u306E\u8B66\u544A\u3092\u6709\u52B9\u306B\u3059\u308B javac.opt.Xlint.suboptlist=\u7279\u5B9A\u306E\u8B66\u544A\u3092\u6709\u52B9\u307E\u305F\u306F\u7121\u52B9\u306B\u3059\u308B +javac.opt.Xdoclint=javadoc\u30B3\u30E1\u30F3\u30C8\u306E\u554F\u984C\u306B\u95A2\u3059\u308B\u63A8\u5968\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3059\u308B +javac.opt.Xdoclint.subopts = (all|[-])[/] +javac.opt.Xdoclint.custom=\n javadoc\u30B3\u30E1\u30F3\u30C8\u306E\u554F\u984C\u306B\u95A2\u3059\u308B\u7279\u5B9A\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u307E\u305F\u306F\u7121\u52B9\u306B\u3057\u307E\u3059\u3002\n \u3053\u3053\u3067\u3001\u306Faccessibility\u3001html\u3001reference\u307E\u305F\u306Fsyntax\u306E\u3044\u305A\u308C\u304B\u3067\u3001\n \u306Fpublic\u3001protected\u3001package\u307E\u305F\u306Fprivate\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002 javac.opt.Xstdout=\u6A19\u6E96\u51FA\u529B\u3092\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3059\u308B javac.opt.X=\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3059\u308B javac.opt.help=\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3059\u308B @@ -107,6 +114,7 @@ javac.err.dir.not.found=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u3042\u308A\u javac.err.file.not.found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} javac.err.file.not.directory=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u306F\u3042\u308A\u307E\u305B\u3093: {0} javac.err.file.not.file=\u30D5\u30A1\u30A4\u30EB\u3067\u306F\u3042\u308A\u307E\u305B\u3093: {0} +javac.msg.plugin.not.found=\u30D7\u30E9\u30B0\u30A4\u30F3\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} ## messages javac.msg.usage.header=\u4F7F\u7528\u65B9\u6CD5: {0} \n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002 @@ -117,11 +125,13 @@ javac.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u3 javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u306B\u540C\u3058\u30D0\u30B0\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u3092\u3054\u78BA\u8A8D\u306E\u4E0A\u3001Java Developer Connection(http://java.sun.com/webapps/bugreport)\u3067\u30D0\u30B0\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 -javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n +javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n -javac.msg.proc.annotation.uncaught.exception=\n\n\u6CE8\u91C8\u51E6\u7406\u3067\u6355\u6349\u3055\u308C\u306A\u3044\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n +javac.msg.proc.annotation.uncaught.exception=\n\n\u6CE8\u91C8\u51E6\u7406\u3067\u6355\u6349\u3055\u308C\u306A\u3044\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n -javac.msg.resource=\n\n\u30B7\u30B9\u30C6\u30E0\u30FB\u30EA\u30BD\u30FC\u30B9\u304C\u4E0D\u8DB3\u3057\u3066\u3044\u307E\u3059\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n +javac.msg.plugin.uncaught.exception=\n\n\u30D7\u30E9\u30B0\u30A4\u30F3\u3067\u6355\u6349\u3055\u308C\u306A\u3044\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n + +javac.msg.resource=\n\n\u30B7\u30B9\u30C6\u30E0\u30FB\u30EA\u30BD\u30FC\u30B9\u304C\u4E0D\u8DB3\u3057\u3066\u3044\u307E\u3059\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n javac.version={0} {1} javac.fullVersion={0}\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"{1}" diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties index a2f023c735a..aa2338d344b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -40,9 +40,11 @@ javac.opt.endorseddirs=\u8986\u76D6\u7B7E\u540D\u7684\u6807\u51C6\u8DEF\u5F84\u7 javac.opt.extdirs=\u8986\u76D6\u6240\u5B89\u88C5\u6269\u5C55\u7684\u4F4D\u7F6E javac.opt.processorpath=\u6307\u5B9A\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u4F4D\u7F6E javac.opt.processor=\u8981\u8FD0\u884C\u7684\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u540D\u79F0; \u7ED5\u8FC7\u9ED8\u8BA4\u7684\u641C\u7D22\u8FDB\u7A0B +javac.opt.parameters=\u751F\u6210\u5143\u6570\u636E\u4EE5\u7528\u4E8E\u65B9\u6CD5\u53C2\u6570\u7684\u53CD\u5C04 javac.opt.proc.none.only=\u63A7\u5236\u662F\u5426\u6267\u884C\u6CE8\u91CA\u5904\u7406\u548C/\u6216\u7F16\u8BD1\u3002 javac.opt.d=\u6307\u5B9A\u653E\u7F6E\u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E javac.opt.sourceDest=\u6307\u5B9A\u653E\u7F6E\u751F\u6210\u7684\u6E90\u6587\u4EF6\u7684\u4F4D\u7F6E +javac.opt.headerDest=\u6307\u5B9A\u653E\u7F6E\u751F\u6210\u7684\u672C\u673A\u6807\u5934\u6587\u4EF6\u7684\u4F4D\u7F6E javac.opt.J=\u76F4\u63A5\u5C06 <\u6807\u8BB0> \u4F20\u9012\u7ED9\u8FD0\u884C\u65F6\u7CFB\u7EDF javac.opt.encoding=\u6307\u5B9A\u6E90\u6587\u4EF6\u4F7F\u7528\u7684\u5B57\u7B26\u7F16\u7801 javac.opt.target=\u751F\u6210\u7279\u5B9A VM \u7248\u672C\u7684\u7C7B\u6587\u4EF6 @@ -61,6 +63,8 @@ javac.opt.arg.directory=<\u76EE\u5F55> javac.opt.arg.encoding=<\u7F16\u7801> javac.opt.arg.release=<\u53D1\u884C\u7248> javac.opt.arg.number=<\u7F16\u53F7> +javac.opt.plugin=\u8981\u8FD0\u884C\u7684\u63D2\u4EF6\u7684\u540D\u79F0\u548C\u53EF\u9009\u53C2\u6570 +javac.opt.arg.plugin="\u540D\u79F0\u53C2\u6570" ## extended options @@ -80,6 +84,9 @@ javac.opt.arg.pathname=<\u8DEF\u5F84\u540D> javac.opt.arg.file=<\u6587\u4EF6\u540D> javac.opt.Xlint=\u542F\u7528\u5EFA\u8BAE\u7684\u8B66\u544A javac.opt.Xlint.suboptlist=\u542F\u7528\u6216\u7981\u7528\u7279\u5B9A\u7684\u8B66\u544A +javac.opt.Xdoclint=\u4E3A javadoc \u6CE8\u91CA\u4E2D\u7684\u95EE\u9898\u542F\u7528\u5EFA\u8BAE\u7684\u68C0\u67E5 +javac.opt.Xdoclint.subopts = (all|[-])[/] +javac.opt.Xdoclint.custom=\n \u4E3A javadoc \u6CE8\u91CA\u4E2D\u7684\u95EE\u9898\u542F\u7528\u6216\u7981\u7528\u7279\u5B9A\u68C0\u67E5,\n \u5176\u4E2D \u4E3A\u53EF\u8BBF\u95EE\u6027, html, \u5F15\u7528\u6216\u8BED\u6CD5\u4E4B\u4E00,\n \u4E3A public, protected, package \u6216 private \u4E4B\u4E00\u3002 javac.opt.Xstdout=\u91CD\u5B9A\u5411\u6807\u51C6\u8F93\u51FA javac.opt.X=\u8F93\u51FA\u975E\u6807\u51C6\u9009\u9879\u7684\u63D0\u8981 javac.opt.help=\u8F93\u51FA\u6807\u51C6\u9009\u9879\u7684\u63D0\u8981 @@ -107,6 +114,7 @@ javac.err.dir.not.found=\u627E\u4E0D\u5230\u76EE\u5F55: {0} javac.err.file.not.found=\u627E\u4E0D\u5230\u6587\u4EF6: {0} javac.err.file.not.directory=\u4E0D\u662F\u76EE\u5F55: {0} javac.err.file.not.file=\u4E0D\u662F\u6587\u4EF6: {0} +javac.msg.plugin.not.found=\u627E\u4E0D\u5230\u63D2\u4EF6: {0} ## messages javac.msg.usage.header=\u7528\u6CD5: {0} \n\u5176\u4E2D, \u53EF\u80FD\u7684\u9009\u9879\u5305\u62EC: @@ -121,6 +129,8 @@ javac.msg.io=\n\n\u53D1\u751F\u8F93\u5165/\u8F93\u51FA\u9519\u8BEF\u3002\n\u6709 javac.msg.proc.annotation.uncaught.exception=\n\n\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u629B\u51FA\u672A\u6355\u83B7\u7684\u5F02\u5E38\u9519\u8BEF\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n +javac.msg.plugin.uncaught.exception=\n\n\u63D2\u4EF6\u629B\u51FA\u672A\u6355\u83B7\u7684\u5F02\u5E38\u9519\u8BEF\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n + javac.msg.resource=\n\n\u7CFB\u7EDF\u8D44\u6E90\u4E0D\u8DB3\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n javac.version={0} {1} diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties index 72a9992fef3..22938542182 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties +++ b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties @@ -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 @@ -37,7 +37,6 @@ main.No_packages_or_classes_specified=\u30D1\u30C3\u30B1\u30FC\u30B8\u307E\u305F main.incompatible.access.flags=-public\u3001-private\u3001-package\u307E\u305F\u306F-protected\u306E\u3046\u3061\u306E2\u3064\u4EE5\u4E0A\u3092\u6307\u5B9A\u3057\u307E\u3057\u305F\u3002 main.cant.read={0}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093 main.Loading_source_files_for_package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059... -main.Loading_source_file_for_class=\u30AF\u30E9\u30B9{0}\u306E\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059... main.Loading_source_file=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059... main.Building_tree=Javadoc\u60C5\u5831\u3092\u69CB\u7BC9\u3057\u3066\u3044\u307E\u3059... main.no_source_files_for_package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u3042\u308A\u307E\u305B\u3093 @@ -67,13 +66,12 @@ tag.see.missing_sharp=\u30BF\u30B0{0}: ''#''\u304C\u3042\u308A\u307E\u305B\u3093 tag.see.can_not_find_member=\u30BF\u30B0{0}: {2}\u3067{1}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 tag.see.no_close_bracket_on_url=\u30BF\u30B0{0}: \u9589\u3058\u30BF\u30B0''>''\u304C\u3042\u308A\u307E\u305B\u3093: "{1}" tag.see.no_close_quote=\u30BF\u30B0{0}: \u9589\u3058\u5F15\u7528\u7B26\u304C\u3042\u308A\u307E\u305B\u3093: "{1}" -tag.see.class_not_found=@see\u30BF\u30B0\u7528\u306E\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: "{1}" tag.see.class_not_specified=\u30BF\u30B0{0}: \u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093: "{1}" tag.see.illegal_character=\u30BF\u30B0{0}: "{2}"\u306B\u4E0D\u6B63\u306A\u6587\u5B57"{1}"\u304C\u3042\u308A\u307E\u3059 tag.see.malformed_see_tag=\u30BF\u30B0{0}: \u66F8\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093: "{1}" -tag.throws.exception_not_found={0}\u30BF\u30B0\u3001\u30AF\u30E9\u30B9{1}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 tag.End_delimiter_missing_for_possible_SeeTag=\u30B3\u30E1\u30F3\u30C8\u6587\u5B57\u5217"{0}"\u3067\u3001\u6709\u52B9\u306Asee\u30BF\u30B0\u306B\u7D42\u7AEF\u30C7\u30EA\u30DF\u30BF}\u304C\u3042\u308A\u307E\u305B\u3093 tag.Improper_Use_Of_Link_Tag=\u30A4\u30F3\u30E9\u30A4\u30F3\u30FB\u30BF\u30B0"{0}"\u306B\u7D42\u4E86\u6587\u5B57''}''\u304C\u3042\u308A\u307E\u305B\u3093 +tag.serialField.illegal_character=@serialField\u30BF\u30B0\u306B\u4E0D\u6B63\u306A\u6587\u5B57{0}\u304C\u3042\u308A\u307E\u3059: {1}\u3002 javadoc.File_Read_Error=\u30D5\u30A1\u30A4\u30EB{0}\u306E\u8AAD\u8FBC\u307F\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F javadoc.Body_missing_from_html_file=HTML\u306Bbody\u30BF\u30B0\u304C\u3042\u308A\u307E\u305B\u3093 javadoc.End_body_missing_from_html_file=HTML\u30D5\u30A1\u30A4\u30EB\u306Bbody\u306E\u9589\u3058\u30BF\u30B0\u304C\u3042\u308A\u307E\u305B\u3093 @@ -81,4 +79,8 @@ javadoc.Multiple_package_comments=\u30D1\u30C3\u30B1\u30FC\u30B8"{0}"\u306B\u890 javadoc.class_not_found=\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 javadoc.error=\u30A8\u30E9\u30FC javadoc.warning=\u8B66\u544A -tag.serialField.illegal_character=@serialField\u30BF\u30B0\u306B\u4E0D\u6B63\u306A\u6587\u5B57{0}\u304C\u3042\u308A\u307E\u3059: {1}\u3002 + +javadoc.error.msg={0}: \u30A8\u30E9\u30FC - {1} +javadoc.warning.msg={0}: \u8B66\u544A - {1} +javadoc.note.msg = {1} +javadoc.note.pos.msg= {0}: {1} diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties index 1e66cd12366..bb16ec27d9b 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties +++ b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties @@ -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 @@ -37,7 +37,6 @@ main.No_packages_or_classes_specified=\u672A\u6307\u5B9A\u7A0B\u5E8F\u5305\u6216 main.incompatible.access.flags=\u6307\u5B9A\u4E86\u591A\u4E2A -public, -private, -package \u6216 -protected\u3002 main.cant.read=\u65E0\u6CD5\u8BFB\u53D6{0} main.Loading_source_files_for_package=\u6B63\u5728\u52A0\u8F7D\u7A0B\u5E8F\u5305{0}\u7684\u6E90\u6587\u4EF6... -main.Loading_source_file_for_class=\u6B63\u5728\u52A0\u8F7D\u7C7B{0}\u7684\u6E90\u6587\u4EF6... main.Loading_source_file=\u6B63\u5728\u52A0\u8F7D\u6E90\u6587\u4EF6{0}... main.Building_tree=\u6B63\u5728\u6784\u9020 Javadoc \u4FE1\u606F... main.no_source_files_for_package=\u6CA1\u6709\u7A0B\u5E8F\u5305{0}\u7684\u6E90\u6587\u4EF6 @@ -67,13 +66,12 @@ tag.see.missing_sharp=\u6807\u8BB0{0}: \u7F3A\u5C11 ''#'': "{1}" tag.see.can_not_find_member=\u6807\u8BB0{0}: \u5728{2}\u4E2D\u627E\u4E0D\u5230{1} tag.see.no_close_bracket_on_url=\u6807\u8BB0{0}: \u7F3A\u5C11\u6700\u540E\u7684 ''>'': "{1}" tag.see.no_close_quote=\u6807\u8BB0{0}: \u65E0\u53F3\u5F15\u53F7: "{1}" -tag.see.class_not_found=\u627E\u4E0D\u5230 @see \u6807\u8BB0\u7684\u7C7B{0}: "{1}" tag.see.class_not_specified=\u6807\u8BB0{0}: \u672A\u6307\u5B9A\u7C7B: "{1}" tag.see.illegal_character=\u6807\u8BB0{0}: "{2}" \u4E2D\u7684 "{1}" \u4E3A\u975E\u6CD5\u5B57\u7B26 tag.see.malformed_see_tag=\u6807\u8BB0{0}: \u683C\u5F0F\u9519\u8BEF: "{1}" -tag.throws.exception_not_found=\u6807\u8BB0{0}: \u627E\u4E0D\u5230\u7C7B{1}\u3002 tag.End_delimiter_missing_for_possible_SeeTag=\u6CE8\u91CA\u5B57\u7B26\u4E32\u4E2D\u53EF\u80FD\u51FA\u73B0\u7684 See \u6807\u8BB0\u7F3A\u5C11\u7ED3\u675F\u5206\u9694\u7B26 }: "{0}" tag.Improper_Use_Of_Link_Tag=\u5185\u5D4C\u6807\u8BB0\u7F3A\u5C11\u7ED3\u675F ''}'' \u5B57\u7B26: "{0}" +tag.serialField.illegal_character=@serialField \u6807\u8BB0\u4E2D\u7684\u975E\u6CD5\u5B57\u7B26 {0}: {1}\u3002 javadoc.File_Read_Error=\u8BFB\u53D6\u6587\u4EF6{0}\u65F6\u51FA\u9519 javadoc.Body_missing_from_html_file=HTML \u6587\u4EF6\u4E2D\u7F3A\u5C11\u4E3B\u4F53\u6807\u8BB0 javadoc.End_body_missing_from_html_file=HTML \u6587\u4EF6\u4E2D\u7F3A\u5C11\u4E3B\u4F53\u7ED3\u675F\u6807\u8BB0 @@ -81,4 +79,8 @@ javadoc.Multiple_package_comments=\u627E\u5230\u7A0B\u5E8F\u5305 "{0}" \u7684\u5 javadoc.class_not_found=\u627E\u4E0D\u5230\u7C7B{0}\u3002 javadoc.error=\u9519\u8BEF javadoc.warning=\u8B66\u544A -tag.serialField.illegal_character=@serialField \u6807\u8BB0\u4E2D\u7684\u975E\u6CD5\u5B57\u7B26 {0}: {1}\u3002 + +javadoc.error.msg={0}: \u9519\u8BEF - {1} +javadoc.warning.msg={0}: \u8B66\u544A - {1} +javadoc.note.msg = {1} +javadoc.note.pos.msg= {0}: {1} diff --git a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties index 74f9acd569f..6a5e90e7836 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties +++ b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2010, 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 @@ -33,10 +33,10 @@ at.args.io.exception=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u306E@\u5F15\u65 old.jni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-old\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 old.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-old\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 old.not.supported=\u3053\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306Ejavah\u3067\u306F\u30AA\u30D7\u30B7\u30E7\u30F3-old\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 -invalid.method.signature=\u7121\u52B9\u306A\u30E1\u30BD\u30C3\u30C9\u30FB\u30B7\u30B0\u30CB\u30C1\u30E3: {0} +invalid.method.signature=\u7121\u52B9\u306A\u30E1\u30BD\u30C3\u30C9\u30FB\u30B7\u30B0\u30CD\u30C1\u30E3: {0} jni.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 jni.no.stubs=JNI\u306F\u30B9\u30BF\u30D6\u3092\u5FC5\u8981\u3068\u3057\u307E\u305B\u3093\u3002JNI\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -jni.sigerror={0}\u306E\u7F72\u540D\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093 +jni.sigerror={0}\u306E\u30B7\u30B0\u30CD\u30C1\u30E3\u3092\u5224\u5225\u3067\u304D\u307E\u305B\u3093 dir.file.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-d\u3068-o\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 no.classes.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 no.outputfile.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 @@ -51,7 +51,7 @@ tracing.not.supported=\u8B66\u544A: \u30C8\u30EC\u30FC\u30B9\u306F\u73FE\u5728\u # usage=\u4F7F\u7528\u65B9\u6CD5: javah [options] \n\n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002\n\n\t-help \u30D8\u30EB\u30D7\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3059\u308B\n\t-classpath \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9\n\t-bootclasspath \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9\n\t-d \u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\n\t-o \u51FA\u529B\u30D5\u30A1\u30A4\u30EB(-d\u304B-o\u306E\u3069\u3061\u3089\u304B\u4E00\u65B9\u3092\u4F7F\u7528\u3059\u308B)\n\t-jni JNI\u5F62\u5F0F\u306E\u30D8\u30C3\u30C0\u30FC\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3059\u308B(\u30C7\u30D5\u30A9\u30EB\u30C8)\n\t-version \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3059\u308B\n\t-verbose \u8A73\u7D30\u306A\u51FA\u529B\u3092\u884C\u3046\n\t-force \u5E38\u306B\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u3092\u66F8\u304D\u8FBC\u3080\n\n \u306F\u5B8C\u5168\u6307\u5B9A\u306E\u540D\u524D\u3067\u6307\u5B9A\u3057\u307E\u3059\n(java.lang.Object\u306A\u3069)\u3002\n -main.usage=\u4F7F\u7528\u65B9\u6CD5: \n\ javah [options] \n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002 +main.usage=\u4F7F\u7528\u65B9\u6CD5: \n javah [options] \n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002 main.opt.o=\ -o \u51FA\u529B\u30D5\u30A1\u30A4\u30EB(-d\u304B-o\u306E\u3069\u3061\u3089\u304B\u4E00\u65B9\u3092\u4F7F\u7528\u3059\u308B) main.opt.d=\ -d \u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA main.opt.v=\ -v -verbose \u8A73\u7D30\u306A\u51FA\u529B\u3092\u884C\u3046 diff --git a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties index 8059d5e5812..995b1cad499 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties +++ b/langtools/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2010, 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 @@ -51,7 +51,7 @@ tracing.not.supported=\u8B66\u544A: \u4E0D\u518D\u652F\u6301\u8DDF\u8E2A\u3002\u # usage=\u7528\u6CD5: javah [options] \n\n\u5176\u4E2D, [options] \u5305\u62EC:\n\n\t-help \u8F93\u51FA\u6B64\u5E2E\u52A9\u6D88\u606F\u5E76\u9000\u51FA\n\t-classpath \u4ECE\u4E2D\u52A0\u8F7D\u7C7B\u7684\u8DEF\u5F84\n\t-bootclasspath \u4ECE\u4E2D\u52A0\u8F7D\u5F15\u5BFC\u7C7B\u7684\u8DEF\u5F84\n\t-d \u8F93\u51FA\u76EE\u5F55\n\t-o \u8F93\u51FA\u6587\u4EF6 (\u53EA\u80FD\u4F7F\u7528 -d \u6216 -o \u4E4B\u4E00)\n\t-jni \u751F\u6210 JNI \u6837\u5F0F\u7684\u6807\u5934\u6587\u4EF6 (\u9ED8\u8BA4\u503C)\n\t-version \u8F93\u51FA\u7248\u672C\u4FE1\u606F\n\t-verbose \u542F\u7528\u8BE6\u7EC6\u8F93\u51FA\n\t-force \u59CB\u7EC8\u5199\u5165\u8F93\u51FA\u6587\u4EF6\n\n \u662F\u4F7F\u7528\u5176\u5168\u9650\u5B9A\u540D\u79F0\u6307\u5B9A\u7684,\n(\u4F8B\u5982 java.lang.Object)\u3002\n -main.usage=\u7528\u6CD5: \n\ javah [options] \n\u5176\u4E2D, [options] \u5305\u62EC: +main.usage=\u7528\u6CD5: \n javah [options] \n\u5176\u4E2D, [options] \u5305\u62EC: main.opt.o=\ -o \u8F93\u51FA\u6587\u4EF6 (\u53EA\u80FD\u4F7F\u7528 -d \u6216 -o \u4E4B\u4E00) main.opt.d=\ -d \u8F93\u51FA\u76EE\u5F55 main.opt.v=\ -v -verbose \u542F\u7528\u8BE6\u7EC6\u8F93\u51FA From 6964a690ed9a23d4c0692da2dfbced46e1436355 Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Mon, 25 Mar 2013 17:13:26 -0700 Subject: [PATCH 064/155] 7198429: need checked categorization of caller-sensitive methods in the JDK Reviewed-by: kvn, jrose --- hotspot/src/share/vm/ci/ciMethod.cpp | 11 + hotspot/src/share/vm/ci/ciMethod.hpp | 8 +- .../share/vm/classfile/classFileParser.cpp | 11 +- .../share/vm/classfile/classFileParser.hpp | 1 + .../share/vm/classfile/classLoaderData.cpp | 7 + .../share/vm/classfile/classLoaderData.hpp | 1 + .../src/share/vm/classfile/javaClasses.hpp | 15 +- .../share/vm/classfile/systemDictionary.cpp | 11 + .../share/vm/classfile/systemDictionary.hpp | 9 +- hotspot/src/share/vm/classfile/vmSymbols.hpp | 8 +- hotspot/src/share/vm/oops/method.cpp | 32 ++- hotspot/src/share/vm/oops/method.hpp | 33 ++- hotspot/src/share/vm/opto/library_call.cpp | 160 ++++------- hotspot/src/share/vm/prims/jvm.cpp | 67 ++++- hotspot/src/share/vm/prims/methodHandles.cpp | 25 +- hotspot/src/share/vm/prims/unsafe.cpp | 269 ++++++++++-------- hotspot/src/share/vm/runtime/vframe.cpp | 49 ++-- hotspot/src/share/vm/runtime/vframe.hpp | 1 + 18 files changed, 413 insertions(+), 305 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index 0fa11470c94..646de740f8f 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -790,6 +790,17 @@ int ciMethod::scale_count(int count, float prof_factor) { return count; } + +// ------------------------------------------------------------------ +// ciMethod::is_special_get_caller_class_method +// +bool ciMethod::is_ignored_by_security_stack_walk() const { + check_is_loaded(); + VM_ENTRY_MARK; + return get_Method()->is_ignored_by_security_stack_walk(); +} + + // ------------------------------------------------------------------ // invokedynamic support diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index c98f2c0dccf..cbef39b3cdc 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -166,8 +166,9 @@ class ciMethod : public ciMetadata { // Code size for inlining decisions. int code_size_for_inlining(); - bool force_inline() { return get_Method()->force_inline(); } - bool dont_inline() { return get_Method()->dont_inline(); } + bool caller_sensitive() { return get_Method()->caller_sensitive(); } + bool force_inline() { return get_Method()->force_inline(); } + bool dont_inline() { return get_Method()->dont_inline(); } int comp_level(); int highest_osr_comp_level(); @@ -264,6 +265,9 @@ class ciMethod : public ciMetadata { int instructions_size(); int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC + // Stack walking support + bool is_ignored_by_security_stack_walk() const; + // JSR 292 support bool is_method_handle_intrinsic() const; bool is_compiled_lambda_form() const; diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 9f2a9f419a4..d1d8a692b50 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -1735,9 +1735,14 @@ ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_d Symbol* name) { vmSymbols::SID sid = vmSymbols::find_sid(name); // Privileged code can use all annotations. Other code silently drops some. - bool privileged = loader_data->is_the_null_class_loader_data() || - loader_data->is_anonymous(); + const bool privileged = loader_data->is_the_null_class_loader_data() || + loader_data->is_ext_class_loader_data() || + loader_data->is_anonymous(); switch (sid) { + case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_reflect_CallerSensitive_signature): + if (_location != _in_method) break; // only allow for methods + if (!privileged) break; // only allow in privileged code + return _method_CallerSensitive; case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature): if (_location != _in_method) break; // only allow for methods if (!privileged) break; // only allow in privileged code @@ -1775,6 +1780,8 @@ ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() { } void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) { + if (has_annotation(_method_CallerSensitive)) + m->set_caller_sensitive(true); if (has_annotation(_method_ForceInline)) m->set_force_inline(true); if (has_annotation(_method_DontInline)) diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp index 0fd8830463d..3d6046935d5 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.hpp +++ b/hotspot/src/share/vm/classfile/classFileParser.hpp @@ -119,6 +119,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { enum Location { _in_field, _in_method, _in_class }; enum ID { _unknown = 0, + _method_CallerSensitive, _method_ForceInline, _method_DontInline, _method_LambdaForm_Compiled, diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index f74f8f1ce13..b680574d952 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -321,6 +321,13 @@ ClassLoaderData::~ClassLoaderData() { } } +/** + * Returns true if this class loader data is for the extension class loader. + */ +bool ClassLoaderData::is_ext_class_loader_data() const { + return SystemDictionary::is_ext_class_loader(class_loader()); +} + Metaspace* ClassLoaderData::metaspace_non_null() { assert(!DumpSharedSpaces, "wrong metaspace!"); // If the metaspace has not been allocated, create a new one. Might want diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 8fbf454fed6..6c8906b26b7 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -191,6 +191,7 @@ class ClassLoaderData : public CHeapObj { bool is_the_null_class_loader_data() const { return this == _the_null_class_loader_data; } + bool is_ext_class_loader_data() const; // The Metaspace is created lazily so may be NULL. This // method will allocate a Metaspace if needed. diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 478509d5c66..ac0f15e2cee 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -1050,15 +1050,16 @@ class java_lang_invoke_MemberName: AllStatic { // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): enum { - MN_IS_METHOD = 0x00010000, // method (not constructor) - MN_IS_CONSTRUCTOR = 0x00020000, // constructor - MN_IS_FIELD = 0x00040000, // field - MN_IS_TYPE = 0x00080000, // nested type + MN_IS_METHOD = 0x00010000, // method (not constructor) + MN_IS_CONSTRUCTOR = 0x00020000, // constructor + MN_IS_FIELD = 0x00040000, // field + MN_IS_TYPE = 0x00080000, // nested type + MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected MN_REFERENCE_KIND_SHIFT = 24, // refKind - MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, + MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers: - MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes - MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces + MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes + MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces }; // Accessors for code generation: diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index edd3107062b..b4e4cd38bbf 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -146,6 +146,17 @@ bool SystemDictionary::is_parallelDefine(Handle class_loader) { } return false; } + +/** + * Returns true if the passed class loader is the extension class loader. + */ +bool SystemDictionary::is_ext_class_loader(Handle class_loader) { + if (class_loader.is_null()) { + return false; + } + return (class_loader->klass()->name() == vmSymbols::sun_misc_Launcher_ExtClassLoader()); +} + // ---------------------------------------------------------------------------- // Resolving of classes diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index d282fedfb4d..2fd8c5d9757 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -106,6 +106,7 @@ class SymbolPropertyTable; do_klass(ThreadDeath_klass, java_lang_ThreadDeath, Pre ) \ do_klass(Exception_klass, java_lang_Exception, Pre ) \ do_klass(RuntimeException_klass, java_lang_RuntimeException, Pre ) \ + do_klass(SecurityManager_klass, java_lang_SecurityManager, Pre ) \ do_klass(ProtectionDomain_klass, java_security_ProtectionDomain, Pre ) \ do_klass(AccessControlContext_klass, java_security_AccessControlContext, Pre ) \ do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre ) \ @@ -138,13 +139,14 @@ class SymbolPropertyTable; /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \ /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ - do_klass(lambda_MagicLambdaImpl_klass, java_lang_invoke_MagicLambdaImpl, Opt ) \ + do_klass(lambda_MagicLambdaImpl_klass, java_lang_invoke_MagicLambdaImpl, Opt ) \ do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \ do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \ do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \ do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \ do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \ do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \ + do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \ \ /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \ do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \ @@ -628,12 +630,15 @@ private: static bool is_parallelCapable(Handle class_loader); static bool is_parallelDefine(Handle class_loader); +public: + static bool is_ext_class_loader(Handle class_loader); + +private: static Klass* find_shared_class(Symbol* class_name); // Setup link to hierarchy static void add_to_hierarchy(instanceKlassHandle k, TRAPS); -private: // We pass in the hashtable index so we can calculate it outside of // the SystemDictionary_lock. diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index f28f6d4884b..1e66346eec5 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -91,6 +91,7 @@ template(java_lang_StringBuffer, "java/lang/StringBuffer") \ template(java_lang_StringBuilder, "java/lang/StringBuilder") \ template(java_lang_CharSequence, "java/lang/CharSequence") \ + template(java_lang_SecurityManager, "java/lang/SecurityManager") \ template(java_security_AccessControlContext, "java/security/AccessControlContext") \ template(java_security_ProtectionDomain, "java/security/ProtectionDomain") \ template(java_io_OutputStream, "java/io/OutputStream") \ @@ -211,6 +212,8 @@ template(sun_reflect_SerializationConstructorAccessorImpl, "sun/reflect/SerializationConstructorAccessorImpl") \ template(sun_reflect_DelegatingClassLoader, "sun/reflect/DelegatingClassLoader") \ template(sun_reflect_Reflection, "sun/reflect/Reflection") \ + template(sun_reflect_CallerSensitive, "sun/reflect/CallerSensitive") \ + template(sun_reflect_CallerSensitive_signature, "Lsun/reflect/CallerSensitive;") \ template(checkedExceptions_name, "checkedExceptions") \ template(clazz_name, "clazz") \ template(exceptionTypes_name, "exceptionTypes") \ @@ -343,6 +346,7 @@ template(contextClassLoader_name, "contextClassLoader") \ template(inheritedAccessControlContext_name, "inheritedAccessControlContext") \ template(isPrivileged_name, "isPrivileged") \ + template(getClassContext_name, "getClassContext") \ template(wait_name, "wait") \ template(checkPackageAccess_name, "checkPackageAccess") \ template(stackSize_name, "stackSize") \ @@ -463,6 +467,7 @@ template(void_classloader_signature, "()Ljava/lang/ClassLoader;") \ template(void_object_signature, "()Ljava/lang/Object;") \ template(void_class_signature, "()Ljava/lang/Class;") \ + template(void_class_array_signature, "()[Ljava/lang/Class;") \ template(void_string_signature, "()Ljava/lang/String;") \ template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \ template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\ @@ -705,9 +710,8 @@ do_intrinsic(_getLength, java_lang_reflect_Array, getLength_name, object_int_signature, F_SN) \ do_name( getLength_name, "getLength") \ \ - do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name, getCallerClass_signature, F_SN) \ + do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name, void_class_signature, F_SN) \ do_name( getCallerClass_name, "getCallerClass") \ - do_signature(getCallerClass_signature, "(I)Ljava/lang/Class;") \ \ do_intrinsic(_newArray, java_lang_reflect_Array, newArray_name, newArray_signature, F_SN) \ do_name( newArray_name, "newArray") \ diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 11ddd21f1f6..650076d8044 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -967,6 +967,32 @@ bool Method::should_not_be_cached() const { return false; } + +/** + * Returns true if this is one of the specially treated methods for + * security related stack walks (like Reflection.getCallerClass). + */ +bool Method::is_ignored_by_security_stack_walk() const { + const bool use_new_reflection = JDK_Version::is_gte_jdk14x_version() && UseNewReflection; + + assert(intrinsic_id() != vmIntrinsics::_invoke || Universe::reflect_invoke_cache()->is_same_method((Method*)this), "sanity"); + if (intrinsic_id() == vmIntrinsics::_invoke) { + // This is Method.invoke() -- ignore it + return true; + } + if (use_new_reflection && + method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { + // This is an auxilary frame -- ignore it + return true; + } + if (is_method_handle_intrinsic() || is_compiled_lambda_form()) { + // This is an internal adapter frame for method handles -- ignore it + return true; + } + return false; +} + + // Constant pool structure for invoke methods: enum { _imcp_invoke_name = 1, // utf8: 'invokeExact', etc. @@ -1178,13 +1204,13 @@ vmSymbols::SID Method::klass_id_for_intrinsics(Klass* holder) { // because we are not loading from core libraries // exception: the AES intrinsics come from lib/ext/sunjce_provider.jar // which does not use the class default class loader so we check for its loader here - if ((InstanceKlass::cast(holder)->class_loader() != NULL) && - InstanceKlass::cast(holder)->class_loader()->klass()->name() != vmSymbols::sun_misc_Launcher_ExtClassLoader()) { + InstanceKlass* ik = InstanceKlass::cast(holder); + if ((ik->class_loader() != NULL) && !SystemDictionary::is_ext_class_loader(ik->class_loader())) { return vmSymbols::NO_SID; // regardless of name, no intrinsics here } // see if the klass name is well-known: - Symbol* klass_name = InstanceKlass::cast(holder)->name(); + Symbol* klass_name = ik->name(); return vmSymbols::find_sid(klass_name); } diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp index 0c6203fc624..ea92383d1c2 100644 --- a/hotspot/src/share/vm/oops/method.hpp +++ b/hotspot/src/share/vm/oops/method.hpp @@ -118,11 +118,12 @@ class Method : public Metadata { #endif u2 _method_size; // size of this object u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none) - u1 _jfr_towrite : 1, // Flags - _force_inline : 1, - _hidden : 1, - _dont_inline : 1, - : 4; + u1 _jfr_towrite : 1, // Flags + _caller_sensitive : 1, + _force_inline : 1, + _hidden : 1, + _dont_inline : 1, + : 3; u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting u2 _number_of_breakpoints; // fullspeed debugging support InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations @@ -618,6 +619,9 @@ class Method : public Metadata { // Reflection support bool is_overridden_in(Klass* k) const; + // Stack walking support + bool is_ignored_by_security_stack_walk() const; + // JSR 292 support bool is_method_handle_intrinsic() const; // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id) bool is_compiled_lambda_form() const; // intrinsic_id() == vmIntrinsics::_compiledLambdaForm @@ -705,15 +709,16 @@ class Method : public Metadata { void init_intrinsic_id(); // updates from _none if a match static vmSymbols::SID klass_id_for_intrinsics(Klass* holder); - bool jfr_towrite() { return _jfr_towrite; } - void set_jfr_towrite(bool towrite) { _jfr_towrite = towrite; } - - bool force_inline() { return _force_inline; } - void set_force_inline(bool x) { _force_inline = x; } - bool dont_inline() { return _dont_inline; } - void set_dont_inline(bool x) { _dont_inline = x; } - bool is_hidden() { return _hidden; } - void set_hidden(bool x) { _hidden = x; } + bool jfr_towrite() { return _jfr_towrite; } + void set_jfr_towrite(bool x) { _jfr_towrite = x; } + bool caller_sensitive() { return _caller_sensitive; } + void set_caller_sensitive(bool x) { _caller_sensitive = x; } + bool force_inline() { return _force_inline; } + void set_force_inline(bool x) { _force_inline = x; } + bool dont_inline() { return _dont_inline; } + void set_dont_inline(bool x) { _dont_inline = x; } + bool is_hidden() { return _hidden; } + void set_hidden(bool x) { _hidden = x; } ConstMethod::MethodType method_type() const { return _constMethod->method_type(); } diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index cdcb9417760..1f4b58ebbbb 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -231,7 +231,6 @@ class LibraryCallKit : public GraphKit { void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark); bool inline_native_clone(bool is_virtual); bool inline_native_Reflection_getCallerClass(); - bool is_method_invoke_or_aux_frame(JVMState* jvms); // Helper function for inlining native object hash method bool inline_native_hashcode(bool is_virtual, bool is_static); bool inline_native_getClass(); @@ -393,7 +392,7 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { case vmIntrinsics::_getCallerClass: if (!UseNewReflection) return NULL; if (!InlineReflectionGetCallerClass) return NULL; - if (!JDK_Version::is_gte_jdk14x_version()) return NULL; + if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return NULL; break; case vmIntrinsics::_bitCount_i: @@ -3872,13 +3871,13 @@ bool LibraryCallKit::inline_native_getClass() { } //-----------------inline_native_Reflection_getCallerClass--------------------- -// public static native Class sun.reflect.Reflection.getCallerClass(int realFramesToSkip); +// public static native Class sun.reflect.Reflection.getCallerClass(); // // In the presence of deep enough inlining, getCallerClass() becomes a no-op. // -// NOTE that this code must perform the same logic as -// vframeStream::security_get_caller_frame in that it must skip -// Method.invoke() and auxiliary frames. +// NOTE: This code must perform the same logic as JVM_GetCallerClass +// in that it must skip particular security frames and checks for +// caller sensitive methods. bool LibraryCallKit::inline_native_Reflection_getCallerClass() { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { @@ -3886,35 +3885,6 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() { } #endif - Node* caller_depth_node = argument(0); - - // The depth value must be a constant in order for the runtime call - // to be eliminated. - const TypeInt* caller_depth_type = _gvn.type(caller_depth_node)->isa_int(); - if (caller_depth_type == NULL || !caller_depth_type->is_con()) { -#ifndef PRODUCT - if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Bailing out because caller depth was not a constant"); - } -#endif - return false; - } - // Note that the JVM state at this point does not include the - // getCallerClass() frame which we are trying to inline. The - // semantics of getCallerClass(), however, are that the "first" - // frame is the getCallerClass() frame, so we subtract one from the - // requested depth before continuing. We don't inline requests of - // getCallerClass(0). - int caller_depth = caller_depth_type->get_con() - 1; - if (caller_depth < 0) { -#ifndef PRODUCT - if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Bailing out because caller depth was %d", caller_depth); - } -#endif - return false; - } - if (!jvms()->has_method()) { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { @@ -3923,95 +3893,67 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() { #endif return false; } - int _depth = jvms()->depth(); // cache call chain depth // Walk back up the JVM state to find the caller at the required - // depth. NOTE that this code must perform the same logic as - // vframeStream::security_get_caller_frame in that it must skip - // Method.invoke() and auxiliary frames. Note also that depth is - // 1-based (1 is the bottom of the inlining). - int inlining_depth = _depth; - JVMState* caller_jvms = NULL; + // depth. + JVMState* caller_jvms = jvms(); - if (inlining_depth > 0) { - caller_jvms = jvms(); - assert(caller_jvms = jvms()->of_depth(inlining_depth), "inlining_depth == our depth"); - do { - // The following if-tests should be performed in this order - if (is_method_invoke_or_aux_frame(caller_jvms)) { - // Skip a Method.invoke() or auxiliary frame - } else if (caller_depth > 0) { - // Skip real frame - --caller_depth; - } else { - // We're done: reached desired caller after skipping. - break; - } - caller_jvms = caller_jvms->caller(); - --inlining_depth; - } while (inlining_depth > 0); - } - - if (inlining_depth == 0) { + // Cf. JVM_GetCallerClass + // NOTE: Start the loop at depth 1 because the current JVM state does + // not include the Reflection.getCallerClass() frame. + for (int n = 1; caller_jvms != NULL; caller_jvms = caller_jvms->caller(), n++) { + ciMethod* m = caller_jvms->method(); + switch (n) { + case 0: + fatal("current JVM state does not include the Reflection.getCallerClass frame"); + break; + case 1: + // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass). + if (!m->caller_sensitive()) { #ifndef PRODUCT - if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Bailing out because caller depth (%d) exceeded inlining depth (%d)", caller_depth_type->get_con(), _depth); - tty->print_cr(" JVM state at this point:"); - for (int i = _depth; i >= 1; i--) { - ciMethod* m = jvms()->of_depth(i)->method(); - tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); - } - } + if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { + tty->print_cr(" Bailing out: CallerSensitive annotation expected at frame %d", n); + } #endif - return false; // Reached end of inlining + return false; // bail-out; let JVM_GetCallerClass do the work + } + break; + default: + if (!m->is_ignored_by_security_stack_walk()) { + // We have reached the desired frame; return the holder class. + // Acquire method holder as java.lang.Class and push as constant. + ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); + ciInstance* caller_mirror = caller_klass->java_mirror(); + set_result(makecon(TypeInstPtr::make(caller_mirror))); + +#ifndef PRODUCT + if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { + tty->print_cr(" Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth()); + tty->print_cr(" JVM state at this point:"); + for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { + ciMethod* m = jvms()->of_depth(i)->method(); + tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); + } + } +#endif + return true; + } + break; + } } - // Acquire method holder as java.lang.Class - ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); - ciInstance* caller_mirror = caller_klass->java_mirror(); - - // Push this as a constant - set_result(makecon(TypeInstPtr::make(caller_mirror))); - #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Succeeded: caller = %s.%s, caller depth = %d, depth = %d", caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), caller_depth_type->get_con(), _depth); + tty->print_cr(" Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth()); tty->print_cr(" JVM state at this point:"); - for (int i = _depth; i >= 1; i--) { + for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { ciMethod* m = jvms()->of_depth(i)->method(); - tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); + tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); } } #endif - return true; -} -// Helper routine for above -bool LibraryCallKit::is_method_invoke_or_aux_frame(JVMState* jvms) { - ciMethod* method = jvms->method(); - - // Is this the Method.invoke method itself? - if (method->intrinsic_id() == vmIntrinsics::_invoke) - return true; - - // Is this a helper, defined somewhere underneath MethodAccessorImpl. - ciKlass* k = method->holder(); - if (k->is_instance_klass()) { - ciInstanceKlass* ik = k->as_instance_klass(); - for (; ik != NULL; ik = ik->super()) { - if (ik->name() == ciSymbol::sun_reflect_MethodAccessorImpl() && - ik == env()->find_system_klass(ik->name())) { - return true; - } - } - } - else if (method->is_method_handle_intrinsic() || - method->is_compiled_lambda_form()) { - // This is an internal adapter frame from the MethodHandleCompiler -- skip it - return true; - } - - return false; + return false; // bail-out; let JVM_GetCallerClass do the work } bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 1c277b76ccc..e5d94c532fd 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -30,6 +30,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "gc_interface/collectedHeap.inline.hpp" +#include "interpreter/bytecode.hpp" #include "memory/oopFactory.hpp" #include "memory/universe.inline.hpp" #include "oops/fieldStreams.hpp" @@ -665,8 +666,51 @@ JVM_END JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) JVMWrapper("JVM_GetCallerClass"); - Klass* k = thread->security_get_caller_class(depth); - return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); + + // Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation. + if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) { + Klass* k = thread->security_get_caller_class(depth); + return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); + } else { + // Basic handshaking with Java_sun_reflect_Reflection_getCallerClass + assert(depth == -1, "wrong handshake depth"); + } + + // Getting the class of the caller frame. + // + // The call stack at this point looks something like this: + // + // [0] [ @CallerSensitive public sun.reflect.Reflection.getCallerClass ] + // [1] [ @CallerSensitive API.method ] + // [.] [ (skipped intermediate frames) ] + // [n] [ caller ] + vframeStream vfst(thread); + // Cf. LibraryCallKit::inline_native_Reflection_getCallerClass + for (int n = 0; !vfst.at_end(); vfst.security_next(), n++) { + Method* m = vfst.method(); + assert(m != NULL, "sanity"); + switch (n) { + case 0: + // This must only be called from Reflection.getCallerClass + if (m->intrinsic_id() != vmIntrinsics::_getCallerClass) { + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetCallerClass must only be called from Reflection.getCallerClass"); + } + // fall-through + case 1: + // Frame 0 and 1 must be caller sensitive. + if (!m->caller_sensitive()) { + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), err_msg("CallerSensitive annotation expected at frame %d", n)); + } + break; + default: + if (!m->is_ignored_by_security_stack_walk()) { + // We have reached the desired frame; return the holder class. + return (jclass) JNIHandles::make_local(env, m->method_holder()->java_mirror()); + } + break; + } + } + return NULL; JVM_END @@ -3160,11 +3204,24 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) KlassLink* first = NULL; KlassLink* last = NULL; int depth = 0; + vframeStream vfst(thread); - for(vframeStream vfst(thread); !vfst.at_end(); vfst.security_get_caller_frame(1)) { + if (SystemDictionary::reflect_CallerSensitive_klass() != NULL) { + // This must only be called from SecurityManager.getClassContext + Method* m = vfst.method(); + if (!(m->method_holder() == SystemDictionary::SecurityManager_klass() && + m->name() == vmSymbols::getClassContext_name() && + m->signature() == vmSymbols::void_class_array_signature())) { + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"); + } + } + + // Collect method holders + for (; !vfst.at_end(); vfst.security_next()) { + Method* m = vfst.method(); // Native frames are not returned - if (!vfst.method()->is_native()) { - Klass* holder = vfst.method()->method_holder(); + if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) { + Klass* holder = m->method_holder(); assert(holder->is_klass(), "just checking"); depth++; KlassLink* l = new KlassLink(KlassHandle(thread, holder)); diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index c3b58796723..54881388bd1 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -105,14 +105,15 @@ void MethodHandles::set_enabled(bool z) { // import java_lang_invoke_MemberName.* enum { - IS_METHOD = java_lang_invoke_MemberName::MN_IS_METHOD, - IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR, - IS_FIELD = java_lang_invoke_MemberName::MN_IS_FIELD, - IS_TYPE = java_lang_invoke_MemberName::MN_IS_TYPE, + IS_METHOD = java_lang_invoke_MemberName::MN_IS_METHOD, + IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR, + IS_FIELD = java_lang_invoke_MemberName::MN_IS_FIELD, + IS_TYPE = java_lang_invoke_MemberName::MN_IS_TYPE, + CALLER_SENSITIVE = java_lang_invoke_MemberName::MN_CALLER_SENSITIVE, REFERENCE_KIND_SHIFT = java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT, REFERENCE_KIND_MASK = java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK, - SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES, - SEARCH_INTERFACES = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES, + SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES, + SEARCH_INTERFACES = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES, ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE }; @@ -207,10 +208,15 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp vmindex = m->vtable_index(); } - java_lang_invoke_MemberName::set_flags(mname_oop, flags); + // @CallerSensitive annotation detected + if (m->caller_sensitive()) { + flags |= CALLER_SENSITIVE; + } + + java_lang_invoke_MemberName::set_flags( mname_oop, flags); java_lang_invoke_MemberName::set_vmtarget(mname_oop, m); - java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); // vtable/itable index - java_lang_invoke_MemberName::set_clazz(mname_oop, receiver_limit->java_mirror()); + java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index + java_lang_invoke_MemberName::set_clazz( mname_oop, receiver_limit->java_mirror()); // Note: name and type can be lazily computed by resolve_MemberName, // if Java code needs them as resolved String and MethodType objects. // The clazz must be eagerly stored, because it provides a GC @@ -940,6 +946,7 @@ JVM_END template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \ template(java_lang_invoke_MemberName,MN_IS_FIELD) \ template(java_lang_invoke_MemberName,MN_IS_TYPE) \ + template(java_lang_invoke_MemberName,MN_CALLER_SENSITIVE) \ template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \ template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \ template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \ diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 18252c15453..243570b1813 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -868,7 +868,7 @@ static inline void throw_new(JNIEnv *env, const char *ename) { env->ThrowNew(cls, msg); } -static jclass Unsafe_DefineClass(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { +static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { { // Code lifted from JDK 1.3 ClassLoader.c @@ -939,6 +939,15 @@ static jclass Unsafe_DefineClass(JNIEnv *env, jstring name, jbyteArray data, int } +UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd)) + UnsafeWrapper("Unsafe_DefineClass"); + { + ThreadToNativeFromVM ttnfv(thread); + return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd); + } +UNSAFE_END + + UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length)) UnsafeWrapper("Unsafe_DefineClass"); { @@ -949,20 +958,11 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller); jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller); - return Unsafe_DefineClass(env, name, data, offset, length, loader, pd); + return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd); } UNSAFE_END -UNSAFE_ENTRY(jclass, Unsafe_DefineClass1(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd)) - UnsafeWrapper("Unsafe_DefineClass"); - { - ThreadToNativeFromVM ttnfv(thread); - - return Unsafe_DefineClass(env, name, data, offset, length, loader, pd); - } -UNSAFE_END - #define DAC_Args CLS"[B["OBJ // define a class but do not make it known to the class loader or system dictionary // - host_class: supplies context for linkage, access control, protection domain, and class loader @@ -1323,7 +1323,7 @@ UNSAFE_END #define THR LANG"Throwable;" #define DC0_Args LANG"String;[BII" -#define DC1_Args DC0_Args LANG"ClassLoader;" "Ljava/security/ProtectionDomain;" +#define DC_Args DC0_Args LANG"ClassLoader;" "Ljava/security/ProtectionDomain;" #define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) @@ -1352,10 +1352,8 @@ UNSAFE_END -// %%% These are temporarily supported until the SDK sources -// contain the necessarily updated Unsafe.java. +// These are the methods for 1.4.0 static JNINativeMethod methods_140[] = { - {CC"getObject", CC"("OBJ"I)"OBJ"", FN_PTR(Unsafe_GetObject140)}, {CC"putObject", CC"("OBJ"I"OBJ")V", FN_PTR(Unsafe_SetObject140)}, @@ -1381,12 +1379,10 @@ static JNINativeMethod methods_140[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, - {CC"fieldOffset", CC"("FLD")I", FN_PTR(Unsafe_FieldOffset)}, //deprecated - {CC"staticFieldBase", CC"("CLS")"OBJ, FN_PTR(Unsafe_StaticFieldBaseFromClass)}, //deprecated + {CC"fieldOffset", CC"("FLD")I", FN_PTR(Unsafe_FieldOffset)}, + {CC"staticFieldBase", CC"("CLS")"OBJ, FN_PTR(Unsafe_StaticFieldBaseFromClass)}, {CC"ensureClassInitialized",CC"("CLS")V", FN_PTR(Unsafe_EnsureClassInitialized)}, {CC"arrayBaseOffset", CC"("CLS")I", FN_PTR(Unsafe_ArrayBaseOffset)}, {CC"arrayIndexScale", CC"("CLS")I", FN_PTR(Unsafe_ArrayIndexScale)}, @@ -1394,16 +1390,15 @@ static JNINativeMethod methods_140[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, {CC"throwException", CC"("THR")V", FN_PTR(Unsafe_ThrowException)} }; -// These are the old methods prior to the JSR 166 changes in 1.5.0 +// These are the methods prior to the JSR 166 changes in 1.5.0 static JNINativeMethod methods_141[] = { - {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, @@ -1429,8 +1424,6 @@ static JNINativeMethod methods_141[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, @@ -1443,7 +1436,7 @@ static JNINativeMethod methods_141[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, @@ -1451,9 +1444,8 @@ static JNINativeMethod methods_141[] = { }; -// These are the old methods prior to the JSR 166 changes in 1.6.0 +// These are the methods prior to the JSR 166 changes in 1.6.0 static JNINativeMethod methods_15[] = { - {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, {CC"getObjectVolatile",CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObjectVolatile)}, @@ -1482,8 +1474,6 @@ static JNINativeMethod methods_15[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, @@ -1496,7 +1486,7 @@ static JNINativeMethod methods_15[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, @@ -1509,15 +1499,13 @@ static JNINativeMethod methods_15[] = { }; -// These are the correct methods, moving forward: -static JNINativeMethod methods[] = { - +// These are the methods for 1.6.0 and 1.7.0 +static JNINativeMethod methods_16[] = { {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, {CC"getObjectVolatile",CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObjectVolatile)}, {CC"putObjectVolatile",CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObjectVolatile)}, - DECLARE_GETSETOOP(Boolean, Z), DECLARE_GETSETOOP(Byte, B), DECLARE_GETSETOOP(Short, S), @@ -1540,8 +1528,6 @@ static JNINativeMethod methods[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, @@ -1554,7 +1540,7 @@ static JNINativeMethod methods[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, @@ -1566,23 +1552,68 @@ static JNINativeMethod methods[] = { {CC"putOrderedObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetOrderedObject)}, {CC"putOrderedInt", CC"("OBJ"JI)V", FN_PTR(Unsafe_SetOrderedInt)}, {CC"putOrderedLong", CC"("OBJ"JJ)V", FN_PTR(Unsafe_SetOrderedLong)}, - {CC"loadFence", CC"()V", FN_PTR(Unsafe_LoadFence)}, - {CC"storeFence", CC"()V", FN_PTR(Unsafe_StoreFence)}, - {CC"fullFence", CC"()V", FN_PTR(Unsafe_FullFence)}, {CC"park", CC"(ZJ)V", FN_PTR(Unsafe_Park)}, {CC"unpark", CC"("OBJ")V", FN_PTR(Unsafe_Unpark)} +}; -// {CC"getLoadAverage", CC"([DI)I", FN_PTR(Unsafe_Loadavg)}, +// These are the methods for 1.8.0 +static JNINativeMethod methods_18[] = { + {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, + {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, + {CC"getObjectVolatile",CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObjectVolatile)}, + {CC"putObjectVolatile",CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObjectVolatile)}, -// {CC"prefetchRead", CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchRead)}, -// {CC"prefetchWrite", CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchWrite)} -// {CC"prefetchReadStatic", CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchRead)}, -// {CC"prefetchWriteStatic",CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchWrite)} + DECLARE_GETSETOOP(Boolean, Z), + DECLARE_GETSETOOP(Byte, B), + DECLARE_GETSETOOP(Short, S), + DECLARE_GETSETOOP(Char, C), + DECLARE_GETSETOOP(Int, I), + DECLARE_GETSETOOP(Long, J), + DECLARE_GETSETOOP(Float, F), + DECLARE_GETSETOOP(Double, D), + DECLARE_GETSETNATIVE(Byte, B), + DECLARE_GETSETNATIVE(Short, S), + DECLARE_GETSETNATIVE(Char, C), + DECLARE_GETSETNATIVE(Int, I), + DECLARE_GETSETNATIVE(Long, J), + DECLARE_GETSETNATIVE(Float, F), + DECLARE_GETSETNATIVE(Double, D), + + {CC"getAddress", CC"("ADR")"ADR, FN_PTR(Unsafe_GetNativeAddress)}, + {CC"putAddress", CC"("ADR""ADR")V", FN_PTR(Unsafe_SetNativeAddress)}, + + {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, + {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, + {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, + + {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, + {CC"staticFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_StaticFieldOffset)}, + {CC"staticFieldBase", CC"("FLD")"OBJ, FN_PTR(Unsafe_StaticFieldBaseFromField)}, + {CC"ensureClassInitialized",CC"("CLS")V", FN_PTR(Unsafe_EnsureClassInitialized)}, + {CC"arrayBaseOffset", CC"("CLS")I", FN_PTR(Unsafe_ArrayBaseOffset)}, + {CC"arrayIndexScale", CC"("CLS")I", FN_PTR(Unsafe_ArrayIndexScale)}, + {CC"addressSize", CC"()I", FN_PTR(Unsafe_AddressSize)}, + {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, + + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, + {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, + {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, + {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, + {CC"tryMonitorEnter", CC"("OBJ")Z", FN_PTR(Unsafe_TryMonitorEnter)}, + {CC"throwException", CC"("THR")V", FN_PTR(Unsafe_ThrowException)}, + {CC"compareAndSwapObject", CC"("OBJ"J"OBJ""OBJ")Z", FN_PTR(Unsafe_CompareAndSwapObject)}, + {CC"compareAndSwapInt", CC"("OBJ"J""I""I"")Z", FN_PTR(Unsafe_CompareAndSwapInt)}, + {CC"compareAndSwapLong", CC"("OBJ"J""J""J"")Z", FN_PTR(Unsafe_CompareAndSwapLong)}, + {CC"putOrderedObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetOrderedObject)}, + {CC"putOrderedInt", CC"("OBJ"JI)V", FN_PTR(Unsafe_SetOrderedInt)}, + {CC"putOrderedLong", CC"("OBJ"JJ)V", FN_PTR(Unsafe_SetOrderedLong)}, + {CC"park", CC"(ZJ)V", FN_PTR(Unsafe_Park)}, + {CC"unpark", CC"("OBJ")V", FN_PTR(Unsafe_Unpark)} }; JNINativeMethod loadavg_method[] = { - {CC"getLoadAverage", CC"([DI)I", FN_PTR(Unsafe_Loadavg)} + {CC"getLoadAverage", CC"([DI)I", FN_PTR(Unsafe_Loadavg)} }; JNINativeMethod prefetch_methods[] = { @@ -1592,7 +1623,7 @@ JNINativeMethod prefetch_methods[] = { {CC"prefetchWriteStatic",CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchWrite)} }; -JNINativeMethod memcopy_methods[] = { +JNINativeMethod memcopy_methods_17[] = { {CC"copyMemory", CC"("OBJ"J"OBJ"JJ)V", FN_PTR(Unsafe_CopyMemory2)}, {CC"setMemory", CC"("OBJ"JJB)V", FN_PTR(Unsafe_SetMemory2)} }; @@ -1610,6 +1641,12 @@ JNINativeMethod lform_methods[] = { {CC"shouldBeInitialized",CC"("CLS")Z", FN_PTR(Unsafe_ShouldBeInitialized)}, }; +JNINativeMethod fence_methods[] = { + {CC"loadFence", CC"()V", FN_PTR(Unsafe_LoadFence)}, + {CC"storeFence", CC"()V", FN_PTR(Unsafe_StoreFence)}, + {CC"fullFence", CC"()V", FN_PTR(Unsafe_FullFence)}, +}; + #undef CC #undef FN_PTR @@ -1622,12 +1659,32 @@ JNINativeMethod lform_methods[] = { #undef MTH #undef THR #undef DC0_Args -#undef DC1_Args +#undef DC_Args #undef DECLARE_GETSETOOP #undef DECLARE_GETSETNATIVE +/** + * Helper method to register native methods. + */ +static bool register_natives(const char* message, JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) { + int status = env->RegisterNatives(clazz, methods, nMethods); + if (status < 0 || env->ExceptionOccurred()) { + if (PrintMiscellaneous && (Verbose || WizardMode)) { + tty->print_cr("Unsafe: failed registering %s", message); + } + env->ExceptionClear(); + return false; + } else { + if (PrintMiscellaneous && (Verbose || WizardMode)) { + tty->print_cr("Unsafe: successfully registered %s", message); + } + return true; + } +} + + // This one function is exported, used by NativeLookup. // The Unsafe_xxx functions above are called only from the interpreter. // The optimizer looks at names and signatures to recognize @@ -1637,83 +1694,57 @@ JVM_ENTRY(void, JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls)) UnsafeWrapper("JVM_RegisterUnsafeMethods"); { ThreadToNativeFromVM ttnfv(thread); + + // Unsafe methods { - env->RegisterNatives(unsafecls, loadavg_method, sizeof(loadavg_method)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.6 Unsafe.loadavg not found."); - } - env->ExceptionClear(); - } - } - { - env->RegisterNatives(unsafecls, prefetch_methods, sizeof(prefetch_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.6 Unsafe.prefetchRead/Write not found."); - } - env->ExceptionClear(); - } - } - { - env->RegisterNatives(unsafecls, memcopy_methods, sizeof(memcopy_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.7 Unsafe.copyMemory not found."); - } - env->ExceptionClear(); - env->RegisterNatives(unsafecls, memcopy_methods_15, sizeof(memcopy_methods_15)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.5 Unsafe.copyMemory not found."); - } - env->ExceptionClear(); - } + bool success = false; + // We need to register the 1.6 methods first because the 1.8 methods would register fine on 1.7 and 1.6 + if (!success) { + success = register_natives("1.6 methods", env, unsafecls, methods_16, sizeof(methods_16)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.8 methods", env, unsafecls, methods_18, sizeof(methods_18)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.5 methods", env, unsafecls, methods_15, sizeof(methods_15)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.4.1 methods", env, unsafecls, methods_141, sizeof(methods_141)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.4.0 methods", env, unsafecls, methods_140, sizeof(methods_140)/sizeof(JNINativeMethod)); + } + guarantee(success, "register unsafe natives"); + } + + // Unsafe.getLoadAverage + register_natives("1.6 loadavg method", env, unsafecls, loadavg_method, sizeof(loadavg_method)/sizeof(JNINativeMethod)); + + // Prefetch methods + register_natives("1.6 prefetch methods", env, unsafecls, prefetch_methods, sizeof(prefetch_methods)/sizeof(JNINativeMethod)); + + // Memory copy methods + { + bool success = false; + if (!success) { + success = register_natives("1.7 memory copy methods", env, unsafecls, memcopy_methods_17, sizeof(memcopy_methods_17)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.5 memory copy methods", env, unsafecls, memcopy_methods_15, sizeof(memcopy_methods_15)/sizeof(JNINativeMethod)); } } + + // Unsafe.defineAnonymousClass if (EnableInvokeDynamic) { - env->RegisterNatives(unsafecls, anonk_methods, sizeof(anonk_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.7 Unsafe.defineClass (anonymous version) not found."); - } - env->ExceptionClear(); - } + register_natives("1.7 define anonymous class method", env, unsafecls, anonk_methods, sizeof(anonk_methods)/sizeof(JNINativeMethod)); } + + // Unsafe.shouldBeInitialized if (EnableInvokeDynamic) { - env->RegisterNatives(unsafecls, lform_methods, sizeof(lform_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.7 LambdaForm support in Unsafe not found."); - } - env->ExceptionClear(); - } + register_natives("1.7 LambdaForm support", env, unsafecls, lform_methods, sizeof(lform_methods)/sizeof(JNINativeMethod)); } - int status = env->RegisterNatives(unsafecls, methods, sizeof(methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.6 version of Unsafe not found."); - } - env->ExceptionClear(); - // %%% For now, be backward compatible with an older class: - status = env->RegisterNatives(unsafecls, methods_15, sizeof(methods_15)/sizeof(JNINativeMethod)); - } - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.5 version of Unsafe not found."); - } - env->ExceptionClear(); - // %%% For now, be backward compatible with an older class: - status = env->RegisterNatives(unsafecls, methods_141, sizeof(methods_141)/sizeof(JNINativeMethod)); - } - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.4.1 version of Unsafe not found."); - } - env->ExceptionClear(); - // %%% For now, be backward compatible with an older class: - status = env->RegisterNatives(unsafecls, methods_140, sizeof(methods_140)/sizeof(JNINativeMethod)); - } - guarantee(status == 0, "register unsafe natives"); + + // Fence methods + register_natives("1.8 fence methods", env, unsafecls, fence_methods, sizeof(fence_methods)/sizeof(JNINativeMethod)); } JVM_END diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index bc9ca0a419d..1b05aaa79c1 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -391,40 +391,27 @@ vframeStream::vframeStream(JavaThread* thread, frame top_frame, // Step back n frames, skip any pseudo frames in between. // This function is used in Class.forName, Class.newInstance, Method.Invoke, // AccessController.doPrivileged. -// -// NOTE that in JDK 1.4 this has been exposed to Java as -// sun.reflect.Reflection.getCallerClass(), which can be inlined. -// Inlined versions must match this routine's logic. -// Native method prefixing logic does not need to match since -// the method names don't match and inlining will not occur. -// See, for example, -// Parse::inline_native_Reflection_getCallerClass in -// opto/library_call.cpp. void vframeStreamCommon::security_get_caller_frame(int depth) { - bool use_new_reflection = JDK_Version::is_gte_jdk14x_version() && UseNewReflection; - - while (!at_end()) { - if (Universe::reflect_invoke_cache()->is_same_method(method())) { - // This is Method.invoke() -- skip it - } else if (use_new_reflection && - method()->method_holder() - ->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { - // This is an auxilary frame -- skip it - } else if (method()->is_method_handle_intrinsic() || - method()->is_compiled_lambda_form()) { - // This is an internal adapter frame for method handles -- skip it - } else { - // This is non-excluded frame, we need to count it against the depth - if (depth-- <= 0) { - // we have reached the desired depth, we are done - break; + assert(depth >= 0, err_msg("invalid depth: %d", depth)); + for (int n = 0; !at_end(); security_next()) { + if (!method()->is_ignored_by_security_stack_walk()) { + if (n == depth) { + // We have reached the desired depth; return. + return; } + n++; // this is a non-skipped frame; count it against the depth } - if (method()->is_prefixed_native()) { - skip_prefixed_method_and_wrappers(); - } else { - next(); - } + } + // NOTE: At this point there were not enough frames on the stack + // to walk to depth. Callers of this method have to check for at_end. +} + + +void vframeStreamCommon::security_next() { + if (method()->is_prefixed_native()) { + skip_prefixed_method_and_wrappers(); // calls next() + } else { + next(); } } diff --git a/hotspot/src/share/vm/runtime/vframe.hpp b/hotspot/src/share/vm/runtime/vframe.hpp index b6bf34fc940..2e7191c04b4 100644 --- a/hotspot/src/share/vm/runtime/vframe.hpp +++ b/hotspot/src/share/vm/runtime/vframe.hpp @@ -336,6 +336,7 @@ class vframeStreamCommon : StackObj { _frame = _frame.sender(&_reg_map); } while (!fill_from_frame()); } + void security_next(); bool at_end() const { return _mode == at_end_mode; } From f20cadfd8bd161011d2f59049f49b630564af33c Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Tue, 26 Mar 2013 08:42:35 +0100 Subject: [PATCH 065/155] 8010706: -Dnashorn.args system property to create command lines to wrapped nashorn.jar:s Reviewed-by: hannesw, sundar --- nashorn/docs/DEVELOPER_README | 11 +++++++++++ .../jdk/nashorn/internal/runtime/options/Options.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/nashorn/docs/DEVELOPER_README b/nashorn/docs/DEVELOPER_README index 3bd220b2a7c..d0587ce6f1a 100644 --- a/nashorn/docs/DEVELOPER_README +++ b/nashorn/docs/DEVELOPER_README @@ -13,6 +13,17 @@ properties described herein are subject to change without notice. This documentation of the system property flags assume that the default value of the flag is false, unless otherwise specified. +SYSTEM PROPERTY: -Dnashorn.args= + +This property takes as its value a space separated list of Nashorn +command line options that should be passed to Nashorn. This might be useful +in environments where it is hard to tell how a nashorn.jar is launched. + +Example: + +> java -Dnashorn.args="--lazy-complation --log=compiler" large-java-app-with-nashorn.jar +> ant -Dnashorn.args="--log=codegen" antjob + SYSTEM PROPERTY: -Dnashorn.unstable.relink.threshold=x This property controls how many call site misses are allowed before a diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java index 0f30b1a171d..3e09fa57c08 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java @@ -66,6 +66,9 @@ public final class Options { /** The options map of enabled options */ private final TreeMap> options; + /** System property that can be used for command line option propagation */ + private static final String NASHORN_ARGS_PROPERTY = "nashorn.args"; + /** * Constructor * @@ -386,6 +389,14 @@ public final class Options { final LinkedList argList = new LinkedList<>(); Collections.addAll(argList, args); + final String extra = getStringProperty(NASHORN_ARGS_PROPERTY, null); + if (extra != null) { + final StringTokenizer st = new StringTokenizer(extra); + while (st.hasMoreTokens()) { + argList.add(st.nextToken()); + } + } + while (!argList.isEmpty()) { final String arg = argList.remove(0); From 143a0039a3aaf5c44cac70e92c3963cb33190f01 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Tue, 26 Mar 2013 10:05:33 +0100 Subject: [PATCH 066/155] 8010281: Remove code that is never executed Reviewed-by: kvn, roland --- hotspot/src/share/vm/opto/ifg.cpp | 44 +++---------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp index 44828fa6ab8..c40265214dc 100644 --- a/hotspot/src/share/vm/opto/ifg.cpp +++ b/hotspot/src/share/vm/opto/ifg.cpp @@ -37,8 +37,6 @@ #include "opto/memnode.hpp" #include "opto/opcodes.hpp" -#define EXACT_PRESSURE 1 - //============================================================================= //------------------------------IFG-------------------------------------------- PhaseIFG::PhaseIFG( Arena *arena ) : Phase(Interference_Graph), _arena(arena) { @@ -445,23 +443,15 @@ static void lower_pressure( LRG *lrg, uint where, Block *b, uint *pressure, uint pressure[1] -= lrg->reg_pressure(); if( pressure[1] == (uint)FLOATPRESSURE ) { hrp_index[1] = where; -#ifdef EXACT_PRESSURE - if( pressure[1] > b->_freg_pressure ) - b->_freg_pressure = pressure[1]+1; -#else - b->_freg_pressure = (uint)FLOATPRESSURE+1; -#endif + if( pressure[1] > b->_freg_pressure ) + b->_freg_pressure = pressure[1]+1; } } else if( lrg->mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { pressure[0] -= lrg->reg_pressure(); if( pressure[0] == (uint)INTPRESSURE ) { hrp_index[0] = where; -#ifdef EXACT_PRESSURE - if( pressure[0] > b->_reg_pressure ) - b->_reg_pressure = pressure[0]+1; -#else - b->_reg_pressure = (uint)INTPRESSURE+1; -#endif + if( pressure[0] > b->_reg_pressure ) + b->_reg_pressure = pressure[0]+1; } } } @@ -526,17 +516,13 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { if (lrg.mask().is_UP() && lrg.mask_size()) { if (lrg._is_float || lrg._is_vector) { // Count float pressure pressure[1] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[1] > b->_freg_pressure ) b->_freg_pressure = pressure[1]; -#endif // Count int pressure, but do not count the SP, flags } else if( lrgs(lidx).mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { pressure[0] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[0] > b->_reg_pressure ) b->_reg_pressure = pressure[0]; -#endif } } } @@ -589,30 +575,20 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { RegMask itmp = lrgs(r).mask(); itmp.AND(*Matcher::idealreg2regmask[Op_RegI]); int iregs = itmp.Size(); -#ifdef EXACT_PRESSURE if( pressure[0]+iregs > b->_reg_pressure ) b->_reg_pressure = pressure[0]+iregs; -#endif if( pressure[0] <= (uint)INTPRESSURE && pressure[0]+iregs > (uint)INTPRESSURE ) { -#ifndef EXACT_PRESSURE - b->_reg_pressure = (uint)INTPRESSURE+1; -#endif hrp_index[0] = j-1; } // Count the float-only registers RegMask ftmp = lrgs(r).mask(); ftmp.AND(*Matcher::idealreg2regmask[Op_RegD]); int fregs = ftmp.Size(); -#ifdef EXACT_PRESSURE if( pressure[1]+fregs > b->_freg_pressure ) b->_freg_pressure = pressure[1]+fregs; -#endif if( pressure[1] <= (uint)FLOATPRESSURE && pressure[1]+fregs > (uint)FLOATPRESSURE ) { -#ifndef EXACT_PRESSURE - b->_freg_pressure = (uint)FLOATPRESSURE+1; -#endif hrp_index[1] = j-1; } } @@ -769,16 +745,12 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { if (lrg.mask().is_UP() && lrg.mask_size()) { if (lrg._is_float || lrg._is_vector) { pressure[1] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[1] > b->_freg_pressure ) b->_freg_pressure = pressure[1]; -#endif } else if( lrg.mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { pressure[0] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[0] > b->_reg_pressure ) b->_reg_pressure = pressure[0]; -#endif } } assert( pressure[0] == count_int_pressure (&liveout), "" ); @@ -794,21 +766,13 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { // the whole block is high pressure. if( pressure[0] > (uint)INTPRESSURE ) { hrp_index[0] = 0; -#ifdef EXACT_PRESSURE if( pressure[0] > b->_reg_pressure ) b->_reg_pressure = pressure[0]; -#else - b->_reg_pressure = (uint)INTPRESSURE+1; -#endif } if( pressure[1] > (uint)FLOATPRESSURE ) { hrp_index[1] = 0; -#ifdef EXACT_PRESSURE if( pressure[1] > b->_freg_pressure ) b->_freg_pressure = pressure[1]; -#else - b->_freg_pressure = (uint)FLOATPRESSURE+1; -#endif } // Compute high pressure indice; avoid landing in the middle of projnodes From 97d7f98a215734face729dbb39070d88cbd8704c Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 26 Mar 2013 18:26:19 +0530 Subject: [PATCH 067/155] 8010720: Linkage problem with java.lang.String.length() Reviewed-by: hannesw, lagergren --- .../internal/objects/NativeString.java | 13 +++++ .../runtime/linker/PrimitiveLookup.java | 1 - nashorn/test/script/basic/JDK-8010720.js | 49 +++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/script/basic/JDK-8010720.js diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeString.java b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java index b2b1cf2bcbc..5f48ad98ecb 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeString.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeString.java @@ -122,6 +122,19 @@ public final class NativeString extends ScriptObject { return value.length(); } + // This is to support length as method call as well. + @Override + protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) { + final String name = desc.getNameToken(2); + + // if str.length(), then let the bean linker handle it + if ("length".equals(name) && "getMethod".equals(operator)) { + return null; + } + + return super.findGetMethod(desc, request, operator); + } + // This is to provide array-like access to string characters without creating a NativeString wrapper. @Override protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java index 968dba91e58..eaba64f4629 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/PrimitiveLookup.java @@ -109,7 +109,6 @@ public class PrimitiveLookup { } return new GuardedInvocation(method, guard, link.getSwitchPoint()); } - assert desc.getNameTokenCount() <= 2; // Named operations would hit the return null after findProperty return null; } } diff --git a/nashorn/test/script/basic/JDK-8010720.js b/nashorn/test/script/basic/JDK-8010720.js new file mode 100644 index 00000000000..1dddf22be85 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8010720.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010, 2013, 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. + */ + +/** + * JDK-8010720: Linkage problem with java.lang.String.length() + * + * @test + * @run + */ + +var s = new java.lang.String("nashorn"); + +if (s.length() != 7) { + fail("s.length() does not return expected value"); +} + +if (s.length != 7) { + fail("s.length does not return expected value"); +} + + +if ('hello'.length() != 5) { + fail("'hello'.length() does not return expected value"); +} + +if ('hello'.length != 5) { + fail("'hello'.length does not return expected value"); +} + From feec2af7b40bf40bb149a4fcf2675b764a2cbc2d Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Tue, 26 Mar 2013 09:06:16 -0400 Subject: [PATCH 068/155] 8009595: The UseSplitVerifier option needs to be deprecated Put UseSplitVerifier option on the deprecated list. Reviewed-by: dcubed, kmo, acorn --- hotspot/src/share/vm/classfile/classFileParser.cpp | 3 +-- hotspot/src/share/vm/classfile/verifier.cpp | 3 +-- hotspot/src/share/vm/runtime/arguments.cpp | 1 + hotspot/src/share/vm/runtime/globals.hpp | 3 --- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 9f2a9f419a4..47692ac6342 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -2196,8 +2196,7 @@ methodHandle ClassFileParser::parse_method(bool is_interface, true, // is LVTT CHECK_(nullHandle)); lvtt_cnt++; - } else if (UseSplitVerifier && - _major_version >= Verifier::STACKMAP_ATTRIBUTE_MAJOR_VERSION && + } else if (_major_version >= Verifier::STACKMAP_ATTRIBUTE_MAJOR_VERSION && _cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_stack_map_table()) { // Stack map is only needed by the new verifier in JDK1.5. if (parsed_stackmap_attribute) { diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 96912df1971..f5261c5a67c 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -127,8 +127,7 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul if (TraceClassInitialization) { tty->print_cr("Start class verification for: %s", klassName); } - if (UseSplitVerifier && - klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) { + if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) { ClassVerifier split_verifier(klass, THREAD); split_verifier.verify_class(THREAD); exception_name = split_verifier.result(); diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index a2bcb956249..91561005174 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -260,6 +260,7 @@ static ObsoleteFlag obsolete_jvm_flags[] = { { "CMSRevisitStackSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "PrintRevisitStats", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "UseVectoredExceptions", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "UseSplitVerifier", JDK_Version::jdk(8), JDK_Version::jdk(9) }, #ifdef PRODUCT { "DesiredMethodLimit", JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 681a0f72d93..e73e5089bab 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -679,9 +679,6 @@ class CommandLineFlags { product(bool, UseCompilerSafepoints, true, \ "Stop at safepoints in compiled code") \ \ - product(bool, UseSplitVerifier, true, \ - "use split verifier with StackMapTable attributes") \ - \ product(bool, FailOverToOldVerifier, true, \ "fail over to old verifier when split verifier fails") \ \ From ee3ea81f6549243ed02deda33e09d9907aa380a1 Mon Sep 17 00:00:00 2001 From: Joel Borggren-Franck Date: Tue, 26 Mar 2013 15:00:34 +0100 Subject: [PATCH 069/155] 8009382: Add JVM_Get{Field|Method}TypeAnnotations Reviewed-by: dcubed, rbackman --- hotspot/make/bsd/makefiles/mapfile-vers-debug | 2 + .../make/bsd/makefiles/mapfile-vers-product | 2 + .../make/linux/makefiles/mapfile-vers-debug | 2 + .../make/linux/makefiles/mapfile-vers-product | 2 + hotspot/make/solaris/makefiles/mapfile-vers | 2 + hotspot/src/share/vm/prims/jvm.cpp | 78 +++++++++++++++---- hotspot/src/share/vm/prims/jvm.h | 8 ++ 7 files changed, 81 insertions(+), 15 deletions(-) diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-debug b/hotspot/make/bsd/makefiles/mapfile-vers-debug index 24144fe9b70..eb33112062c 100644 --- a/hotspot/make/bsd/makefiles/mapfile-vers-debug +++ b/hotspot/make/bsd/makefiles/mapfile-vers-debug @@ -135,6 +135,7 @@ SUNWprivate_1.1 { JVM_GetEnclosingMethodInfo; JVM_GetFieldAnnotations; JVM_GetFieldIxModifiers; + JVM_GetFieldTypeAnnotations; JVM_GetHostName; JVM_GetInheritedAccessControlContext; JVM_GetInterfaceVersion; @@ -156,6 +157,7 @@ SUNWprivate_1.1 { JVM_GetMethodIxSignatureUTF; JVM_GetMethodParameterAnnotations; JVM_GetMethodParameters; + JVM_GetMethodTypeAnnotations; JVM_GetPrimitiveArrayElement; JVM_GetProtectionDomain; JVM_GetSockName; diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-product b/hotspot/make/bsd/makefiles/mapfile-vers-product index c165c16e2d8..ace133748b7 100644 --- a/hotspot/make/bsd/makefiles/mapfile-vers-product +++ b/hotspot/make/bsd/makefiles/mapfile-vers-product @@ -135,6 +135,7 @@ SUNWprivate_1.1 { JVM_GetEnclosingMethodInfo; JVM_GetFieldAnnotations; JVM_GetFieldIxModifiers; + JVM_GetFieldTypeAnnotations; JVM_GetHostName; JVM_GetInheritedAccessControlContext; JVM_GetInterfaceVersion; @@ -156,6 +157,7 @@ SUNWprivate_1.1 { JVM_GetMethodIxSignatureUTF; JVM_GetMethodParameterAnnotations; JVM_GetMethodParameters; + JVM_GetMethodTypeAnnotations; JVM_GetPrimitiveArrayElement; JVM_GetProtectionDomain; JVM_GetSockName; diff --git a/hotspot/make/linux/makefiles/mapfile-vers-debug b/hotspot/make/linux/makefiles/mapfile-vers-debug index 27238f5720a..b18fb74fd9a 100644 --- a/hotspot/make/linux/makefiles/mapfile-vers-debug +++ b/hotspot/make/linux/makefiles/mapfile-vers-debug @@ -131,6 +131,7 @@ SUNWprivate_1.1 { JVM_GetEnclosingMethodInfo; JVM_GetFieldAnnotations; JVM_GetFieldIxModifiers; + JVM_GetFieldTypeAnnotations; JVM_GetHostName; JVM_GetInheritedAccessControlContext; JVM_GetInterfaceVersion; @@ -152,6 +153,7 @@ SUNWprivate_1.1 { JVM_GetMethodIxSignatureUTF; JVM_GetMethodParameterAnnotations; JVM_GetMethodParameters; + JVM_GetMethodTypeAnnotations; JVM_GetPrimitiveArrayElement; JVM_GetProtectionDomain; JVM_GetSockName; diff --git a/hotspot/make/linux/makefiles/mapfile-vers-product b/hotspot/make/linux/makefiles/mapfile-vers-product index 04531fa15aa..168d84c1e90 100644 --- a/hotspot/make/linux/makefiles/mapfile-vers-product +++ b/hotspot/make/linux/makefiles/mapfile-vers-product @@ -131,6 +131,7 @@ SUNWprivate_1.1 { JVM_GetEnclosingMethodInfo; JVM_GetFieldAnnotations; JVM_GetFieldIxModifiers; + JVM_GetFieldTypeAnnotations; JVM_GetHostName; JVM_GetInheritedAccessControlContext; JVM_GetInterfaceVersion; @@ -152,6 +153,7 @@ SUNWprivate_1.1 { JVM_GetMethodIxSignatureUTF; JVM_GetMethodParameterAnnotations; JVM_GetMethodParameters; + JVM_GetMethodTypeAnnotations; JVM_GetPrimitiveArrayElement; JVM_GetProtectionDomain; JVM_GetSockName; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers b/hotspot/make/solaris/makefiles/mapfile-vers index d58807b046d..1a0b572a5c6 100644 --- a/hotspot/make/solaris/makefiles/mapfile-vers +++ b/hotspot/make/solaris/makefiles/mapfile-vers @@ -131,6 +131,7 @@ SUNWprivate_1.1 { JVM_GetEnclosingMethodInfo; JVM_GetFieldAnnotations; JVM_GetFieldIxModifiers; + JVM_GetFieldTypeAnnotations; JVM_GetHostName; JVM_GetInheritedAccessControlContext; JVM_GetInterfaceVersion; @@ -152,6 +153,7 @@ SUNWprivate_1.1 { JVM_GetMethodIxSignatureUTF; JVM_GetMethodParameterAnnotations; JVM_GetMethodParameters; + JVM_GetMethodTypeAnnotations; JVM_GetPrimitiveArrayElement; JVM_GetProtectionDomain; JVM_GetSockName; diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index ce66961269f..4e599d8dd75 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -1457,7 +1457,7 @@ JVM_END JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls)) assert (cls != NULL, "illegal class"); JVMWrapper("JVM_GetClassAnnotations"); - ResourceMark rm(THREAD); + // Return null for arrays and primitives if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); @@ -1470,20 +1470,15 @@ JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls)) JVM_END -JVM_ENTRY(jbyteArray, JVM_GetFieldAnnotations(JNIEnv *env, jobject field)) - assert(field != NULL, "illegal field"); - JVMWrapper("JVM_GetFieldAnnotations"); - +static bool jvm_get_field_common(jobject field, fieldDescriptor& fd, TRAPS) { // some of this code was adapted from from jni_FromReflectedField - // field is a handle to a java.lang.reflect.Field object oop reflected = JNIHandles::resolve_non_null(field); oop mirror = java_lang_reflect_Field::clazz(reflected); Klass* k = java_lang_Class::as_Klass(mirror); int slot = java_lang_reflect_Field::slot(reflected); int modifiers = java_lang_reflect_Field::modifiers(reflected); - fieldDescriptor fd; KlassHandle kh(THREAD, k); intptr_t offset = InstanceKlass::cast(kh())->field_offset(slot); @@ -1491,16 +1486,29 @@ JVM_ENTRY(jbyteArray, JVM_GetFieldAnnotations(JNIEnv *env, jobject field)) // for static fields we only look in the current class if (!InstanceKlass::cast(kh())->find_local_field_from_offset(offset, true, &fd)) { assert(false, "cannot find static field"); - return NULL; // robustness + return false; } } else { // for instance fields we start with the current class and work // our way up through the superclass chain if (!InstanceKlass::cast(kh())->find_field_from_offset(offset, false, &fd)) { assert(false, "cannot find instance field"); - return NULL; // robustness + return false; } } + return true; +} + +JVM_ENTRY(jbyteArray, JVM_GetFieldAnnotations(JNIEnv *env, jobject field)) + // field is a handle to a java.lang.reflect.Field object + assert(field != NULL, "illegal field"); + JVMWrapper("JVM_GetFieldAnnotations"); + + fieldDescriptor fd; + bool gotFd = jvm_get_field_common(field, fd, CHECK_NULL); + if (!gotFd) { + return NULL; + } return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.annotations(), THREAD)); JVM_END @@ -1525,12 +1533,8 @@ static Method* jvm_get_method_common(jobject method) { Klass* k = java_lang_Class::as_Klass(mirror); Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); - if (m == NULL) { - assert(false, "cannot find method"); - return NULL; // robustness - } - - return m; + assert(m != NULL, "cannot find method"); + return m; // caller has to deal with NULL in product mode } @@ -1539,6 +1543,10 @@ JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) // method is a handle to a java.lang.reflect.Method object Method* m = jvm_get_method_common(method); + if (m == NULL) { + return NULL; + } + return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(m->annotations(), THREAD)); JVM_END @@ -1549,6 +1557,10 @@ JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject m // method is a handle to a java.lang.reflect.Method object Method* m = jvm_get_method_common(method); + if (m == NULL) { + return NULL; + } + return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(m->annotation_default(), THREAD)); JVM_END @@ -1559,6 +1571,10 @@ JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject met // method is a handle to a java.lang.reflect.Method object Method* m = jvm_get_method_common(method); + if (m == NULL) { + return NULL; + } + return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(m->parameter_annotations(), THREAD)); JVM_END @@ -1583,6 +1599,38 @@ JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls)) return NULL; JVM_END +JVM_ENTRY(jbyteArray, JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method)) + assert (method != NULL, "illegal method"); + JVMWrapper("JVM_GetMethodTypeAnnotations"); + + // method is a handle to a java.lang.reflect.Method object + Method* m = jvm_get_method_common(method); + if (m == NULL) { + return NULL; + } + + AnnotationArray* type_annotations = m->type_annotations(); + if (type_annotations != NULL) { + typeArrayOop a = Annotations::make_java_array(type_annotations, CHECK_NULL); + return (jbyteArray) JNIHandles::make_local(env, a); + } + + return NULL; +JVM_END + +JVM_ENTRY(jbyteArray, JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field)) + assert (field != NULL, "illegal field"); + JVMWrapper("JVM_GetFieldTypeAnnotations"); + + fieldDescriptor fd; + bool gotFd = jvm_get_field_common(field, fd, CHECK_NULL); + if (!gotFd) { + return NULL; + } + + return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.type_annotations(), THREAD)); +JVM_END + static void bounds_check(constantPoolHandle cp, jint index, TRAPS) { if (!cp->is_within_bounds(index)) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds"); diff --git a/hotspot/src/share/vm/prims/jvm.h b/hotspot/src/share/vm/prims/jvm.h index 52cef93077c..486b13531af 100644 --- a/hotspot/src/share/vm/prims/jvm.h +++ b/hotspot/src/share/vm/prims/jvm.h @@ -523,6 +523,14 @@ JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method); JNIEXPORT jbyteArray JNICALL JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls); +// field is a handle to a java.lang.reflect.Field object +JNIEXPORT jbyteArray JNICALL +JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field); + +// method is a handle to a java.lang.reflect.Method object +JNIEXPORT jbyteArray JNICALL +JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method); + /* * New (JDK 1.4) reflection implementation */ From 7c46953faf0f170ba173e0dd53767533f1c8470f Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Tue, 26 Mar 2013 14:11:21 -0400 Subject: [PATCH 070/155] 8010651: create.bat still builds the kernel Remove old kernel build targets and VS C++ projects created by create.bat on Windows Reviewed-by: coleenp, sla --- hotspot/make/windows/build.make | 8 ++--- hotspot/make/windows/create.bat | 4 +-- hotspot/make/windows/makefiles/compile.make | 7 ----- hotspot/make/windows/makefiles/product.make | 8 ----- hotspot/make/windows/makefiles/vm.make | 4 --- .../make/windows/projectfiles/kernel/Makefile | 27 ----------------- .../make/windows/projectfiles/kernel/vm.def | 7 ----- .../make/windows/projectfiles/kernel/vm.dsw | 29 ------------------ .../tools/ProjectCreator/BuildConfig.java | 30 ------------------- .../ProjectCreator/WinGammaPlatform.java | 6 ---- 10 files changed, 5 insertions(+), 125 deletions(-) delete mode 100644 hotspot/make/windows/projectfiles/kernel/Makefile delete mode 100644 hotspot/make/windows/projectfiles/kernel/vm.def delete mode 100644 hotspot/make/windows/projectfiles/kernel/vm.dsw diff --git a/hotspot/make/windows/build.make b/hotspot/make/windows/build.make index 8a53ee5d4b1..e2f50542523 100644 --- a/hotspot/make/windows/build.make +++ b/hotspot/make/windows/build.make @@ -110,8 +110,6 @@ VARIANT_TEXT=Server !endif !elseif "$(Variant)" == "tiered" VARIANT_TEXT=Tiered -!elseif "$(Variant)" == "kernel" -VARIANT_TEXT=Kernel !endif ######################################################################### @@ -305,9 +303,9 @@ $(variantDir)\local.make: checks checks: checkVariant checkWorkSpace checkSA checkVariant: - @ if "$(Variant)"=="" echo Need to specify "Variant=[tiered|compiler2|compiler1|kernel|core]" && false - @ if "$(Variant)" NEQ "tiered" if "$(Variant)" NEQ "compiler2" if "$(Variant)" NEQ "compiler1" if "$(Variant)" NEQ "kernel" if "$(Variant)" NEQ "core" \ - echo Need to specify "Variant=[tiered|compiler2|compiler1|kernel|core]" && false + @ if "$(Variant)"=="" echo Need to specify "Variant=[tiered|compiler2|compiler1|core]" && false + @ if "$(Variant)" NEQ "tiered" if "$(Variant)" NEQ "compiler2" if "$(Variant)" NEQ "compiler1" if "$(Variant)" NEQ "core" \ + echo Need to specify "Variant=[tiered|compiler2|compiler1|core]" && false checkWorkSpace: @ if "$(WorkSpace)"=="" echo Need to specify "WorkSpace=..." && false diff --git a/hotspot/make/windows/create.bat b/hotspot/make/windows/create.bat index ee4a1865e51..16602c8ea90 100644 --- a/hotspot/make/windows/create.bat +++ b/hotspot/make/windows/create.bat @@ -148,7 +148,7 @@ echo HotSpotJDKDist=%HotSpotJDKDist% REM This is now safe to do. :copyfiles -for /D %%i in (compiler1, compiler2, tiered, core, kernel) do ( +for /D %%i in (compiler1, compiler2, tiered, core) do ( if NOT EXIST %HotSpotBuildSpace%\%%i\generated mkdir %HotSpotBuildSpace%\%%i\generated copy %HotSpotWorkSpace%\make\windows\projectfiles\%%i\* %HotSpotBuildSpace%\%%i\generated > NUL ) @@ -156,7 +156,7 @@ copy %HotSpotWorkSpace%\make\windows\projectfiles\%%i\* %HotSpotBuildSpace%\%%i\ REM force regneration of ProjectFile if exist %ProjectFile% del %ProjectFile% -for /D %%i in (compiler1, compiler2, tiered, core, kernel) do ( +for /D %%i in (compiler1, compiler2, tiered, core) do ( echo -- %%i -- echo # Generated file! > %HotSpotBuildSpace%\%%i\local.make echo # Changing a variable below and then deleting %ProjectFile% will cause >> %HotSpotBuildSpace%\%%i\local.make diff --git a/hotspot/make/windows/makefiles/compile.make b/hotspot/make/windows/makefiles/compile.make index 38c0bd57c9a..819aae43e22 100644 --- a/hotspot/make/windows/makefiles/compile.make +++ b/hotspot/make/windows/makefiles/compile.make @@ -221,13 +221,6 @@ LD_FLAGS = /SAFESEH $(LD_FLAGS) !endif !endif -# Compile for space above time. -!if "$(Variant)" == "kernel" -PRODUCT_OPT_OPTION = /O1 /Oy- -FASTDEBUG_OPT_OPTION = /O1 /Oy- -DEBUG_OPT_OPTION = /Od -!endif - # If NO_OPTIMIZATIONS is defined in the environment, turn everything off !ifdef NO_OPTIMIZATIONS PRODUCT_OPT_OPTION = $(DEBUG_OPT_OPTION) diff --git a/hotspot/make/windows/makefiles/product.make b/hotspot/make/windows/makefiles/product.make index 2b21d1ceb58..f166f7377bf 100644 --- a/hotspot/make/windows/makefiles/product.make +++ b/hotspot/make/windows/makefiles/product.make @@ -51,13 +51,6 @@ HS_BUILD_ID=$(HS_BUILD_VER) # Force resources to be rebuilt every time $(Res_Files): FORCE -# Kernel doesn't need exported vtbl symbols. -!if "$(Variant)" == "kernel" -$(AOUT): $(Res_Files) $(Obj_Files) - $(LD) @<< - $(LD_FLAGS) /out:$@ /implib:$*.lib $(Obj_Files) $(Res_Files) -<< -!else vm.def: $(Obj_Files) sh $(WorkSpace)/make/windows/build_vm_def.sh @@ -65,7 +58,6 @@ $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) << -!endif !if "$(MT)" != "" # The previous link command created a .manifest file that we want to # insert into the linked artifact so we do not need to track it diff --git a/hotspot/make/windows/makefiles/vm.make b/hotspot/make/windows/makefiles/vm.make index 2e501a7b9f7..bd02d42fa4f 100644 --- a/hotspot/make/windows/makefiles/vm.make +++ b/hotspot/make/windows/makefiles/vm.make @@ -89,12 +89,8 @@ STACK_SIZE= # AsyncGetCallTrace is not supported on IA64 yet AGCT_EXPORT= !else -!if "$(Variant)" == "kernel" -AGCT_EXPORT= -!else AGCT_EXPORT=/export:AsyncGetCallTrace !endif -!endif # If you modify exports below please do the corresponding changes in # src/share/tools/ProjectCreator/WinGammaPlatformVC7.java diff --git a/hotspot/make/windows/projectfiles/kernel/Makefile b/hotspot/make/windows/projectfiles/kernel/Makefile deleted file mode 100644 index a11b06b3850..00000000000 --- a/hotspot/make/windows/projectfiles/kernel/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2007, 2010, 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. -# -# - -!include ../local.make - -!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile diff --git a/hotspot/make/windows/projectfiles/kernel/vm.def b/hotspot/make/windows/projectfiles/kernel/vm.def deleted file mode 100644 index b450e81fd01..00000000000 --- a/hotspot/make/windows/projectfiles/kernel/vm.def +++ /dev/null @@ -1,7 +0,0 @@ -; -; This .DEF file is a placeholder for one which is automatically -; generated during the build process. See -; make\windows\build_vm_def.sh and -; make\windows\makefiles\projectcreator.make (esp. the "-prelink" -; options). -; diff --git a/hotspot/make/windows/projectfiles/kernel/vm.dsw b/hotspot/make/windows/projectfiles/kernel/vm.dsw deleted file mode 100644 index 934f51afdb3..00000000000 --- a/hotspot/make/windows/projectfiles/kernel/vm.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "vm"=.\vm.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java index 00441dfb220..953967fccd4 100644 --- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java +++ b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java @@ -568,36 +568,6 @@ class CoreProductConfig extends ProductConfig { } } -class KernelDebugConfig extends GenericDebugConfig { - String getOptFlag() { - return getCI().getNoOptFlag(); - } - - KernelDebugConfig() { - initNames("kernel", "debug", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - - -class KernelFastDebugConfig extends GenericDebugConfig { - String getOptFlag() { - return getCI().getOptFlag(); - } - - KernelFastDebugConfig() { - initNames("kernel", "fastdebug", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} - - -class KernelProductConfig extends ProductConfig { - KernelProductConfig() { - initNames("kernel", "product", "jvm.dll"); - init(getIncludes(), getDefines()); - } -} abstract class CompilerInterface { abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java index 2cc6f542ee5..db93a27cf72 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java +++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java @@ -564,12 +564,6 @@ public abstract class WinGammaPlatform { allConfigs.add(new CoreFastDebugConfig()); allConfigs.add(new CoreProductConfig()); - if (platform.equals("Win32")) { - allConfigs.add(new KernelDebugConfig()); - allConfigs.add(new KernelFastDebugConfig()); - allConfigs.add(new KernelProductConfig()); - } - return allConfigs; } From 848ccdbdfebe031209871c1d0fcfed652c76a347 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 26 Mar 2013 12:55:26 -0700 Subject: [PATCH 071/155] 8004640: C2 assert failure in memnode.cpp: NULL+offs not RAW address Always transform AddP nodes in IdealKit by calling _gvn.transform(). Reviewed-by: roland, twisti --- hotspot/src/share/vm/opto/graphKit.cpp | 1 - hotspot/src/share/vm/opto/idealKit.cpp | 28 +++--------- hotspot/src/share/vm/opto/idealKit.hpp | 13 +++--- hotspot/src/share/vm/opto/loopnode.cpp | 12 +++--- hotspot/src/share/vm/opto/phaseX.cpp | 59 ++++++++++++++------------ 5 files changed, 48 insertions(+), 65 deletions(-) diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index cd329a211a9..028020f51de 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -3445,7 +3445,6 @@ void GraphKit::sync_kit(IdealKit& ideal) { void GraphKit::final_sync(IdealKit& ideal) { // Final sync IdealKit and graphKit. - __ drain_delay_transform(); sync_kit(ideal); } diff --git a/hotspot/src/share/vm/opto/idealKit.cpp b/hotspot/src/share/vm/opto/idealKit.cpp index 986f2e178ec..90eff2bb5d7 100644 --- a/hotspot/src/share/vm/opto/idealKit.cpp +++ b/hotspot/src/share/vm/opto/idealKit.cpp @@ -48,9 +48,9 @@ IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarati _cvstate = NULL; // We can go memory state free or else we need the entire memory state assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split"); + assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase"); int init_size = 5; _pending_cvstates = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0); - _delay_transform = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0); DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0)); if (!has_declarations) { declarations_done(); @@ -296,19 +296,16 @@ Node* IdealKit::transform(Node* n) { return delay_transform(n); } else { n = gvn().transform(n); - if (!gvn().is_IterGVN()) { - C->record_for_igvn(n); - } + C->record_for_igvn(n); return n; } } //-----------------------------delay_transform----------------------------------- Node* IdealKit::delay_transform(Node* n) { - if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) { - gvn().set_type(n, n->bottom_type()); - } - _delay_transform->push(n); + // Delay transform until IterativeGVN + gvn().set_type(n, n->bottom_type()); + C->record_for_igvn(n); return n; } @@ -332,17 +329,6 @@ void IdealKit::clear(Node* m) { for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL); } -//-----------------------------drain_delay_transform---------------------------- -void IdealKit::drain_delay_transform() { - while (_delay_transform->length() > 0) { - Node* n = _delay_transform->pop(); - gvn().transform(n); - if (!gvn().is_IterGVN()) { - C->record_for_igvn(n); - } - } -} - //-----------------------------IdealVariable---------------------------- IdealVariable::IdealVariable(IdealKit &k) { k.declare(this); @@ -351,9 +337,7 @@ IdealVariable::IdealVariable(IdealKit &k) { Node* IdealKit::memory(uint alias_idx) { MergeMemNode* mem = merged_memory(); Node* p = mem->memory_at(alias_idx); - if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) { - _gvn.set_type(p, Type::MEMORY); // must be mapped - } + _gvn.set_type(p, Type::MEMORY); // must be mapped return p; } diff --git a/hotspot/src/share/vm/opto/idealKit.hpp b/hotspot/src/share/vm/opto/idealKit.hpp index 15e4274db7c..16833c0cbfe 100644 --- a/hotspot/src/share/vm/opto/idealKit.hpp +++ b/hotspot/src/share/vm/opto/idealKit.hpp @@ -102,7 +102,6 @@ class IdealKit: public StackObj { Compile * const C; PhaseGVN &_gvn; GrowableArray* _pending_cvstates; // stack of cvstates - GrowableArray* _delay_transform; // delay invoking gvn.transform until drain Node* _cvstate; // current cvstate (control, memory and variables) uint _var_ct; // number of variables bool _delay_all_transforms; // flag forcing all transforms to be delayed @@ -121,7 +120,7 @@ class IdealKit: public StackObj { void clear(Node* m); // clear a cvstate void stop() { clear(_cvstate); } // clear current cvstate Node* delay_transform(Node* n); - Node* transform(Node* n); // gvn.transform or push node on delay list + Node* transform(Node* n); // gvn.transform or skip it Node* promote_to_phi(Node* n, Node* reg);// Promote "n" to a phi on region "reg" bool was_promoted_to_phi(Node* n, Node* reg) { return (n->is_Phi() && n->in(0) == reg); @@ -146,7 +145,6 @@ class IdealKit: public StackObj { IdealKit(GraphKit* gkit, bool delay_all_transforms = false, bool has_declarations = false); ~IdealKit() { stop(); - drain_delay_transform(); } void sync_kit(GraphKit* gkit); @@ -173,7 +171,6 @@ class IdealKit: public StackObj { void bind(Node* lab); void goto_(Node* lab, bool bind = false); void declarations_done(); - void drain_delay_transform(); Node* IfTrue(IfNode* iff) { return transform(new (C) IfTrueNode(iff)); } Node* IfFalse(IfNode* iff) { return transform(new (C) IfFalseNode(iff)); } @@ -198,7 +195,11 @@ class IdealKit: public StackObj { Node* thread() { return gvn().transform(new (C) ThreadLocalNode()); } // Pointers - Node* AddP(Node *base, Node *ptr, Node *off) { return transform(new (C) AddPNode(base, ptr, off)); } + + // Raw address should be transformed regardless 'delay_transform' flag + // to produce canonical form CastX2P(offset). + Node* AddP(Node *base, Node *ptr, Node *off) { return _gvn.transform(new (C) AddPNode(base, ptr, off)); } + Node* CmpP(Node* l, Node* r) { return transform(new (C) CmpPNode(l, r)); } #ifdef _LP64 Node* XorX(Node* l, Node* r) { return transform(new (C) XorLNode(l, r)); } @@ -208,8 +209,6 @@ class IdealKit: public StackObj { Node* URShiftX(Node* l, Node* r) { return transform(new (C) URShiftXNode(l, r)); } Node* ConX(jint k) { return (Node*)gvn().MakeConX(k); } Node* CastPX(Node* ctl, Node* p) { return transform(new (C) CastP2XNode(ctl, p)); } - // Add a fixed offset to a pointer - Node* basic_plus_adr(Node* base, Node* ptr, intptr_t offset); // Memory operations diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index 6812c62fae6..c323d02f842 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -2251,6 +2251,11 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) return; } + // clear out the dead code after build_loop_late + while (_deadlist.size()) { + _igvn.remove_globally_dead_node(_deadlist.pop()); + } + if (stop_early) { assert(do_expensive_nodes, "why are we here?"); if (process_expensive_nodes()) { @@ -2260,9 +2265,7 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) // nodes again. C->set_major_progress(); } - _igvn.optimize(); - return; } @@ -2273,11 +2276,6 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) eliminate_useless_predicates(); } - // clear out the dead code - while(_deadlist.size()) { - _igvn.remove_globally_dead_node(_deadlist.pop()); - } - #ifndef PRODUCT C->verify_graph_edges(); if (_verify_me) { // Nested verify pass? diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index 85714c4e349..a8c979662d2 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -1166,31 +1166,30 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { if (progress_state == PROCESS_INPUTS) { // After following inputs, continue to outputs _stack.set_index(PROCESS_OUTPUTS); - // Remove from iterative worklist - _worklist.remove(dead); if (!dead->is_Con()) { // Don't kill cons but uses bool recurse = false; // Remove from hash table _table.hash_delete( dead ); // Smash all inputs to 'dead', isolating him completely - for( uint i = 0; i < dead->req(); i++ ) { + for (uint i = 0; i < dead->req(); i++) { Node *in = dead->in(i); - if( in ) { // Points to something? - dead->set_req(i,NULL); // Kill the edge - if (in->outcnt() == 0 && in != C->top()) {// Made input go dead? + if (in != NULL && in != C->top()) { // Points to something? + int nrep = dead->replace_edge(in, NULL); // Kill edges + assert((nrep > 0), "sanity"); + if (in->outcnt() == 0) { // Made input go dead? _stack.push(in, PROCESS_INPUTS); // Recursively remove recurse = true; } else if (in->outcnt() == 1 && in->has_special_unique_user()) { _worklist.push(in->unique_out()); } else if (in->outcnt() <= 2 && dead->is_Phi()) { - if( in->Opcode() == Op_Region ) + if (in->Opcode() == Op_Region) { _worklist.push(in); - else if( in->is_Store() ) { + } else if (in->is_Store()) { DUIterator_Fast imax, i = in->fast_outs(imax); _worklist.push(in->fast_out(i)); i++; - if(in->outcnt() == 2) { + if (in->outcnt() == 2) { _worklist.push(in->fast_out(i)); i++; } @@ -1209,38 +1208,42 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { } } } - } - } - C->record_dead_node(dead->_idx); - if (dead->is_macro()) { - C->remove_macro_node(dead); - } - if (dead->is_expensive()) { - C->remove_expensive_node(dead); - } - + } // if (in != NULL && in != C->top()) + } // for (uint i = 0; i < dead->req(); i++) if (recurse) { continue; } - } - // Constant node that has no out-edges and has only one in-edge from - // root is usually dead. However, sometimes reshaping walk makes - // it reachable by adding use edges. So, we will NOT count Con nodes - // as dead to be conservative about the dead node count at any - // given time. - } + } // if (!dead->is_Con()) + } // if (progress_state == PROCESS_INPUTS) // Aggressively kill globally dead uses // (Rather than pushing all the outs at once, we push one at a time, // plus the parent to resume later, because of the indefinite number // of edge deletions per loop trip.) if (dead->outcnt() > 0) { - // Recursively remove + // Recursively remove output edges _stack.push(dead->raw_out(0), PROCESS_INPUTS); } else { + // Finished disconnecting all input and output edges. _stack.pop(); + // Remove dead node from iterative worklist + _worklist.remove(dead); + // Constant node that has no out-edges and has only one in-edge from + // root is usually dead. However, sometimes reshaping walk makes + // it reachable by adding use edges. So, we will NOT count Con nodes + // as dead to be conservative about the dead node count at any + // given time. + if (!dead->is_Con()) { + C->record_dead_node(dead->_idx); + } + if (dead->is_macro()) { + C->remove_macro_node(dead); + } + if (dead->is_expensive()) { + C->remove_expensive_node(dead); + } } - } + } // while (_stack.is_nonempty()) } //------------------------------subsume_node----------------------------------- From cf6d13410cad6bf1708873c5ec7740f79f5be422 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Wed, 27 Mar 2013 10:55:37 +0100 Subject: [PATCH 072/155] 8010818: NPG: Remove metaspace memory pools Reviewed-by: mgerdin, stefank --- hotspot/src/share/vm/memory/metaspace.hpp | 8 +- hotspot/src/share/vm/memory/universe.cpp | 1 - .../src/share/vm/services/memoryManager.cpp | 4 - .../src/share/vm/services/memoryManager.hpp | 10 --- hotspot/src/share/vm/services/memoryPool.cpp | 34 --------- hotspot/src/share/vm/services/memoryPool.hpp | 26 ------- .../src/share/vm/services/memoryService.cpp | 21 +----- .../src/share/vm/services/memoryService.hpp | 5 -- .../metaspace/TestMetaspaceMemoryPools.java | 75 ------------------- 9 files changed, 7 insertions(+), 177 deletions(-) delete mode 100644 hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index 56197fdd070..f704804795f 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -157,16 +157,16 @@ class Metaspace : public CHeapObj { class MetaspaceAux : AllStatic { - static size_t free_chunks_total(Metaspace::MetadataType mdtype); - static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); - - public: // Statistics for class space and data space in metaspace. static size_t used_in_bytes(Metaspace::MetadataType mdtype); static size_t free_in_bytes(Metaspace::MetadataType mdtype); static size_t capacity_in_bytes(Metaspace::MetadataType mdtype); static size_t reserved_in_bytes(Metaspace::MetadataType mdtype); + static size_t free_chunks_total(Metaspace::MetadataType mdtype); + static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); + + public: // Total of space allocated to metadata in all Metaspaces static size_t used_in_bytes() { return used_in_bytes(Metaspace::ClassType) + diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 4406addc9e8..79e092a3b19 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -1108,7 +1108,6 @@ bool universe_post_init() { // Initialize performance counters for metaspaces MetaspaceCounters::initialize_performance_counters(); - MemoryService::add_metaspace_memory_pools(); GC_locker::unlock(); // allow gc after bootstrapping diff --git a/hotspot/src/share/vm/services/memoryManager.cpp b/hotspot/src/share/vm/services/memoryManager.cpp index d5e54f5ff15..3996d2163c8 100644 --- a/hotspot/src/share/vm/services/memoryManager.cpp +++ b/hotspot/src/share/vm/services/memoryManager.cpp @@ -61,10 +61,6 @@ MemoryManager* MemoryManager::get_code_cache_memory_manager() { return (MemoryManager*) new CodeCacheMemoryManager(); } -MemoryManager* MemoryManager::get_metaspace_memory_manager() { - return (MemoryManager*) new MetaspaceMemoryManager(); -} - GCMemoryManager* MemoryManager::get_copy_memory_manager() { return (GCMemoryManager*) new CopyMemoryManager(); } diff --git a/hotspot/src/share/vm/services/memoryManager.hpp b/hotspot/src/share/vm/services/memoryManager.hpp index 12c0a0ec458..370d830e977 100644 --- a/hotspot/src/share/vm/services/memoryManager.hpp +++ b/hotspot/src/share/vm/services/memoryManager.hpp @@ -56,7 +56,6 @@ public: enum Name { Abstract, CodeCache, - Metaspace, Copy, MarkSweepCompact, ParNew, @@ -89,7 +88,6 @@ public: // Static factory methods to get a memory manager of a specific type static MemoryManager* get_code_cache_memory_manager(); - static MemoryManager* get_metaspace_memory_manager(); static GCMemoryManager* get_copy_memory_manager(); static GCMemoryManager* get_msc_memory_manager(); static GCMemoryManager* get_parnew_memory_manager(); @@ -110,14 +108,6 @@ public: const char* name() { return "CodeCacheManager"; } }; -class MetaspaceMemoryManager : public MemoryManager { -public: - MetaspaceMemoryManager() : MemoryManager() {} - - MemoryManager::Name kind() { return MemoryManager::Metaspace; } - const char *name() { return "MetaspaceManager"; } -}; - class GCStatInfo : public ResourceObj { private: size_t _index; diff --git a/hotspot/src/share/vm/services/memoryPool.cpp b/hotspot/src/share/vm/services/memoryPool.cpp index 969ed7f22bf..e2895b1f816 100644 --- a/hotspot/src/share/vm/services/memoryPool.cpp +++ b/hotspot/src/share/vm/services/memoryPool.cpp @@ -26,15 +26,12 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "oops/oop.inline.hpp" -#include "runtime/globals.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" -#include "runtime/os.hpp" #include "services/lowMemoryDetector.hpp" #include "services/management.hpp" #include "services/memoryManager.hpp" #include "services/memoryPool.hpp" -#include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" MemoryPool::MemoryPool(const char* name, @@ -259,34 +256,3 @@ MemoryUsage CodeHeapPool::get_memory_usage() { return MemoryUsage(initial_size(), used, committed, maxSize); } - -MetaspacePoolBase::MetaspacePoolBase(const char *name, - Metaspace::MetadataType md_type, - size_t max_size) : - _md_type(md_type), - MemoryPool(name, NonHeap, MetaspaceAux::capacity_in_bytes(_md_type), max_size, - true, false) { } - -size_t MetaspacePoolBase::used_in_bytes() { - return MetaspaceAux::used_in_bytes(_md_type); -} - -MemoryUsage MetaspacePoolBase::get_memory_usage() { - size_t used = MetaspaceAux::used_in_bytes(_md_type); - size_t committed = align_size_down_(MetaspaceAux::capacity_in_bytes(_md_type), os::vm_page_size()); - return MemoryUsage(initial_size(), used, committed, max_size()); -} - -ClassMetaspacePool::ClassMetaspacePool() : - MetaspacePoolBase("Class Metaspace", Metaspace::ClassType, calculate_max_size()) { } - -size_t ClassMetaspacePool::calculate_max_size() { - return UseCompressedKlassPointers ? ClassMetaspaceSize : _undefined_max_size; -} - -MetaspacePool::MetaspacePool() : - MetaspacePoolBase("Metaspace", Metaspace::NonClassType, calculate_max_size()) { } - -size_t MetaspacePool::calculate_max_size() { - return FLAG_IS_CMDLINE(MaxMetaspaceSize) ? MaxMetaspaceSize : _undefined_max_size; -} diff --git a/hotspot/src/share/vm/services/memoryPool.hpp b/hotspot/src/share/vm/services/memoryPool.hpp index f36c3984ced..82606185340 100644 --- a/hotspot/src/share/vm/services/memoryPool.hpp +++ b/hotspot/src/share/vm/services/memoryPool.hpp @@ -28,7 +28,6 @@ #include "gc_implementation/shared/mutableSpace.hpp" #include "memory/defNewGeneration.hpp" #include "memory/heap.hpp" -#include "memory/metaspace.hpp" #include "memory/space.hpp" #include "services/memoryUsage.hpp" #include "utilities/macros.hpp" @@ -223,29 +222,4 @@ public: size_t used_in_bytes() { return _codeHeap->allocated_capacity(); } }; -class MetaspacePoolBase : public MemoryPool { -private: - Metaspace::MetadataType _md_type; -protected: - static const size_t _undefined_max_size = (size_t) -1; -public: - MetaspacePoolBase(const char *name, Metaspace::MetadataType md_type, size_t max_size); - MemoryUsage get_memory_usage(); - size_t used_in_bytes(); -}; - -class ClassMetaspacePool : public MetaspacePoolBase { -private: - size_t calculate_max_size(); -public: - ClassMetaspacePool(); -}; - -class MetaspacePool : public MetaspacePoolBase { -private: - size_t calculate_max_size(); -public: - MetaspacePool(); -}; - #endif // SHARE_VM_SERVICES_MEMORYPOOL_HPP diff --git a/hotspot/src/share/vm/services/memoryService.cpp b/hotspot/src/share/vm/services/memoryService.cpp index 41f7328d8a8..75693dbcf69 100644 --- a/hotspot/src/share/vm/services/memoryService.cpp +++ b/hotspot/src/share/vm/services/memoryService.cpp @@ -60,11 +60,9 @@ GrowableArray* MemoryService::_pools_list = GrowableArray* MemoryService::_managers_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_managers_list_size, true); -GCMemoryManager* MemoryService::_minor_gc_manager = NULL; -GCMemoryManager* MemoryService::_major_gc_manager = NULL; -MemoryPool* MemoryService::_code_heap_pool = NULL; -MemoryPool* MemoryService::_metaspace_pool = NULL; -MemoryPool* MemoryService::_class_metaspace_pool = NULL; +GCMemoryManager* MemoryService::_minor_gc_manager = NULL; +GCMemoryManager* MemoryService::_major_gc_manager = NULL; +MemoryPool* MemoryService::_code_heap_pool = NULL; class GcThreadCountClosure: public ThreadClosure { private: @@ -401,19 +399,6 @@ void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) { _managers_list->append(mgr); } -void MemoryService::add_metaspace_memory_pools() { - _metaspace_pool = new MetaspacePool(); - _class_metaspace_pool = new ClassMetaspacePool(); - - MemoryManager* mgr = MemoryManager::get_metaspace_memory_manager(); - mgr->add_pool(_metaspace_pool); - mgr->add_pool(_class_metaspace_pool); - - _pools_list->append(_metaspace_pool); - _pools_list->append(_class_metaspace_pool); - _managers_list->append(mgr); -} - MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) { for (int i = 0; i < _managers_list->length(); i++) { MemoryManager* mgr = _managers_list->at(i); diff --git a/hotspot/src/share/vm/services/memoryService.hpp b/hotspot/src/share/vm/services/memoryService.hpp index fcd2fdf421d..44cf62ea3cb 100644 --- a/hotspot/src/share/vm/services/memoryService.hpp +++ b/hotspot/src/share/vm/services/memoryService.hpp @@ -73,10 +73,6 @@ private: // Code heap memory pool static MemoryPool* _code_heap_pool; - // Metaspace pools - static MemoryPool* _metaspace_pool; - static MemoryPool* _class_metaspace_pool; - static void add_generation_memory_pool(Generation* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr); @@ -125,7 +121,6 @@ private: public: static void set_universe_heap(CollectedHeap* heap); static void add_code_heap_memory_pool(CodeHeap* heap); - static void add_metaspace_memory_pools(); static MemoryPool* get_memory_pool(instanceHandle pool); static MemoryManager* get_memory_manager(instanceHandle mgr); diff --git a/hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java b/hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java deleted file mode 100644 index 884f377bc22..00000000000 --- a/hotspot/test/gc/metaspace/TestMetaspaceMemoryPools.java +++ /dev/null @@ -1,75 +0,0 @@ -import java.util.List; -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryManagerMXBean; -import java.lang.management.MemoryPoolMXBean; -import java.lang.management.MemoryUsage; - -/* @test TestMetaspaceMemoryPools - * @bug 8000754 - * @summary Tests that two MemoryPoolMXBeans are created, one for metaspace and - * one for class metaspace, is created and that a MemoryManagerMXBean - * is created. - * @run main/othervm TestMetaspaceMemoryPools defined undefined - * @run main/othervm -XX:-UseCompressedKlassPointers TestMetaspaceMemoryPools undefined undefined - * @run main/othervm -XX:-UseCompressedKlassPointers -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPools undefined defined - */ -public class TestMetaspaceMemoryPools { - public static void main(String[] args) { - boolean isClassMetaspaceMaxDefined = args[0].equals("defined"); - boolean isMetaspaceMaxDefined = args[1].equals("defined"); - - verifyThatMetaspaceMemoryManagerExists(); - - verifyMemoryPool(getMemoryPool("Class Metaspace"), isClassMetaspaceMaxDefined); - verifyMemoryPool(getMemoryPool("Metaspace"), isMetaspaceMaxDefined); - } - - private static void verifyThatMetaspaceMemoryManagerExists() { - List managers = ManagementFactory.getMemoryManagerMXBeans(); - for (MemoryManagerMXBean manager : managers) { - if (manager.getName().equals("MetaspaceManager")) { - return; - } - } - - throw new RuntimeException("Expected to find a metaspace memory manager"); - } - - private static MemoryPoolMXBean getMemoryPool(String name) { - List pools = ManagementFactory.getMemoryPoolMXBeans(); - for (MemoryPoolMXBean pool : pools) { - if (pool.getName().equals(name)) { - return pool; - } - } - - throw new RuntimeException("Expected to find a memory pool with name " + name); - } - - private static void verifyMemoryPool(MemoryPoolMXBean pool, boolean isMaxDefined) { - MemoryUsage mu = pool.getUsage(); - assertDefined(mu.getInit(), "init"); - assertDefined(mu.getUsed(), "used"); - assertDefined(mu.getCommitted(), "committed"); - - if (isMaxDefined) { - assertDefined(mu.getMax(), "max"); - } else { - assertUndefined(mu.getMax(), "max"); - } - } - - private static void assertDefined(long value, String name) { - assertTrue(value != -1, "Expected " + name + " to be defined"); - } - - private static void assertUndefined(long value, String name) { - assertTrue(value == -1, "Expected " + name + " to be undefined"); - } - - private static void assertTrue(boolean condition, String msg) { - if (!condition) { - throw new RuntimeException(msg); - } - } -} From 878c7e4cd0588df1a6ae148c59601b92c057648b Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 27 Mar 2013 08:19:50 -0400 Subject: [PATCH 073/155] 8009531: Crash when redefining class with annotated method Neglected to copy the annotations in clone_with_new_data when they were moved to ConstMethod. Reviewed-by: acorn, sspitsyn, dcubed --- hotspot/src/share/vm/oops/constMethod.cpp | 20 ++++++++++++++++++++ hotspot/src/share/vm/oops/constMethod.hpp | 3 +++ hotspot/src/share/vm/oops/method.cpp | 2 ++ 3 files changed, 25 insertions(+) diff --git a/hotspot/src/share/vm/oops/constMethod.cpp b/hotspot/src/share/vm/oops/constMethod.cpp index 98a29a2e1dc..1d0376a0b74 100644 --- a/hotspot/src/share/vm/oops/constMethod.cpp +++ b/hotspot/src/share/vm/oops/constMethod.cpp @@ -363,6 +363,26 @@ AnnotationArray** ConstMethod::default_annotations_addr() const { return (AnnotationArray**)constMethod_end() - offset; } +// copy annotations from 'cm' to 'this' +void ConstMethod::copy_annotations_from(ConstMethod* cm) { + if (cm->has_method_annotations()) { + assert(has_method_annotations(), "should be allocated already"); + set_method_annotations(cm->method_annotations()); + } + if (cm->has_parameter_annotations()) { + assert(has_parameter_annotations(), "should be allocated already"); + set_parameter_annotations(cm->parameter_annotations()); + } + if (cm->has_type_annotations()) { + assert(has_type_annotations(), "should be allocated already"); + set_type_annotations(cm->type_annotations()); + } + if (cm->has_default_annotations()) { + assert(has_default_annotations(), "should be allocated already"); + set_default_annotations(cm->default_annotations()); + } +} + // Printing void ConstMethod::print_on(outputStream* st) const { diff --git a/hotspot/src/share/vm/oops/constMethod.hpp b/hotspot/src/share/vm/oops/constMethod.hpp index 0c4212564b0..21df75bdec0 100644 --- a/hotspot/src/share/vm/oops/constMethod.hpp +++ b/hotspot/src/share/vm/oops/constMethod.hpp @@ -441,6 +441,9 @@ public: return has_default_annotations() ? default_annotations()->length() : 0; } + // Copy annotations from other ConstMethod + void copy_annotations_from(ConstMethod* cm); + // byte codes void set_code(address code) { if (code_size() > 0) { diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 11ddd21f1f6..2e866bed195 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -1170,6 +1170,8 @@ methodHandle Method::clone_with_new_data(methodHandle m, u_char* new_code, int n newm->set_stackmap_data(stackmap_data); } + // copy annotations over to new method + newcm->copy_annotations_from(cm); return newm; } From 366b7e1c5ef84d6bcd026877414a0c1eb1dd52eb Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 27 Mar 2013 11:41:51 -0400 Subject: [PATCH 074/155] 8010833: Test7116786.java is failing on most configs after fix for 8010667 Update test to recognize that non-zero pad bytes for lookupswitch/tablewsitch opcodes are now valid. Reviewed-by: dcubed, twisti, kvn, coleenp, dholmes --- hotspot/test/runtime/7116786/Test7116786.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotspot/test/runtime/7116786/Test7116786.java b/hotspot/test/runtime/7116786/Test7116786.java index 8c137ecdca0..b914019258e 100644 --- a/hotspot/test/runtime/7116786/Test7116786.java +++ b/hotspot/test/runtime/7116786/Test7116786.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -338,9 +338,12 @@ class VerifyErrorCases { "invalid constant pool index in ldc", "Invalid index in ldc"), - new Case("case58", "verifier.cpp", true, "verify_switch", + /* No longer a valid test case for bytecode version >= 51. Nonzero + * padding bytes are permitted with lookupswitch and tableswitch + * bytecodes as of JVMS 3d edition */ + new Case("case58", "verifier.cpp", false, "verify_switch", "bad switch padding", - "Nonzero padding byte in lookswitch or tableswitch"), + "Nonzero padding byte in lookupswitch or tableswitch"), new Case("case59", "verifier.cpp", true, "verify_switch", "tableswitch low is greater than high", From 2ffe97f06e9a4829aad18025cee7f67cb1b509e2 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Wed, 27 Mar 2013 09:00:34 -0700 Subject: [PATCH 075/155] 8010837: FileInputStream.available() throw IOException when encountering negative available values Remove the check in the native code to allow negative values Reviewed-by: mchung --- jdk/src/solaris/native/java/io/io_util_md.c | 8 +- .../io/FileInputStream/NegativeAvailable.java | 90 +++++++++++++++++++ 2 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/io/FileInputStream/NegativeAvailable.java diff --git a/jdk/src/solaris/native/java/io/io_util_md.c b/jdk/src/solaris/native/java/io/io_util_md.c index a1acbe5d409..e74bc127102 100644 --- a/jdk/src/solaris/native/java/io/io_util_md.c +++ b/jdk/src/solaris/native/java/io/io_util_md.c @@ -200,12 +200,8 @@ handleAvailable(FD fd, jlong *pbytes) return 0; } - if (size >= current) { - *pbytes = size - current; - return 1; - } else { - return 0; - } + *pbytes = size - current; + return 1; } jint diff --git a/jdk/test/java/io/FileInputStream/NegativeAvailable.java b/jdk/test/java/io/FileInputStream/NegativeAvailable.java new file mode 100644 index 00000000000..a4dedbcdcf7 --- /dev/null +++ b/jdk/test/java/io/FileInputStream/NegativeAvailable.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, 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 8010837 + * @summary Test if available returns correct value when skipping beyond + * the end of a file. + * @author Dan Xu + */ + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; + +public class NegativeAvailable { + + public static void main(String[] args) throws IOException { + final int SIZE = 10; + final int SKIP = 5; + + // Create a temporary file with size of 10 bytes. + Path tmp = Files.createTempFile(null, null); + try (BufferedWriter writer = + Files.newBufferedWriter(tmp, Charset.defaultCharset())) { + for (int i = 0; i < SIZE; i++) { + writer.write('1'); + } + } + + File tempFile = tmp.toFile(); + try (FileInputStream fis = new FileInputStream(tempFile)) { + if (tempFile.length() != SIZE) { + throw new RuntimeException("unexpected file size = " + + tempFile.length()); + } + long space = skipBytes(fis, SKIP, SIZE); + space = skipBytes(fis, SKIP, space); + space = skipBytes(fis, SKIP, space); + space = skipBytes(fis, SKIP, space); + } + Files.deleteIfExists(tmp); + } + + /** + * Skip toSkip number of bytes and return the remaining bytes of the file. + */ + private static long skipBytes(FileInputStream fis, int toSkip, long space) + throws IOException { + long skip = fis.skip(toSkip); + if (skip != toSkip) { + throw new RuntimeException("skip() returns " + skip + + " but expected " + toSkip); + } + long remaining = space - toSkip; + int avail = fis.available(); + if (avail != remaining) { + throw new RuntimeException("available() returns " + avail + + " but expected " + remaining); + } + + System.out.println("Skipped " + skip + " bytes " + + " available() returns " + avail); + return remaining; + } +} From 3987724a24254f7b4cc3cbf22872fa2a2f3f7887 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 27 Mar 2013 09:38:53 -0700 Subject: [PATCH 076/155] 7185456: (ann) Optimize Annotation handling in java/sun.reflect.* code for small number of annotations Reviewed-by: mduigou, jfranck --- .../sun/reflect/annotation/AnnotationType.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/sun/reflect/annotation/AnnotationType.java b/jdk/src/share/classes/sun/reflect/annotation/AnnotationType.java index 530834c1e2e..cfc14444138 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationType.java +++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -45,19 +45,18 @@ public class AnnotationType { * types. This matches the return value that must be used for a * dynamic proxy, allowing for a simple isInstance test. */ - private final Map> memberTypes = new HashMap>(); + private final Map> memberTypes; /** * Member name -> default value mapping. */ - private final Map memberDefaults = - new HashMap(); + private final Map memberDefaults; /** * Member name -> Method object mapping. This (and its assoicated * accessor) are used only to generate AnnotationTypeMismatchExceptions. */ - private final Map members = new HashMap(); + private final Map members; /** * The retention policy for this annotation type. @@ -105,6 +104,9 @@ public class AnnotationType { } }); + memberTypes = new HashMap>(methods.length+1, 1.0f); + memberDefaults = new HashMap(0); + members = new HashMap(methods.length+1, 1.0f); for (Method method : methods) { if (method.getParameterTypes().length != 0) @@ -117,8 +119,6 @@ public class AnnotationType { Object defaultValue = method.getDefaultValue(); if (defaultValue != null) memberDefaults.put(name, defaultValue); - - members.put(name, method); } sun.misc.SharedSecrets.getJavaLangAccess(). From c2a873f014b8b7cad55091c382c8958d5be0a70a Mon Sep 17 00:00:00 2001 From: Gary Collins Date: Wed, 27 Mar 2013 09:49:51 -0700 Subject: [PATCH 077/155] 8009152: A number of jtreg tests need review/improvement Added a new test_env.txt file to capture common shell variable. Added concept of COMPILEJAVA for use when TESTJAVA is a JRE. If COMPILEJAVA not set then TESTJAVA will be the default with assumption it is a JDK. Reviewed-by: kvn, brutisso, coleenp --- hotspot/test/compiler/5091921/Test6890943.sh | 24 +-- hotspot/test/compiler/5091921/Test7005594.sh | 23 +-- hotspot/test/compiler/6857159/Test6857159.sh | 23 +-- hotspot/test/compiler/7068051/Test7068051.sh | 22 +-- hotspot/test/compiler/7070134/Test7070134.sh | 23 +-- hotspot/test/compiler/7200264/Test7200264.sh | 47 +---- hotspot/test/gc/6941923/test6941923.sh | 39 ++-- hotspot/test/runtime/6626217/Test6626217.sh | 69 +------ hotspot/test/runtime/6878713/Test6878713.sh | 54 +----- hotspot/test/runtime/6929067/Test6929067.sh | 26 ++- hotspot/test/runtime/7020373/Test7020373.sh | 52 +---- hotspot/test/runtime/7051189/Xchecksig.sh | 24 +-- hotspot/test/runtime/7107135/Test7107135.sh | 21 +- hotspot/test/runtime/7110720/Test7110720.sh | 19 +- hotspot/test/runtime/7158804/Test7158804.sh | 11 +- hotspot/test/runtime/7162488/Test7162488.sh | 24 +-- hotspot/test/test_env.sh | 193 +++++++++++++++++++ 17 files changed, 310 insertions(+), 384 deletions(-) create mode 100644 hotspot/test/test_env.sh diff --git a/hotspot/test/compiler/5091921/Test6890943.sh b/hotspot/test/compiler/5091921/Test6890943.sh index 7ebda8f6e8e..755f56890f1 100644 --- a/hotspot/test/compiler/5091921/Test6890943.sh +++ b/hotspot/test/compiler/5091921/Test6890943.sh @@ -22,26 +22,16 @@ # questions. # # - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh + set -x @@ -50,7 +40,7 @@ cp ${TESTSRC}/input6890943.txt . cp ${TESTSRC}/output6890943.txt . cp ${TESTSRC}/Test6890943.sh . -${TESTJAVA}/bin/javac -d . Test6890943.java +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test6890943.java ${TESTJAVA}/bin/java -XX:-PrintVMOptions -XX:+IgnoreUnrecognizedVMOptions ${TESTVMOPTS} Test6890943 < input6890943.txt > pretest.out 2>&1 diff --git a/hotspot/test/compiler/5091921/Test7005594.sh b/hotspot/test/compiler/5091921/Test7005594.sh index 858e38a4e8a..9458a16bb55 100644 --- a/hotspot/test/compiler/5091921/Test7005594.sh +++ b/hotspot/test/compiler/5091921/Test7005594.sh @@ -22,26 +22,15 @@ # questions. # # - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh # Amount of physical memory in megabytes MEM=0 @@ -87,7 +76,7 @@ set -x cp ${TESTSRC}/Test7005594.java . cp ${TESTSRC}/Test7005594.sh . -${TESTJAVA}/bin/javac -d . Test7005594.java +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test7005594.java ${TESTJAVA}/bin/java ${TESTVMOPTS} -Xms1600m -XX:+IgnoreUnrecognizedVMOptions -XX:-ZapUnusedHeapArea -Xcomp -XX:CompileOnly=Test7005594.test Test7005594 > test.out 2>&1 diff --git a/hotspot/test/compiler/6857159/Test6857159.sh b/hotspot/test/compiler/6857159/Test6857159.sh index 341130e773f..b73f1e2aafa 100644 --- a/hotspot/test/compiler/6857159/Test6857159.sh +++ b/hotspot/test/compiler/6857159/Test6857159.sh @@ -22,33 +22,22 @@ # questions. # # - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh set -x cp ${TESTSRC}/Test6857159.java . cp ${TESTSRC}/Test6857159.sh . -${TESTJAVA}/bin/javac -d . Test6857159.java +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test6857159.java ${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbatch -XX:+PrintCompilation -XX:CompileOnly=Test6857159\$ct.run Test6857159 > test.out 2>&1 diff --git a/hotspot/test/compiler/7068051/Test7068051.sh b/hotspot/test/compiler/7068051/Test7068051.sh index 3fc263b4e04..b1ecd453a6c 100644 --- a/hotspot/test/compiler/7068051/Test7068051.sh +++ b/hotspot/test/compiler/7068051/Test7068051.sh @@ -22,28 +22,24 @@ # questions. # # - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh set -x -${TESTJAVA}/bin/jar xf ${TESTJAVA}/jre/lib/javaws.jar -${TESTJAVA}/bin/jar cf foo.jar * +${COMPILEJAVA}/bin/jar xf ${COMPILEJAVA}/jre/lib/javaws.jar +${COMPILEJAVA}/bin/jar cf foo.jar * cp ${TESTSRC}/Test7068051.java ./ -${TESTJAVA}/bin/jar -uf0 foo.jar Test7068051.java +${COMPILEJAVA}/bin/jar -uf0 foo.jar Test7068051.java -${TESTJAVA}/bin/javac -d . Test7068051.java +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test7068051.java ${TESTJAVA}/bin/java ${TESTVMOPTS} -showversion -Xbatch Test7068051 foo.jar diff --git a/hotspot/test/compiler/7070134/Test7070134.sh b/hotspot/test/compiler/7070134/Test7070134.sh index cbebfbab07e..f11be642f5b 100644 --- a/hotspot/test/compiler/7070134/Test7070134.sh +++ b/hotspot/test/compiler/7070134/Test7070134.sh @@ -22,33 +22,22 @@ # questions. # # - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh set -x cp ${TESTSRC}/Stemmer.java . cp ${TESTSRC}/words . -${TESTJAVA}/bin/javac -d . Stemmer.java +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Stemmer.java ${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbatch Stemmer words > test.out 2>&1 diff --git a/hotspot/test/compiler/7200264/Test7200264.sh b/hotspot/test/compiler/7200264/Test7200264.sh index 4276a8f134b..1652bf3fbe6 100644 --- a/hotspot/test/compiler/7200264/Test7200264.sh +++ b/hotspot/test/compiler/7200264/Test7200264.sh @@ -23,50 +23,15 @@ # # +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows_* ) - NULL=NUL - PS=";" - FS="\\" - ;; - CYGWIN_* ) - NULL=/dev/null - PS=";" - FS="/" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion | sed 's/amd64/x86/' | grep "x86" | grep "Server VM" | grep "debug" @@ -88,7 +53,7 @@ else fi cp ${TESTSRC}${FS}TestIntVect.java . -${TESTJAVA}${FS}bin${FS}javac -d . TestIntVect.java +${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} -d . TestIntVect.java ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+PrintCompilation -XX:+TraceNewVectors TestIntVect > test.out 2>&1 diff --git a/hotspot/test/gc/6941923/test6941923.sh b/hotspot/test/gc/6941923/test6941923.sh index 0c751de12e0..9b33e32f449 100644 --- a/hotspot/test/gc/6941923/test6941923.sh +++ b/hotspot/test/gc/6941923/test6941923.sh @@ -5,38 +5,25 @@ ## @author yqi ## @run shell test6941923.sh ## +## some tests require path to find test source dir +if [ "${TESTSRC}" = "" ] +then + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" +fi +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh ## skip on windows OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) - NULL=/dev/null - PS=":" - FS="/" - ;; Windows_* | CYGWIN_* ) echo "Test skipped for Windows" exit 0 ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; esac -if [ "${JAVA_HOME}" = "" ] -then - echo "JAVA_HOME not set" - exit 0 -fi - -$JAVA_HOME/bin/java ${TESTVMOPTS} -version > $NULL 2>&1 - -if [ $? != 0 ]; then - echo "Wrong JAVA_HOME? JAVA_HOME: $JAVA_HOME" - exit $? -fi - # create a small test case testname="Test" if [ -e ${testname}.java ]; then @@ -96,10 +83,10 @@ msgsuccess="succeeded" msgfail="failed" gclogsize="16K" filesize=$((16*1024)) -$JAVA_HOME/bin/javac ${testname}.java > $NULL 2>&1 +${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${testname}.java > $NULL 2>&1 if [ $? != 0 ]; then - echo "$JAVA_HOME/bin/javac ${testname}.java $fail" + echo "${COMPILEJAVA}/bin/javac ${testname}.java $fail" exit -1 fi @@ -119,7 +106,7 @@ fi options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=$gclogsize" echo "Test gc log rotation in same file, wait for $tts minutes ...." -$JAVA_HOME/bin/java ${TESTVMOPTS} $options $testname $tts +${TESTJAVA}/bin/java $options $testname $tts if [ $? != 0 ]; then echo "$msgfail" exit -1 @@ -148,7 +135,7 @@ fi numoffiles=3 options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=$numoffiles -XX:GCLogFileSize=$gclogsize" echo "Test gc log rotation in $numoffiles files, wait for $tts minutes ...." -$JAVA_HOME/bin/java ${TESTVMOPTS} $options $testname $tts +${TESTJAVA}/bin/java $options $testname $tts if [ $? != 0 ]; then echo "$msgfail" exit -1 diff --git a/hotspot/test/runtime/6626217/Test6626217.sh b/hotspot/test/runtime/6626217/Test6626217.sh index a8c8a2395cf..ae340798054 100644 --- a/hotspot/test/runtime/6626217/Test6626217.sh +++ b/hotspot/test/runtime/6626217/Test6626217.sh @@ -27,78 +27,29 @@ # @summary Loader-constraint table allows arrays instead of only the base-classes # @run shell Test6626217.sh # - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] - then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi - -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - NULL=/dev/null - PS=":" - FS="/" - RM=/bin/rm - CP=/bin/cp - MV=/bin/mv - ;; - Windows_* ) - NULL=NUL - PS=";" - FS="\\" - RM=rm - CP=cp - MV=mv - ;; - CYGWIN_* ) - NULL=/dev/null - PS=";" - FS="/" - RM=rm - CP=cp - MV=mv - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -JEMMYPATH=${CPAPPEND} -CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH - -THIS_DIR=`pwd` +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh JAVA=${TESTJAVA}${FS}bin${FS}java -JAVAC=${TESTJAVA}${FS}bin${FS}javac - -${JAVA} ${TESTVMOPTS} -version +JAVAC=${COMPILEJAVA}${FS}bin${FS}javac # Current directory is scratch directory, copy all the test source there # (for the subsequent moves to work). -${CP} ${TESTSRC}${FS}* ${THIS_DIR} +${CP} ${TESTSRC}${FS}* ${THIS_DIR} # A Clean Compile: this line will probably fail within jtreg as have a clean dir: ${RM} -f *.class *.impl many_loader.java # Compile all the usual suspects, including the default 'many_loader' ${CP} many_loader1.java.foo many_loader.java -${JAVAC} -source 1.4 -target 1.4 -Xlint *.java +${JAVAC} ${TESTJAVACOPTS} -source 1.4 -target 1.4 -Xlint *.java # Rename the class files, so the custom loader (and not the system loader) will find it ${MV} from_loader2.class from_loader2.impl2 @@ -106,7 +57,7 @@ ${MV} from_loader2.class from_loader2.impl2 # Compile the next version of 'many_loader' ${MV} many_loader.class many_loader.impl1 ${CP} many_loader2.java.foo many_loader.java -${JAVAC} -source 1.4 -target 1.4 -Xlint many_loader.java +${JAVAC} ${TESTJAVACOPTS} -source 1.4 -target 1.4 -Xlint many_loader.java # Rename the class file, so the custom loader (and not the system loader) will find it ${MV} many_loader.class many_loader.impl2 diff --git a/hotspot/test/runtime/6878713/Test6878713.sh b/hotspot/test/runtime/6878713/Test6878713.sh index a452ad58fcd..47a18ad8fa0 100644 --- a/hotspot/test/runtime/6878713/Test6878713.sh +++ b/hotspot/test/runtime/6878713/Test6878713.sh @@ -6,57 +6,17 @@ ## @summary Verifier heap corruption, relating to backward jsrs ## @run shell/timeout=120 Test6878713.sh ## - +## some tests require path to find test source dir if [ "${TESTSRC}" = "" ] -then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows_* ) - NULL=NUL - PS=";" - FS="\\" - ;; - CYGWIN_* ) - NULL=/dev/null - PS=";" - FS="/" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -JEMMYPATH=${CPAPPEND} -CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH - -THIS_DIR=`pwd` - -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version - -${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar +${COMPILEJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass1960_2 > test.out 2>&1 diff --git a/hotspot/test/runtime/6929067/Test6929067.sh b/hotspot/test/runtime/6929067/Test6929067.sh index e4b649df82b..b707e096304 100644 --- a/hotspot/test/runtime/6929067/Test6929067.sh +++ b/hotspot/test/runtime/6929067/Test6929067.sh @@ -7,18 +7,15 @@ ## @compile T.java ## @run shell Test6929067.sh ## - +set -x if [ "${TESTSRC}" = "" ] -then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh # set platform-dependent variables OS=`uname -s` @@ -107,7 +104,7 @@ then fi -LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH +LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH cp ${TESTSRC}${FS}invoke.c . @@ -115,15 +112,16 @@ cp ${TESTSRC}${FS}invoke.c . # Copy the result of our @compile action: cp ${TESTCLASSES}${FS}T.class . -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -fullversion - echo "Architecture: ${ARCH}" echo "Compilation flag: ${COMP_FLAG}" echo "VM type: ${VMTYPE}" +# Note pthread may not be found thus invoke creation will fail to be created. +# Check to ensure you have a /usr/lib/libpthread.so if you don't please look +# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation. gcc -DLINUX ${COMP_FLAG} -o invoke \ - -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \ - -L${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE} \ + -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \ + -L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \ -ljvm -lpthread invoke.c ./invoke diff --git a/hotspot/test/runtime/7020373/Test7020373.sh b/hotspot/test/runtime/7020373/Test7020373.sh index 83e7f4c449d..83b7028c82f 100644 --- a/hotspot/test/runtime/7020373/Test7020373.sh +++ b/hotspot/test/runtime/7020373/Test7020373.sh @@ -10,55 +10,15 @@ ## if [ "${TESTSRC}" = "" ] -then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows_* ) - NULL=NUL - PS=";" - FS="\\" - ;; - CYGWIN_* ) - NULL=/dev/null - PS=";" - FS="/" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -JEMMYPATH=${CPAPPEND} -CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH - -THIS_DIR=`pwd` - -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version - -${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar +${COMPILEJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass4000_1 > test.out 2>&1 diff --git a/hotspot/test/runtime/7051189/Xchecksig.sh b/hotspot/test/runtime/7051189/Xchecksig.sh index f3eabce57d5..143e1445624 100644 --- a/hotspot/test/runtime/7051189/Xchecksig.sh +++ b/hotspot/test/runtime/7051189/Xchecksig.sh @@ -29,34 +29,22 @@ # if [ "${TESTSRC}" = "" ] - then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - printf "TESTJAVA not set, selecting " ${TESTJAVA} - printf " If this is incorrect, try setting the variable manually.\n" + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi - +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh OS=`uname -s` case "$OS" in - SunOS | Linux | Darwin ) - FS="/" - ;; Windows_* | CYGWIN_* ) printf "Not testing libjsig.so on Windows. PASSED.\n " exit 0 ;; - * ) - printf "Not testing libjsig.so on unrecognised system. PASSED.\n " - exit 0 - ;; esac - JAVA=${TESTJAVA}${FS}bin${FS}java # LD_PRELOAD arch needs to match the binary we run, so run the java @@ -97,7 +85,7 @@ case $ARCH in ;; esac -LIBJSIG=${TESTJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so +LIBJSIG=${COMPILEJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so # If libjsig and binary do not match, skip test. diff --git a/hotspot/test/runtime/7107135/Test7107135.sh b/hotspot/test/runtime/7107135/Test7107135.sh index 6dc91a3039c..c283456438d 100644 --- a/hotspot/test/runtime/7107135/Test7107135.sh +++ b/hotspot/test/runtime/7107135/Test7107135.sh @@ -32,26 +32,19 @@ ## if [ "${TESTSRC}" = "" ] -then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi - -BIT_FLAG="" +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh # set platform-dependent variables OS=`uname -s` case "$OS" in Linux) - NULL=/dev/null - PS=":" - FS="/" + echo "Testing on Linux" ;; *) NULL=NUL @@ -64,7 +57,7 @@ esac ARCH=`uname -m` -THIS_DIR=`pwd` +THIS_DIR=. cp ${TESTSRC}${FS}*.java ${THIS_DIR} ${TESTJAVA}${FS}bin${FS}javac *.java diff --git a/hotspot/test/runtime/7110720/Test7110720.sh b/hotspot/test/runtime/7110720/Test7110720.sh index 0788cb56a58..b051266fd2d 100644 --- a/hotspot/test/runtime/7110720/Test7110720.sh +++ b/hotspot/test/runtime/7110720/Test7110720.sh @@ -12,22 +12,13 @@ # if [ "${TESTSRC}" = "" ] - then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." -fi - -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh # Jtreg sets TESTVMOPTS which may include -d64 which is # required to test a 64-bit JVM on some platforms. diff --git a/hotspot/test/runtime/7158804/Test7158804.sh b/hotspot/test/runtime/7158804/Test7158804.sh index e7f14238409..b5380ec8eb4 100644 --- a/hotspot/test/runtime/7158804/Test7158804.sh +++ b/hotspot/test/runtime/7158804/Test7158804.sh @@ -10,13 +10,14 @@ ## @summary Improve config file parsing ## @run shell Test7158804.sh ## - -if [ "${TESTJAVA}" = "" ] +if [ "${TESTSRC}" = "" ] then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi -echo "TESTJAVA=${TESTJAVA}" +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh rm -f .hotspotrc echo -XX:+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >.hotspotrc diff --git a/hotspot/test/runtime/7162488/Test7162488.sh b/hotspot/test/runtime/7162488/Test7162488.sh index bd70d027d46..0250f774c15 100644 --- a/hotspot/test/runtime/7162488/Test7162488.sh +++ b/hotspot/test/runtime/7162488/Test7162488.sh @@ -29,27 +29,13 @@ # if [ "${TESTSRC}" = "" ] - then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - printf "TESTJAVA not set, selecting " ${TESTJAVA} - printf " If this is incorrect, try setting the variable manually.\n" + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - Windows_* ) - FS="\\" - ;; - * ) - FS="/" - ;; -esac +echo "TESTSRC=${TESTSRC}" +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh JAVA=${TESTJAVA}${FS}bin${FS}java diff --git a/hotspot/test/test_env.sh b/hotspot/test/test_env.sh new file mode 100644 index 00000000000..fa912dde237 --- /dev/null +++ b/hotspot/test/test_env.sh @@ -0,0 +1,193 @@ +#!/bin/sh +# +# Copyright (c) 2013, 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. +# + +# +# This Environment script was written to capture typically used environment +# setup for a given shell test. +# + +# TESTJAVA can be a JDK or JRE. If JRE you need to set COMPILEJAVA +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi +echo "TESTJAVA=${TESTJAVA}" + +# COMPILEJAVA requires a JDK, some shell test use javac,jar,etc +if [ "${COMPILEJAVA}" = "" ] +then + echo "COMPILEJAVA not set. Using TESTJAVA as default" + COMPILEJAVA=${TESTJAVA} +fi +echo "COMPILEJAVA=${COMPILEJAVA}" + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASES not set. Using "." as default" + TESTCLASSES=. +fi +echo "TESTCLASSES=${TESTCLASSES}" + +# set platform-dependent variables +OS=`uname -s` +case "$OS" in + SunOS | Linux | Darwin ) + NULL=/dev/null + PS=":" + FS="/" + RM=/bin/rm + CP=/bin/cp + MV=/bin/mv + ;; + Windows_* ) + NULL=NUL + PS=";" + FS="\\" + RM=rm + CP=cp + MV=mv + ;; + CYGWIN_* ) + NULL=/dev/null + PS=";" + FS="/" + RM=rm + CP=cp + MV=mv + ;; + * ) + echo "Unrecognized system!" + exit 1; + ;; +esac + +export NULL PS FS RM CP MV +echo "NULL =${NULL}" +echo "PS =${PS}" +echo "FS =${FS}" +echo "RM =${RM}" +echo "CP =${CP}" +echo "MV =${MV}" + +# jtreg -classpathappend: +JEMMYPATH=${CPAPPEND} +CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH +echo "CLASSPATH =${CLASSPATH}" + +# Current directory is scratch directory +THIS_DIR=. +echo "THIS_DIR=${THIS_DIR}" + +# Check to ensure the java defined actually works +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version +if [ $? != 0 ]; then + echo "Wrong TESTJAVA or TESTVMOPTS:" + echo $TESTJAVA TESTVMOPTS + exit 1 +fi + +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1 + +VM_TYPE="unknown" +grep "Server" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_TYPE="server" +fi +grep "Client" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_TYPE="client" +fi + +VM_BITS="32" +grep "64-Bit" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_BITS="64" +fi + +VM_OS="unknown" +grep "solaris" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_OS="solaris" +fi +grep "linux" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_OS="linux" +fi +grep "windows" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_OS="windows" +fi +grep "bsd" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_OS="bsd" +fi + +VM_CPU="unknown" +grep "sparc" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_CPU="sparc" + if [ $VM_BITS = "64" ] + then + VM_CPU="sparcv9" + fi +fi +grep "x86" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_CPU="i386" +fi +grep "amd64" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_CPU="amd64" +fi +grep "arm" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_CPU="arm" +fi +grep "ppc" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_CPU="ppc" +fi +grep "ia64" vm_version.out > ${NULL} +if [ $? = 0 ] +then + VM_CPU="ia64" +fi +export VM_TYPE VM_BITS VM_OS VM_CPU +echo "VM_TYPE=${VM_TYPE}" +echo "VM_BITS=${VM_BITS}" +echo "VM_OS=${VM_OS}" +echo "VM_CPU=${VM_CPU}" From f45e9f484dfd7fe86c1c2eacaf8dcd89c8816b32 Mon Sep 17 00:00:00 2001 From: Karen Kinnear Date: Wed, 27 Mar 2013 13:40:26 -0400 Subject: [PATCH 078/155] 8010846: Update the corresponding test in test/vm/verifier/TestStaticIF.java Remove test flag -XX:-UseSplitVerifier, not supported classfile 52 Reviewed-by: acorn, hseigel --- jdk/test/vm/verifier/TestStaticIF.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/vm/verifier/TestStaticIF.java b/jdk/test/vm/verifier/TestStaticIF.java index 5a6776f3fc6..d3c3239e816 100644 --- a/jdk/test/vm/verifier/TestStaticIF.java +++ b/jdk/test/vm/verifier/TestStaticIF.java @@ -26,7 +26,7 @@ * @test * @bug 8007736 * @summary Test static interface method. - * @run main/othervm -Xverify:all -XX:-UseSplitVerifier TestStaticIF + * @run main/othervm -Xverify:all TestStaticIF */ public class TestStaticIF implements StaticMethodInInterface { From b79e2c6803d46d908f8de0a0edb3fd7ea19d2b83 Mon Sep 17 00:00:00 2001 From: Karen Kinnear Date: Wed, 27 Mar 2013 14:10:59 -0400 Subject: [PATCH 079/155] 8009731: Confusing error message for loader constraint violation Fix text, overwritten type and holder for resolved method Reviewed-by: coleenp, dcubed, minqi, dholmes --- .../share/vm/classfile/systemDictionary.cpp | 11 ++---- .../share/vm/classfile/systemDictionary.hpp | 4 +- .../src/share/vm/interpreter/linkResolver.cpp | 39 +++++++++++-------- hotspot/src/share/vm/oops/klassVtable.cpp | 10 +++-- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index edd3107062b..2f7c7c9553f 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -2185,10 +2185,9 @@ Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int whi // Make sure all class components (including arrays) in the given // signature will be resolved to the same class in both loaders. // Returns the name of the type that failed a loader constraint check, or -// NULL if no constraint failed. The returned C string needs cleaning up -// with a ResourceMark in the caller. No exception except OOME is thrown. +// NULL if no constraint failed. No exception except OOME is thrown. // Arrays are not added to the loader constraint table, their elements are. -char* SystemDictionary::check_signature_loaders(Symbol* signature, +Symbol* SystemDictionary::check_signature_loaders(Symbol* signature, Handle loader1, Handle loader2, bool is_method, TRAPS) { // Nothing to do if loaders are the same. @@ -2196,14 +2195,12 @@ char* SystemDictionary::check_signature_loaders(Symbol* signature, return NULL; } - ResourceMark rm(THREAD); SignatureStream sig_strm(signature, is_method); while (!sig_strm.is_done()) { if (sig_strm.is_object()) { - Symbol* s = sig_strm.as_symbol(CHECK_NULL); - Symbol* sig = s; + Symbol* sig = sig_strm.as_symbol(CHECK_NULL); if (!add_loader_constraint(sig, loader1, loader2, THREAD)) { - return sig->as_C_string(); + return sig; } } sig_strm.next(); diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index d282fedfb4d..8810d35f627 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -483,8 +483,8 @@ public: // Check class loader constraints static bool add_loader_constraint(Symbol* name, Handle loader1, Handle loader2, TRAPS); - static char* check_signature_loaders(Symbol* signature, Handle loader1, - Handle loader2, bool is_method, TRAPS); + static Symbol* check_signature_loaders(Symbol* signature, Handle loader1, + Handle loader2, bool is_method, TRAPS); // JSR 292 // find a java.lang.invoke.MethodHandle.invoke* method for a given signature diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index f5639a55b4b..f4b67eeed39 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -458,25 +458,27 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle res Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(method_signature, loader, class_loader, true, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving method" " \"%s\" the class loader (instance of %s) of the current class, %s," - " and the class loader (instance of %s) for resolved class, %s, have" + " and the class loader (instance of %s) for the method's defining class, %s, have" " different Class objects for the type %s used in the signature"; char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); const char* loader1 = SystemDictionary::loader_name(loader()); char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(class_loader()); - char* resolved = InstanceKlass::cast(resolved_klass())->name()->as_C_string(); + char* target = InstanceKlass::cast(resolved_method->method_holder()) + ->name()->as_C_string(); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + - strlen(current) + strlen(loader2) + strlen(resolved) + - strlen(failed_type_name); + strlen(current) + strlen(loader2) + strlen(target) + + strlen(failed_type_name) + 1; char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, - resolved, failed_type_name); + target, failed_type_name); THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); } } @@ -520,26 +522,28 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(method_signature, loader, class_loader, true, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving " "interface method \"%s\" the class loader (instance of %s) of the " "current class, %s, and the class loader (instance of %s) for " - "resolved class, %s, have different Class objects for the type %s " + "the method's defining class, %s, have different Class objects for the type %s " "used in the signature"; char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); const char* loader1 = SystemDictionary::loader_name(loader()); char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(class_loader()); - char* resolved = InstanceKlass::cast(resolved_klass())->name()->as_C_string(); + char* target = InstanceKlass::cast(resolved_method->method_holder()) + ->name()->as_C_string(); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + - strlen(current) + strlen(loader2) + strlen(resolved) + - strlen(failed_type_name); + strlen(current) + strlen(loader2) + strlen(target) + + strlen(failed_type_name) + 1; char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, - resolved, failed_type_name); + target, failed_type_name); THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); } } @@ -642,12 +646,12 @@ void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle poo Symbol* signature_ref = pool->signature_ref_at(index); { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(signature_ref, ref_loader, sel_loader, false, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving field" " \"%s\" the class loader (instance of %s) of the referring class, " "%s, and the class loader (instance of %s) for the field's resolved " @@ -656,8 +660,9 @@ void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle poo const char* loader1 = SystemDictionary::loader_name(ref_loader()); char* sel = InstanceKlass::cast(sel_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(sel_loader()); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) + - strlen(sel) + strlen(loader2) + strlen(failed_type_name); + strlen(sel) + strlen(loader2) + strlen(failed_type_name) + 1; char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2, failed_type_name); diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp index 43036e75437..3f8609532fa 100644 --- a/hotspot/src/share/vm/oops/klassVtable.cpp +++ b/hotspot/src/share/vm/oops/klassVtable.cpp @@ -327,11 +327,11 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle tar if (target_loader() != super_loader()) { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(signature, target_loader, super_loader, true, CHECK_(false)); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving " "overridden method \"%s\" the class loader (instance" " of %s) of the current class, %s, and its superclass loader " @@ -341,6 +341,7 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle tar const char* loader1 = SystemDictionary::loader_name(target_loader()); char* current = _klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(super_loader()); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(failed_type_name); char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); @@ -787,12 +788,12 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass Handle method_holder_loader (THREAD, target->method_holder()->class_loader()); if (method_holder_loader() != interface_loader()) { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(method_signature, method_holder_loader, interface_loader, true, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation in interface " "itable initialization: when resolving method \"%s\" the class" " loader (instance of %s) of the current class, %s, " @@ -804,6 +805,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass char* current = klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(interface_loader()); char* iface = InstanceKlass::cast(interf_h())->name()->as_C_string(); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(iface) + strlen(failed_type_name); From 7363c58e3220d4aaba8f42968b0afb09453f9d20 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 27 Mar 2013 15:41:53 -0400 Subject: [PATCH 080/155] 8010474: [parfait] Undefined return value of the functions in hotspot/src/share/vm/services/memTracker.hpp Fixed functions that miss return values Reviewed-by: coleenp, acorn, kvn --- hotspot/src/share/vm/services/memTracker.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 934daf06ab9..ebcc41500d3 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -86,13 +86,13 @@ class MemTracker : AllStatic { static inline void set_autoShutdown(bool value) { } static void shutdown(ShutdownReason reason) { } - static inline bool shutdown_in_progress() { } + static inline bool shutdown_in_progress() { return false; } static bool print_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true) { } + bool summary_only = true) { return false; } static bool compare_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true) { } + bool summary_only = true) { return false; } - static bool wbtest_wait_for_data_merge() { } + static bool wbtest_wait_for_data_merge() { return false; } static inline void sync() { } static inline void thread_exiting(JavaThread* thread) { } From e56c5733ecb26019a2a7c0f4bae733b267efbe5c Mon Sep 17 00:00:00 2001 From: Jia-Hong Chen Date: Wed, 27 Mar 2013 12:42:51 -0700 Subject: [PATCH 081/155] 8010005: [parfait] Memory leak in jdk/src/macosx/native/sun/awt/CTextPipe.m Reviewed-by: bae, prr --- jdk/src/macosx/native/sun/awt/CTextPipe.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jdk/src/macosx/native/sun/awt/CTextPipe.m b/jdk/src/macosx/native/sun/awt/CTextPipe.m index 6b1da8dea2b..578bf9ca0e3 100644 --- a/jdk/src/macosx/native/sun/awt/CTextPipe.m +++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m @@ -501,10 +501,22 @@ static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc int *uniChars = (int *)malloc(sizeof(int) * length); CGSize *advances = (CGSize *)malloc(sizeof(CGSize) * length); - if (glyphs == NULL || advances == NULL) + if (glyphs == NULL || uniChars == NULL || advances == NULL) { (*env)->DeleteLocalRef(env, glyphsArray); [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__]; + if (glyphs) + { + free(glyphs); + } + if (uniChars) + { + free(uniChars); + } + if (advances) + { + free(advances); + } return; } From 76cc94fb9995252f4b00ed7f17e97f9d01db235c Mon Sep 17 00:00:00 2001 From: Yumin Qi Date: Wed, 27 Mar 2013 17:03:19 -0700 Subject: [PATCH 082/155] 2178143: JVM crashes if the number of bound CPUs changed during runtime Supply a new flag -XX:+AssumeMP to workaround the problem. With the flag is turned on, assume VM run on MP platform so is_MP() will return true that sync calls will not skip away. Reviewed-by: dholmes, acorn, dcubed, jmasa --- hotspot/src/share/vm/runtime/arguments.cpp | 7 +++++++ hotspot/src/share/vm/runtime/globals.hpp | 3 +++ hotspot/src/share/vm/runtime/os.hpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 91561005174..217d82798c9 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -3325,6 +3325,13 @@ jint Arguments::parse(const JavaVMInitArgs* args) { } check_deprecated_gcs(); check_deprecated_gc_flags(); + if (AssumeMP && !UseSerialGC) { + if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { + warning("If the number of processors is expected to increase from one, then" + " you should configure the number of parallel GC threads appropriately" + " using -XX:ParallelGCThreads=N"); + } + } #else // INCLUDE_ALL_GCS assert(verify_serial_gc_flags(), "SerialGC unset"); #endif // INCLUDE_ALL_GCS diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index e73e5089bab..4f3fcbb369b 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -457,6 +457,9 @@ class CommandLineFlags { lp64_product(intx, ObjectAlignmentInBytes, 8, \ "Default object alignment in bytes, 8 is minimum") \ \ + product(bool, AssumeMP, false, \ + "Instruct the VM to assume multiple processors are available") \ + \ /* UseMembar is theoretically a temp flag used for memory barrier \ * removal testing. It was supposed to be removed before FCS but has \ * been re-added (see 6401008) */ \ diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index d061a0848c6..f5dc130545a 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -180,7 +180,7 @@ class os: AllStatic { // Interface for detecting multiprocessor system static inline bool is_MP() { assert(_processor_count > 0, "invalid processor count"); - return _processor_count > 1; + return _processor_count > 1 || AssumeMP; } static julong available_memory(); static julong physical_memory(); From d81ec5b9f38e24aaaeb685ef3f89331dc558f604 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 28 Mar 2013 09:36:43 +0100 Subject: [PATCH 083/155] 8010908: Images target failes when configured with --disable-zip-debug-info Reviewed-by: tbell --- jdk/makefiles/Images.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/makefiles/Images.gmk b/jdk/makefiles/Images.gmk index 4a3a23525d1..70a816145b2 100644 --- a/jdk/makefiles/Images.gmk +++ b/jdk/makefiles/Images.gmk @@ -649,7 +649,7 @@ ifneq ($(POST_STRIP_CMD),) EXEC_LIST_BIN:=$(filter-out %$(notdir $(MSVCR_DLL)),$(filter %.exe %.dll,$(ALL_BIN_LIST))) else # Find all executables in JDK_OUTPUTDIR since they exist when this makefile is parsed - EXEC_LIST_BIN:=$(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX)` \ + EXEC_LIST_BIN:=$(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX) ! -name \*.debuginfo` \ | $(EGREP) 'ELF' | $(CUT) -d':' -f1) # On mac, the old build searches for static libraries for stripping instead of shared. # Not clear if it's intentional. From d891c7c5604b3bcc1674cb0d4c7aa28868465abf Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 28 Mar 2013 14:36:10 +0530 Subject: [PATCH 084/155] 8010991: Enable test/javax/script/GetInterfaceTest.java again Reviewed-by: lagergren, hannesw --- jdk/test/javax/script/GetInterfaceTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jdk/test/javax/script/GetInterfaceTest.java b/jdk/test/javax/script/GetInterfaceTest.java index dffc74ea3b4..654147e1141 100644 --- a/jdk/test/javax/script/GetInterfaceTest.java +++ b/jdk/test/javax/script/GetInterfaceTest.java @@ -22,7 +22,6 @@ */ /* - * @run ignore * @test * @bug 6960211 * @summary JavaScript engine allows creation of interface although methods not available. @@ -49,30 +48,30 @@ public class GetInterfaceTest { } // now define "run" - engine.eval("function run() { println('this is run function'); }"); + engine.eval("function run() { print('this is run function'); }"); runnable = ((Invocable)engine).getInterface(Runnable.class); // should not return null now! runnable.run(); // define only one method of "Foo2" - engine.eval("function bar() { println('bar function'); }"); + engine.eval("function bar() { print('bar function'); }"); Foo2 foo2 = ((Invocable)engine).getInterface(Foo2.class); if (foo2 != null) { throw new RuntimeException("foo2 is not null!"); } // now define other method of "Foo2" - engine.eval("function bar2() { println('bar2 function'); }"); + engine.eval("function bar2() { print('bar2 function'); }"); foo2 = ((Invocable)engine).getInterface(Foo2.class); foo2.bar(); foo2.bar2(); } - interface Foo { + public interface Foo { public void bar(); } - interface Foo2 extends Foo { + public interface Foo2 extends Foo { public void bar2(); } } From 4a64ecdf42d3134bb220ed36ce611c71f3ecee26 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Thu, 28 Mar 2013 20:27:53 +0800 Subject: [PATCH 085/155] 8010125: keytool -importkeystore could create a pkcs12 keystore with different storepass and keypass Reviewed-by: vinnie --- .../sun/security/tools/keytool/Main.java | 15 ++- .../sun/security/tools/keytool/Resources.java | 6 +- .../sun/security/tools/keytool/p12importks.sh | 118 ++++++++++++++++++ 3 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 jdk/test/sun/security/tools/keytool/p12importks.sh diff --git a/jdk/src/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/share/classes/sun/security/tools/keytool/Main.java index a33e00a0c46..c8e96eb6d65 100644 --- a/jdk/src/share/classes/sun/security/tools/keytool/Main.java +++ b/jdk/src/share/classes/sun/security/tools/keytool/Main.java @@ -1832,9 +1832,9 @@ public final class Main { if (alias != null) { doImportKeyStoreSingle(loadSourceKeyStore(), alias); } else { - if (dest != null || srckeyPass != null || destKeyPass != null) { + if (dest != null || srckeyPass != null) { throw new Exception(rb.getString( - "if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified")); + "if.alias.not.specified.destalias.and.srckeypass.must.not.be.specified")); } doImportKeyStoreAll(loadSourceKeyStore()); } @@ -1888,14 +1888,25 @@ public final class Main { // using destkeypass. If destkeypass is not provided, the destination // entry will be protected with the source entry password." // so always try to protect with destKeyPass. + char[] newPass = null; if (destKeyPass != null) { + newPass = destKeyPass; pp = new PasswordProtection(destKeyPass); } else if (objs.snd != null) { + newPass = objs.snd; pp = new PasswordProtection(objs.snd); } try { keyStore.setEntry(newAlias, entry, pp); + // Place the check so that only successful imports are blocked. + // For example, we don't block a failed SecretEntry import. + if (P12KEYSTORE.equalsIgnoreCase(storetype)) { + if (newPass != null && !Arrays.equals(newPass, storePass)) { + throw new Exception(rb.getString( + "The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified.")); + } + } return 1; } catch (KeyStoreException kse) { Object[] source2 = {alias, kse.toString()}; diff --git a/jdk/src/share/classes/sun/security/tools/keytool/Resources.java b/jdk/src/share/classes/sun/security/tools/keytool/Resources.java index 262fe20ea4a..393aa3babe1 100644 --- a/jdk/src/share/classes/sun/security/tools/keytool/Resources.java +++ b/jdk/src/share/classes/sun/security/tools/keytool/Resources.java @@ -242,8 +242,10 @@ public class Resources extends java.util.ListResourceBundle { {"Certification.request.stored.in.file.filename.", "Certification request stored in file <{0}>"}, {"Submit.this.to.your.CA", "Submit this to your CA"}, - {"if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified", - "if alias not specified, destalias, srckeypass, and destkeypass must not be specified"}, + {"if.alias.not.specified.destalias.and.srckeypass.must.not.be.specified", + "if alias not specified, destalias and srckeypass must not be specified"}, + {"The.destination.pkcs12.keystore.has.different.storepass.and.keypass.Please.retry.with.destkeypass.specified.", + "The destination pkcs12 keystore has different storepass and keypass. Please retry with -destkeypass specified."}, {"Certificate.stored.in.file.filename.", "Certificate stored in file <{0}>"}, {"Certificate.reply.was.installed.in.keystore", diff --git a/jdk/test/sun/security/tools/keytool/p12importks.sh b/jdk/test/sun/security/tools/keytool/p12importks.sh new file mode 100644 index 00000000000..efdb56a3426 --- /dev/null +++ b/jdk/test/sun/security/tools/keytool/p12importks.sh @@ -0,0 +1,118 @@ +# +# Copyright (c) 2013, 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 8010125 +# @summary keytool -importkeystore could create a pkcs12 keystore with +# different storepass and keypass +# + +if [ "${TESTJAVA}" = "" ] ; then + JAVAC_CMD=`which javac` + TESTJAVA=`dirname $JAVAC_CMD`/.. +fi + +# set platform-dependent variables +OS=`uname -s` +case "$OS" in + Windows_* ) + FS="\\" + ;; + * ) + FS="/" + ;; +esac + +LANG=C +KT=$TESTJAVA${FS}bin${FS}keytool + +# Part 1: JKS keystore with same storepass and keypass + +rm jks 2> /dev/null +$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \ + -storepass pass1111 -keypass pass1111 || exit 11 + +# Cannot only change storepass +rm p12 2> /dev/null +$KT -importkeystore -noprompt \ + -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \ + -srcstorepass pass1111 \ + -deststorepass pass2222 \ + && exit 12 + +# You can keep storepass unchanged +rm p12 2> /dev/null +$KT -importkeystore -noprompt \ + -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \ + -srcstorepass pass1111 \ + -deststorepass pass1111 \ + || exit 13 +$KT -certreq -storetype pkcs12 -keystore p12 -alias me \ + -storepass pass1111 -keypass pass1111 || exit 14 + +# Or change storepass and keypass both +rm p12 2> /dev/null +$KT -importkeystore -noprompt \ + -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \ + -srcstorepass pass1111 \ + -deststorepass pass2222 -destkeypass pass2222 \ + || exit 15 +$KT -certreq -storetype pkcs12 -keystore p12 -alias me \ + -storepass pass2222 -keypass pass2222 || exit 16 + +# Part 2: JKS keystore with different storepass and keypass +# Must import by alias (-srckeypass is not available when importing all) + +rm jks 2> /dev/null +$KT -genkeypair -keystore jks -storetype jks -alias me -dname CN=Me \ + -storepass pass1111 -keypass pass2222 || exit 21 + +# Can use old keypass as new storepass so new storepass and keypass are same +rm p12 2> /dev/null +$KT -importkeystore -noprompt -srcalias me \ + -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \ + -srcstorepass pass1111 -srckeypass pass2222 \ + -deststorepass pass2222 \ + || exit 22 +$KT -certreq -storetype pkcs12 -keystore p12 -alias me \ + -storepass pass2222 -keypass pass2222 || exit 23 + +# Or specify both storepass and keypass to brand new ones +rm p12 2> /dev/null +$KT -importkeystore -noprompt -srcalias me \ + -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \ + -srcstorepass pass1111 -srckeypass pass2222 \ + -deststorepass pass3333 -destkeypass pass3333 \ + || exit 24 +$KT -certreq -storetype pkcs12 -keystore p12 -alias me \ + -storepass pass3333 -keypass pass3333 || exit 25 + +# Anyway you cannot make new storepass and keypass different +rm p12 2> /dev/null +$KT -importkeystore -noprompt -srcalias me \ + -srcstoretype jks -srckeystore jks -destkeystore p12 -deststoretype pkcs12 \ + -srcstorepass pass1111 -srckeypass pass2222 \ + -deststorepass pass1111 \ + && exit 26 + +exit 0 From cbe728a9bddbba068e930a8c4da59451e0aaebb2 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Sun, 31 Mar 2013 21:43:10 -0400 Subject: [PATCH 086/155] 8010723: fatal error: acquiring lock Metaspace allocation lock/5 out of order Avoid holding SystemDictionary_lock while calling Klass::remove_unshareable_info Reviewed-by: coleenp, acorn --- .../share/vm/classfile/systemDictionary.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 2f7c7c9553f..fa1f8363812 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -816,13 +816,28 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, Handle cla // We didn't go as far as Klass::restore_unshareable_info(), // so nothing to clean up. } else { - MutexLocker mu(SystemDictionary_lock, THREAD); - Klass* kk = find_class(name, ik->class_loader_data()); + Klass *kk; + { + MutexLocker mu(SystemDictionary_lock, THREAD); + kk = find_class(name, ik->class_loader_data()); + } if (kk != NULL) { // No clean up is needed if the shared class has been entered // into system dictionary, as load_shared_class() won't be called // again. } else { + // This must be done outside of the SystemDictionary_lock to + // avoid deadlock. + // + // Note that Klass::restore_unshareable_info (called via + // load_instance_class above) is also called outside + // of SystemDictionary_lock. Other threads are blocked from + // loading this class because they are waiting on the + // SystemDictionary_lock until this thread removes + // the placeholder below. + // + // This need to be re-thought when parallel-capable non-boot + // classloaders are supported by CDS (today they're not). clean_up_shared_class(ik, class_loader, THREAD); } } From 388d803077fff7d75b5419f946078eda486abcf2 Mon Sep 17 00:00:00 2001 From: Peter Allwin Date: Thu, 28 Mar 2013 15:39:52 +0100 Subject: [PATCH 087/155] 8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM Reviewed-by: sspitsyn, zgu --- .../jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java index fe7559d05fa..22957a27deb 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java @@ -572,9 +572,14 @@ public class WindbgDebuggerLocal extends DebuggerBase implements WindbgDebugger DTFWHome = sysRoot + File.separator + ".." + File.separator + "Program Files" + File.separator + "Debugging Tools For Windows"; searchList.add(DTFWHome); - searchList.add(DTFWHome + " (x86)"); - searchList.add(DTFWHome + " (x64)"); + // Only add the search path for the current CPU architecture: + String cpu = PlatformInfo.getCPU(); + if (cpu.equals("x86")) { + searchList.add(DTFWHome + " (x86)"); + } else if (cpu.equals("amd64")) { + searchList.add(DTFWHome + " (x64)"); + } // The last place to search is the system directory: searchList.add(sysRoot + File.separator + "system32"); } From 361893b41ad5d49f4f1abfdc577a3225b8fd4840 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:53:50 -0700 Subject: [PATCH 088/155] Added tag jdk8-b83 for changeset 64247ba55872 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 7b38704aae9..db8b4550f1e 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -204,3 +204,4 @@ fd1a5574cf68af24bfd52decc37ac6361afb278a jdk8-b78 907a926d3c96472f357617b48b6b968ea855c23c jdk8-b80 145dbc56f931c134e837b675b9e6e7bf08902e93 jdk8-b81 29153d0df68f84162ffe8c2cf4f402a3f2245e85 jdk8-b82 +466685ba01bfb7bc1e1ac61490fd8c0f3cc18763 jdk8-b83 From 91473e6924d39dd60d3803340e19a61f3085a2a4 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:53:52 -0700 Subject: [PATCH 089/155] Added tag jdk8-b83 for changeset d2d074c62b67 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 92bf938663c..5a2a5cfc102 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -204,3 +204,4 @@ e41fb1aa0329767b2737303c994e38bede1baa07 jdk8-b79 5f3d4a6bdd027a1631d97e2dfff63fd5e46987a4 jdk8-b80 2a00aeeb466b9dee22508f6261f63b70f9c696fe jdk8-b81 48e1bc77004d9af575b733c04637b98fd17603c2 jdk8-b82 +a45bb25a67c7517b45f00c9682e317f46fecbba9 jdk8-b83 From afd676cdb3468ebc1d6573e59820de9c0597454d Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:54:00 -0700 Subject: [PATCH 090/155] Added tag jdk8-b83 for changeset 395a7c20e300 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index bfb3baa2ed0..d2b3a33d041 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -326,3 +326,4 @@ dd6350b4abc4a6c19c89dd982cc0e4f3d119885c hs25-b22 0631ebcc45f05c73b09a56c2586685af1f781c1d hs25-b23 3db4ab0e12f437fe374817de346b2b0c6b4a5b31 jdk8-b82 e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24 +1c8db54ee9f315e20d6d5d9bf0b5c10349e9d301 jdk8-b83 From 65616fa742e2ad4b07ea2e550371a21db453126b Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:54:36 -0700 Subject: [PATCH 091/155] Added tag jdk8-b83 for changeset 8ca744a5d6f4 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 0c78beb6716..21b40f387ac 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -204,3 +204,4 @@ ff0b73a6b3f6cea644d37d56d746a37743419fa7 jdk8-b75 4873a0499bc3bd263b7dd3b551a2b4e275ab5a0b jdk8-b80 ef3495555a4c6e706a3058c18aa229b14220de0b jdk8-b81 d5a58291f09a5081eaf22c2a6ab2f9ced4b78882 jdk8-b82 +a46d69a1a8ec9652a48114823535372e1c980799 jdk8-b83 From ff17e3e399c49f7b47d2cc887c1b8a124b730166 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:54:47 -0700 Subject: [PATCH 092/155] Added tag jdk8-b83 for changeset 74e3fc2986f0 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index e02bdee2151..7bfa0ebd9f6 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -204,3 +204,4 @@ c4853f3f0e89ac60aa5b517f5f224f0f60e08577 jdk8-b76 b0224010e2f0c2474055ac592c8d3f37b9264690 jdk8-b80 c88bb21560ccf1a9e6d2a2ba08ed2045a002676f jdk8-b81 d8d8032d02d77fbf5f9b3bb8df73663f42fd4dd0 jdk8-b82 +a1dcc0d83da1e07f3ada60ef110dd105d95d3554 jdk8-b83 From e4d9e1a5e7c9b833bea612d73814c4f9adaf73e4 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:55:14 -0700 Subject: [PATCH 093/155] Added tag jdk8-b83 for changeset fd242a461861 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 4f56fa54e99..359cd5e1440 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -204,3 +204,4 @@ af8417e590f4e76e0dfed09e71239fb102ef0d43 jdk8-b78 a8227c61768499dac847ea718af6719027c949f2 jdk8-b80 ed69d087fdfd394491657a28ba9bc58e7849b7db jdk8-b81 825da6847791994a8f405ee397df9e7fa638a458 jdk8-b82 +22ba3f92d4ae43bbc19793e854171cae2586f644 jdk8-b83 From ea13857a216630e87272b563813ebe23982e8fbf Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 28 Mar 2013 10:55:17 -0700 Subject: [PATCH 094/155] Added tag jdk8-b83 for changeset 4f4788d62566 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index ef0d7251625..d182815a343 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -192,3 +192,4 @@ b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b67 b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b68 b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b69 5759f600fcf7b51ccc6cc8229be980e2153f8675 jdk8-b82 +053d7c55dc8272b58b8bb870dc92a4acf896d52a jdk8-b83 From 2ca495dd4333388f244de28b834ccbd3381501c8 Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Thu, 28 Mar 2013 13:14:09 -0700 Subject: [PATCH 095/155] 8010309: Improve PlatformLogger.isLoggable performance by direct mapping from an integer to Level Co-authored-by: Laurent Bourges Reviewed-by: mchung --- .../sun/util/logging/PlatformLogger.java | 387 ++++++++++-------- .../sun/util/logging/PlatformLoggerTest.java | 78 +++- 2 files changed, 296 insertions(+), 169 deletions(-) diff --git a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java index 000a1603fe9..ef9789b7bf1 100644 --- a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java +++ b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java @@ -27,14 +27,11 @@ package sun.util.logging; import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.security.AccessController; import java.security.PrivilegedAction; -import java.text.MessageFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -87,18 +84,51 @@ import sun.misc.SharedSecrets; * @since 1.7 */ public class PlatformLogger { - // Same values as java.util.logging.Level for easy mapping - public static final int OFF = Integer.MAX_VALUE; - public static final int SEVERE = 1000; - public static final int WARNING = 900; - public static final int INFO = 800; - public static final int CONFIG = 700; - public static final int FINE = 500; - public static final int FINER = 400; - public static final int FINEST = 300; - public static final int ALL = Integer.MIN_VALUE; + // shortcut to PlatformLogger.Level enums + public static final Level OFF = Level.OFF; + public static final Level SEVERE = Level.SEVERE; + public static final Level WARNING = Level.WARNING; + public static final Level INFO = Level.INFO; + public static final Level CONFIG = Level.CONFIG; + public static final Level FINE = Level.FINE; + public static final Level FINER = Level.FINER; + public static final Level FINEST = Level.FINEST; + public static final Level ALL = Level.ALL; - private static final int defaultLevel = INFO; + /** + * PlatformLogger logging levels. + */ + public static enum Level { + // The name and value must match that of {@code java.util.logging.Level} objects. + ALL(Integer.MIN_VALUE), + FINEST(300), + FINER(400), + FINE(500), + CONFIG(700), + INFO(800), + WARNING(900), + SEVERE(1000), + OFF(Integer.MAX_VALUE); + + /** + * Associated java.util.logging.Level lazily initialized in + * JavaLoggerProxy's static initializer only once + * when java.util.logging is available and enabled. + * Only accessed by JavaLoggerProxy. + */ + /* java.util.logging.Level */ Object javaLevel; + + private final int value; + public int intValue() { + return value; + } + + Level(int value) { + this.value = value; + } + } + + private static final Level DEFAULT_LEVEL = INFO; private static boolean loggingEnabled; static { loggingEnabled = AccessController.doPrivileged( @@ -109,6 +139,20 @@ public class PlatformLogger { return (cname != null || fname != null); } }); + + // force loading of all JavaLoggerProxy (sub)classes to make JIT de-optimizations + // less probable. Don't initialize JavaLoggerProxy class since + // java.util.logging may not be enabled. + try { + Class.forName("sun.util.logging.PlatformLogger$DefaultLoggerProxy", + false, + PlatformLogger.class.getClassLoader()); + Class.forName("sun.util.logging.PlatformLogger$JavaLoggerProxy", + false, // do not invoke class initializer + PlatformLogger.class.getClassLoader()); + } catch (ClassNotFoundException ex) { + throw new InternalError(ex); + } } // Table of known loggers. Maps names to PlatformLoggers. @@ -143,27 +187,32 @@ public class PlatformLogger { WeakReference ref = entry.getValue(); PlatformLogger plog = ref.get(); if (plog != null) { - plog.newJavaLogger(); + plog.redirectToJavaLoggerProxy(); } } } /** - * Creates a new JavaLogger that the platform logger uses + * Creates a new JavaLoggerProxy and redirects the platform logger to it */ - private void newJavaLogger() { - logger = new JavaLogger(logger.name, logger.effectiveLevel); + private void redirectToJavaLoggerProxy() { + DefaultLoggerProxy lp = DefaultLoggerProxy.class.cast(this.loggerProxy); + JavaLoggerProxy jlp = new JavaLoggerProxy(lp.name, lp.level); + // the order of assignments is important + this.javaLoggerProxy = jlp; // isLoggable checks javaLoggerProxy if set + this.loggerProxy = jlp; } - // logger may be replaced with a JavaLogger object - // when the logging facility is enabled - private volatile LoggerProxy logger; - + // DefaultLoggerProxy may be replaced with a JavaLoggerProxy object + // when the java.util.logging facility is enabled + private volatile LoggerProxy loggerProxy; + // javaLoggerProxy is only set when the java.util.logging facility is enabled + private volatile JavaLoggerProxy javaLoggerProxy; private PlatformLogger(String name) { if (loggingEnabled) { - this.logger = new JavaLogger(name); + this.loggerProxy = this.javaLoggerProxy = new JavaLoggerProxy(name); } else { - this.logger = new LoggerProxy(name); + this.loggerProxy = new DefaultLoggerProxy(name); } } @@ -172,204 +221,248 @@ public class PlatformLogger { * (i.e. its level is OFF). */ public boolean isEnabled() { - return logger.isEnabled(); + return loggerProxy.isEnabled(); } /** * Gets the name for this platform logger. */ public String getName() { - return logger.name; + return loggerProxy.name; } /** * Returns true if a message of the given level would actually * be logged by this logger. */ - public boolean isLoggable(int level) { - return logger.isLoggable(level); + public boolean isLoggable(Level level) { + // performance-sensitive method: use two monomorphic call-sites + JavaLoggerProxy jlp = javaLoggerProxy; + return jlp != null ? jlp.isLoggable(level) : loggerProxy.isLoggable(level); } /** - * Gets the current log level. Returns 0 if the current effective level - * is not set (equivalent to Logger.getLevel() returns null). + * Get the log level that has been specified for this PlatformLogger. + * The result may be null, which means that this logger's + * effective level will be inherited from its parent. + * + * This method is primarily for testing purpose and not recommended + * to be used at runtime since it does not support custom j.u.l.Level. + * + * @return this PlatformLogger's level + * + * @throw IllegalArgumentException if j.u.l.Logger is set to + * a custom j.u.l.Level when java.util.logging facility is enabled */ - public int getLevel() { - return logger.getLevel(); + public Level getLevel() { + return loggerProxy.getLevel(); } /** - * Sets the log level. + * Set the log level specifying which message levels will be + * logged by this logger. Message levels lower than this + * value will be discarded. The level value {@link #OFF} + * can be used to turn off logging. + *

    + * If the new level is null, it means that this node should + * inherit its level from its nearest ancestor with a specific + * (non-null) level value. + * + * @param newLevel the new value for the log level (may be null) */ - public void setLevel(int newLevel) { - logger.setLevel(newLevel); + public void setLevel(Level newLevel) { + loggerProxy.setLevel(newLevel); } /** * Logs a SEVERE message. */ public void severe(String msg) { - logger.doLog(SEVERE, msg); + loggerProxy.doLog(SEVERE, msg); } public void severe(String msg, Throwable t) { - logger.doLog(SEVERE, msg, t); + loggerProxy.doLog(SEVERE, msg, t); } public void severe(String msg, Object... params) { - logger.doLog(SEVERE, msg, params); + loggerProxy.doLog(SEVERE, msg, params); } /** * Logs a WARNING message. */ public void warning(String msg) { - logger.doLog(WARNING, msg); + loggerProxy.doLog(WARNING, msg); } public void warning(String msg, Throwable t) { - logger.doLog(WARNING, msg, t); + loggerProxy.doLog(WARNING, msg, t); } public void warning(String msg, Object... params) { - logger.doLog(WARNING, msg, params); + loggerProxy.doLog(WARNING, msg, params); } /** * Logs an INFO message. */ public void info(String msg) { - logger.doLog(INFO, msg); + loggerProxy.doLog(INFO, msg); } public void info(String msg, Throwable t) { - logger.doLog(INFO, msg, t); + loggerProxy.doLog(INFO, msg, t); } public void info(String msg, Object... params) { - logger.doLog(INFO, msg, params); + loggerProxy.doLog(INFO, msg, params); } /** * Logs a CONFIG message. */ public void config(String msg) { - logger.doLog(CONFIG, msg); + loggerProxy.doLog(CONFIG, msg); } public void config(String msg, Throwable t) { - logger.doLog(CONFIG, msg, t); + loggerProxy.doLog(CONFIG, msg, t); } public void config(String msg, Object... params) { - logger.doLog(CONFIG, msg, params); + loggerProxy.doLog(CONFIG, msg, params); } /** * Logs a FINE message. */ public void fine(String msg) { - logger.doLog(FINE, msg); + loggerProxy.doLog(FINE, msg); } public void fine(String msg, Throwable t) { - logger.doLog(FINE, msg, t); + loggerProxy.doLog(FINE, msg, t); } public void fine(String msg, Object... params) { - logger.doLog(FINE, msg, params); + loggerProxy.doLog(FINE, msg, params); } /** * Logs a FINER message. */ public void finer(String msg) { - logger.doLog(FINER, msg); + loggerProxy.doLog(FINER, msg); } public void finer(String msg, Throwable t) { - logger.doLog(FINER, msg, t); + loggerProxy.doLog(FINER, msg, t); } public void finer(String msg, Object... params) { - logger.doLog(FINER, msg, params); + loggerProxy.doLog(FINER, msg, params); } /** * Logs a FINEST message. */ public void finest(String msg) { - logger.doLog(FINEST, msg); + loggerProxy.doLog(FINEST, msg); } public void finest(String msg, Throwable t) { - logger.doLog(FINEST, msg, t); + loggerProxy.doLog(FINEST, msg, t); } public void finest(String msg, Object... params) { - logger.doLog(FINEST, msg, params); + loggerProxy.doLog(FINEST, msg, params); } /** - * Default platform logging support - output messages to - * System.err - equivalent to ConsoleHandler with SimpleFormatter. + * Abstract base class for logging support, defining the API and common field. */ - static class LoggerProxy { - private static final PrintStream defaultStream = System.err; - + private static abstract class LoggerProxy { final String name; - volatile int levelValue; - volatile int effectiveLevel = 0; // current effective level value - LoggerProxy(String name) { - this(name, defaultLevel); + protected LoggerProxy(String name) { + this.name = name; } - LoggerProxy(String name, int level) { - this.name = name; - this.levelValue = level == 0 ? defaultLevel : level; + abstract boolean isEnabled(); + + abstract Level getLevel(); + abstract void setLevel(Level newLevel); + + abstract void doLog(Level level, String msg); + abstract void doLog(Level level, String msg, Throwable thrown); + abstract void doLog(Level level, String msg, Object... params); + + abstract boolean isLoggable(Level level); + } + + + private static final class DefaultLoggerProxy extends LoggerProxy { + /** + * Default platform logging support - output messages to System.err - + * equivalent to ConsoleHandler with SimpleFormatter. + */ + private static PrintStream outputStream() { + return System.err; + } + + volatile Level effectiveLevel; // effective level (never null) + volatile Level level; // current level set for this node (may be null) + + DefaultLoggerProxy(String name) { + super(name); + this.effectiveLevel = deriveEffectiveLevel(null); + this.level = null; } boolean isEnabled() { - return levelValue != OFF; + return effectiveLevel != OFF; } - int getLevel() { - return effectiveLevel; + Level getLevel() { + return level; } - void setLevel(int newLevel) { - levelValue = newLevel; - effectiveLevel = newLevel; - } - - void doLog(int level, String msg) { - if (level < levelValue || levelValue == OFF) { - return; + void setLevel(Level newLevel) { + Level oldLevel = level; + if (oldLevel != newLevel) { + level = newLevel; + effectiveLevel = deriveEffectiveLevel(newLevel); } - defaultStream.print(format(level, msg, null)); } - void doLog(int level, String msg, Throwable thrown) { - if (level < levelValue || levelValue == OFF) { - return; + void doLog(Level level, String msg) { + if (isLoggable(level)) { + outputStream().print(format(level, msg, null)); } - defaultStream.print(format(level, msg, thrown)); } - void doLog(int level, String msg, Object... params) { - if (level < levelValue || levelValue == OFF) { - return; + void doLog(Level level, String msg, Throwable thrown) { + if (isLoggable(level)) { + outputStream().print(format(level, msg, thrown)); } - String newMsg = formatMessage(msg, params); - defaultStream.print(format(level, newMsg, null)); } - public boolean isLoggable(int level) { - if (level < levelValue || levelValue == OFF) { - return false; + void doLog(Level level, String msg, Object... params) { + if (isLoggable(level)) { + String newMsg = formatMessage(msg, params); + outputStream().print(format(level, newMsg, null)); } - return true; + } + + boolean isLoggable(Level level) { + Level effectiveLevel = this.effectiveLevel; + return level.intValue() >= effectiveLevel.intValue() && effectiveLevel != OFF; + } + + // derive effective level (could do inheritance search like j.u.l.Logger) + private Level deriveEffectiveLevel(Level level) { + return level == null ? DEFAULT_LEVEL : level; } // Copied from java.util.logging.Formatter.formatMessage @@ -401,7 +494,7 @@ public class PlatformLogger { // minimize memory allocation private Date date = new Date(); - private synchronized String format(int level, String msg, Throwable thrown) { + private synchronized String format(Level level, String msg, Throwable thrown) { date.setTime(System.currentTimeMillis()); String throwable = ""; if (thrown != null) { @@ -417,7 +510,7 @@ public class PlatformLogger { date, getCallerInfo(), name, - PlatformLogger.getLevelName(level), + level.name(), msg, throwable); } @@ -464,58 +557,41 @@ public class PlatformLogger { } /** - * JavaLogger forwards all the calls to its corresponding + * JavaLoggerProxy forwards all the calls to its corresponding * java.util.logging.Logger object. */ - static class JavaLogger extends LoggerProxy { - private static final Map levelObjects = - new HashMap<>(); - + private static final class JavaLoggerProxy extends LoggerProxy { + // initialize javaLevel fields for mapping from Level enum -> j.u.l.Level object static { - if (LoggingSupport.isAvailable()) { - // initialize the map to Level objects - getLevelObjects(); + for (Level level : Level.values()) { + level.javaLevel = LoggingSupport.parseLevel(level.name()); } } - private static void getLevelObjects() { - // get all java.util.logging.Level objects - int[] levelArray = new int[] {OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL}; - for (int l : levelArray) { - Object level = LoggingSupport.parseLevel(getLevelName(l)); - levelObjects.put(l, level); - } + private final /* java.util.logging.Logger */ Object javaLogger; + + JavaLoggerProxy(String name) { + this(name, null); } - private final Object javaLogger; - JavaLogger(String name) { - this(name, 0); - } - - JavaLogger(String name, int level) { - super(name, level); + JavaLoggerProxy(String name, Level level) { + super(name); this.javaLogger = LoggingSupport.getLogger(name); - if (level != 0) { + if (level != null) { // level has been updated and so set the Logger's level - LoggingSupport.setLevel(javaLogger, levelObjects.get(level)); + LoggingSupport.setLevel(javaLogger, level.javaLevel); } } - /** - * Let Logger.log() do the filtering since if the level of a - * platform logger is altered directly from - * java.util.logging.Logger.setLevel(), the levelValue will - * not be updated. - */ - void doLog(int level, String msg) { - LoggingSupport.log(javaLogger, levelObjects.get(level), msg); + void doLog(Level level, String msg) { + LoggingSupport.log(javaLogger, level.javaLevel, msg); } - void doLog(int level, String msg, Throwable t) { - LoggingSupport.log(javaLogger, levelObjects.get(level), msg, t); + void doLog(Level level, String msg, Throwable t) { + LoggingSupport.log(javaLogger, level.javaLevel, msg, t); } - void doLog(int level, String msg, Object... params) { + void doLog(Level level, String msg, Object... params) { if (!isLoggable(level)) { return; } @@ -526,49 +602,32 @@ public class PlatformLogger { for (int i = 0; i < len; i++) { sparams [i] = String.valueOf(params[i]); } - LoggingSupport.log(javaLogger, levelObjects.get(level), msg, sparams); + LoggingSupport.log(javaLogger, level.javaLevel, msg, sparams); } boolean isEnabled() { - Object level = LoggingSupport.getLevel(javaLogger); - return level == null || level.equals(levelObjects.get(OFF)) == false; + return LoggingSupport.isLoggable(javaLogger, Level.OFF.javaLevel); } - int getLevel() { - Object level = LoggingSupport.getLevel(javaLogger); - if (level != null) { - for (Map.Entry l : levelObjects.entrySet()) { - if (level == l.getValue()) { - return l.getKey(); - } - } - } - return 0; + /** + * Returns the PlatformLogger.Level mapped from j.u.l.Level + * set in the logger. + * @throw IllegalArgumentException if j.u.l.Logger is set to + * a custom j.u.l.Level + */ + Level getLevel() { + Object javaLevel = LoggingSupport.getLevel(javaLogger); + return javaLevel == null + ? null + : Level.valueOf(LoggingSupport.getLevelName(javaLevel)); } - void setLevel(int newLevel) { - levelValue = newLevel; - LoggingSupport.setLevel(javaLogger, levelObjects.get(newLevel)); + void setLevel(Level level) { + LoggingSupport.setLevel(javaLogger, level == null ? null : level.javaLevel); } - public boolean isLoggable(int level) { - return LoggingSupport.isLoggable(javaLogger, levelObjects.get(level)); + boolean isLoggable(Level level) { + return LoggingSupport.isLoggable(javaLogger, level.javaLevel); } } - - private static String getLevelName(int level) { - switch (level) { - case OFF : return "OFF"; - case SEVERE : return "SEVERE"; - case WARNING : return "WARNING"; - case INFO : return "INFO"; - case CONFIG : return "CONFIG"; - case FINE : return "FINE"; - case FINER : return "FINER"; - case FINEST : return "FINEST"; - case ALL : return "ALL"; - default : return "UNKNOWN"; - } - } - } diff --git a/jdk/test/sun/util/logging/PlatformLoggerTest.java b/jdk/test/sun/util/logging/PlatformLoggerTest.java index 25018874af4..7fc007aae0f 100644 --- a/jdk/test/sun/util/logging/PlatformLoggerTest.java +++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6882376 6985460 + * @bug 6882376 6985460 8010309 * @summary Test if java.util.logging.Logger is created before and after * logging is enabled. Also validate some basic PlatformLogger * operations. othervm mode to make sure java.util.logging @@ -33,11 +33,11 @@ * @run main/othervm PlatformLoggerTest */ +import java.lang.reflect.Field; import java.util.logging.*; import sun.util.logging.PlatformLogger; public class PlatformLoggerTest { - private static final int defaultEffectiveLevel = 0; public static void main(String[] args) throws Exception { final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo"; final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar"; @@ -72,6 +72,7 @@ public class PlatformLoggerTest { foo.setLevel(PlatformLogger.SEVERE); checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE); + checkPlatformLoggerLevels(foo, bar); } private static void checkPlatformLogger(PlatformLogger logger, String name) { @@ -80,9 +81,9 @@ public class PlatformLoggerTest { logger.getName() + " but expected " + name); } - if (logger.getLevel() != defaultEffectiveLevel) { + if (logger.getLevel() != null) { throw new RuntimeException("Invalid default level for logger " + - logger.getName()); + logger.getName() + ": " + logger.getLevel()); } if (logger.isLoggable(PlatformLogger.FINE) != false) { @@ -91,7 +92,7 @@ public class PlatformLoggerTest { } logger.setLevel(PlatformLogger.FINER); - if (logger.getLevel() != Level.FINER.intValue()) { + if (logger.getLevel() != PlatformLogger.FINER) { throw new RuntimeException("Invalid level for logger " + logger.getName() + " " + logger.getLevel()); } @@ -125,6 +126,73 @@ public class PlatformLoggerTest { logger.info("Test info(String)"); } + private static void checkPlatformLoggerLevels(PlatformLogger... loggers) { + final Level[] levels = new Level[] { + Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, + Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING + }; + + int count = PlatformLogger.Level.values().length; + if (levels.length != count) { + throw new RuntimeException("There are " + count + + " PlatformLogger.Level members, but " + levels.length + + " standard java.util.logging levels - the numbers should be equal."); + } + // check mappings + for (Level level : levels) { + checkPlatformLoggerLevelMapping(level); + } + + for (Level level : levels) { + PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName()); + for (PlatformLogger logger : loggers) { + // verify PlatformLogger.setLevel to a given level + logger.setLevel(platformLevel); + PlatformLogger.Level retrievedPlatformLevel = logger.getLevel(); + if (platformLevel != retrievedPlatformLevel) { + throw new RuntimeException("Retrieved PlatformLogger level " + + retrievedPlatformLevel + + " is not the same as set level " + platformLevel); + } + + // check the level set in java.util.logging.Logger + Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName()); + Level javaLevel = javaLogger.getLevel(); + if (javaLogger.getLevel() != level) { + throw new RuntimeException("Retrieved backing java.util.logging.Logger level " + + javaLevel + " is not the expected " + level); + } + } + } + } + + private static void checkPlatformLoggerLevelMapping(Level level) { + // map the given level to PlatformLogger.Level of the same name and value + PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName()); + if (platformLevel.intValue() != level.intValue()) { + throw new RuntimeException("Mismatched level: " + level + + " PlatformLogger.Level" + platformLevel); + } + + PlatformLogger.Level plevel; + try { + // validate if there is a public static final field in PlatformLogger + // matching the level name + Field platformLevelField = PlatformLogger.class.getField(level.getName()); + plevel = (PlatformLogger.Level) platformLevelField.get(null); + } catch (Exception e) { + throw new RuntimeException("No public static PlatformLogger." + level.getName() + + " field", e); + } + if (!plevel.name().equals(level.getName())) + throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is " + + platformLevel.name() + " but expected " + level.getName()); + + if (plevel.intValue() != level.intValue()) + throw new RuntimeException("The value of PlatformLogger." + level.intValue() + ".intValue() is " + + platformLevel.intValue() + " but expected " + level.intValue()); + } + static Point[] getPoints() { Point[] res = new Point[3]; res[0] = new Point(0,0); From 142f171fb666bff6c9f759b7f929e39bb0b2e11c Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Thu, 28 Mar 2013 19:02:00 -0700 Subject: [PATCH 096/155] Added tag hs25-b25 for changeset 4c619ad74be5 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index d2b3a33d041..40fd36ae97f 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -327,3 +327,4 @@ dd6350b4abc4a6c19c89dd982cc0e4f3d119885c hs25-b22 3db4ab0e12f437fe374817de346b2b0c6b4a5b31 jdk8-b82 e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24 1c8db54ee9f315e20d6d5d9bf0b5c10349e9d301 jdk8-b83 +8d0f263a370c5f3e61791bb06054560804117288 hs25-b25 From f6b3e5b4950ba157c4fa03af1dd37d918cdabd8c Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Thu, 28 Mar 2013 19:13:22 -0700 Subject: [PATCH 097/155] 8011022: new hotspot build - hs25-b26 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 c6bad83dffd..03616715c5c 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=25 +HS_BUILD_NUMBER=26 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From 3c586e8f26743d2b7b1b859c8b9fb0cb6c274676 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 29 Mar 2013 17:25:27 +0100 Subject: [PATCH 098/155] 8010934: assert failure in c1_LinearScan.cpp: "asumption: non-Constant instructions have only virtual operands" Incorrect code to skip some ArrayLength instructions in LIRGenerator Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 2 -- hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index a3970cb3f8f..84402a9ef0d 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1872,8 +1872,6 @@ void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) { void LIRGenerator::do_ArrayLength(ArrayLength* x) { - if (x->use_count() == 0 && !x->can_trap()) return; - LIRItem array(x->array(), this); array.load_item(); LIR_Opr reg = rlock_result(x); diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp index 948f635c27f..40c448a39ed 100644 --- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp @@ -645,7 +645,7 @@ Instruction* RangeCheckEliminator::predicate_add_cmp_with_const(Instruction* lef return predicate_add(left, left_const, cond, const_instr, state, insert_position); } -// Insert deoptimization, returns true if sucessful or false if range check should not be removed +// Insert deoptimization void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper, AccessIndexed *ai) { assert(is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, lower, upper_instr, upper), "should have been tested before"); bool upper_check = !(upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr); @@ -669,6 +669,9 @@ void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction } } + // No upper check required -> skip + if (!upper_check) return; + // We need to know length of array if (!length_instr) { // Load length if necessary @@ -680,9 +683,6 @@ void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction length_instr = length; } - // No upper check required -> skip - if (!upper_check) return; - if (!upper_instr) { // Compare for geq array.length insert_position = predicate_cmp_with_const(length_instr, Instruction::leq, upper, state, insert_position, bci); @@ -777,7 +777,7 @@ void RangeCheckEliminator::process_access_indexed(BlockBegin *loop_header, Block tty->fill_to(block->dominator_depth()*2) ); TRACE_RANGE_CHECK_ELIMINATION( - tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), ai->length()->id()) + tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), (ai->length() != NULL ? ai->length()->id() :-1 )) ); if (ai->check_flag(Instruction::NeedsRangeCheckFlag)) { From 214b7d9dcff30ed8485e1a3723c697d3b71ed632 Mon Sep 17 00:00:00 2001 From: Krystal Mo Date: Sat, 30 Mar 2013 08:01:05 -0700 Subject: [PATCH 099/155] 8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros Improve EC_TRACE and RC_TRACE* to use the do-while(0) trick for statement-like macro Reviewed-by: sspitsyn, dcubed --- .../share/vm/prims/jvmtiEventController.cpp | 7 +- .../vm/prims/jvmtiRedefineClassesTrace.hpp | 77 ++++++++++--------- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiEventController.cpp b/hotspot/src/share/vm/prims/jvmtiEventController.cpp index 6b7b72b7ae6..cdec7d71f2d 100644 --- a/hotspot/src/share/vm/prims/jvmtiEventController.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEventController.cpp @@ -39,7 +39,12 @@ #include "runtime/vm_operations.hpp" #ifdef JVMTI_TRACE -#define EC_TRACE(out) if (JvmtiTrace::trace_event_controller()) { SafeResourceMark rm; tty->print_cr out; } while (0) +#define EC_TRACE(out) do { \ + if (JvmtiTrace::trace_event_controller()) { \ + SafeResourceMark rm; \ + tty->print_cr out; \ + } \ +} while (0) #else #define EC_TRACE(out) #endif /*JVMTI_TRACE */ diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp index 878d300f5f3..43174e49426 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp @@ -72,36 +72,6 @@ // 0x20000000 | 536870912 - unused // 0x40000000 | 1073741824 - unused // 0x80000000 | 2147483648 - unused -// -// Note: The ResourceMark is to cleanup resource allocated args. -// The "while (0)" is so we can use semi-colon at end of RC_TRACE(). -#define RC_TRACE(level, args) \ - if ((TraceRedefineClasses & level) != 0) { \ - ResourceMark rm; \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print_cr args; \ - } while (0) - -#define RC_TRACE_NO_CR(level, args) \ - if ((TraceRedefineClasses & level) != 0) { \ - ResourceMark rm; \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print args; \ - } while (0) - -#define RC_TRACE_WITH_THREAD(level, thread, args) \ - if ((TraceRedefineClasses & level) != 0) { \ - ResourceMark rm(thread); \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print_cr args; \ - } while (0) - -#define RC_TRACE_MESG(args) \ - { \ - ResourceMark rm; \ - tty->print("RedefineClasses: "); \ - tty->print_cr args; \ - } while (0) // Macro for checking if TraceRedefineClasses has a specific bit // enabled. Returns true if the bit specified by level is set. @@ -120,16 +90,49 @@ #define RC_TRACE_IN_RANGE(low, high) \ (((TraceRedefineClasses & ((high << 1) - 1)) & ~(low - 1)) != 0) -// Timer support macros. Only do timer operations if timer tracing -// is enabled. The "while (0)" is so we can use semi-colon at end of -// the macro. -#define RC_TIMER_START(t) \ +// Note: The ResourceMark is to cleanup resource allocated args. +// The "do {...} while (0)" is so we can use semi-colon at end of RC_TRACE(). +#define RC_TRACE(level, args) do { \ + if (RC_TRACE_ENABLED(level)) { \ + ResourceMark rm; \ + tty->print("RedefineClasses-0x%x: ", level); \ + tty->print_cr args; \ + } \ +} while (0) + +#define RC_TRACE_NO_CR(level, args) do { \ + if (RC_TRACE_ENABLED(level)) { \ + ResourceMark rm; \ + tty->print("RedefineClasses-0x%x: ", level); \ + tty->print args; \ + } \ +} while (0) + +#define RC_TRACE_WITH_THREAD(level, thread, args) do { \ + if (RC_TRACE_ENABLED(level)) { \ + ResourceMark rm(thread); \ + tty->print("RedefineClasses-0x%x: ", level); \ + tty->print_cr args; \ + } \ +} while (0) + +#define RC_TRACE_MESG(args) do { \ + ResourceMark rm; \ + tty->print("RedefineClasses: "); \ + tty->print_cr args; \ +} while (0) + +// Timer support macros. Only do timer operations if timer tracing is enabled. +// The "do {...} while (0)" is so we can use semi-colon at end of the macro. +#define RC_TIMER_START(t) do { \ if (RC_TRACE_ENABLED(0x00000004)) { \ t.start(); \ - } while (0) -#define RC_TIMER_STOP(t) \ + } \ +} while (0) +#define RC_TIMER_STOP(t) do { \ if (RC_TRACE_ENABLED(0x00000004)) { \ t.stop(); \ - } while (0) + } \ +} while (0) #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP From cd2f264ba1b8f3562c16b78e421b0671bd24acab Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Mon, 1 Apr 2013 12:02:19 -0700 Subject: [PATCH 100/155] 8010268: Remove dependence upon clean target from jdk/test/Makefile prep target Reviewed-by: tbell, mchung --- jdk/test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/Makefile b/jdk/test/Makefile index 2b4bfa14594..676d6bcf35d 100644 --- a/jdk/test/Makefile +++ b/jdk/test/Makefile @@ -336,7 +336,7 @@ all: jdk_default @$(ECHO) "Testing completed successfully" # Prep for output -prep: clean +prep: @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR) @$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` From ba2c11a93a0df87b8ac44ca9e72d8b8751c5b0cf Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Mon, 1 Apr 2013 14:05:41 -0700 Subject: [PATCH 101/155] 8011048: Possible reading from unmapped memory in UTF8::as_quoted_ascii() Pass utf_length parameter to UTF8::as_quoted_ascii() Reviewed-by: dcubed, minqi --- hotspot/src/share/vm/oops/symbol.cpp | 2 +- hotspot/src/share/vm/utilities/utf8.cpp | 8 +++++--- hotspot/src/share/vm/utilities/utf8.hpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/oops/symbol.cpp b/hotspot/src/share/vm/oops/symbol.cpp index b3c71813bdb..253d0df887c 100644 --- a/hotspot/src/share/vm/oops/symbol.cpp +++ b/hotspot/src/share/vm/oops/symbol.cpp @@ -162,7 +162,7 @@ char* Symbol::as_quoted_ascii() const { const char *ptr = (const char *)&_body[0]; int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length()); char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1); - UTF8::as_quoted_ascii(ptr, result, quoted_length + 1); + UTF8::as_quoted_ascii(ptr, utf8_length(), result, quoted_length + 1); return result; } diff --git a/hotspot/src/share/vm/utilities/utf8.cpp b/hotspot/src/share/vm/utilities/utf8.cpp index da470b18cc0..8c013c9b30b 100644 --- a/hotspot/src/share/vm/utilities/utf8.cpp +++ b/hotspot/src/share/vm/utilities/utf8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -180,11 +180,12 @@ int UTF8::quoted_ascii_length(const char* utf8_str, int utf8_length) { } // converts a utf8 string to quoted ascii -void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { +void UTF8::as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen) { const char *ptr = utf8_str; + const char *utf8_end = ptr + utf8_length; char* p = buf; char* end = buf + buflen; - while (*ptr != '\0') { + while (ptr < utf8_end) { jchar c; ptr = UTF8::next(ptr, &c); if (c >= 32 && c < 127) { @@ -196,6 +197,7 @@ void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { p += 6; } } + assert(p < end, "sanity"); *p = '\0'; } diff --git a/hotspot/src/share/vm/utilities/utf8.hpp b/hotspot/src/share/vm/utilities/utf8.hpp index 69710fccec4..354941e6dc0 100644 --- a/hotspot/src/share/vm/utilities/utf8.hpp +++ b/hotspot/src/share/vm/utilities/utf8.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -45,7 +45,7 @@ class UTF8 : AllStatic { static int quoted_ascii_length(const char* utf8_str, int utf8_length); // converts a utf8 string to quoted ascii - static void as_quoted_ascii(const char* utf8_str, char* buf, int buflen); + static void as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen); // converts a quoted ascii string to utf8 string. returns the original // string unchanged if nothing needs to be done. From 3e6daeda3a112e9cb201d048c4d924a8b8946f17 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Mon, 1 Apr 2013 20:15:48 -0700 Subject: [PATCH 102/155] 7143928: Optimize empty HashMap and ArrayList Co-authored-by: Sergey Linetskiy Co-authored-by: John Rose Reviewed-by: mduigou --- .../share/classes/java/util/ArrayList.java | 50 ++-- jdk/src/share/classes/java/util/HashMap.java | 118 +++++++--- .../java/util/Map/BasicSerialization.java | 221 ++++++++++++++++++ 3 files changed, 337 insertions(+), 52 deletions(-) create mode 100644 jdk/test/java/util/Map/BasicSerialization.java diff --git a/jdk/src/share/classes/java/util/ArrayList.java b/jdk/src/share/classes/java/util/ArrayList.java index 42a97e70f04..1377326988f 100644 --- a/jdk/src/share/classes/java/util/ArrayList.java +++ b/jdk/src/share/classes/java/util/ArrayList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -104,6 +104,11 @@ public class ArrayList extends AbstractList { private static final long serialVersionUID = 8683452581122892189L; + /** + * Shared empty array instance used for empty instances. + */ + private static final Object EMPTY_ELEMENTDATA[] = new Object[0]; + /** * The array buffer into which the elements of the ArrayList are stored. * The capacity of the ArrayList is the length of this array buffer. @@ -136,7 +141,8 @@ public class ArrayList extends AbstractList * Constructs an empty list with an initial capacity of ten. */ public ArrayList() { - this(10); + super(); + this.elementData = EMPTY_ELEMENTDATA; } /** @@ -162,8 +168,7 @@ public class ArrayList extends AbstractList */ public void trimToSize() { modCount++; - int oldCapacity = elementData.length; - if (size < oldCapacity) { + if (size < elementData.length) { elementData = Arrays.copyOf(elementData, size); } } @@ -177,11 +182,20 @@ public class ArrayList extends AbstractList */ public void ensureCapacity(int minCapacity) { if (minCapacity > 0) - ensureCapacityInternal(minCapacity); + ensureExplicitCapacity(minCapacity); } private void ensureCapacityInternal(int minCapacity) { + if(elementData == EMPTY_ELEMENTDATA) { + minCapacity = Math.max(10, minCapacity); + } + + ensureExplicitCapacity(minCapacity); + } + + private void ensureExplicitCapacity(int minCapacity) { modCount++; + // overflow-conscious code if (minCapacity - elementData.length > 0) grow(minCapacity); @@ -506,8 +520,7 @@ public class ArrayList extends AbstractList modCount++; // Let gc do its work - for (int i = 0; i < size; i++) - elementData[i] = null; + Arrays.fill(elementData, null); size = 0; } @@ -588,8 +601,8 @@ public class ArrayList extends AbstractList // Let gc do its work int newSize = size - (toIndex-fromIndex); - while (size != newSize) - elementData[--size] = null; + Arrays.fill(elementData, newSize, size, null); + size = newSize; } /** @@ -677,8 +690,8 @@ public class ArrayList extends AbstractList w += size - r; } if (w != size) { - for (int i = w; i < size; i++) - elementData[i] = null; + // Let gc do its work + Arrays.fill(elementData, w, size, null); modCount += size - w; size = w; modified = true; @@ -702,7 +715,7 @@ public class ArrayList extends AbstractList s.defaultWriteObject(); // Write out array length - s.writeInt(elementData.length); + s.writeInt((elementData == EMPTY_ELEMENTDATA) ? 10 : elementData.length); // Write out all elements in the proper order. for (int i=0; i extends AbstractList if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } - } /** @@ -723,10 +735,16 @@ public class ArrayList extends AbstractList // Read in size, and any hidden stuff s.defaultReadObject(); - // Read in array length and allocate array - int arrayLength = s.readInt(); - Object[] a = elementData = new Object[arrayLength]; + // Read in array length + int initialCapacity = s.readInt(); + elementData = EMPTY_ELEMENTDATA; + if((size > 0) || (initialCapacity != 10)) { + // allocate array based upon size. + ensureCapacityInternal(size); + } + + Object[] a = elementData; // Read in all elements in the proper order. for (int i=0; i */ static final float DEFAULT_LOAD_FACTOR = 0.75f; + /** + * An empty table instance to share when the table is not inflated. + */ + static final Entry[] EMPTY_TABLE = {}; + /** * The table, resized as necessary. Length MUST Always be a power of two. */ - transient Entry[] table; + transient Entry[] table = EMPTY_TABLE; /** * The number of key-value mappings contained in this map. @@ -223,14 +228,8 @@ public class HashMap throw new IllegalArgumentException("Illegal load factor: " + loadFactor); - // Find a power of 2 >= initialCapacity - int capacity = 1; - while (capacity < initialCapacity) - capacity <<= 1; - this.loadFactor = loadFactor; - threshold = (int)Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); - table = new Entry[capacity]; + threshold = initialCapacity; init(); } @@ -265,9 +264,30 @@ public class HashMap public HashMap(Map m) { this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); + inflateTable(threshold); + putAllForCreate(m); } + private static int roundUpToPowerOf2(int number) { + int rounded = (rounded = Integer.highestOneBit(number)) != 0 + ? (Integer.bitCount(number) > 1) ? rounded << 1 : rounded + : 1; + + return rounded; + } + + /** + * Inflate the table + */ + final void inflateTable(int toSize) { + // Find a power of 2 >= initialCapacity + int capacity = roundUpToPowerOf2(toSize); + + threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); + table = new Entry[capacity]; + } + // internal utilities /** @@ -305,6 +325,7 @@ public class HashMap * Returns index for hash code h. */ static int indexFor(int h, int length) { + if (Integer.bitCount(length) != 1) { throw new Error("Ya dun messed up good"); } return h & (length-1); } @@ -369,6 +390,10 @@ public class HashMap */ @SuppressWarnings("unchecked") final Entry getEntry(Object key) { + if (isEmpty()) { + return null; + } + int hash = (key == null) ? 0 : hash(key); for (Entry e = table[indexFor(hash, table.length)]; e != null; @@ -381,7 +406,6 @@ public class HashMap return null; } - /** * Associates the specified value with the specified key in this map. * If the map previously contained a mapping for the key, the old @@ -395,6 +419,9 @@ public class HashMap * previously associated null with key.) */ public V put(K key, V value) { + if (table == EMPTY_TABLE) { + inflateTable(threshold); + } if (key == null) return putForNullKey(value); int hash = hash(key); @@ -529,6 +556,10 @@ public class HashMap if (numKeysToBeAdded == 0) return; + if (table == EMPTY_TABLE) { + inflateTable(Math.max((int) (numKeysToBeAdded * loadFactor), threshold)); + } + /* * Expand the map if the map if the number of mappings to be added * is greater than or equal to threshold. This is conservative; the @@ -573,6 +604,9 @@ public class HashMap * for this key. */ final Entry removeEntryForKey(Object key) { + if(isEmpty()) { + return null; + } int hash = (key == null) ? 0 : hash(key); int i = indexFor(hash, table.length); @SuppressWarnings("unchecked") @@ -605,7 +639,7 @@ public class HashMap * for matching. */ final Entry removeMapping(Object o) { - if (!(o instanceof Map.Entry)) + if (isEmpty() || !(o instanceof Map.Entry)) return null; Map.Entry entry = (Map.Entry) o; @@ -641,9 +675,7 @@ public class HashMap */ public void clear() { modCount++; - Entry[] tab = table; - for (int i = 0; i < tab.length; i++) - tab[i] = null; + Arrays.fill(table, null); size = 0; } @@ -656,6 +688,10 @@ public class HashMap * specified value */ public boolean containsValue(Object value) { + if(isEmpty()) { + return false; + } + if (value == null) return containsNullValue(); @@ -693,7 +729,9 @@ public class HashMap } catch (CloneNotSupportedException e) { // assert false; } - result.table = new Entry[table.length]; + result.table = (table == EMPTY_TABLE) + ? EMPTY_TABLE + : new Entry[table.length]; result.entrySet = null; result.modCount = 0; result.size = 0; @@ -749,8 +787,7 @@ public class HashMap } public final int hashCode() { - return (key==null ? 0 : key.hashCode()) ^ - (value==null ? 0 : value.hashCode()); + return Objects.hashCode(getKey()) ^ Objects.hashCode(getValue()); } public final String toString() { @@ -1008,7 +1045,7 @@ public class HashMap * serialize it). * * @serialData The capacity of the HashMap (the length of the - * bucket array) is emitted (int), followed by the + * bucket array, a power of 2) is emitted (int), followed by the * size (an int, the number of key-value * mappings), followed by the key (Object) and value (Object) * for each key-value mapping. The key-value mappings are @@ -1017,14 +1054,14 @@ public class HashMap private void writeObject(java.io.ObjectOutputStream s) throws IOException { - Iterator> i = - (size > 0) ? entrySet0().iterator() : null; - // Write out the threshold, loadfactor, and any hidden stuff s.defaultWriteObject(); // Write out number of buckets - s.writeInt(table.length); + if (table==EMPTY_TABLE) + s.writeInt(roundUpToPowerOf2(threshold)); + else + s.writeInt(table.length); // Write out size (number of Mappings) s.writeInt(size); @@ -1058,7 +1095,15 @@ public class HashMap sun.misc.Hashing.randomHashSeed(this)); // Read in number of buckets and allocate the bucket array; - s.readInt(); // ignored + table = EMPTY_TABLE; + + int buckets = s.readInt(); + + if ((buckets < 0) || // negative + (buckets > HashMap.MAXIMUM_CAPACITY) || // fits in array + (Integer.bitCount(buckets) > 1)) /* not power of 2 or zero */ { + throw new InvalidObjectException("Illegal capacity: " + buckets); + } // Read number of mappings int mappings = s.readInt(); @@ -1066,23 +1111,24 @@ public class HashMap throw new InvalidObjectException("Illegal mappings count: " + mappings); - int initialCapacity = (int) Math.min( - // capacity chosen by number of mappings - // and desired load (if >= 0.25) - mappings * Math.min(1 / loadFactor, 4.0f), - // we have limits... - HashMap.MAXIMUM_CAPACITY); - int capacity = 1; - // find smallest power of two which holds all mappings - while (capacity < initialCapacity) { - capacity <<= 1; + int mappingsCapacity = Math.max( + (int) Math.min( + // capacity chosen by number of mappings + // and desired load (if >= 0.25) + mappings * Math.min(1 / loadFactor, 4.0f), + // we have limits... + HashMap.MAXIMUM_CAPACITY), + // maybe they want extra buckets. + buckets); + + if(mappings > 0) { + inflateTable(mappingsCapacity); + } else { + threshold = mappingsCapacity; } - table = new Entry[capacity]; - threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); init(); // Give subclass a chance to do its thing. - // Read the keys and values, and put the mappings in the HashMap for (int i=0; i Map mapClone(Map map) { + Method cloneMethod; + + try { + cloneMethod = map.getClass().getMethod("clone", new Class[]{}); + } catch (NoSuchMethodException | SecurityException all) { + cloneMethod = null; + } + + if (null != cloneMethod) { + try { + Map result = (Map)cloneMethod.invoke(map, new Object[]{}); + return result; + } catch (Exception all) { + fail("clone() failed " + map.getClass().getSimpleName(), all); + return null; + } + } else { + Constructor copyConstructor; + try { + copyConstructor = (Constructor)map.getClass().getConstructor(new Class[]{Map.class}); + + Map result = (Map)copyConstructor.newInstance(new Object[]{map}); + + return result; + } catch (Exception all) { + return serialClone(map); + } + } + } + + @Test(dataProvider = "Map") + public void testSerialization(String description, Map map) { + Object foo = new Object(); + + Map clone = mapClone(map); + Map serialClone = serialClone(map); + + assertEquals(map, map, description + ":should equal self"); + assertEquals(clone, map, description + ":should equal clone"); + assertEquals(map, clone, description + ": should equal orginal map"); + assertEquals(serialClone, map, description + ": should equal deserialized clone"); + assertEquals(map, serialClone, description + ": should equal original map"); + assertEquals(serialClone, clone, description + ": deserialized clone should equal clone"); + assertEquals(clone, serialClone, description + ": clone should equal deserialized clone"); + + assertFalse(map.containsKey(EXTRA_KEY), description + ":unexpected key"); + assertFalse(clone.containsKey(EXTRA_KEY), description + ":unexpected key"); + assertFalse(serialClone.containsKey(EXTRA_KEY), description + ":unexpected key"); + map.put(EXTRA_KEY, EXTRA_VALUE); + clone.put(EXTRA_KEY, EXTRA_VALUE); + serialClone.put(EXTRA_KEY, EXTRA_VALUE); + assertTrue(map.containsKey(EXTRA_KEY), description + ":missing key"); + assertTrue(clone.containsKey(EXTRA_KEY), description + ":missing key"); + assertTrue(serialClone.containsKey(EXTRA_KEY), description + ":missing key"); + assertSame(map.get(EXTRA_KEY), EXTRA_VALUE, description + ":wrong value"); + assertSame(clone.get(EXTRA_KEY), EXTRA_VALUE, description + ":wrong value"); + assertSame(serialClone.get(EXTRA_KEY), EXTRA_VALUE, description + ":wrong value"); + + assertEquals(map, map, description + ":should equal self"); + assertEquals(clone, map, description + ":should equal clone"); + assertEquals(map, clone, description + ": should equal orginal map"); + assertEquals(serialClone, map, description + ": should equal deserialized clone"); + assertEquals(map, serialClone, description + ": should equal original map"); + assertEquals(serialClone, clone, description + ": deserialized clone should equal clone"); + assertEquals(clone, serialClone, description + ": clone should equal deserialized clone"); + } + + static byte[] serializedForm(Object obj) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + new ObjectOutputStream(baos).writeObject(obj); + return baos.toByteArray(); + } catch (IOException e) { + fail("Unexpected Exception", e); + return null; + } + } + + static Object readObject(byte[] bytes) throws IOException, ClassNotFoundException { + InputStream is = new ByteArrayInputStream(bytes); + return new ObjectInputStream(is).readObject(); + } + + @SuppressWarnings("unchecked") + static T serialClone(T obj) { + try { + return (T)readObject(serializedForm(obj)); + } catch (IOException | ClassNotFoundException e) { + fail("Unexpected Exception", e); + return null; + } + } + + @DataProvider(name = "Map", parallel = true) + private static Iterator makeMaps() { + return Arrays.asList( + // empty + new Object[]{"HashMap", new HashMap()}, + new Object[]{"LinkedHashMap", new LinkedHashMap()}, + new Object[]{"Collections.checkedMap(HashMap)", Collections.checkedMap(new HashMap(), IntegerEnum.class, String.class)}, + new Object[]{"Collections.synchronizedMap(HashMap)", Collections.synchronizedMap(new HashMap())}, + // null hostile + new Object[]{"EnumMap", new EnumMap(IntegerEnum.class)}, + new Object[]{"Hashtable", new Hashtable()}, + new Object[]{"TreeMap", new TreeMap()}, + new Object[]{"ConcurrentHashMap", new ConcurrentHashMap()}, + new Object[]{"ConcurrentSkipListMap", new ConcurrentSkipListMap()}, + new Object[]{"Collections.checkedMap(ConcurrentHashMap)", Collections.checkedMap(new ConcurrentHashMap(), IntegerEnum.class, String.class)}, + new Object[]{"Collections.synchronizedMap(EnumMap)", Collections.synchronizedMap(new EnumMap(IntegerEnum.class))}, + // filled + new Object[]{"HashMap", fillMap(new HashMap())}, + new Object[]{"LinkedHashMap", fillMap(new LinkedHashMap())}, + new Object[]{"Collections.checkedMap(HashMap)", Collections.checkedMap(fillMap(new HashMap()), IntegerEnum.class, String.class)}, + new Object[]{"Collections.synchronizedMap(HashMap)", Collections.synchronizedMap(fillMap(new HashMap()))}, + // null hostile + new Object[]{"EnumMap", fillMap(new EnumMap(IntegerEnum.class))}, + new Object[]{"Hashtable", fillMap(new Hashtable())}, + new Object[]{"TreeMap", fillMap(new TreeMap())}, + new Object[]{"ConcurrentHashMap", fillMap(new ConcurrentHashMap())}, + new Object[]{"ConcurrentSkipListMap", fillMap(new ConcurrentSkipListMap())}, + new Object[]{"Collections.checkedMap(ConcurrentHashMap)", Collections.checkedMap(fillMap(new ConcurrentHashMap()), IntegerEnum.class, String.class)}, + new Object[]{"Collections.synchronizedMap(EnumMap)", Collections.synchronizedMap(fillMap(new EnumMap(IntegerEnum.class)))}).iterator(); + } + + private static Map fillMap(Map result) { + for (int each = 0; each < TEST_SIZE; each++) { + result.put(KEYS[each], VALUES[each]); + } + + return result; + } +} From 12f1183c74d9ab2896e9db0f2a106bbbdb10322d Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Mon, 1 Apr 2013 20:15:48 -0700 Subject: [PATCH 103/155] 8011187: Remove obsolete/unused targets from jdk/test/Makefile Reviewed-by: ohair --- jdk/test/Makefile | 196 +--------------------------------------------- 1 file changed, 1 insertion(+), 195 deletions(-) diff --git a/jdk/test/Makefile b/jdk/test/Makefile index 676d6bcf35d..cb8a2e8433f 100644 --- a/jdk/test/Makefile +++ b/jdk/test/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 2013, 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 @@ -704,200 +704,6 @@ PHONY_LIST += jtreg_tests shared_library_permissions ################################################################ -# packtest - -# Expect JPRT to set JPRT_PACKTEST_HOME. -PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest -ifdef JPRT_PACKTEST_HOME - PACKTEST_HOME = $(JPRT_PACKTEST_HOME) -endif - -packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME) - ( $(CD) $(PACKTEST_HOME) && \ - $(PACKTEST_HOME)/ptest \ - -t "$(PRODUCT_HOME)" \ - $(PACKTEST_STRESS_OPTION) \ - $(EXTRA_PACKTEST_OPTIONS) \ - -W $(ABS_TEST_OUTPUT_DIR) \ - $(JAVA_ARGS:%=-J %) \ - $(JAVA_VM_ARGS:%=-J %) \ - ) ; $(BUNDLE_UP_AND_EXIT) - -packtest_stress: PACKTEST_STRESS_OPTION=-s -packtest_stress: packtest - -PHONY_LIST += packtest packtest_stress - -################################################################ - -# perftest to collect statistics - -# Expect JPRT to set JPRT_PACKTEST_HOME. -PERFTEST_HOME = $(TEST_ROOT)/perf -ifdef JPRT_PERFTEST_HOME - PERFTEST_HOME = $(JPRT_PERFTEST_HOME) -endif - -perftest: ( $(PERFTEST_HOME)/perftest \ - -t $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - -w $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)") \ - -h $(PERFTEST_HOME) \ - ) ; $(BUNDLE_UP_AND_EXIT) - - -PHONY_LIST += perftest - -################################################################ - -# vmsqe tests - -# Expect JPRT to set JPRT_VMSQE_HOME. -VMSQE_HOME = $(SLASH_JAVA)/sqe/comp/vm/testbase/sqe/vm/current/build/latest/vm -ifdef JPRT_VMSQE_HOME - VMSQE_HOME = $(JPRT_VMSQE_HOME) -endif - -# Expect JPRT to set JPRT_RUNVMSQE_HOME. -RUNVMSQE_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/runvmsqe -ifdef JPRT_RUNVMSQE_HOME - RUNVMSQE_HOME = $(JPRT_RUNVMSQE_HOME) -endif - -# Expect JPRT to set JPRT_TONGA3_HOME. -TONGA3_HOME = $(SLASH_JAVA)/sqe/tools/gtee/harness/tonga -ifdef JPRT_TONGA3_HOME - TONGA3_HOME = $(JPRT_TONGA3_HOME) -endif - -RUNVMSQE_BIN = $(RUNVMSQE_HOME)/bin/runvmsqe - -vmsqe_tests: prep $(VMSQE_HOME)/vm $(TONGA3_HOME) $(RUNVMSQE_BIN) $(PRODUCT_HOME) - $(RM) -r $(ABS_TEST_OUTPUT_DIR)/vmsqe - ( $(CD) $(ABS_TEST_OUTPUT_DIR) && \ - $(RUNVMSQE_BIN) \ - -jdk "$(PRODUCT_HOME)" \ - -o "$(ABS_TEST_OUTPUT_DIR)/vmsqe" \ - -testbase "$(VMSQE_HOME)/vm" \ - -tonga "$(TONGA3_HOME)" \ - -tongajdk "$(ALT_BOOTDIR)" \ - $(JAVA_ARGS) \ - $(JAVA_VM_ARGS) \ - $(RUNVMSQE_TEST_OPTION) \ - $(EXTRA_RUNVMSQE_OPTIONS) \ - ) ; $(BUNDLE_UP_AND_EXIT) - -vmsqe_jdwp: RUNVMSQE_TEST_OPTION=-jdwp -vmsqe_jdwp: vmsqe_tests - -vmsqe_jdi: RUNVMSQE_TEST_OPTION=-jdi -vmsqe_jdi: vmsqe_tests - -vmsqe_jdb: RUNVMSQE_TEST_OPTION=-jdb -vmsqe_jdb: vmsqe_tests - -vmsqe_quick-jdi: RUNVMSQE_TEST_OPTION=-quick-jdi -vmsqe_quick-jdi: vmsqe_tests - -vmsqe_sajdi: RUNVMSQE_TEST_OPTION=-sajdi -vmsqe_sajdi: vmsqe_tests - -vmsqe_jvmti: RUNVMSQE_TEST_OPTION=-jvmti -vmsqe_jvmti: vmsqe_tests - -vmsqe_hprof: RUNVMSQE_TEST_OPTION=-hprof -vmsqe_hprof: vmsqe_tests - -vmsqe_monitoring: RUNVMSQE_TEST_OPTION=-monitoring -vmsqe_monitoring: vmsqe_tests - -PHONY_LIST += vmsqe_jdwp vmsqe_jdi vmsqe_jdb vmsqe_quick-jdi vmsqe_sajdi \ - vmsqe_jvmti vmsqe_hprof vmsqe_monitoring vmsqe_tests - -################################################################ - -# jck tests - -# Default is to use jck 7 from /java/re -JCK7_DEFAULT_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries - -# Expect JPRT to set JPRT_JCK7COMPILER_HOME. -JCK7COMPILER_HOME = $(JCK7_DEFAULT_HOME)/JCK-compiler-7 -ifdef JPRT_JCK7COMPILER_HOME - JCK7COMPILER_HOME = $(JPRT_JCK7COMPILER_HOME)/JCK-compiler-7 -endif - -# Expect JPRT to set JPRT_JCK7RUNTIME_HOME. -JCK7RUNTIME_HOME = $(JCK7_DEFAULT_HOME)/JCK-runtime-7 -ifdef JPRT_JCK7RUNTIME_HOME - JCK7RUNTIME_HOME = $(JPRT_JCK7RUNTIME_HOME)/JCK-runtime-7 -endif - -# Expect JPRT to set JPRT_JCK7DEVTOOLS_HOME. -JCK7DEVTOOLS_HOME = $(JCK7_DEFAULT_HOME)/JCK-devtools-7 -ifdef JPRT_JCK7DEVTOOLS_HOME - JCK7DEVTOOLS_HOME = $(JPRT_JCK7DEVTOOLS_HOME)/JCK-devtools-7 -endif - -# The jtjck.jar utility to use to run the tests -JTJCK_JAR = $(JCK_HOME)/lib/jtjck.jar -JTJCK_JAVA_ARGS = -XX:MaxPermSize=256m -Xmx512m -JTJCK_OPTIONS = -headless -v - -# Default tests to run -ifndef JCK_COMPILER_TESTS - JCK_COMPILER_TESTS = -endif -ifndef JCK_RUNTIME_TESTS - JCK_RUNTIME_TESTS = -endif -ifndef JCK_DEVTOOLS_TESTS - JCK_DEVTOOLS_TESTS = -endif - -# Generic rule used to run jck tests -_generic_jck_tests: prep $(PRODUCT_HOME) $(EXCLUDELIST) - @$(EXPAND) $(EXCLUDELIST) \ - | $(CUT) -d' ' -f1 \ - | $(SED) -e 's@^@Excluding: @' - ( $(CD) $(ABS_TEST_OUTPUT_DIR) && \ - $(PRODUCT_HOME)/bin/java $(JTJCK_JAVA_ARGS) \ - -jar "$(JTJCK_JAR)" \ - $(JTJCK_OPTIONS) \ - -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \ - -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \ - -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - $(TESTDIRS) \ - ) ; $(BUNDLE_UP_AND_EXIT) - -# JCK7 compiler tests -jck7compiler: - $(MAKE) UNIQUE_DIR=$@ \ - JCK_HOME=$(JCK7COMPILER_HOME) \ - TESTDIRS="$(JCK_COMPILER_TESTS)" \ - _generic_jck_tests - -# JCK7 runtime tests -jck7runtime: - $(MAKE) UNIQUE_DIR=$@ \ - JCK_HOME=$(JCK7RUNTIME_HOME) \ - TESTDIRS="$(JCK_RUNTIME_TESTS)" \ - _generic_jck_tests - -# JCK7 devtools tests -jck7devtools: - $(MAKE) UNIQUE_DIR=$@ \ - JCK_HOME=$(JCK7DEVTOOLS_HOME) \ - TESTDIRS="$(JCK_DEVTOOLS_TESTS)" \ - _generic_jck_tests - -# Run all 3 sets of JCK7 tests -jck_all: jck7runtime jck7devtools jck7compiler - -PHONY_LIST += jck_all _generic_jck_tests \ - jck7compiler jck7runtime jck7devtools - -################################################################ - # Phony targets (e.g. these are not filenames) .PHONY: all clean prep $(PHONY_LIST) From 7d45058eaa0972fa272077e3aeed7e57c22d56da Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Mon, 1 Apr 2013 20:51:40 -0700 Subject: [PATCH 104/155] 8011199: Backout changeset JDK-7143928 (2b34a1eb3153) Reviewed-by: darcy, dholmes --- .../share/classes/java/util/ArrayList.java | 50 ++-- jdk/src/share/classes/java/util/HashMap.java | 118 +++------- .../java/util/Map/BasicSerialization.java | 221 ------------------ 3 files changed, 52 insertions(+), 337 deletions(-) delete mode 100644 jdk/test/java/util/Map/BasicSerialization.java diff --git a/jdk/src/share/classes/java/util/ArrayList.java b/jdk/src/share/classes/java/util/ArrayList.java index 1377326988f..42a97e70f04 100644 --- a/jdk/src/share/classes/java/util/ArrayList.java +++ b/jdk/src/share/classes/java/util/ArrayList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, 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 @@ -104,11 +104,6 @@ public class ArrayList extends AbstractList { private static final long serialVersionUID = 8683452581122892189L; - /** - * Shared empty array instance used for empty instances. - */ - private static final Object EMPTY_ELEMENTDATA[] = new Object[0]; - /** * The array buffer into which the elements of the ArrayList are stored. * The capacity of the ArrayList is the length of this array buffer. @@ -141,8 +136,7 @@ public class ArrayList extends AbstractList * Constructs an empty list with an initial capacity of ten. */ public ArrayList() { - super(); - this.elementData = EMPTY_ELEMENTDATA; + this(10); } /** @@ -168,7 +162,8 @@ public class ArrayList extends AbstractList */ public void trimToSize() { modCount++; - if (size < elementData.length) { + int oldCapacity = elementData.length; + if (size < oldCapacity) { elementData = Arrays.copyOf(elementData, size); } } @@ -182,20 +177,11 @@ public class ArrayList extends AbstractList */ public void ensureCapacity(int minCapacity) { if (minCapacity > 0) - ensureExplicitCapacity(minCapacity); + ensureCapacityInternal(minCapacity); } private void ensureCapacityInternal(int minCapacity) { - if(elementData == EMPTY_ELEMENTDATA) { - minCapacity = Math.max(10, minCapacity); - } - - ensureExplicitCapacity(minCapacity); - } - - private void ensureExplicitCapacity(int minCapacity) { modCount++; - // overflow-conscious code if (minCapacity - elementData.length > 0) grow(minCapacity); @@ -520,7 +506,8 @@ public class ArrayList extends AbstractList modCount++; // Let gc do its work - Arrays.fill(elementData, null); + for (int i = 0; i < size; i++) + elementData[i] = null; size = 0; } @@ -601,8 +588,8 @@ public class ArrayList extends AbstractList // Let gc do its work int newSize = size - (toIndex-fromIndex); - Arrays.fill(elementData, newSize, size, null); - size = newSize; + while (size != newSize) + elementData[--size] = null; } /** @@ -690,8 +677,8 @@ public class ArrayList extends AbstractList w += size - r; } if (w != size) { - // Let gc do its work - Arrays.fill(elementData, w, size, null); + for (int i = w; i < size; i++) + elementData[i] = null; modCount += size - w; size = w; modified = true; @@ -715,7 +702,7 @@ public class ArrayList extends AbstractList s.defaultWriteObject(); // Write out array length - s.writeInt((elementData == EMPTY_ELEMENTDATA) ? 10 : elementData.length); + s.writeInt(elementData.length); // Write out all elements in the proper order. for (int i=0; i extends AbstractList if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } + } /** @@ -735,16 +723,10 @@ public class ArrayList extends AbstractList // Read in size, and any hidden stuff s.defaultReadObject(); - // Read in array length - int initialCapacity = s.readInt(); - elementData = EMPTY_ELEMENTDATA; + // Read in array length and allocate array + int arrayLength = s.readInt(); + Object[] a = elementData = new Object[arrayLength]; - if((size > 0) || (initialCapacity != 10)) { - // allocate array based upon size. - ensureCapacityInternal(size); - } - - Object[] a = elementData; // Read in all elements in the proper order. for (int i=0; i */ static final float DEFAULT_LOAD_FACTOR = 0.75f; - /** - * An empty table instance to share when the table is not inflated. - */ - static final Entry[] EMPTY_TABLE = {}; - /** * The table, resized as necessary. Length MUST Always be a power of two. */ - transient Entry[] table = EMPTY_TABLE; + transient Entry[] table; /** * The number of key-value mappings contained in this map. @@ -228,8 +223,14 @@ public class HashMap throw new IllegalArgumentException("Illegal load factor: " + loadFactor); + // Find a power of 2 >= initialCapacity + int capacity = 1; + while (capacity < initialCapacity) + capacity <<= 1; + this.loadFactor = loadFactor; - threshold = initialCapacity; + threshold = (int)Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); + table = new Entry[capacity]; init(); } @@ -264,30 +265,9 @@ public class HashMap public HashMap(Map m) { this(Math.max((int) (m.size() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR); - inflateTable(threshold); - putAllForCreate(m); } - private static int roundUpToPowerOf2(int number) { - int rounded = (rounded = Integer.highestOneBit(number)) != 0 - ? (Integer.bitCount(number) > 1) ? rounded << 1 : rounded - : 1; - - return rounded; - } - - /** - * Inflate the table - */ - final void inflateTable(int toSize) { - // Find a power of 2 >= initialCapacity - int capacity = roundUpToPowerOf2(toSize); - - threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); - table = new Entry[capacity]; - } - // internal utilities /** @@ -325,7 +305,6 @@ public class HashMap * Returns index for hash code h. */ static int indexFor(int h, int length) { - if (Integer.bitCount(length) != 1) { throw new Error("Ya dun messed up good"); } return h & (length-1); } @@ -390,10 +369,6 @@ public class HashMap */ @SuppressWarnings("unchecked") final Entry getEntry(Object key) { - if (isEmpty()) { - return null; - } - int hash = (key == null) ? 0 : hash(key); for (Entry e = table[indexFor(hash, table.length)]; e != null; @@ -406,6 +381,7 @@ public class HashMap return null; } + /** * Associates the specified value with the specified key in this map. * If the map previously contained a mapping for the key, the old @@ -419,9 +395,6 @@ public class HashMap * previously associated null with key.) */ public V put(K key, V value) { - if (table == EMPTY_TABLE) { - inflateTable(threshold); - } if (key == null) return putForNullKey(value); int hash = hash(key); @@ -556,10 +529,6 @@ public class HashMap if (numKeysToBeAdded == 0) return; - if (table == EMPTY_TABLE) { - inflateTable(Math.max((int) (numKeysToBeAdded * loadFactor), threshold)); - } - /* * Expand the map if the map if the number of mappings to be added * is greater than or equal to threshold. This is conservative; the @@ -604,9 +573,6 @@ public class HashMap * for this key. */ final Entry removeEntryForKey(Object key) { - if(isEmpty()) { - return null; - } int hash = (key == null) ? 0 : hash(key); int i = indexFor(hash, table.length); @SuppressWarnings("unchecked") @@ -639,7 +605,7 @@ public class HashMap * for matching. */ final Entry removeMapping(Object o) { - if (isEmpty() || !(o instanceof Map.Entry)) + if (!(o instanceof Map.Entry)) return null; Map.Entry entry = (Map.Entry) o; @@ -675,7 +641,9 @@ public class HashMap */ public void clear() { modCount++; - Arrays.fill(table, null); + Entry[] tab = table; + for (int i = 0; i < tab.length; i++) + tab[i] = null; size = 0; } @@ -688,10 +656,6 @@ public class HashMap * specified value */ public boolean containsValue(Object value) { - if(isEmpty()) { - return false; - } - if (value == null) return containsNullValue(); @@ -729,9 +693,7 @@ public class HashMap } catch (CloneNotSupportedException e) { // assert false; } - result.table = (table == EMPTY_TABLE) - ? EMPTY_TABLE - : new Entry[table.length]; + result.table = new Entry[table.length]; result.entrySet = null; result.modCount = 0; result.size = 0; @@ -787,7 +749,8 @@ public class HashMap } public final int hashCode() { - return Objects.hashCode(getKey()) ^ Objects.hashCode(getValue()); + return (key==null ? 0 : key.hashCode()) ^ + (value==null ? 0 : value.hashCode()); } public final String toString() { @@ -1045,7 +1008,7 @@ public class HashMap * serialize it). * * @serialData The capacity of the HashMap (the length of the - * bucket array, a power of 2) is emitted (int), followed by the + * bucket array) is emitted (int), followed by the * size (an int, the number of key-value * mappings), followed by the key (Object) and value (Object) * for each key-value mapping. The key-value mappings are @@ -1054,14 +1017,14 @@ public class HashMap private void writeObject(java.io.ObjectOutputStream s) throws IOException { + Iterator> i = + (size > 0) ? entrySet0().iterator() : null; + // Write out the threshold, loadfactor, and any hidden stuff s.defaultWriteObject(); // Write out number of buckets - if (table==EMPTY_TABLE) - s.writeInt(roundUpToPowerOf2(threshold)); - else - s.writeInt(table.length); + s.writeInt(table.length); // Write out size (number of Mappings) s.writeInt(size); @@ -1095,15 +1058,7 @@ public class HashMap sun.misc.Hashing.randomHashSeed(this)); // Read in number of buckets and allocate the bucket array; - table = EMPTY_TABLE; - - int buckets = s.readInt(); - - if ((buckets < 0) || // negative - (buckets > HashMap.MAXIMUM_CAPACITY) || // fits in array - (Integer.bitCount(buckets) > 1)) /* not power of 2 or zero */ { - throw new InvalidObjectException("Illegal capacity: " + buckets); - } + s.readInt(); // ignored // Read number of mappings int mappings = s.readInt(); @@ -1111,24 +1066,23 @@ public class HashMap throw new InvalidObjectException("Illegal mappings count: " + mappings); - int mappingsCapacity = Math.max( - (int) Math.min( - // capacity chosen by number of mappings - // and desired load (if >= 0.25) - mappings * Math.min(1 / loadFactor, 4.0f), - // we have limits... - HashMap.MAXIMUM_CAPACITY), - // maybe they want extra buckets. - buckets); - - if(mappings > 0) { - inflateTable(mappingsCapacity); - } else { - threshold = mappingsCapacity; + int initialCapacity = (int) Math.min( + // capacity chosen by number of mappings + // and desired load (if >= 0.25) + mappings * Math.min(1 / loadFactor, 4.0f), + // we have limits... + HashMap.MAXIMUM_CAPACITY); + int capacity = 1; + // find smallest power of two which holds all mappings + while (capacity < initialCapacity) { + capacity <<= 1; } + table = new Entry[capacity]; + threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1); init(); // Give subclass a chance to do its thing. + // Read the keys and values, and put the mappings in the HashMap for (int i=0; i Map mapClone(Map map) { - Method cloneMethod; - - try { - cloneMethod = map.getClass().getMethod("clone", new Class[]{}); - } catch (NoSuchMethodException | SecurityException all) { - cloneMethod = null; - } - - if (null != cloneMethod) { - try { - Map result = (Map)cloneMethod.invoke(map, new Object[]{}); - return result; - } catch (Exception all) { - fail("clone() failed " + map.getClass().getSimpleName(), all); - return null; - } - } else { - Constructor copyConstructor; - try { - copyConstructor = (Constructor)map.getClass().getConstructor(new Class[]{Map.class}); - - Map result = (Map)copyConstructor.newInstance(new Object[]{map}); - - return result; - } catch (Exception all) { - return serialClone(map); - } - } - } - - @Test(dataProvider = "Map") - public void testSerialization(String description, Map map) { - Object foo = new Object(); - - Map clone = mapClone(map); - Map serialClone = serialClone(map); - - assertEquals(map, map, description + ":should equal self"); - assertEquals(clone, map, description + ":should equal clone"); - assertEquals(map, clone, description + ": should equal orginal map"); - assertEquals(serialClone, map, description + ": should equal deserialized clone"); - assertEquals(map, serialClone, description + ": should equal original map"); - assertEquals(serialClone, clone, description + ": deserialized clone should equal clone"); - assertEquals(clone, serialClone, description + ": clone should equal deserialized clone"); - - assertFalse(map.containsKey(EXTRA_KEY), description + ":unexpected key"); - assertFalse(clone.containsKey(EXTRA_KEY), description + ":unexpected key"); - assertFalse(serialClone.containsKey(EXTRA_KEY), description + ":unexpected key"); - map.put(EXTRA_KEY, EXTRA_VALUE); - clone.put(EXTRA_KEY, EXTRA_VALUE); - serialClone.put(EXTRA_KEY, EXTRA_VALUE); - assertTrue(map.containsKey(EXTRA_KEY), description + ":missing key"); - assertTrue(clone.containsKey(EXTRA_KEY), description + ":missing key"); - assertTrue(serialClone.containsKey(EXTRA_KEY), description + ":missing key"); - assertSame(map.get(EXTRA_KEY), EXTRA_VALUE, description + ":wrong value"); - assertSame(clone.get(EXTRA_KEY), EXTRA_VALUE, description + ":wrong value"); - assertSame(serialClone.get(EXTRA_KEY), EXTRA_VALUE, description + ":wrong value"); - - assertEquals(map, map, description + ":should equal self"); - assertEquals(clone, map, description + ":should equal clone"); - assertEquals(map, clone, description + ": should equal orginal map"); - assertEquals(serialClone, map, description + ": should equal deserialized clone"); - assertEquals(map, serialClone, description + ": should equal original map"); - assertEquals(serialClone, clone, description + ": deserialized clone should equal clone"); - assertEquals(clone, serialClone, description + ": clone should equal deserialized clone"); - } - - static byte[] serializedForm(Object obj) { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - new ObjectOutputStream(baos).writeObject(obj); - return baos.toByteArray(); - } catch (IOException e) { - fail("Unexpected Exception", e); - return null; - } - } - - static Object readObject(byte[] bytes) throws IOException, ClassNotFoundException { - InputStream is = new ByteArrayInputStream(bytes); - return new ObjectInputStream(is).readObject(); - } - - @SuppressWarnings("unchecked") - static T serialClone(T obj) { - try { - return (T)readObject(serializedForm(obj)); - } catch (IOException | ClassNotFoundException e) { - fail("Unexpected Exception", e); - return null; - } - } - - @DataProvider(name = "Map", parallel = true) - private static Iterator makeMaps() { - return Arrays.asList( - // empty - new Object[]{"HashMap", new HashMap()}, - new Object[]{"LinkedHashMap", new LinkedHashMap()}, - new Object[]{"Collections.checkedMap(HashMap)", Collections.checkedMap(new HashMap(), IntegerEnum.class, String.class)}, - new Object[]{"Collections.synchronizedMap(HashMap)", Collections.synchronizedMap(new HashMap())}, - // null hostile - new Object[]{"EnumMap", new EnumMap(IntegerEnum.class)}, - new Object[]{"Hashtable", new Hashtable()}, - new Object[]{"TreeMap", new TreeMap()}, - new Object[]{"ConcurrentHashMap", new ConcurrentHashMap()}, - new Object[]{"ConcurrentSkipListMap", new ConcurrentSkipListMap()}, - new Object[]{"Collections.checkedMap(ConcurrentHashMap)", Collections.checkedMap(new ConcurrentHashMap(), IntegerEnum.class, String.class)}, - new Object[]{"Collections.synchronizedMap(EnumMap)", Collections.synchronizedMap(new EnumMap(IntegerEnum.class))}, - // filled - new Object[]{"HashMap", fillMap(new HashMap())}, - new Object[]{"LinkedHashMap", fillMap(new LinkedHashMap())}, - new Object[]{"Collections.checkedMap(HashMap)", Collections.checkedMap(fillMap(new HashMap()), IntegerEnum.class, String.class)}, - new Object[]{"Collections.synchronizedMap(HashMap)", Collections.synchronizedMap(fillMap(new HashMap()))}, - // null hostile - new Object[]{"EnumMap", fillMap(new EnumMap(IntegerEnum.class))}, - new Object[]{"Hashtable", fillMap(new Hashtable())}, - new Object[]{"TreeMap", fillMap(new TreeMap())}, - new Object[]{"ConcurrentHashMap", fillMap(new ConcurrentHashMap())}, - new Object[]{"ConcurrentSkipListMap", fillMap(new ConcurrentSkipListMap())}, - new Object[]{"Collections.checkedMap(ConcurrentHashMap)", Collections.checkedMap(fillMap(new ConcurrentHashMap()), IntegerEnum.class, String.class)}, - new Object[]{"Collections.synchronizedMap(EnumMap)", Collections.synchronizedMap(fillMap(new EnumMap(IntegerEnum.class)))}).iterator(); - } - - private static Map fillMap(Map result) { - for (int each = 0; each < TEST_SIZE; each++) { - result.put(KEYS[each], VALUES[each]); - } - - return result; - } -} From 5b838d4ce156211980428d26dcd83aeb4b6e8998 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Tue, 2 Apr 2013 09:30:07 +0200 Subject: [PATCH 105/155] 7034299: Faulty winsock initialization code Reviewed-by: dholmes, sla, ctornqvi --- hotspot/src/os/windows/vm/os_windows.cpp | 40 +++++++++--------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 4a99a1b3975..04953802064 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3768,6 +3768,8 @@ extern "C" { } } +static jint initSock(); + // this is called _after_ the global arguments have been parsed jint os::init_2(void) { // Allocate a single page and mark it as readable for safepoint polling @@ -3898,6 +3900,10 @@ jint os::init_2(void) { if (!success) UseNUMAInterleaving = false; } + if (initSock() != JNI_OK) { + return JNI_ERR; + } + return JNI_OK; } @@ -4894,42 +4900,24 @@ LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) { // We don't build a headless jre for Windows bool os::is_headless_jre() { return false; } - -typedef CRITICAL_SECTION mutex_t; -#define mutexInit(m) InitializeCriticalSection(m) -#define mutexDestroy(m) DeleteCriticalSection(m) -#define mutexLock(m) EnterCriticalSection(m) -#define mutexUnlock(m) LeaveCriticalSection(m) - -static bool sock_initialized = FALSE; -static mutex_t sockFnTableMutex; - -static void initSock() { +static jint initSock() { WSADATA wsadata; if (!os::WinSock2Dll::WinSock2Available()) { - jio_fprintf(stderr, "Could not load Winsock 2 (error: %d)\n", + jio_fprintf(stderr, "Could not load Winsock (error: %d)\n", ::GetLastError()); - return; + return JNI_ERR; } - if (sock_initialized == TRUE) return; - ::mutexInit(&sockFnTableMutex); - ::mutexLock(&sockFnTableMutex); - if (os::WinSock2Dll::WSAStartup(MAKEWORD(1,1), &wsadata) != 0) { - jio_fprintf(stderr, "Could not initialize Winsock\n"); + if (os::WinSock2Dll::WSAStartup(MAKEWORD(2,2), &wsadata) != 0) { + jio_fprintf(stderr, "Could not initialize Winsock (error: %d)\n", + ::GetLastError()); + return JNI_ERR; } - sock_initialized = TRUE; - ::mutexUnlock(&sockFnTableMutex); + return JNI_OK; } struct hostent* os::get_host_by_name(char* name) { - if (!sock_initialized) { - initSock(); - } - if (!os::WinSock2Dll::WinSock2Available()) { - return NULL; - } return (struct hostent*)os::WinSock2Dll::gethostbyname(name); } From 45cc7f61db5c9fe7d91134f6e070d42705bddc26 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 2 Apr 2013 10:03:02 +0200 Subject: [PATCH 106/155] 8005857: assert in GC_locker from PSOldGen::expand with -XX:+PrintGCDetails and Verbose Use GC_locker::is_active_and_needs_gc() instead of GC_locker::is_active() for providing information about the reason of heap expansion. Reviewed-by: jmasa, johnc --- .../share/vm/gc_implementation/parallelScavenge/psOldGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp index 48e3ebb45c5..2cb3b35e091 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp @@ -256,7 +256,7 @@ void PSOldGen::expand(size_t bytes) { } if (PrintGC && Verbose) { - if (success && GC_locker::is_active()) { + if (success && GC_locker::is_active_and_needs_gc()) { gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead"); } } From bce70c8f7b1f0fd54026c3f28faf8d300ad9bf6e Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Tue, 2 Apr 2013 10:32:21 +0200 Subject: [PATCH 107/155] 8009558: linked_md.c::dll_build_name can get stuck in an infinite loop Reviewed-by: alanb, sspitsyn --- jdk/src/share/back/export/sys.h | 2 +- jdk/src/share/back/transport.c | 8 ++-- jdk/src/share/demo/jvmti/hprof/hprof_md.h | 2 +- jdk/src/solaris/back/linker_md.c | 37 +++++++---------- jdk/src/solaris/demo/jvmti/hprof/hprof_md.c | 46 +++++++++------------ jdk/src/windows/back/linker_md.c | 43 +++++++------------ jdk/src/windows/demo/jvmti/hprof/hprof_md.c | 42 +++++++------------ 7 files changed, 73 insertions(+), 107 deletions(-) diff --git a/jdk/src/share/back/export/sys.h b/jdk/src/share/back/export/sys.h index 4c42ec23d64..bd4bb9dd1d0 100644 --- a/jdk/src/share/back/export/sys.h +++ b/jdk/src/share/back/export/sys.h @@ -37,7 +37,7 @@ /* Implemented in linker_md.c */ -void dbgsysBuildLibName(char *, int, char *, char *); +void dbgsysBuildLibName(char *, int, const char *, const char *); void * dbgsysLoadLibrary(const char *, char *err_buf, int err_buflen); void dbgsysUnloadLibrary(void *); void * dbgsysFindLibraryEntry(void *, const char *); diff --git a/jdk/src/share/back/transport.c b/jdk/src/share/back/transport.c index 1d7335d660b..20892e3d998 100644 --- a/jdk/src/share/back/transport.c +++ b/jdk/src/share/back/transport.c @@ -97,12 +97,12 @@ findTransportOnLoad(void *handle) /* Load transport library (directory=="" means do system search) */ static void * -loadTransportLibrary(char *libdir, char *name) +loadTransportLibrary(const char *libdir, const char *name) { void *handle; char libname[MAXPATHLEN+2]; char buf[MAXPATHLEN*2+100]; - char *plibdir; + const char *plibdir; /* Convert libdir from UTF-8 to platform encoding */ plibdir = NULL; @@ -131,12 +131,12 @@ loadTransportLibrary(char *libdir, char *name) * JDK 1.2 javai.c v1.61 */ static jdwpError -loadTransport(char *name, jdwpTransportEnv **transportPtr) +loadTransport(const char *name, jdwpTransportEnv **transportPtr) { JNIEnv *env; jdwpTransport_OnLoad_t onLoad; void *handle; - char *libdir; + const char *libdir; /* Make sure library name is not empty */ if (name == NULL) { diff --git a/jdk/src/share/demo/jvmti/hprof/hprof_md.h b/jdk/src/share/demo/jvmti/hprof/hprof_md.h index b3e66fe36a6..b65cba0ed9b 100644 --- a/jdk/src/share/demo/jvmti/hprof/hprof_md.h +++ b/jdk/src/share/demo/jvmti/hprof/hprof_md.h @@ -69,7 +69,7 @@ unsigned md_htonl(unsigned l); unsigned md_ntohs(unsigned short s); unsigned md_ntohl(unsigned l); -void md_build_library_name(char *holder, int holderlen, char *pname, char *fname); +void md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname); void * md_load_library(const char *name, char *err_buf, int err_buflen); void md_unload_library(void *handle); void * md_find_library_entry(void *handle, const char *name); diff --git a/jdk/src/solaris/back/linker_md.c b/jdk/src/solaris/back/linker_md.c index dbcfc04a40a..07be055a5ff 100644 --- a/jdk/src/solaris/back/linker_md.c +++ b/jdk/src/solaris/back/linker_md.c @@ -55,34 +55,27 @@ #endif static void dll_build_name(char* buffer, size_t buflen, - const char* pname, const char* fname) { - // Based on os_solaris.cpp + const char* paths, const char* fname) { + char *path, *paths_copy, *next_token; - char *path_sep = PATH_SEPARATOR; - char *pathname = (char *)pname; - *buffer = '\0'; - while (strlen(pathname) > 0) { - char *p = strchr(pathname, *path_sep); - if (p == NULL) { - p = pathname + strlen(pathname); - } - /* check for NULL path */ - if (p == pathname) { - continue; - } - (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (int)(p - pathname), - pathname, fname); + paths_copy = strdup(paths); + if (paths_copy == NULL) { + return; + } + next_token = NULL; + path = strtok_r(paths_copy, PATH_SEPARATOR, &next_token); + + while (path != NULL) { + snprintf(buffer, buflen, "%s/lib%s." LIB_SUFFIX, path, fname); if (access(buffer, F_OK) == 0) { break; } - if (*p == '\0') { - pathname = p; - } else { - pathname = p + 1; - } *buffer = '\0'; + path = strtok_r(NULL, PATH_SEPARATOR, &next_token); } + + free(paths_copy); } /* @@ -103,7 +96,7 @@ dbgsysBuildFunName(char *name, int nameLen, int args_size, int encodingIndex) * appropriate pre and extensions to a filename and the path */ void -dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname) +dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname) { const int pnamelen = pname ? strlen(pname) : 0; diff --git a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c index 204636328f9..9cfcc592c3a 100644 --- a/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c +++ b/jdk/src/solaris/demo/jvmti/hprof/hprof_md.c @@ -381,38 +381,32 @@ md_ntohl(unsigned l) } static void dll_build_name(char* buffer, size_t buflen, - const char* pname, const char* fname) { - // Loosely based on os_solaris.cpp + const char* paths, const char* fname) { + char *path, *paths_copy, *next_token; - char *pathname = (char *)pname; - *buffer = '\0'; - while (strlen(pathname) > 0) { - char *p = strchr(pathname, ':'); - if (p == NULL) { - p = pathname + strlen(pathname); - } - /* check for NULL path */ - if (p == pathname) { - continue; - } - (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX, - (int)(p - pathname), pathname, fname); + paths_copy = strdup(paths); + if (paths_copy == NULL) { + return; + } - if (access(buffer, F_OK) == 0) { - break; - } - if (*p == '\0') { - pathname = p; - } else { - pathname = p + 1; - } - *buffer = '\0'; - } + next_token = NULL; + path = strtok_r(paths_copy, ":", &next_token); + + while (path != NULL) { + snprintf(buffer, buflen, "%s/lib%s" JNI_LIB_SUFFIX, path, fname); + if (access(buffer, F_OK) == 0) { + break; + } + *buffer = '\0'; + path = strtok_r(NULL, ":", &next_token); + } + + free(paths_copy); } /* Create the actual fill filename for a dynamic library. */ void -md_build_library_name(char *holder, int holderlen, char *pname, char *fname) +md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname) { int pnamelen; diff --git a/jdk/src/windows/back/linker_md.c b/jdk/src/windows/back/linker_md.c index ad48d3d57c2..52bf494186d 100644 --- a/jdk/src/windows/back/linker_md.c +++ b/jdk/src/windows/back/linker_md.c @@ -39,38 +39,27 @@ #include "path_md.h" static void dll_build_name(char* buffer, size_t buflen, - const char* pname, const char* fname) { - // Based on os_windows.cpp + const char* paths, const char* fname) { + char *path, *paths_copy, *next_token; - char *path_sep = PATH_SEPARATOR; - char *pathname = (char *)pname; - *buffer = '\0'; - while (strlen(pathname) > 0) { - char *p = strchr(pathname, *path_sep); - if (p == NULL) { - p = pathname + strlen(pathname); - } - /* check for NULL path */ - if (p == pathname) { - continue; - } - if (*(p-1) == ':' || *(p-1) == '\\') { - (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname), - pathname, fname); - } else { - (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname), - pathname, fname); - } + paths_copy = strdup(paths); + if (paths_copy == NULL) { + return; + } + + next_token = NULL; + path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token); + + while (path != NULL) { + _snprintf(buffer, buflen, "%s\\%s.dll", path, fname); if (_access(buffer, 0) == 0) { break; } - if (*p == '\0') { - pathname = p; - } else { - pathname = p + 1; - } *buffer = '\0'; + path = strtok_s(NULL, PATH_SEPARATOR, &next_token); } + + free(paths_copy); } /* @@ -113,7 +102,7 @@ dbgsysGetLastErrorString(char *buf, int len) * Build a machine dependent library name out of a path and file name. */ void -dbgsysBuildLibName(char *holder, int holderlen, char *pname, char *fname) +dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname) { const int pnamelen = pname ? (int)strlen(pname) : 0; diff --git a/jdk/src/windows/demo/jvmti/hprof/hprof_md.c b/jdk/src/windows/demo/jvmti/hprof/hprof_md.c index 4bd4a40f049..90e15ed5b84 100644 --- a/jdk/src/windows/demo/jvmti/hprof/hprof_md.c +++ b/jdk/src/windows/demo/jvmti/hprof/hprof_md.c @@ -368,42 +368,32 @@ get_last_error_string(char *buf, int len) } static void dll_build_name(char* buffer, size_t buflen, - const char* pname, const char* fname) { - // Loosley based on os_windows.cpp + const char* paths, const char* fname) { + char *path, *paths_copy, *next_token; - char *pathname = (char *)pname; - *buffer = '\0'; - while (strlen(pathname) > 0) { - char *p = strchr(pathname, ';'); - if (p == NULL) { - p = pathname + strlen(pathname); - } - /* check for NULL path */ - if (p == pathname) { - continue; - } - if (*(p-1) == ':' || *(p-1) == '\\') { - (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname), - pathname, fname); - } else { - (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname), - pathname, fname); - } + paths_copy = strdup(paths); + if (paths_copy == NULL) { + return; + } + + next_token = NULL; + path = strtok_s(paths_copy, ";", &next_token); + + while (path != NULL) { + _snprintf(buffer, buflen, "%s\\%s.dll", path, fname); if (_access(buffer, 0) == 0) { break; } - if (*p == '\0') { - pathname = p; - } else { - pathname = p + 1; - } *buffer = '\0'; + path = strtok_s(NULL, ";", &next_token); } + + free(paths_copy); } /* Build a machine dependent library name out of a path and file name. */ void -md_build_library_name(char *holder, int holderlen, char *pname, char *fname) +md_build_library_name(char *holder, int holderlen, const char *pname, const char *fname) { int pnamelen; From a4300aa98bcfeeca1ce5cf6b1b1111e93317f5cf Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Tue, 2 Apr 2013 11:28:33 +0200 Subject: [PATCH 108/155] 8009763: Add WB test for String.intern() Add convenience method in StringTable, add WhiteBox method and simple sanity test Reviewed-by: mgerdin, zgu --- .../src/share/vm/classfile/symbolTable.cpp | 11 +++- .../src/share/vm/classfile/symbolTable.hpp | 1 + hotspot/src/share/vm/prims/whitebox.cpp | 20 +++++++ hotspot/test/runtime/interned/SanityTest.java | 59 +++++++++++++++++++ .../whitebox/sun/hotspot/WhiteBox.java | 6 ++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 hotspot/test/runtime/interned/SanityTest.java diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index fc19dd55564..0f8da2d895e 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -677,9 +677,14 @@ oop StringTable::lookup(Symbol* symbol) { ResourceMark rm; int length; jchar* chars = symbol->as_unicode(length); - unsigned int hashValue = hash_string(chars, length); - int index = the_table()->hash_to_index(hashValue); - return the_table()->lookup(index, chars, length, hashValue); + return lookup(chars, length); +} + + +oop StringTable::lookup(jchar* name, int len) { + unsigned int hash = hash_string(name, len); + int index = the_table()->hash_to_index(hash); + return the_table()->lookup(index, name, len, hash); } diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp index 3eee99ddbc2..a2896382f63 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.hpp +++ b/hotspot/src/share/vm/classfile/symbolTable.hpp @@ -287,6 +287,7 @@ public: // Probing static oop lookup(Symbol* symbol); + static oop lookup(jchar* chars, int length); // Interning static oop intern(Symbol* symbol, TRAPS); diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 4758210ee0c..9b3cd297f8a 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -254,6 +254,24 @@ WB_ENTRY(jint, WB_GetCompileQueuesSize(JNIEnv* env, jobject o)) CompileBroker::queue_size(CompLevel_full_profile) /* C1 */; WB_END +WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString)) + ResourceMark rm(THREAD); + int len; + jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len); + oop found_string = StringTable::the_table()->lookup(name, len); + if (found_string == NULL) { + return false; + } + return true; +WB_END + + +WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) + Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true); + Universe::heap()->collect(GCCause::_last_ditch_collection); +WB_END + + //Some convenience methods to deal with objects from java int WhiteBox::offset_for_field(const char* field_name, oop object, Symbol* signature_symbol) { @@ -343,6 +361,8 @@ static JNINativeMethod methods[] = { CC"(Ljava/lang/reflect/Method;)I", (void*)&WB_GetMethodCompilationLevel}, {CC"getCompileQueuesSize", CC"()I", (void*)&WB_GetCompileQueuesSize}, + {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, + {CC"fullGC", CC"()V", (void*)&WB_FullGC }, }; #undef CC diff --git a/hotspot/test/runtime/interned/SanityTest.java b/hotspot/test/runtime/interned/SanityTest.java new file mode 100644 index 00000000000..779d3fc78c6 --- /dev/null +++ b/hotspot/test/runtime/interned/SanityTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013, 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 SanityTest + * @summary Sanity check of String.intern() & GC + * @library /testlibrary /testlibrary/whitebox + * @build SanityTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SanityTest + */ + +import java.util.*; +import sun.hotspot.WhiteBox; + + +public class SanityTest { + public static Object tmp; + public static void main(String... args) { + + WhiteBox wb = WhiteBox.getWhiteBox(); + StringBuilder sb = new StringBuilder(); + sb.append("1234x"); sb.append("x56789"); + String str = sb.toString(); + + if (wb.isInStringTable(str)) { + throw new RuntimeException("String " + str + " is already interned"); + } + str.intern(); + if (!wb.isInStringTable(str)) { + throw new RuntimeException("String " + str + " is not interned"); + } + str = sb.toString(); + wb.fullGC(); + if (wb.isInStringTable(str)) { + throw new RuntimeException("String " + str + " is in StringTable even after GC"); + } + } +} diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java index c9d23ef5fa5..d5d3ab525c5 100644 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java @@ -94,4 +94,10 @@ public class WhiteBox { public native int getMethodCompilationLevel(Method method); public native boolean setDontInlineMethod(Method method, boolean value); public native int getCompileQueuesSize(); + + //Intered strings + public native boolean isInStringTable(String str); + + // force Full GC + public native void fullGC(); } From c6ab956b21d94db40fe0abc040ab30bbe702dea4 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 2 Apr 2013 13:59:30 +0100 Subject: [PATCH 109/155] 8009988: build-infra: Fix configure output for zip debuginfo check No output from zip debuginfo option when default is used. Reviewed-by: tbell --- common/autoconf/autogen.sh | 18 +- common/autoconf/generated-configure.sh | 456 ++++++++++++------------- common/autoconf/jdk-options.m4 | 6 +- 3 files changed, 234 insertions(+), 246 deletions(-) diff --git a/common/autoconf/autogen.sh b/common/autoconf/autogen.sh index 64f11204678..6df1f557552 100644 --- a/common/autoconf/autogen.sh +++ b/common/autoconf/autogen.sh @@ -43,14 +43,24 @@ fi custom_hook=$custom_script_dir/custom-hook.m4 -if test "x`which autoconf 2> /dev/null`" = x; then +AUTOCONF=$(which autoconf 2> /dev/null); +AUTOCONF_267=$(which autoconf-2.67 2> /dev/null); + +echo "Autoconf found: ${AUTOCONF}" +echo "Autoconf-2.67 found: ${AUTOCONF_267}" + +if test "x${AUTOCONF}" = x; then echo You need autoconf installed to be able to regenerate the configure script echo Error: Cannot find autoconf 1>&2 exit 1 fi -echo Generating generated-configure.sh -cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | autoconf -W all -I$script_dir - > $script_dir/generated-configure.sh +if test "x${AUTOCONF_267}" != x; then + AUTOCONF=${AUTOCONF_267}; +fi + +echo Generating generated-configure.sh with ${AUTOCONF} +cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | ${AUTOCONF} -W all -I$script_dir - > $script_dir/generated-configure.sh rm -rf autom4te.cache if test -e $custom_hook; then @@ -58,7 +68,7 @@ if test -e $custom_hook; then # We have custom sources available; also generate configure script # with custom hooks compiled in. cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \ - sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|" | autoconf -W all -I$script_dir - > $custom_script_dir/generated-configure.sh + sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|" | ${AUTOCONF} -W all -I$script_dir - > $custom_script_dir/generated-configure.sh rm -rf autom4te.cache else echo No custom hook found: $custom_hook diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 4d9ec980421..394b541bbd2 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. # # Report bugs to . # @@ -91,7 +91,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -217,18 +216,11 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -1450,7 +1442,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac @@ -1882,7 +1874,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1928,7 +1920,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1966,7 +1958,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -2004,7 +1996,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_objc_try_compile @@ -2041,7 +2033,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2078,7 +2070,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -2091,10 +2083,10 @@ fi ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -2161,7 +2153,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -2170,7 +2162,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_mongrel @@ -2211,7 +2203,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -2225,7 +2217,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2243,7 +2235,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_compile @@ -2420,7 +2412,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_compute_int @@ -2466,7 +2458,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -2479,7 +2471,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2534,7 +2526,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_func @@ -2547,7 +2539,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2565,7 +2557,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF @@ -2573,7 +2565,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -3753,7 +3745,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1363706268 +DATE_WHEN_GENERATED=1364562324 ############################################################################### # @@ -3791,7 +3783,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASENAME+:} false; then : +if test "${ac_cv_path_BASENAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3850,7 +3842,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASH+:} false; then : +if test "${ac_cv_path_BASH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3909,7 +3901,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CAT+:} false; then : +if test "${ac_cv_path_CAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -3968,7 +3960,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHMOD+:} false; then : +if test "${ac_cv_path_CHMOD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -4027,7 +4019,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CMP+:} false; then : +if test "${ac_cv_path_CMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -4086,7 +4078,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -4145,7 +4137,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CP+:} false; then : +if test "${ac_cv_path_CP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -4204,7 +4196,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : +if test "${ac_cv_path_CPIO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CPIO in @@ -4263,7 +4255,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CUT+:} false; then : +if test "${ac_cv_path_CUT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -4322,7 +4314,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DATE+:} false; then : +if test "${ac_cv_path_DATE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -4381,7 +4373,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIFF+:} false; then : +if test "${ac_cv_path_DIFF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -4440,7 +4432,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIRNAME+:} false; then : +if test "${ac_cv_path_DIRNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -4499,7 +4491,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ECHO+:} false; then : +if test "${ac_cv_path_ECHO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -4558,7 +4550,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_EXPR+:} false; then : +if test "${ac_cv_path_EXPR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -4617,7 +4609,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FILE+:} false; then : +if test "${ac_cv_path_FILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -4676,7 +4668,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FIND+:} false; then : +if test "${ac_cv_path_FIND+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -4735,7 +4727,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HEAD+:} false; then : +if test "${ac_cv_path_HEAD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -4794,7 +4786,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LN+:} false; then : +if test "${ac_cv_path_LN+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4853,7 +4845,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LS+:} false; then : +if test "${ac_cv_path_LS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4912,7 +4904,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKDIR+:} false; then : +if test "${ac_cv_path_MKDIR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -4971,7 +4963,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKTEMP+:} false; then : +if test "${ac_cv_path_MKTEMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -5030,7 +5022,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MV+:} false; then : +if test "${ac_cv_path_MV+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -5089,7 +5081,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PRINTF+:} false; then : +if test "${ac_cv_path_PRINTF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -5148,7 +5140,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_THEPWDCMD+:} false; then : +if test "${ac_cv_path_THEPWDCMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $THEPWDCMD in @@ -5207,7 +5199,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_RM+:} false; then : +if test "${ac_cv_path_RM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -5266,7 +5258,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SH+:} false; then : +if test "${ac_cv_path_SH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -5325,7 +5317,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SORT+:} false; then : +if test "${ac_cv_path_SORT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -5384,7 +5376,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAIL+:} false; then : +if test "${ac_cv_path_TAIL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -5443,7 +5435,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAR+:} false; then : +if test "${ac_cv_path_TAR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -5502,7 +5494,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TEE+:} false; then : +if test "${ac_cv_path_TEE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -5561,7 +5553,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOUCH+:} false; then : +if test "${ac_cv_path_TOUCH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -5620,7 +5612,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TR+:} false; then : +if test "${ac_cv_path_TR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -5679,7 +5671,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNAME+:} false; then : +if test "${ac_cv_path_UNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -5738,7 +5730,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNIQ+:} false; then : +if test "${ac_cv_path_UNIQ+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5797,7 +5789,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WC+:} false; then : +if test "${ac_cv_path_WC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5856,7 +5848,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WHICH+:} false; then : +if test "${ac_cv_path_WHICH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5915,7 +5907,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XARGS+:} false; then : +if test "${ac_cv_path_XARGS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5975,7 +5967,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : +if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -6025,7 +6017,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -6100,7 +6092,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -6179,7 +6171,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : +if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -6258,7 +6250,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : +if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -6344,7 +6336,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NAWK+:} false; then : +if test "${ac_cv_path_NAWK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -6404,7 +6396,7 @@ RM="$RM -f" set dummy cygpath; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGPATH+:} false; then : +if test "${ac_cv_path_CYGPATH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -6444,7 +6436,7 @@ fi set dummy readlink; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READLINK+:} false; then : +if test "${ac_cv_path_READLINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -6484,7 +6476,7 @@ fi set dummy df; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DF+:} false; then : +if test "${ac_cv_path_DF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -6524,7 +6516,7 @@ fi set dummy SetFile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SETFILE+:} false; then : +if test "${ac_cv_path_SETFILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -6570,7 +6562,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -6604,7 +6596,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -6637,7 +6629,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then @@ -8118,7 +8110,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PKGHANDLER+:} false; then : +if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -8483,7 +8475,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -8837,7 +8829,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -9196,7 +9188,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -9549,7 +9541,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -9945,7 +9937,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNZIP+:} false; then : +if test "${ac_cv_path_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -10004,7 +9996,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ZIP+:} false; then : +if test "${ac_cv_path_ZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -10063,7 +10055,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LDD+:} false; then : +if test "${ac_cv_path_LDD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -10109,7 +10101,7 @@ fi set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_OTOOL+:} false; then : +if test "${ac_cv_path_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -10154,7 +10146,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READELF+:} false; then : +if test "${ac_cv_path_READELF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -10197,7 +10189,7 @@ done set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HG+:} false; then : +if test "${ac_cv_path_HG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -10237,7 +10229,7 @@ fi set dummy stat; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STAT+:} false; then : +if test "${ac_cv_path_STAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -10277,7 +10269,7 @@ fi set dummy time; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TIME+:} false; then : +if test "${ac_cv_path_TIME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -10322,7 +10314,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -10386,7 +10378,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -10429,7 +10421,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -10602,7 +10594,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_UNZIP+:} false; then : +if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -10648,7 +10640,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_FTP+:} false; then : +if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -11921,7 +11913,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVAC_CHECK+:} false; then : +if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -11961,7 +11953,7 @@ fi set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVA_CHECK+:} false; then : +if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -16035,7 +16027,7 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGWIN_LINK+:} false; then : +if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -17450,7 +17442,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CC+:} false; then : +if test "${ac_cv_path_BUILD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -17761,7 +17753,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CXX+:} false; then : +if test "${ac_cv_path_BUILD_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -18070,7 +18062,7 @@ $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} set dummy ld; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_LD+:} false; then : +if test "${ac_cv_path_BUILD_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -18586,7 +18578,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CC+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CC in @@ -18638,7 +18630,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CC+:} false; then : +if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -19051,7 +19043,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -19095,7 +19087,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -19545,7 +19537,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -19589,7 +19581,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -19870,7 +19862,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19921,7 +19913,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19958,7 +19950,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -20036,7 +20028,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -20159,7 +20151,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CXX+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CXX in @@ -20211,7 +20203,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CXX+:} false; then : +if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -20624,7 +20616,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -20668,7 +20660,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -21122,7 +21114,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -21166,7 +21158,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -21244,7 +21236,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21281,7 +21273,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : +if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -21379,7 +21371,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJC+:} false; then : +if test "${ac_cv_prog_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -21423,7 +21415,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJC+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -21499,7 +21491,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if ${ac_cv_objc_compiler_gnu+:} false; then : +if test "${ac_cv_objc_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21536,7 +21528,7 @@ ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if ${ac_cv_prog_objc_g+:} false; then : +if test "${ac_cv_prog_objc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag @@ -21912,7 +21904,7 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : +if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -21952,7 +21944,7 @@ if test -z "$ac_cv_prog_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -22294,7 +22286,7 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then : set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINLD+:} false; then : +if test "${ac_cv_prog_WINLD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -22633,7 +22625,7 @@ $as_echo "yes" >&6; } set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MT+:} false; then : +if test "${ac_cv_prog_MT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -22954,7 +22946,7 @@ $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} set dummy rc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RC+:} false; then : +if test "${ac_cv_prog_RC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -23345,7 +23337,7 @@ fi set dummy lib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINAR+:} false; then : +if test "${ac_cv_prog_WINAR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -23651,7 +23643,7 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} set dummy dumpbin; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -23970,7 +23962,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -24370,7 +24362,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : + if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -24788,7 +24780,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_AS+:} false; then : +if test "${ac_cv_path_AS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -25102,7 +25094,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NM+:} false; then : +if test "${ac_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -25411,7 +25403,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STRIP+:} false; then : +if test "${ac_cv_path_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -25717,7 +25709,7 @@ $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} set dummy mcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MCS+:} false; then : +if test "${ac_cv_path_MCS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -26025,7 +26017,7 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NM+:} false; then : +if test "${ac_cv_prog_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -26065,7 +26057,7 @@ if test -z "$ac_cv_prog_NM"; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NM+:} false; then : +if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -26383,7 +26375,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -26423,7 +26415,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -26748,7 +26740,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJCOPY+:} false; then : +if test "${ac_cv_prog_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -26792,7 +26784,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -27119,7 +27111,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : +if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -27163,7 +27155,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -27487,7 +27479,7 @@ if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LIPO+:} false; then : +if test "${ac_cv_path_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -27802,7 +27794,7 @@ PATH="$OLD_PATH" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27978,7 +27970,7 @@ fi for ac_header in stdio.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = xyes; then : +if test "x$ac_cv_header_stdio_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDIO_H 1 _ACEOF @@ -28007,7 +27999,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if ${ac_cv_sizeof_int_p+:} false; then : +if test "${ac_cv_sizeof_int_p+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : @@ -28064,7 +28056,7 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -28903,14 +28895,15 @@ $as_echo "$ENABLE_DEBUG_SYMBOLS" >&6; } # # ZIP_DEBUGINFO_FILES # -# Check whether --enable-zip-debug-info was given. -if test "${enable_zip_debug_info+set}" = set; then : - enableval=$enable_zip_debug_info; -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should zip debug-info files" >&5 $as_echo_n "checking if we should zip debug-info files... " >&6; } +# Check whether --enable-zip-debug-info was given. +if test "${enable_zip_debug_info+set}" = set; then : + enableval=$enable_zip_debug_info; enable_zip_debug_info="${enableval}" +else + enable_zip_debug_info="yes" +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_zip_debug_info}" >&5 $as_echo "${enable_zip_debug_info}" >&6; } @@ -29076,7 +29069,7 @@ if test "x$with_x" = xno; then else case $x_includes,$x_libraries in #( *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -29353,7 +29346,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29387,14 +29380,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29428,7 +29421,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi @@ -29447,14 +29440,14 @@ rm -f core conftest.err conftest.$ac_objext \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes; then : +if test "x$ac_cv_func_gethostbyname" = x""yes; then : fi if test $ac_cv_func_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_gethostbyname+:} false; then : +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29488,14 +29481,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_gethostbyname+:} false; then : +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29529,7 +29522,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -29544,14 +29537,14 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = xyes; then : +if test "x$ac_cv_func_connect" = x""yes; then : fi if test $ac_cv_func_connect = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if ${ac_cv_lib_socket_connect+:} false; then : +if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29585,7 +29578,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = xyes; then : +if test "x$ac_cv_lib_socket_connect" = x""yes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -29593,14 +29586,14 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = xyes; then : +if test "x$ac_cv_func_remove" = x""yes; then : fi if test $ac_cv_func_remove = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if ${ac_cv_lib_posix_remove+:} false; then : +if test "${ac_cv_lib_posix_remove+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29634,7 +29627,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = xyes; then : +if test "x$ac_cv_lib_posix_remove" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -29642,14 +29635,14 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = xyes; then : +if test "x$ac_cv_func_shmat" = x""yes; then : fi if test $ac_cv_func_shmat = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if ${ac_cv_lib_ipc_shmat+:} false; then : +if test "${ac_cv_lib_ipc_shmat+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29683,7 +29676,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = xyes; then : +if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -29701,7 +29694,7 @@ fi # John Interrante, Karl Berry { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29735,7 +29728,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -30748,7 +30741,7 @@ $as_echo "$FREETYPE2_FOUND" >&6; } LDFLAGS="$FREETYPE2_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then : +if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30782,7 +30775,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then : +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : FREETYPE2_FOUND=true else as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 @@ -31070,7 +31063,7 @@ fi for ac_header in alsa/asoundlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" -if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : +if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF @@ -31129,7 +31122,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_main+:} false; then : +if test "${ac_cv_lib_jpeg_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31157,7 +31150,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = xyes; then : +if test "x$ac_cv_lib_jpeg_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -31181,7 +31174,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgif" >&5 $as_echo_n "checking for main in -lgif... " >&6; } -if ${ac_cv_lib_gif_main+:} false; then : +if test "${ac_cv_lib_gif_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31209,7 +31202,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_main" >&5 $as_echo "$ac_cv_lib_gif_main" >&6; } -if test "x$ac_cv_lib_gif_main" = xyes; then : +if test "x$ac_cv_lib_gif_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -31239,7 +31232,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if ${ac_cv_lib_z_compress+:} false; then : +if test "${ac_cv_lib_z_compress+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31273,7 +31266,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = xyes; then : +if test "x$ac_cv_lib_z_compress" = x""yes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no @@ -31366,7 +31359,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if ${ac_cv_lib_m_cos+:} false; then : +if test "${ac_cv_lib_m_cos+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31400,7 +31393,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = xyes; then : +if test "x$ac_cv_lib_m_cos" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -31424,7 +31417,7 @@ save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31458,7 +31451,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -32148,7 +32141,7 @@ fi set dummy ccache; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CCACHE+:} false; then : +if test "${ac_cv_path_CCACHE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -32409,21 +32402,10 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then + test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi + cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -32455,7 +32437,7 @@ LTLIBOBJS=$ac_ltlibobjs -: "${CONFIG_STATUS=./config.status}" +: ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -32556,7 +32538,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -32864,7 +32845,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -32927,7 +32908,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -33078,10 +33059,9 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= ac_tmp= + tmp= trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -33089,13 +33069,12 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" + test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -33117,7 +33096,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF @@ -33145,7 +33124,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -33193,7 +33172,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && +cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -33225,7 +33204,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -33259,7 +33238,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || +cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -33271,8 +33250,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -33392,7 +33371,7 @@ do for ac_f do case $ac_f in - -) ac_f="$ac_tmp/stdin";; + -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -33427,7 +33406,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ + *:-:* | *:-) cat >"$tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; @@ -33553,22 +33532,21 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$ac_tmp/stdin" + rm -f "$tmp/stdin" case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -33579,20 +33557,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ + mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index d3d55e52952..7e286036c51 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -519,10 +519,10 @@ AC_MSG_RESULT([$ENABLE_DEBUG_SYMBOLS]) # # ZIP_DEBUGINFO_FILES # -AC_ARG_ENABLE([zip-debug-info], - [AS_HELP_STRING([--disable-zip-debug-info],[disable zipping of debug-info files @<:@enabled@:>@])]) - AC_MSG_CHECKING([if we should zip debug-info files]) +AC_ARG_ENABLE([zip-debug-info], + [AS_HELP_STRING([--disable-zip-debug-info],[disable zipping of debug-info files @<:@enabled@:>@])], + [enable_zip_debug_info="${enableval}"], [enable_zip_debug_info="yes"]) AC_MSG_RESULT([${enable_zip_debug_info}]) if test "x${enable_zip_debug_info}" = "xno"; then From 3457ff433712d89e1ee1c724c773ada12fda1be6 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Tue, 2 Apr 2013 10:12:20 -0700 Subject: [PATCH 110/155] 8007379: Base64.getMimeDecoder().decode() throws IAE for a non-base64 character after padding 8008925: Base64.getMimeDecoder().decode() does not ignore padding chars Updated implementation and spec for corner cases. Reviewed-by: alanb --- jdk/src/share/classes/java/util/Base64.java | 20 +++++++++++++------- jdk/test/java/util/Base64/TestBase64.java | 10 ++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/jdk/src/share/classes/java/util/Base64.java b/jdk/src/share/classes/java/util/Base64.java index 88b17406799..92b9cb09600 100644 --- a/jdk/src/share/classes/java/util/Base64.java +++ b/jdk/src/share/classes/java/util/Base64.java @@ -620,7 +620,10 @@ public class Base64 { * required. So if the final unit of the encoded byte data only has * two or three Base64 characters (without the corresponding padding * character(s) padded), they are decoded as if followed by padding - * character(s). + * character(s). If there is padding character present in the + * final unit, the correct number of padding character(s) must be + * present, otherwise {@code IllegalArgumentException} is thrown + * during decoding. * *

    Instances of {@link Decoder} class are safe for use by * multiple concurrent threads. @@ -1034,23 +1037,26 @@ public class Base64 { throw new IllegalArgumentException( "Input byte[] should at least have 2 bytes for base64 bytes"); } - if (src[sl - 1] == '=') { - paddings++; - if (src[sl - 2] == '=') - paddings++; - } if (isMIME) { // scan all bytes to fill out all non-alphabet. a performance // trade-off of pre-scan or Arrays.copyOf int n = 0; while (sp < sl) { int b = src[sp++] & 0xff; - if (b == '=') + if (b == '=') { + len -= (sl - sp + 1); break; + } if ((b = base64[b]) == -1) n++; } len -= n; + } else { + if (src[sl - 1] == '=') { + paddings++; + if (src[sl - 2] == '=') + paddings++; + } } if (paddings == 0 && (len & 0x3) != 0) paddings = 4 - (len & 0x3); diff --git a/jdk/test/java/util/Base64/TestBase64.java b/jdk/test/java/util/Base64/TestBase64.java index e0af4de23b7..94413a2aa60 100644 --- a/jdk/test/java/util/Base64/TestBase64.java +++ b/jdk/test/java/util/Base64/TestBase64.java @@ -22,7 +22,7 @@ */ /** - * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 + * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925 * @summary tests java.util.Base64 */ @@ -107,6 +107,9 @@ public class TestBase64 { checkIAE(new Runnable() { public void run() { Base64.getDecoder().decode(ByteBuffer.wrap(decoded), ByteBuffer.allocateDirect(1024)); }}); + // illegal ending unit + checkIAE(new Runnable() { public void run() { Base64.getMimeDecoder().decode("$=#"); }}); + // test return value from decode(ByteBuffer, ByteBuffer) testDecBufRet(); @@ -115,7 +118,6 @@ public class TestBase64 { // test decoding of unpadded data testDecodeUnpadded(); - // test mime decoding with ignored character after padding testDecodeIgnoredAfterPadding(); } @@ -384,6 +386,10 @@ public class TestBase64 { encoded = Arrays.copyOf(encoded, encoded.length + 1); encoded[encoded.length - 1] = nonBase64; checkEqual(decM.decode(encoded), src[i], "Non-base64 char is not ignored"); + byte[] decoded = new byte[src[i].length]; + decM.decode(encoded, decoded); + checkEqual(decoded, src[i], "Non-base64 char is not ignored"); + try { dec.decode(encoded); throw new RuntimeException("No IAE for non-base64 char"); From b34573420a884ee78549bef2f08eabe5c0b2efab Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Tue, 2 Apr 2013 14:13:06 -0400 Subject: [PATCH 111/155] 8011278: Allow using a system-installed giflib Reviewed-by: andrew, prr --- common/autoconf/generated-configure.sh | 514 ++++++++++++++----------- common/autoconf/libraries.m4 | 35 +- 2 files changed, 321 insertions(+), 228 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 394b541bbd2..2293c92d133 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.68 for OpenJDK jdk8. # # Report bugs to . # @@ -91,6 +91,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -216,11 +217,18 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -1005,6 +1013,7 @@ with_freetype with_alsa with_alsa_include with_alsa_lib +with_giflib with_zlib with_stdc__lib with_num_cores @@ -1442,7 +1451,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1763,6 +1772,8 @@ Optional Packages: headers under PATH/include) --with-alsa-include specify directory for the alsa include files --with-alsa-lib specify directory for the alsa library + --with-giflib use giflib from build system or OpenJDK source + (system, bundled) [bundled] --with-zlib use zlib from build system or OpenJDK source (system, bundled) [bundled] --with-stdc++lib=,, @@ -1874,7 +1885,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.67 +generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1920,7 +1931,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1958,7 +1969,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -1996,7 +2007,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_objc_try_compile @@ -2033,7 +2044,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2070,7 +2081,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -2083,10 +2094,10 @@ fi ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval "test \"\${$3+set}\"" = set; then : + if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -2153,7 +2164,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -2162,7 +2173,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel @@ -2203,7 +2214,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -2217,7 +2228,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2235,7 +2246,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile @@ -2412,7 +2423,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_compute_int @@ -2458,7 +2469,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -2471,7 +2482,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2526,7 +2537,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_func @@ -2539,7 +2550,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2557,7 +2568,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF @@ -2565,7 +2576,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.67. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3745,7 +3756,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1364562324 +DATE_WHEN_GENERATED=1364922883 ############################################################################### # @@ -3783,7 +3794,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASENAME+set}" = set; then : +if ${ac_cv_path_BASENAME+:} false; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3842,7 +3853,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASH+set}" = set; then : +if ${ac_cv_path_BASH+:} false; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3901,7 +3912,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CAT+set}" = set; then : +if ${ac_cv_path_CAT+:} false; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -3960,7 +3971,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHMOD+set}" = set; then : +if ${ac_cv_path_CHMOD+:} false; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -4019,7 +4030,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CMP+set}" = set; then : +if ${ac_cv_path_CMP+:} false; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -4078,7 +4089,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_COMM+set}" = set; then : +if ${ac_cv_path_COMM+:} false; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -4137,7 +4148,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CP+set}" = set; then : +if ${ac_cv_path_CP+:} false; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -4196,7 +4207,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CPIO+set}" = set; then : +if ${ac_cv_path_CPIO+:} false; then : $as_echo_n "(cached) " >&6 else case $CPIO in @@ -4255,7 +4266,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CUT+set}" = set; then : +if ${ac_cv_path_CUT+:} false; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -4314,7 +4325,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DATE+set}" = set; then : +if ${ac_cv_path_DATE+:} false; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -4373,7 +4384,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DIFF+set}" = set; then : +if ${ac_cv_path_DIFF+:} false; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -4432,7 +4443,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DIRNAME+set}" = set; then : +if ${ac_cv_path_DIRNAME+:} false; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -4491,7 +4502,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ECHO+set}" = set; then : +if ${ac_cv_path_ECHO+:} false; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -4550,7 +4561,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_EXPR+set}" = set; then : +if ${ac_cv_path_EXPR+:} false; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -4609,7 +4620,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FILE+set}" = set; then : +if ${ac_cv_path_FILE+:} false; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -4668,7 +4679,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FIND+set}" = set; then : +if ${ac_cv_path_FIND+:} false; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -4727,7 +4738,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_HEAD+set}" = set; then : +if ${ac_cv_path_HEAD+:} false; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -4786,7 +4797,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LN+set}" = set; then : +if ${ac_cv_path_LN+:} false; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4845,7 +4856,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LS+set}" = set; then : +if ${ac_cv_path_LS+:} false; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4904,7 +4915,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MKDIR+set}" = set; then : +if ${ac_cv_path_MKDIR+:} false; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -4963,7 +4974,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MKTEMP+set}" = set; then : +if ${ac_cv_path_MKTEMP+:} false; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -5022,7 +5033,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MV+set}" = set; then : +if ${ac_cv_path_MV+:} false; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -5081,7 +5092,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PRINTF+set}" = set; then : +if ${ac_cv_path_PRINTF+:} false; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -5140,7 +5151,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_THEPWDCMD+set}" = set; then : +if ${ac_cv_path_THEPWDCMD+:} false; then : $as_echo_n "(cached) " >&6 else case $THEPWDCMD in @@ -5199,7 +5210,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_RM+set}" = set; then : +if ${ac_cv_path_RM+:} false; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -5258,7 +5269,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SH+set}" = set; then : +if ${ac_cv_path_SH+:} false; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -5317,7 +5328,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SORT+set}" = set; then : +if ${ac_cv_path_SORT+:} false; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -5376,7 +5387,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TAIL+set}" = set; then : +if ${ac_cv_path_TAIL+:} false; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -5435,7 +5446,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TAR+set}" = set; then : +if ${ac_cv_path_TAR+:} false; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -5494,7 +5505,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TEE+set}" = set; then : +if ${ac_cv_path_TEE+:} false; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -5553,7 +5564,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOUCH+set}" = set; then : +if ${ac_cv_path_TOUCH+:} false; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -5612,7 +5623,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TR+set}" = set; then : +if ${ac_cv_path_TR+:} false; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -5671,7 +5682,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNAME+set}" = set; then : +if ${ac_cv_path_UNAME+:} false; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -5730,7 +5741,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNIQ+set}" = set; then : +if ${ac_cv_path_UNIQ+:} false; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5789,7 +5800,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WC+set}" = set; then : +if ${ac_cv_path_WC+:} false; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5848,7 +5859,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WHICH+set}" = set; then : +if ${ac_cv_path_WHICH+:} false; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5907,7 +5918,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_XARGS+set}" = set; then : +if ${ac_cv_path_XARGS+:} false; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5967,7 +5978,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -6017,7 +6028,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -6092,7 +6103,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -6171,7 +6182,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if test "${ac_cv_path_FGREP+set}" = set; then : +if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -6250,7 +6261,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : +if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -6336,7 +6347,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_NAWK+set}" = set; then : +if ${ac_cv_path_NAWK+:} false; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -6396,7 +6407,7 @@ RM="$RM -f" set dummy cygpath; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CYGPATH+set}" = set; then : +if ${ac_cv_path_CYGPATH+:} false; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -6436,7 +6447,7 @@ fi set dummy readlink; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_READLINK+set}" = set; then : +if ${ac_cv_path_READLINK+:} false; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -6476,7 +6487,7 @@ fi set dummy df; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_DF+set}" = set; then : +if ${ac_cv_path_DF+:} false; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -6516,7 +6527,7 @@ fi set dummy SetFile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SETFILE+set}" = set; then : +if ${ac_cv_path_SETFILE+:} false; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -6562,7 +6573,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -6596,7 +6607,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : +if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -6629,7 +6640,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if test "${ac_cv_target+set}" = set; then : +if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then @@ -8110,7 +8121,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : +if ${ac_cv_prog_PKGHANDLER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -8475,7 +8486,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : +if ${ac_cv_path_CHECK_GMAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -8829,7 +8840,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : +if ${ac_cv_path_CHECK_MAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -9188,7 +9199,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : +if ${ac_cv_path_CHECK_TOOLSDIR_GMAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -9541,7 +9552,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : +if ${ac_cv_path_CHECK_TOOLSDIR_MAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -9937,7 +9948,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_UNZIP+set}" = set; then : +if ${ac_cv_path_UNZIP+:} false; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -9996,7 +10007,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ZIP+set}" = set; then : +if ${ac_cv_path_ZIP+:} false; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -10055,7 +10066,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LDD+set}" = set; then : +if ${ac_cv_path_LDD+:} false; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -10101,7 +10112,7 @@ fi set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_OTOOL+set}" = set; then : +if ${ac_cv_path_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -10146,7 +10157,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_READELF+set}" = set; then : +if ${ac_cv_path_READELF+:} false; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -10189,7 +10200,7 @@ done set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_HG+set}" = set; then : +if ${ac_cv_path_HG+:} false; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -10229,7 +10240,7 @@ fi set dummy stat; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STAT+set}" = set; then : +if ${ac_cv_path_STAT+:} false; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -10269,7 +10280,7 @@ fi set dummy time; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TIME+set}" = set; then : +if ${ac_cv_path_TIME+:} false; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -10314,7 +10325,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_COMM+set}" = set; then : +if ${ac_cv_path_COMM+:} false; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -10378,7 +10389,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -10421,7 +10432,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -10594,7 +10605,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : +if ${ac_cv_prog_BDEPS_UNZIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -10640,7 +10651,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : +if ${ac_cv_prog_BDEPS_FTP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -11913,7 +11924,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : +if ${ac_cv_path_JAVAC_CHECK+:} false; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -11953,7 +11964,7 @@ fi set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : +if ${ac_cv_path_JAVA_CHECK+:} false; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -16027,7 +16038,7 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : +if ${ac_cv_path_CYGWIN_LINK+:} false; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -17442,7 +17453,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_CC+set}" = set; then : +if ${ac_cv_path_BUILD_CC+:} false; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -17753,7 +17764,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_CXX+set}" = set; then : +if ${ac_cv_path_BUILD_CXX+:} false; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -18062,7 +18073,7 @@ $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} set dummy ld; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BUILD_LD+set}" = set; then : +if ${ac_cv_path_BUILD_LD+:} false; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -18578,7 +18589,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOOLS_DIR_CC+set}" = set; then : +if ${ac_cv_path_TOOLS_DIR_CC+:} false; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CC in @@ -18630,7 +18641,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : +if ${ac_cv_path_POTENTIAL_CC+:} false; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -19043,7 +19054,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : +if ${ac_cv_prog_PROPER_COMPILER_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -19087,7 +19098,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -19537,7 +19548,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -19581,7 +19592,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -19862,7 +19873,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19913,7 +19924,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19950,7 +19961,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -20028,7 +20039,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -20151,7 +20162,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TOOLS_DIR_CXX+set}" = set; then : +if ${ac_cv_path_TOOLS_DIR_CXX+:} false; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CXX in @@ -20203,7 +20214,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : +if ${ac_cv_path_POTENTIAL_CXX+:} false; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -20616,7 +20627,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : +if ${ac_cv_prog_PROPER_COMPILER_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -20660,7 +20671,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : +if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -21114,7 +21125,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then : +if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -21158,7 +21169,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : +if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -21236,7 +21247,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : +if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21273,7 +21284,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then : +if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -21371,7 +21382,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJC+set}" = set; then : +if ${ac_cv_prog_OBJC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -21415,7 +21426,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -21491,7 +21502,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if test "${ac_cv_objc_compiler_gnu+set}" = set; then : +if ${ac_cv_objc_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21528,7 +21539,7 @@ ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if test "${ac_cv_prog_objc_g+set}" = set; then : +if ${ac_cv_prog_objc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag @@ -21904,7 +21915,7 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then : +if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -21944,7 +21955,7 @@ if test -z "$ac_cv_prog_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : +if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -22286,7 +22297,7 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then : set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINLD+set}" = set; then : +if ${ac_cv_prog_WINLD+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -22625,7 +22636,7 @@ $as_echo "yes" >&6; } set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_MT+set}" = set; then : +if ${ac_cv_prog_MT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -22946,7 +22957,7 @@ $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} set dummy rc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RC+set}" = set; then : +if ${ac_cv_prog_RC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -23337,7 +23348,7 @@ fi set dummy lib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_WINAR+set}" = set; then : +if ${ac_cv_prog_WINAR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -23643,7 +23654,7 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} set dummy dumpbin; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DUMPBIN+set}" = set; then : +if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -23962,7 +23973,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -24362,7 +24373,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then : + if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -24780,7 +24791,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_AS+set}" = set; then : +if ${ac_cv_path_AS+:} false; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -25094,7 +25105,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_NM+set}" = set; then : +if ${ac_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -25403,7 +25414,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STRIP+set}" = set; then : +if ${ac_cv_path_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -25709,7 +25720,7 @@ $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} set dummy mcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_MCS+set}" = set; then : +if ${ac_cv_path_MCS+:} false; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -26017,7 +26028,7 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NM+set}" = set; then : +if ${ac_cv_prog_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -26057,7 +26068,7 @@ if test -z "$ac_cv_prog_NM"; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : +if ${ac_cv_prog_ac_ct_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -26375,7 +26386,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -26415,7 +26426,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -26740,7 +26751,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJCOPY+set}" = set; then : +if ${ac_cv_prog_OBJCOPY+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -26784,7 +26795,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -27111,7 +27122,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -27155,7 +27166,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -27479,7 +27490,7 @@ if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LIPO+set}" = set; then : +if ${ac_cv_path_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -27794,7 +27805,7 @@ PATH="$OLD_PATH" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27970,7 +27981,7 @@ fi for ac_header in stdio.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = x""yes; then : +if test "x$ac_cv_header_stdio_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDIO_H 1 _ACEOF @@ -27999,7 +28010,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if test "${ac_cv_sizeof_int_p+set}" = set; then : +if ${ac_cv_sizeof_int_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : @@ -28056,7 +28067,7 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then : +if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -29069,7 +29080,7 @@ if test "x$with_x" = xno; then else case $x_includes,$x_libraries in #( *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : + *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -29346,7 +29357,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : +if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29380,14 +29391,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : +if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : +if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29421,7 +29432,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi @@ -29440,14 +29451,14 @@ rm -f core conftest.err conftest.$ac_objext \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = x""yes; then : +if test "x$ac_cv_func_gethostbyname" = xyes; then : fi if test $ac_cv_func_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29481,14 +29492,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : +if ${ac_cv_lib_bsd_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29522,7 +29533,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : +if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -29537,14 +29548,14 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = x""yes; then : +if test "x$ac_cv_func_connect" = xyes; then : fi if test $ac_cv_func_connect = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if test "${ac_cv_lib_socket_connect+set}" = set; then : +if ${ac_cv_lib_socket_connect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29578,7 +29589,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = x""yes; then : +if test "x$ac_cv_lib_socket_connect" = xyes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -29586,14 +29597,14 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = x""yes; then : +if test "x$ac_cv_func_remove" = xyes; then : fi if test $ac_cv_func_remove = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if test "${ac_cv_lib_posix_remove+set}" = set; then : +if ${ac_cv_lib_posix_remove+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29627,7 +29638,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = x""yes; then : +if test "x$ac_cv_lib_posix_remove" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -29635,14 +29646,14 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = x""yes; then : +if test "x$ac_cv_func_shmat" = xyes; then : fi if test $ac_cv_func_shmat = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if test "${ac_cv_lib_ipc_shmat+set}" = set; then : +if ${ac_cv_lib_ipc_shmat+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29676,7 +29687,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : +if test "x$ac_cv_lib_ipc_shmat" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -29694,7 +29705,7 @@ fi # John Interrante, Karl Berry { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : +if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29728,7 +29739,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -30741,7 +30752,7 @@ $as_echo "$FREETYPE2_FOUND" >&6; } LDFLAGS="$FREETYPE2_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : +if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30775,7 +30786,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then : FREETYPE2_FOUND=true else as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 @@ -31063,7 +31074,7 @@ fi for ac_header in alsa/asoundlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" -if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : +if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF @@ -31122,7 +31133,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if test "${ac_cv_lib_jpeg_main+set}" = set; then : +if ${ac_cv_lib_jpeg_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31150,7 +31161,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = x""yes; then : +if test "x$ac_cv_lib_jpeg_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -31171,10 +31182,44 @@ fi # Check for the gif library # -USE_EXTERNAL_LIBJPEG=true -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgif" >&5 -$as_echo_n "checking for main in -lgif... " >&6; } -if test "${ac_cv_lib_gif_main+set}" = set; then : + +# Check whether --with-giflib was given. +if test "${with_giflib+set}" = set; then : + withval=$with_giflib; +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for which giflib to use" >&5 +$as_echo_n "checking for which giflib to use... " >&6; } + +# default is bundled +DEFAULT_GIFLIB=bundled + +# +# if user didn't specify, use DEFAULT_GIFLIB +# +if test "x${with_giflib}" = "x"; then + with_giflib=${DEFAULT_GIFLIB} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_giflib}" >&5 +$as_echo "${with_giflib}" >&6; } + +if test "x${with_giflib}" = "xbundled"; then + USE_EXTERNAL_LIBGIF=false +elif test "x${with_giflib}" = "xsystem"; then + ac_fn_cxx_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default" +if test "x$ac_cv_header_gif_lib_h" = xyes; then : + +else + as_fn_error $? "--with-giflib=system specified, but gif_lib.h not found!" "$LINENO" 5 +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifGetCode in -lgif" >&5 +$as_echo_n "checking for DGifGetCode in -lgif... " >&6; } +if ${ac_cv_lib_gif_DGifGetCode+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31182,27 +31227,33 @@ LIBS="-lgif $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char DGifGetCode (); int main () { -return main (); +return DGifGetCode (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_gif_main=yes + ac_cv_lib_gif_DGifGetCode=yes else - ac_cv_lib_gif_main=no + ac_cv_lib_gif_DGifGetCode=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_main" >&5 -$as_echo "$ac_cv_lib_gif_main" >&6; } -if test "x$ac_cv_lib_gif_main" = x""yes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifGetCode" >&5 +$as_echo "$ac_cv_lib_gif_DGifGetCode" >&6; } +if test "x$ac_cv_lib_gif_DGifGetCode" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -31210,13 +31261,15 @@ _ACEOF LIBS="-lgif $LIBS" else - USE_EXTERNAL_LIBGIF=false - { $as_echo "$as_me:${as_lineno-$LINENO}: Will use gif decoder bundled with the OpenJDK source" >&5 -$as_echo "$as_me: Will use gif decoder bundled with the OpenJDK source" >&6;} - + as_fn_error $? "--with-giflib=system specified, but no giflib found!" "$LINENO" 5 fi + USE_EXTERNAL_LIBGIF=true +else + as_fn_error $? "Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'" "$LINENO" 5 +fi + ############################################################################### # @@ -31232,7 +31285,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if test "${ac_cv_lib_z_compress+set}" = set; then : +if ${ac_cv_lib_z_compress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31266,7 +31319,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = x""yes; then : +if test "x$ac_cv_lib_z_compress" = xyes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no @@ -31359,7 +31412,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if test "${ac_cv_lib_m_cos+set}" = set; then : +if ${ac_cv_lib_m_cos+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31393,7 +31446,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = x""yes; then : +if test "x$ac_cv_lib_m_cos" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -31417,7 +31470,7 @@ save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31451,7 +31504,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -32141,7 +32194,7 @@ fi set dummy ccache; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CCACHE+set}" = set; then : +if ${ac_cv_path_CCACHE+:} false; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -32402,10 +32455,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -32437,7 +32501,7 @@ LTLIBOBJS=$ac_ltlibobjs -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -32538,6 +32602,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -32845,7 +32910,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.67. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -32908,7 +32973,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.67, +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -33059,9 +33124,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -33069,12 +33135,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -33096,7 +33163,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -33124,7 +33191,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -33172,7 +33239,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -33204,7 +33271,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -33238,7 +33305,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -33250,8 +33317,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -33371,7 +33438,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -33406,7 +33473,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ + *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; @@ -33532,21 +33599,22 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -33557,20 +33625,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ + mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 6cc9d634b60..21c5a96f292 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -499,11 +499,36 @@ AC_SUBST(USE_EXTERNAL_LIBJPEG) # Check for the gif library # -USE_EXTERNAL_LIBJPEG=true -AC_CHECK_LIB(gif, main, [], - [ USE_EXTERNAL_LIBGIF=false - AC_MSG_NOTICE([Will use gif decoder bundled with the OpenJDK source]) - ]) +AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib], + [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) + + +AC_MSG_CHECKING([for which giflib to use]) + +# default is bundled +DEFAULT_GIFLIB=bundled + +# +# if user didn't specify, use DEFAULT_GIFLIB +# +if test "x${with_giflib}" = "x"; then + with_giflib=${DEFAULT_GIFLIB} +fi + +AC_MSG_RESULT(${with_giflib}) + +if test "x${with_giflib}" = "xbundled"; then + USE_EXTERNAL_LIBGIF=false +elif test "x${with_giflib}" = "xsystem"; then + AC_CHECK_HEADER(gif_lib.h, [], + [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])]) + AC_CHECK_LIB(gif, DGifGetCode, [], + [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])]) + + USE_EXTERNAL_LIBGIF=true +else + AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled']) +fi AC_SUBST(USE_EXTERNAL_LIBGIF) ############################################################################### From 934072f7742f90f1a6fe0eb0fd7877fbac06d51f Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Tue, 2 Apr 2013 14:13:13 -0400 Subject: [PATCH 112/155] 8011278: Allow using a system-installed giflib Reviewed-by: andrew, prr --- jdk/makefiles/CompileNativeLibraries.gmk | 13 +++++++++---- .../native/sun/awt/splashscreen/splashscreen_gif.c | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index 4c5d8dab855..e8b8e1cbbe3 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -2387,18 +2387,23 @@ endif ifndef BUILD_HEADLESS_ONLY LIBSPLASHSCREEN_DIRS:=\ - $(JDK_TOPDIR)/src/share/native/sun/awt/giflib \ $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \ $(JDK_TOPDIR)/src/share/native/sun/awt/libpng \ $(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen +ifeq ($(USE_EXTERNAL_LIBGIF),true) + GIFLIB_LDFLAGS := -lgif +else + LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/giflib + GIFLIB_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/giflib +endif + ifneq ($(OPENJDK_TARGET_OS), macosx) LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen else LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen endif - LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \ $(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir)) @@ -2450,11 +2455,11 @@ $(eval $(call SetupNativeCompilation,LIBSPLASHSCREEN,\ EXCLUDE_FILES:=imageioJPEG.c jpegdecoder.c pngtest.c,\ LANG:=C,\ OPTIMIZATION:=LOW, \ - CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB),\ + CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) $(GIFLIB_CFLAGS),\ MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsplashscreen/mapfile-vers, \ LDFLAGS:=$(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN),\ - LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ),\ + LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ) $(GIFLIB_LDFLAGS),\ LDFLAGS_SUFFIX_solaris:=-lc,\ VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\ RC_FLAGS:=$(RC_FLAGS)\ diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c index 3c2d0fac23e..1fc081e6d72 100644 --- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c +++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c @@ -26,7 +26,7 @@ #include "splashscreen_impl.h" #include "splashscreen_gfx.h" -#include "../giflib/gif_lib.h" +#include #define GIF_TRANSPARENT 0x01 #define GIF_USER_INPUT 0x02 From fa0b9daa08cbefe9928782cff2e632a3862277b7 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 2 Apr 2013 16:26:54 -0700 Subject: [PATCH 113/155] 8004979: java.lang.reflect.Modifier.toString should include "default" Reviewed-by: mduigou --- .../java/lang/reflect/Constructor.java | 7 ++++- .../classes/java/lang/reflect/Executable.java | 21 +++++++++++---- .../classes/java/lang/reflect/Field.java | 4 +++ .../classes/java/lang/reflect/Method.java | 15 ++++++++--- .../classes/java/lang/reflect/Modifier.java | 6 +++++ .../reflect/Method/GenericStringTest.java | 26 +++++++++++++++++-- 6 files changed, 68 insertions(+), 11 deletions(-) diff --git a/jdk/src/share/classes/java/lang/reflect/Constructor.java b/jdk/src/share/classes/java/lang/reflect/Constructor.java index bdbd7c30e20..9d865cb6aaa 100644 --- a/jdk/src/share/classes/java/lang/reflect/Constructor.java +++ b/jdk/src/share/classes/java/lang/reflect/Constructor.java @@ -284,9 +284,13 @@ public final class Constructor extends Executable { * modifiers {@code public}, {@code protected} or * {@code private}. Only one of these may appear, or none if the * constructor has default (package) access. + * + * @return a string describing this {@code Constructor} + * @jls 8.8.3. Constructor Modifiers */ public String toString() { return sharedToString(Modifier.constructorModifiers(), + false, parameterTypes, exceptionTypes); } @@ -328,10 +332,11 @@ public final class Constructor extends Executable { * include type parameters * * @since 1.5 + * @jls 8.8.3. Constructor Modifiers */ @Override public String toGenericString() { - return sharedToGenericString(Modifier.constructorModifiers()); + return sharedToGenericString(Modifier.constructorModifiers(), false); } @Override diff --git a/jdk/src/share/classes/java/lang/reflect/Executable.java b/jdk/src/share/classes/java/lang/reflect/Executable.java index 1a89968b175..51e15f08363 100644 --- a/jdk/src/share/classes/java/lang/reflect/Executable.java +++ b/jdk/src/share/classes/java/lang/reflect/Executable.java @@ -89,20 +89,31 @@ public abstract class Executable extends AccessibleObject } - void printModifiersIfNonzero(StringBuilder sb, int mask) { + void printModifiersIfNonzero(StringBuilder sb, int mask, boolean isDefault) { int mod = getModifiers() & mask; - if (mod != 0) { + + if (mod != 0 && !isDefault) { sb.append(Modifier.toString(mod)).append(' '); + } else { + int access_mod = mod & Modifier.ACCESS_MODIFIERS; + if (access_mod != 0) + sb.append(Modifier.toString(access_mod)).append(' '); + if (isDefault) + sb.append("default "); + mod = (mod & ~Modifier.ACCESS_MODIFIERS); + if (mod != 0) + sb.append(Modifier.toString(mod)).append(' '); } } String sharedToString(int modifierMask, + boolean isDefault, Class[] parameterTypes, Class[] exceptionTypes) { try { StringBuilder sb = new StringBuilder(); - printModifiersIfNonzero(sb, modifierMask); + printModifiersIfNonzero(sb, modifierMask, isDefault); specificToStringHeader(sb); sb.append('('); @@ -124,11 +135,11 @@ public abstract class Executable extends AccessibleObject */ abstract void specificToStringHeader(StringBuilder sb); - String sharedToGenericString(int modifierMask) { + String sharedToGenericString(int modifierMask, boolean isDefault) { try { StringBuilder sb = new StringBuilder(); - printModifiersIfNonzero(sb, modifierMask); + printModifiersIfNonzero(sb, modifierMask, isDefault); TypeVariable[] typeparms = getTypeParameters(); if (typeparms.length > 0) { diff --git a/jdk/src/share/classes/java/lang/reflect/Field.java b/jdk/src/share/classes/java/lang/reflect/Field.java index be13b076832..947d042e17b 100644 --- a/jdk/src/share/classes/java/lang/reflect/Field.java +++ b/jdk/src/share/classes/java/lang/reflect/Field.java @@ -288,6 +288,9 @@ class Field extends AccessibleObject implements Member { * {@code protected} or {@code private} first, and then other * modifiers in the following order: {@code static}, {@code final}, * {@code transient}, {@code volatile}. + * + * @return a string describing this {@code Field} + * @jls 8.3.1 Field Modifiers */ public String toString() { int mod = getModifiers(); @@ -315,6 +318,7 @@ class Field extends AccessibleObject implements Member { * its generic type * * @since 1.5 + * @jls 8.3.1 Field Modifiers */ public String toGenericString() { int mod = getModifiers(); diff --git a/jdk/src/share/classes/java/lang/reflect/Method.java b/jdk/src/share/classes/java/lang/reflect/Method.java index 09438fbebe0..0dc3b244f9a 100644 --- a/jdk/src/share/classes/java/lang/reflect/Method.java +++ b/jdk/src/share/classes/java/lang/reflect/Method.java @@ -343,10 +343,16 @@ public final class Method extends Executable { * {@code public}, {@code protected} or {@code private} first, * and then other modifiers in the following order: * {@code abstract}, {@code static}, {@code final}, - * {@code synchronized}, {@code native}, {@code strictfp}. + * {@code synchronized}, {@code native}, {@code strictfp}, + * {@code default}. + * + * @return a string describing this {@code Method} + * + * @jls 8.4.3 Method Modifiers */ public String toString() { return sharedToString(Modifier.methodModifiers(), + isDefault(), parameterTypes, exceptionTypes); } @@ -389,16 +395,19 @@ public final class Method extends Executable { * {@code public}, {@code protected} or {@code private} first, * and then other modifiers in the following order: * {@code abstract}, {@code static}, {@code final}, - * {@code synchronized}, {@code native}, {@code strictfp}. + * {@code synchronized}, {@code native}, {@code strictfp}, + * {@code default}. * * @return a string describing this {@code Method}, * include type parameters * * @since 1.5 + * + * @jls 8.4.3 Method Modifiers */ @Override public String toGenericString() { - return sharedToGenericString(Modifier.methodModifiers()); + return sharedToGenericString(Modifier.methodModifiers(), isDefault()); } @Override diff --git a/jdk/src/share/classes/java/lang/reflect/Modifier.java b/jdk/src/share/classes/java/lang/reflect/Modifier.java index 8c2b2cc5f5e..9c0b2f40909 100644 --- a/jdk/src/share/classes/java/lang/reflect/Modifier.java +++ b/jdk/src/share/classes/java/lang/reflect/Modifier.java @@ -389,6 +389,12 @@ class Modifier { Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT | Modifier.VOLATILE; + /** + * + */ + static final int ACCESS_MODIFIERS = + Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE; + /** * Return an {@code int} value OR-ing together the source language * modifiers that can be applied to a class. diff --git a/jdk/test/java/lang/reflect/Method/GenericStringTest.java b/jdk/test/java/lang/reflect/Method/GenericStringTest.java index 14c3c6226e6..9e50dca3aae 100644 --- a/jdk/test/java/lang/reflect/Method/GenericStringTest.java +++ b/jdk/test/java/lang/reflect/Method/GenericStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 5033583 6316717 6470106 + * @bug 5033583 6316717 6470106 8004979 * @summary Check toGenericString() and toString() methods * @author Joseph D. Darcy */ @@ -39,6 +39,7 @@ public class GenericStringTest { classList.add(TestClass1.class); classList.add(TestClass2.class); classList.add(Roebling.class); + classList.add(TestInterface1.class); for(Class clazz: classList) @@ -129,6 +130,27 @@ class Roebling implements Comparable { void varArg(Object ... arg) {} } +interface TestInterface1 { + @ExpectedGenericString( + "public default void TestInterface1.foo()") + @ExpectedString( + "public default void TestInterface1.foo()") + public default void foo(){;} + + @ExpectedString( + "public default java.lang.Object TestInterface1.bar()") + @ExpectedGenericString( + "public default A TestInterface1.bar()") + default A bar(){return null;} + + @ExpectedString( + "public default strictfp double TestInterface1.quux()") + @ExpectedGenericString( + "public default strictfp double TestInterface1.quux()") + strictfp default double quux(){return 1.0;} + +} + @Retention(RetentionPolicy.RUNTIME) @interface ExpectedGenericString { String value(); From 84e09062c09f2bafa8749d9b97125b64b2572bcd Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 3 Apr 2013 13:15:39 +0100 Subject: [PATCH 114/155] 8011234: Performance regression with ftp protocol when uploading in image mode Reviewed-by: chegar --- jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java index 1d1b26d873b..babb9f599da 100644 --- a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java @@ -1299,16 +1299,16 @@ public class FtpClient extends sun.net.ftp.FtpClient { * null if the command was unsuccessful. * @throws IOException if an error occured during the transmission. */ - public OutputStream putFileStream(String name, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException { + public OutputStream putFileStream(String name, boolean unique) + throws sun.net.ftp.FtpProtocolException, IOException + { String cmd = unique ? "STOU " : "STOR "; Socket s = openDataConnection(cmd + name); if (s == null) { return null; } - if (type == TransferType.BINARY) { - return s.getOutputStream(); - } - return new sun.net.TelnetOutputStream(s.getOutputStream(), false); + boolean bm = (type == TransferType.BINARY); + return new sun.net.TelnetOutputStream(s.getOutputStream(), bm); } /** From 963ad663527f56ee4f799b646eb6d409c94a0e34 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 3 Apr 2013 13:41:12 +0100 Subject: [PATCH 115/155] 8011373: Property java.runtime.profile should be removed (left-over code) Reviewed-by: lancea, dholmes --- jdk/src/share/classes/sun/misc/Version.java.template | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdk/src/share/classes/sun/misc/Version.java.template b/jdk/src/share/classes/sun/misc/Version.java.template index 710bf7178f5..6897e0a990d 100644 --- a/jdk/src/share/classes/sun/misc/Version.java.template +++ b/jdk/src/share/classes/sun/misc/Version.java.template @@ -52,8 +52,6 @@ public class Version { System.setProperty("java.version", java_version); System.setProperty("java.runtime.version", java_runtime_version); System.setProperty("java.runtime.name", java_runtime_name); - if (java_profile_name.length() > 0) - System.setProperty("java.runtime.profile", java_profile_name); } private static boolean versionsInitialized = false; From fb6bf29f89d794922f6cbb0c9be904dfb4b4c5cd Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Wed, 3 Apr 2013 12:47:15 -0400 Subject: [PATCH 116/155] 8011393: Typo in javadoc for SerialClob.truncate Reviewed-by: darcy --- jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java index 6020e3488be..5ea5fee14bc 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java @@ -508,7 +508,7 @@ public class SerialClob implements Clob, Serializable, Cloneable { * * @param length the length, in bytes, to which the CLOB * value should be truncated - * @throws SerialLException if there is an error accessing the + * @throws SerialException if there is an error accessing the * CLOB value; * if the {@code free} method had been previously called on this object */ From 4952f6a6de33c8c9f6c5ec7301f0f02c6a72edd0 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 3 Apr 2013 10:32:38 -0700 Subject: [PATCH 117/155] 7091601: Arabic Locale: can not set type of digit in application level Reviewed-by: okutsu --- .../provider/HostLocaleProviderAdapter_md.c | 71 +++++++++++++------ .../HostLocaleProviderAdapterImpl.java | 12 ++-- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c index 3e1fda355e9..5cac939a239 100644 --- a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c +++ b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c @@ -32,8 +32,8 @@ static CFDateFormatterStyle convertDateFormatterStyle(jint javaStyle); static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle); static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count); -static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef type); -static jchar getNumberSymbolChar(jchar jdefault, CFStringRef type); +static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type); +static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type); // from java_props_macosx.c extern char * getMacOSXLocale(int cat); @@ -322,7 +322,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte */ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol (JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) { - return getNumberSymbolString(env, currencySymbol, kCFNumberFormatterCurrencySymbol); + return getNumberSymbolString(env, jlangtag, currencySymbol, kCFNumberFormatterCurrencySymbol); } /* @@ -332,7 +332,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) { - return getNumberSymbolChar(decimalSeparator, kCFNumberFormatterDecimalSeparator); + return getNumberSymbolChar(env, jlangtag, decimalSeparator, kCFNumberFormatterDecimalSeparator); } /* @@ -342,7 +342,7 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) { - return getNumberSymbolChar(groupingSeparator, kCFNumberFormatterGroupingSeparator); + return getNumberSymbolChar(env, jlangtag, groupingSeparator, kCFNumberFormatterGroupingSeparator); } /* @@ -352,7 +352,7 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity (JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) { - return getNumberSymbolString(env, infinity, kCFNumberFormatterInfinitySymbol); + return getNumberSymbolString(env, jlangtag, infinity, kCFNumberFormatterInfinitySymbol); } /* @@ -362,7 +362,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte */ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol (JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) { - return getNumberSymbolString(env, internationalCurrencySymbol, kCFNumberFormatterInternationalCurrencySymbol); + return getNumberSymbolString(env, jlangtag, internationalCurrencySymbol, kCFNumberFormatterInternationalCurrencySymbol); } /* @@ -372,7 +372,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign (JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) { - return getNumberSymbolChar(minusSign, kCFNumberFormatterMinusSign); + return getNumberSymbolChar(env, jlangtag, minusSign, kCFNumberFormatterMinusSign); } /* @@ -382,7 +382,7 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) { - return getNumberSymbolChar(monetaryDecimalSeparator, kCFNumberFormatterCurrencyDecimalSeparator); + return getNumberSymbolChar(env, jlangtag, monetaryDecimalSeparator, kCFNumberFormatterCurrencyDecimalSeparator); } /* @@ -392,7 +392,7 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN (JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) { - return getNumberSymbolString(env, nan, kCFNumberFormatterNaNSymbol); + return getNumberSymbolString(env, jlangtag, nan, kCFNumberFormatterNaNSymbol); } /* @@ -402,7 +402,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent (JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) { - return getNumberSymbolChar(percent, kCFNumberFormatterPercentSymbol); + return getNumberSymbolChar(env, jlangtag, percent, kCFNumberFormatterPercentSymbol); } /* @@ -412,7 +412,7 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill (JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) { - return getNumberSymbolChar(perMill, kCFNumberFormatterPerMillSymbol); + return getNumberSymbolChar(env, jlangtag, perMill, kCFNumberFormatterPerMillSymbol); } /* @@ -422,7 +422,36 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit (JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) { - return getNumberSymbolChar(zeroDigit, kCFNumberFormatterZeroSymbol); + // The following code *should* work, but not for some reason :o + // + //return getNumberSymbolChar(env, jlangtag, zeroDigit, kCFNumberFormatterZeroSymbol); + // + // so here is a workaround. + jchar ret = zeroDigit; + CFLocaleRef cflocale = CFLocaleCopyCurrent(); + + if (cflocale != NULL) { + CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault, + cflocale, + kCFNumberFormatterNoStyle); + if (nf != NULL) { + int zero = 0; + CFStringRef str = CFNumberFormatterCreateStringWithValue(kCFAllocatorDefault, + nf, kCFNumberIntType, &zero); + if (str != NULL) { + if (CFStringGetLength(str) > 0) { + ret = CFStringGetCharacterAtIndex(str, 0); + } + CFRelease(str); + } + + CFRelease(nf); + } + + CFRelease(cflocale); + } + + return ret; } /* @@ -432,7 +461,7 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI */ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getExponentSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jstring exponent) { - return getNumberSymbolString(env, exponent, kCFNumberFormatterExponentSymbol); + return getNumberSymbolString(env, jlangtag, exponent, kCFNumberFormatterExponentSymbol); } /* @@ -625,7 +654,7 @@ static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarr } } -static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef type) { +static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type) { char buf[BUFLEN]; jstring ret = jdefault; CFLocaleRef cflocale = CFLocaleCopyCurrent(); @@ -633,7 +662,7 @@ static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef if (cflocale != NULL) { CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault, cflocale, - kCFNumberFormatterDecimalStyle); + kCFNumberFormatterNoStyle); if (nf != NULL) { CFStringRef str = CFNumberFormatterCopyProperty(nf, type); if (str != NULL) { @@ -651,21 +680,21 @@ static jstring getNumberSymbolString(JNIEnv *env, jstring jdefault, CFStringRef return ret; } -static jchar getNumberSymbolChar(jchar jdefault, CFStringRef type) { - char buf[BUFLEN]; +static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type) { jchar ret = jdefault; CFLocaleRef cflocale = CFLocaleCopyCurrent(); if (cflocale != NULL) { CFNumberFormatterRef nf = CFNumberFormatterCreate(kCFAllocatorDefault, cflocale, - kCFNumberFormatterDecimalStyle); + kCFNumberFormatterNoStyle); if (nf != NULL) { CFStringRef str = CFNumberFormatterCopyProperty(nf, type); if (str != NULL) { - CFStringGetCString(str, buf, BUFLEN, kCFStringEncodingUTF8); + if (CFStringGetLength(str) > 0) { + ret = CFStringGetCharacterAtIndex(str, 0); + } CFRelease(str); - ret = buf[0]; } CFRelease(nf); diff --git a/jdk/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java b/jdk/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java index afe980e88c5..fddffb925be 100644 --- a/jdk/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java +++ b/jdk/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java @@ -303,9 +303,7 @@ public class HostLocaleProviderAdapterImpl { dfs.setNaN(getNaN(langTag, dfs.getNaN())); dfs.setPercent(getPercent(langTag, dfs.getPercent())); dfs.setPerMill(getPerMill(langTag, dfs.getPerMill())); - if (isNativeDigit(langTag)) { - dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit())); - } + dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit())); ref = new SoftReference<>(dfs); decimalFormatSymbolsCache.put(locale, ref); } @@ -420,9 +418,13 @@ public class HostLocaleProviderAdapterImpl { return false; } + int calid = getCalendarID(locale.toLanguageTag()); + if (calid <= 0 || calid >= calIDToLDML.length) { + return false; + } + String requestedCalType = locale.getUnicodeLocaleType("ca"); - String nativeCalType = - calIDToLDML[getCalendarID(locale.toLanguageTag())] + String nativeCalType = calIDToLDML[calid] .replaceFirst("_.*", ""); // remove locale part. if (requestedCalType == null) { From 88f70d8026730483e0ae4e00e30fb00cce43ac63 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Wed, 3 Apr 2013 11:12:57 -0700 Subject: [PATCH 118/155] 8011102: Clear AVX registers after return from JNI call Execute vzeroupper instruction after JNI call and on exits in jit compiled code which use 256bit vectors. Reviewed-by: roland --- hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp | 21 +---- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 44 ++++++++- hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 3 + .../src/cpu/x86/vm/sharedRuntime_x86_32.cpp | 3 + .../src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 12 +-- .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 5 ++ .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 8 ++ .../cpu/x86/vm/templateInterpreter_x86_32.cpp | 18 +--- .../cpu/x86/vm/templateInterpreter_x86_64.cpp | 11 +-- hotspot/src/cpu/x86/vm/x86_32.ad | 90 ++++++++++++------- hotspot/src/cpu/x86/vm/x86_64.ad | 62 ++++++++++--- hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad | 18 ---- .../src/os_cpu/linux_x86/vm/linux_x86_64.ad | 18 ---- .../os_cpu/solaris_x86/vm/solaris_x86_64.ad | 29 ------ .../os_cpu/windows_x86/vm/windows_x86_64.ad | 23 +---- 15 files changed, 179 insertions(+), 186 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp index c568c6f4d3a..24e6694082e 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp @@ -1299,25 +1299,8 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { __ push(rdx); #endif // _LP64 - // Either restore the MXCSR register after returning from the JNI Call - // or verify that it wasn't changed. - if (VM_Version::supports_sse()) { - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); - } - else if (CheckJNICalls ) { - __ call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); - } - } - -#ifndef _LP64 - // Either restore the x87 floating pointer control word after returning - // from the JNI call or verify that it wasn't changed. - if (CheckJNICalls) { - __ call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); - } -#endif // _LP64 - + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // change thread state __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index b64518a7bc1..98c93f99a0f 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -4765,6 +4765,31 @@ void MacroAssembler::verify_FPU(int stack_depth, const char* s) { pop_CPU_state(); } +void MacroAssembler::restore_cpu_control_state_after_jni() { + // Either restore the MXCSR register after returning from the JNI Call + // or verify that it wasn't changed (with -Xcheck:jni flag). + if (VM_Version::supports_sse()) { + if (RestoreMXCSROnJNICalls) { + ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); + } else if (CheckJNICalls) { + call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); + } + } + if (VM_Version::supports_avx()) { + // Clear upper bits of YMM registers to avoid SSE <-> AVX transition penalty. + vzeroupper(); + } + +#ifndef _LP64 + // Either restore the x87 floating pointer control word after returning + // from the JNI call or verify that it wasn't changed. + if (CheckJNICalls) { + call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); + } +#endif // _LP64 +} + + void MacroAssembler::load_klass(Register dst, Register src) { #ifdef _LP64 if (UseCompressedKlassPointers) { @@ -5759,6 +5784,8 @@ void MacroAssembler::string_compare(Register str1, Register str2, addptr(result, stride2); subl(cnt2, stride2); jccb(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP); + // clean upper bits of YMM registers + vzeroupper(); // compare wide vectors tail bind(COMPARE_WIDE_TAIL); @@ -5772,6 +5799,8 @@ void MacroAssembler::string_compare(Register str1, Register str2, // Identifies the mismatching (higher or lower)16-bytes in the 32-byte vectors. bind(VECTOR_NOT_EQUAL); + // clean upper bits of YMM registers + vzeroupper(); lea(str1, Address(str1, result, scale)); lea(str2, Address(str2, result, scale)); jmp(COMPARE_16_CHARS); @@ -6028,6 +6057,10 @@ void MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Regist // That's it bind(DONE); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + vzeroupper(); + } } void MacroAssembler::generate_fill(BasicType t, bool aligned, @@ -6157,6 +6190,10 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, vmovdqu(Address(to, 0), xtmp); addptr(to, 32); subl(count, 8 << shift); + + BIND(L_check_fill_8_bytes); + // clean upper bits of YMM registers + vzeroupper(); } else { // Fill 32-byte chunks pshufd(xtmp, xtmp, 0); @@ -6180,8 +6217,9 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, addptr(to, 32); subl(count, 8 << shift); jcc(Assembler::greaterEqual, L_fill_32_bytes_loop); + + BIND(L_check_fill_8_bytes); } - BIND(L_check_fill_8_bytes); addl(count, 8 << shift); jccb(Assembler::zero, L_exit); jmpb(L_fill_8_bytes); @@ -6316,6 +6354,10 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, jccb(Assembler::lessEqual, L_copy_16_chars); bind(L_copy_16_chars_exit); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + vzeroupper(); + } subptr(len, 8); jccb(Assembler::greater, L_copy_8_chars_exit); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 9500f3164fa..e9f409dc500 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -582,6 +582,9 @@ class MacroAssembler: public Assembler { // only if +VerifyFPU void verify_FPU(int stack_depth, const char* s = "illegal FPU state"); + // Verify or restore cpu control state after JNI call + void restore_cpu_control_state_after_jni(); + // prints msg, dumps registers and stops execution void stop(const char* msg); diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index dc705421ca9..0fce7952a70 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -2065,6 +2065,9 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ call(RuntimeAddress(native_func)); + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); + // WARNING - on Windows Java Natives use pascal calling convention and pop the // arguments off of the stack. We could just re-adjust the stack pointer here // and continue to do SP relative addressing but we instead switch to FP diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index 50255eeef0e..db20c1f2388 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -2315,16 +2315,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ call(RuntimeAddress(native_func)); - // Either restore the MXCSR register after returning from the JNI Call - // or verify that it wasn't changed. - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std())); - - } - else if (CheckJNICalls ) { - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::verify_mxcsr_entry()))); - } - + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // Unpack native results. switch (ret_type) { diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index e56bb2266d0..f3a91d03c99 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -835,6 +835,11 @@ class StubGenerator: public StubCodeGenerator { __ BIND(L_copy_64_bytes); __ subl(qword_count, 8); __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); + + if (UseUnalignedLoadStores && (UseAVX >= 2)) { + // clean upper bits of YMM registers + __ vzeroupper(); + } __ addl(qword_count, 8); __ jccb(Assembler::zero, L_exit); // diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index c6b94e243bc..ace545383d7 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -1331,6 +1331,10 @@ class StubGenerator: public StubCodeGenerator { } __ addptr(qword_count, 4); __ BIND(L_end); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + __ vzeroupper(); + } } else { // Copy 32-bytes per iteration __ BIND(L_loop); @@ -1404,6 +1408,10 @@ class StubGenerator: public StubCodeGenerator { } __ subptr(qword_count, 4); __ BIND(L_end); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + __ vzeroupper(); + } } else { // Copy 32-bytes per iteration __ BIND(L_loop); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 5df98394cf5..fb13a44045a 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -1080,22 +1080,8 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { // result potentially in rdx:rax or ST0 - // Either restore the MXCSR register after returning from the JNI Call - // or verify that it wasn't changed. - if (VM_Version::supports_sse()) { - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); - } - else if (CheckJNICalls ) { - __ call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); - } - } - - // Either restore the x87 floating pointer control word after returning - // from the JNI call or verify that it wasn't changed. - if (CheckJNICalls) { - __ call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); - } + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // save potential result in ST(0) & rdx:rax // (if result handler is the T_FLOAT or T_DOUBLE handler, result must be in ST0 - diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index c446cb3c9b1..6b3f7b6ba26 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -1079,15 +1079,8 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { __ call(rax); // result potentially in rax or xmm0 - // Depending on runtime options, either restore the MXCSR - // register after returning from the JNI Call or verify that - // it wasn't changed during -Xcheck:jni. - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std())); - } - else if (CheckJNICalls) { - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::verify_mxcsr_entry()))); - } + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // NOTE: The order of these pushes is known to frame::interpreter_frame_result // in order to extract the result of a method call. If the order of these diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 6ceb50cee84..67f33d3ba27 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -228,10 +228,16 @@ static jlong *float_signflip_pool = double_quadword(&fp_signmask_pool[3*2], CON static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000)); // Offset hacking within calls. -static int pre_call_FPU_size() { - if (Compile::current()->in_24_bit_fp_mode()) - return 6; // fldcw - return 0; +static int pre_call_resets_size() { + int size = 0; + Compile* C = Compile::current(); + if (C->in_24_bit_fp_mode()) { + size += 6; // fldcw + } + if (C->max_vector_size() > 16) { + size += 3; // vzeroupper + } + return size; } static int preserve_SP_size() { @@ -242,21 +248,21 @@ static int preserve_SP_size() { // from the start of the call to the point where the return address // will point. int MachCallStaticJavaNode::ret_addr_offset() { - int offset = 5 + pre_call_FPU_size(); // 5 bytes from start of call to where return address points + int offset = 5 + pre_call_resets_size(); // 5 bytes from start of call to where return address points if (_method_handle_invoke) offset += preserve_SP_size(); return offset; } int MachCallDynamicJavaNode::ret_addr_offset() { - return 10 + pre_call_FPU_size(); // 10 bytes from start of call to where return address points + return 10 + pre_call_resets_size(); // 10 bytes from start of call to where return address points } static int sizeof_FFree_Float_Stack_All = -1; int MachCallRuntimeNode::ret_addr_offset() { assert(sizeof_FFree_Float_Stack_All != -1, "must have been emitted already"); - return sizeof_FFree_Float_Stack_All + 5 + pre_call_FPU_size(); + return sizeof_FFree_Float_Stack_All + 5 + pre_call_resets_size(); } // Indicate if the safepoint node needs the polling page as an input. @@ -272,7 +278,7 @@ bool SafePointNode::needs_polling_address_input() { // The address of the call instruction needs to be 4-byte aligned to // ensure that it does not span a cache line so that it can be patched. int CallStaticJavaDirectNode::compute_padding(int current_offset) const { - current_offset += pre_call_FPU_size(); // skip fldcw, if any + current_offset += pre_call_resets_size(); // skip fldcw, if any current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -280,7 +286,7 @@ int CallStaticJavaDirectNode::compute_padding(int current_offset) const { // The address of the call instruction needs to be 4-byte aligned to // ensure that it does not span a cache line so that it can be patched. int CallStaticJavaHandleNode::compute_padding(int current_offset) const { - current_offset += pre_call_FPU_size(); // skip fldcw, if any + current_offset += pre_call_resets_size(); // skip fldcw, if any current_offset += preserve_SP_size(); // skip mov rbp, rsp current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; @@ -289,7 +295,7 @@ int CallStaticJavaHandleNode::compute_padding(int current_offset) const { // The address of the call instruction needs to be 4-byte aligned to // ensure that it does not span a cache line so that it can be patched. int CallDynamicJavaDirectNode::compute_padding(int current_offset) const { - current_offset += pre_call_FPU_size(); // skip fldcw, if any + current_offset += pre_call_resets_size(); // skip fldcw, if any current_offset += 5; // skip MOV instruction current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; @@ -583,16 +589,20 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const { // Remove two words for return addr and rbp, framesize -= 2*wordSize; - if( C->in_24_bit_fp_mode() ) { + if (C->max_vector_size() > 16) { + st->print("VZEROUPPER"); + st->cr(); st->print("\t"); + } + if (C->in_24_bit_fp_mode()) { st->print("FLDCW standard control word"); st->cr(); st->print("\t"); } - if( framesize ) { + if (framesize) { st->print("ADD ESP,%d\t# Destroy frame",framesize); st->cr(); st->print("\t"); } st->print_cr("POPL EBP"); st->print("\t"); - if( do_polling() && C->is_method_compilation() ) { + if (do_polling() && C->is_method_compilation()) { st->print("TEST PollPage,EAX\t! Poll Safepoint"); st->cr(); st->print("\t"); } @@ -602,8 +612,14 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const { void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { Compile *C = ra_->C; + if (C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler masm(&cbuf); + masm.vzeroupper(); + } // If method set FPU control word, restore to standard control word - if( C->in_24_bit_fp_mode() ) { + if (C->in_24_bit_fp_mode()) { MacroAssembler masm(&cbuf); masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); } @@ -615,12 +631,11 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here - if( framesize >= 128 ) { + if (framesize >= 128) { emit_opcode(cbuf, 0x81); // add SP, #framesize emit_rm(cbuf, 0x3, 0x00, ESP_enc); emit_d32(cbuf, framesize); - } - else if( framesize ) { + } else if (framesize) { emit_opcode(cbuf, 0x83); // add SP, #framesize emit_rm(cbuf, 0x3, 0x00, ESP_enc); emit_d8(cbuf, framesize); @@ -628,7 +643,7 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { emit_opcode(cbuf, 0x58 | EBP_enc); - if( do_polling() && C->is_method_compilation() ) { + if (do_polling() && C->is_method_compilation()) { cbuf.relocate(cbuf.insts_end(), relocInfo::poll_return_type, 0); emit_opcode(cbuf,0x85); emit_rm(cbuf, 0x0, EAX_enc, 0x5); // EAX @@ -640,7 +655,8 @@ uint MachEpilogNode::size(PhaseRegAlloc *ra_) const { Compile *C = ra_->C; // If method set FPU control word, restore to standard control word int size = C->in_24_bit_fp_mode() ? 6 : 0; - if( do_polling() && C->is_method_compilation() ) size += 6; + if (C->max_vector_size() > 16) size += 3; // vzeroupper + if (do_polling() && C->is_method_compilation()) size += 6; int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); @@ -649,7 +665,7 @@ uint MachEpilogNode::size(PhaseRegAlloc *ra_) const { size++; // popl rbp, - if( framesize >= 128 ) { + if (framesize >= 128) { size += 6; } else { size += framesize ? 3 : 0; @@ -1853,20 +1869,26 @@ encode %{ %} - enc_class pre_call_FPU %{ + enc_class pre_call_resets %{ // If method sets FPU control word restore it here debug_only(int off0 = cbuf.insts_size()); - if( Compile::current()->in_24_bit_fp_mode() ) { - MacroAssembler masm(&cbuf); - masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); + if (ra_->C->in_24_bit_fp_mode()) { + MacroAssembler _masm(&cbuf); + __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); + } + if (ra_->C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler _masm(&cbuf); + __ vzeroupper(); } debug_only(int off1 = cbuf.insts_size()); - assert(off1 - off0 == pre_call_FPU_size(), "correct size prediction"); + assert(off1 - off0 == pre_call_resets_size(), "correct size prediction"); %} enc_class post_call_FPU %{ // If method sets FPU control word do it here also - if( Compile::current()->in_24_bit_fp_mode() ) { + if (Compile::current()->in_24_bit_fp_mode()) { MacroAssembler masm(&cbuf); masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24())); } @@ -1877,17 +1899,17 @@ encode %{ // who we intended to call. cbuf.set_insts_mark(); $$$emit8$primary; - if ( !_method ) { + if (!_method) { emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4), runtime_call_Relocation::spec(), RELOC_IMM32 ); - } else if(_optimized_virtual) { + } else if (_optimized_virtual) { emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4), opt_virtual_call_Relocation::spec(), RELOC_IMM32 ); } else { emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4), static_call_Relocation::spec(), RELOC_IMM32 ); } - if( _method ) { // Emit stub for static call + if (_method) { // Emit stub for static call emit_java_to_interp(cbuf); } %} @@ -12828,7 +12850,7 @@ instruct CallStaticJavaDirect(method meth) %{ ins_cost(300); format %{ "CALL,static " %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, Java_Static_Call( meth ), call_epilog, post_call_FPU ); @@ -12849,7 +12871,7 @@ instruct CallStaticJavaHandle(method meth, eBPRegP ebp_mh_SP_save) %{ ins_cost(300); format %{ "CALL,static/MethodHandle " %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, preserve_SP, Java_Static_Call( meth ), restore_SP, @@ -12870,7 +12892,7 @@ instruct CallDynamicJavaDirect(method meth) %{ format %{ "MOV EAX,(oop)-1\n\t" "CALL,dynamic" %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, Java_Dynamic_Call( meth ), call_epilog, post_call_FPU ); @@ -12887,7 +12909,7 @@ instruct CallRuntimeDirect(method meth) %{ format %{ "CALL,runtime " %} opcode(0xE8); /* E8 cd */ // Use FFREEs to clear entries in float stack - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, FFree_Float_Stack_All, Java_To_Runtime( meth ), post_call_FPU ); @@ -12902,7 +12924,7 @@ instruct CallLeafDirect(method meth) %{ ins_cost(300); format %{ "CALL_LEAF,runtime " %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, FFree_Float_Stack_All, Java_To_Runtime( meth ), Verify_FPU_For_Leaf, post_call_FPU ); diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 7c902c4e31c..77dc5b01131 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -399,6 +399,9 @@ source %{ static int preserve_SP_size() { return 3; // rex.w, op, rm(reg/reg) } +static int clear_avx_size() { + return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper +} // !!!!! Special hack to get all types of calls to specify the byte offset // from the start of the call to the point where the return address @@ -406,6 +409,7 @@ static int preserve_SP_size() { int MachCallStaticJavaNode::ret_addr_offset() { int offset = 5; // 5 bytes from start of call to where return address points + offset += clear_avx_size(); if (_method_handle_invoke) offset += preserve_SP_size(); return offset; @@ -413,11 +417,16 @@ int MachCallStaticJavaNode::ret_addr_offset() int MachCallDynamicJavaNode::ret_addr_offset() { - return 15; // 15 bytes from start of call to where return address points + int offset = 15; // 15 bytes from start of call to where return address points + offset += clear_avx_size(); + return offset; } -// In os_cpu .ad file -// int MachCallRuntimeNode::ret_addr_offset() +int MachCallRuntimeNode::ret_addr_offset() { + int offset = 13; // movq r10,#addr; callq (r10) + offset += clear_avx_size(); + return offset; +} // Indicate if the safepoint node needs the polling page as an input, // it does if the polling page is more than disp32 away. @@ -434,6 +443,7 @@ bool SafePointNode::needs_polling_address_input() // ensure that it does not span a cache line so that it can be patched. int CallStaticJavaDirectNode::compute_padding(int current_offset) const { + current_offset += clear_avx_size(); // skip vzeroupper current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -443,6 +453,7 @@ int CallStaticJavaDirectNode::compute_padding(int current_offset) const int CallStaticJavaHandleNode::compute_padding(int current_offset) const { current_offset += preserve_SP_size(); // skip mov rbp, rsp + current_offset += clear_avx_size(); // skip vzeroupper current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -451,6 +462,7 @@ int CallStaticJavaHandleNode::compute_padding(int current_offset) const // ensure that it does not span a cache line so that it can be patched. int CallDynamicJavaDirectNode::compute_padding(int current_offset) const { + current_offset += clear_avx_size(); // skip vzeroupper current_offset += 11; // skip movq instruction + call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -764,6 +776,11 @@ int MachPrologNode::reloc() const void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const { Compile* C = ra_->C; + if (C->max_vector_size() > 16) { + st->print("vzeroupper"); + st->cr(); st->print("\t"); + } + int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); // Remove word for return adr already pushed @@ -793,6 +810,13 @@ void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const void MachEpilogNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { Compile* C = ra_->C; + if (C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler _masm(&cbuf); + __ vzeroupper(); + } + int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); // Remove word for return adr already pushed @@ -2008,6 +2032,25 @@ encode %{ __ bind(miss); %} + enc_class clear_avx %{ + debug_only(int off0 = cbuf.insts_size()); + if (ra_->C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler _masm(&cbuf); + __ vzeroupper(); + } + debug_only(int off1 = cbuf.insts_size()); + assert(off1 - off0 == clear_avx_size(), "correct size prediction"); + %} + + enc_class Java_To_Runtime(method meth) %{ + // No relocation needed + MacroAssembler _masm(&cbuf); + __ mov64(r10, (int64_t) $meth$$method); + __ call(r10); + %} + enc_class Java_To_Interpreter(method meth) %{ // CALL Java_To_Interpreter @@ -11366,7 +11409,7 @@ instruct CallStaticJavaDirect(method meth) %{ ins_cost(300); format %{ "call,static " %} opcode(0xE8); /* E8 cd */ - ins_encode(Java_Static_Call(meth), call_epilog); + ins_encode(clear_avx, Java_Static_Call(meth), call_epilog); ins_pipe(pipe_slow); ins_alignment(4); %} @@ -11384,7 +11427,7 @@ instruct CallStaticJavaHandle(method meth, rbp_RegP rbp_mh_SP_save) %{ ins_cost(300); format %{ "call,static/MethodHandle " %} opcode(0xE8); /* E8 cd */ - ins_encode(preserve_SP, + ins_encode(clear_avx, preserve_SP, Java_Static_Call(meth), restore_SP, call_epilog); @@ -11403,7 +11446,7 @@ instruct CallDynamicJavaDirect(method meth) ins_cost(300); format %{ "movq rax, #Universe::non_oop_word()\n\t" "call,dynamic " %} - ins_encode(Java_Dynamic_Call(meth), call_epilog); + ins_encode(clear_avx, Java_Dynamic_Call(meth), call_epilog); ins_pipe(pipe_slow); ins_alignment(4); %} @@ -11416,8 +11459,7 @@ instruct CallRuntimeDirect(method meth) ins_cost(300); format %{ "call,runtime " %} - opcode(0xE8); /* E8 cd */ - ins_encode(Java_To_Runtime(meth)); + ins_encode(clear_avx, Java_To_Runtime(meth)); ins_pipe(pipe_slow); %} @@ -11429,8 +11471,7 @@ instruct CallLeafDirect(method meth) ins_cost(300); format %{ "call_leaf,runtime " %} - opcode(0xE8); /* E8 cd */ - ins_encode(Java_To_Runtime(meth)); + ins_encode(clear_avx, Java_To_Runtime(meth)); ins_pipe(pipe_slow); %} @@ -11442,7 +11483,6 @@ instruct CallLeafNoFPDirect(method meth) ins_cost(300); format %{ "call_leaf_nofp,runtime " %} - opcode(0xE8); /* E8 cd */ ins_encode(Java_To_Runtime(meth)); ins_pipe(pipe_slow); %} diff --git a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad index f4dc25d34fd..254328e0971 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad +++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad @@ -55,20 +55,6 @@ encode %{ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) %{ - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - %} @@ -76,8 +62,4 @@ encode %{ source %{ -int MachCallRuntimeNode::ret_addr_offset() { - return 13; // movq r10,#addr; callq (r10) -} - %} diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad index cf9adf40e90..3b3ac007cd1 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad @@ -55,20 +55,6 @@ encode %{ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) %{ - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - %} @@ -76,8 +62,4 @@ encode %{ source %{ -int MachCallRuntimeNode::ret_addr_offset() { - return 13; // movq r10,#addr; callq (r10) -} - %} diff --git a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad index fdce355abe9..f3334952f62 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad +++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad @@ -54,39 +54,10 @@ encode %{ // main source block for now. In future, we can generalize this by // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - - enc_class Java_To_Runtime(method meth) %{ - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - - enc_class post_call_verify_mxcsr %{ - MacroAssembler _masm(&cbuf); - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::amd64::mxcsr_std())); - } - else if (CheckJNICalls) { - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::amd64::verify_mxcsr_entry()))); - } - %} %} // Platform dependent source source %{ - -int MachCallRuntimeNode::ret_addr_offset() { - return 13; // movq r10,#addr; callq (r10) -} - %} diff --git a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad index e251b2b0c37..54e183a0bc5 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad +++ b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad @@ -53,30 +53,11 @@ encode %{ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime (method meth) %{ // CALL Java_To_Runtime - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - %} -// + // Platform dependent source -// + source %{ -int MachCallRuntimeNode::ret_addr_offset() -{ - return 13; // movq r10,#addr; callq (r10) -} - %} From 93c40233d6fa31d77d91c7997cf96e601b367539 Mon Sep 17 00:00:00 2001 From: Chuck Rasbold Date: Wed, 3 Apr 2013 15:00:55 -0700 Subject: [PATCH 119/155] 8010437: guarantee(this->is8bit(imm8)) failed: Short forward jump exceeds 8-bit offset Fix shorten_branches() to accurately count an initial nop that may be inserted in a block that starts with a safepoint. Reviewed-by: kvn --- hotspot/src/share/vm/opto/output.cpp | 34 ++++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index c77b9f60c5e..178f3b717eb 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -449,6 +449,17 @@ void Compile::shorten_branches(uint* blk_starts, int& code_size, int& reloc_size int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); if (max_loop_pad > 0) { assert(is_power_of_2(max_loop_pad+relocInfo::addr_unit()), ""); + // Adjust last_call_adr and/or last_avoid_back_to_back_adr. + // If either is the last instruction in this block, bump by + // max_loop_pad in lock-step with blk_size, so sizing + // calculations in subsequent blocks still can conservatively + // detect that it may the last instruction in this block. + if (last_call_adr == blk_starts[i]+blk_size) { + last_call_adr += max_loop_pad; + } + if (last_avoid_back_to_back_adr == blk_starts[i]+blk_size) { + last_avoid_back_to_back_adr += max_loop_pad; + } blk_size += max_loop_pad; } } @@ -1193,8 +1204,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { int last_call_offset = -1; int last_avoid_back_to_back_offset = -1; #ifdef ASSERT - int block_alignment_padding = 0; - uint* jmp_target = NEW_RESOURCE_ARRAY(uint,nblocks); uint* jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks); uint* jmp_size = NEW_RESOURCE_ARRAY(uint,nblocks); @@ -1228,8 +1237,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { Node *delay_slot = NULL; for (uint i=0; i < nblocks; i++) { - guarantee(blk_starts[i] >= (uint)cb->insts_size(),"should not increase size"); - Block *b = _cfg->_blocks[i]; Node *head = b->head(); @@ -1250,14 +1257,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { jmp_offset[i] = 0; jmp_size[i] = 0; jmp_rule[i] = 0; - - // Maximum alignment padding for loop block was used - // during first round of branches shortening, as result - // padding for nodes (sfpt after call) was not added. - // Take this into account for block's size change check - // and allow increase block's size by the difference - // of maximum and actual alignment paddings. - int orig_blk_size = blk_starts[i+1] - blk_starts[i] + block_alignment_padding; #endif int blk_offset = current_offset; @@ -1557,8 +1556,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { } } // End for all instructions in block - assert((uint)blk_offset <= blk_starts[i], "shouldn't increase distance"); - blk_starts[i] = blk_offset; // If the next block is the top of a loop, pad this block out to align // the loop top a little. Helps prevent pipe stalls at loop back branches. @@ -1572,16 +1569,13 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { nop->emit(*cb, _regalloc); current_offset = cb->insts_size(); } -#ifdef ASSERT - int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); - block_alignment_padding = (max_loop_pad - padding); - assert(block_alignment_padding >= 0, "sanity"); -#endif } // Verify that the distance for generated before forward // short branches is still valid. - assert(orig_blk_size >= (current_offset - blk_offset), "shouldn't increase block size"); + guarantee((int)(blk_starts[i+1] - blk_starts[i]) >= (current_offset - blk_offset), "shouldn't increase block size"); + // Save new block start offset + blk_starts[i] = blk_offset; } // End of for all blocks blk_starts[nblocks] = current_offset; From 0f3a43e3184c1207b74fe55b8039b40ce6266f12 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Thu, 4 Apr 2013 09:18:47 +0200 Subject: [PATCH 120/155] 8006008: Memory leak in hotspot/src/share/vm/adlc/archDesc.cpp Reviewed-by: roland, kvn --- hotspot/src/share/vm/adlc/archDesc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp index a8983ebaee0..7e272e4d028 100644 --- a/hotspot/src/share/vm/adlc/archDesc.cpp +++ b/hotspot/src/share/vm/adlc/archDesc.cpp @@ -832,6 +832,7 @@ static const char *getRegMask(const char *reg_class_name) { int length = (int)strlen(rc_name) + (int)strlen(mask) + 5; char *regMask = new char[length]; sprintf(regMask,"%s%s()", rc_name, mask); + delete[] rc_name; return regMask; } } From a88f9ec2d628451ee1d62a85f84d4f79b6f4b059 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 4 Apr 2013 09:24:21 +0200 Subject: [PATCH 121/155] 8006828: "SKIP_BOOT_CYCLE=false" must work in new building infrastructure Reviewed-by: tbell, alanb --- common/autoconf/bootcycle-spec.gmk.in | 14 ++++++++++++-- common/autoconf/spec.gmk.in | 18 ++++++++++-------- common/makefiles/Jprt.gmk | 4 ++++ common/makefiles/Main.gmk | 5 ++--- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/common/autoconf/bootcycle-spec.gmk.in b/common/autoconf/bootcycle-spec.gmk.in index 6edca725b00..9bc4007dbbb 100644 --- a/common/autoconf/bootcycle-spec.gmk.in +++ b/common/autoconf/bootcycle-spec.gmk.in @@ -29,9 +29,16 @@ include @SPEC@ # Check that the user did not try to specify a different java to use for compiling. -ifneq ($(firstword $(SJAVAC_SERVER_JAVA)),$(firstword $(JAVA))) - $(error Bootcycle builds are not possible if --with-sjavac-server-java is specified) +# On windows we need to account for fixpath being first word. +ifeq ($(firstword $(JAVA)),$(FIXPATH)) + JAVA_EXEC_POS=2 +else + JAVA_EXEC_POS=1 endif +ifneq ($(word $(JAVA_EXEC_POS),$(SJAVAC_SERVER_JAVA)),$(word $(JAVA_EXEC_POS),$(JAVA))) + $(error Bootcycle builds are not possible if --with-sjavac-server-java is specified) +endif + # Override specific values to do a boot cycle build @@ -39,5 +46,8 @@ endif BUILD_OUTPUT:=@BUILD_OUTPUT@/bootcycle-build # Use a different Boot JDK +OLD_BOOT_JDK:=$(BOOT_JDK) BOOT_JDK:=@BUILD_OUTPUT@/images/j2sdk-image BOOT_RTJAR:=@BUILD_OUTPUT@/images/j2sdk-image/jre/lib/rt.jar + +SJAVAC_SERVER_JAVA:=$(subst $(OLD_BOOT_JDK),$(BOOT_JDK),$(SJAVAC_SERVER_JAVA)) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index bfba636a7b1..4e5b7b48ca1 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -225,6 +225,7 @@ BUILD_VARIANT_RELEASE:=@BUILD_VARIANT_RELEASE@ # directory. BUILD_OUTPUT:=@BUILD_OUTPUT@ +# Colon left out to be able to override IMAGES_OUTPUTDIR for bootcycle-images LANGTOOLS_OUTPUTDIR=$(BUILD_OUTPUT)/langtools CORBA_OUTPUTDIR=$(BUILD_OUTPUT)/corba JAXP_OUTPUTDIR=$(BUILD_OUTPUT)/jaxp @@ -643,16 +644,17 @@ JDK_IMAGE_SUBDIR:=j2sdk-image JRE_IMAGE_SUBDIR:=j2re-image JDK_OVERLAY_IMAGE_SUBDIR:=j2sdk-overlay-image JRE_OVERLAY_IMAGE_SUBDIR:=j2re-overlay-image -JDK_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR) -JRE_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR) -JDK_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JDK_OVERLAY_IMAGE_SUBDIR) -JRE_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JRE_OVERLAY_IMAGE_SUBDIR) +# Colon left out to be able to override output dir for bootcycle-images +JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR) +JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR) +JDK_OVERLAY_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_OVERLAY_IMAGE_SUBDIR) +JRE_OVERLAY_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_OVERLAY_IMAGE_SUBDIR) # Macosx bundles directory definitions -JDK_BUNDLE_SUBDIR:=j2sdk-bundle/jdk$(JDK_VERSION).jdk/Contents -JRE_BUNDLE_SUBDIR:=j2re-bundle/jre$(JDK_VERSION).jre/Contents -JDK_BUNDLE_DIR:=$(IMAGES_OUTPUTDIR)/$(JDK_BUNDLE_SUBDIR) -JRE_BUNDLE_DIR:=$(IMAGES_OUTPUTDIR)/$(JRE_BUNDLE_SUBDIR) +JDK_BUNDLE_SUBDIR=j2sdk-bundle/jdk$(JDK_VERSION).jdk/Contents +JRE_BUNDLE_SUBDIR=j2re-bundle/jre$(JDK_VERSION).jre/Contents +JDK_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_BUNDLE_SUBDIR) +JRE_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_BUNDLE_SUBDIR) # Include the custom-spec.gmk file if it exists -include $(dir @SPEC@)/custom-spec.gmk diff --git a/common/makefiles/Jprt.gmk b/common/makefiles/Jprt.gmk index c70cf8872b4..938d4362e29 100644 --- a/common/makefiles/Jprt.gmk +++ b/common/makefiles/Jprt.gmk @@ -64,6 +64,10 @@ HOTSPOT_AVAILABLE := $(if $(wildcard $(root_dir)/hotspot),true,false) # Build with the configure bridge. After running configure, restart make # to parse the new spec file. BRIDGE_TARGETS := all +# Add bootcycle-images target if legacy variable is set. +ifeq ($(SKIP_BOOT_CYCLE),false) + BRIDGE_TARGETS += bootcycle-images +endif bridgeBuild: bridge2configure @cd $(root_dir) && $(MAKE) -f NewMakefile.gmk $(BRIDGE_TARGETS) diff --git a/common/makefiles/Main.gmk b/common/makefiles/Main.gmk index 11dda4bcff2..9e2bd401759 100644 --- a/common/makefiles/Main.gmk +++ b/common/makefiles/Main.gmk @@ -175,9 +175,8 @@ sign-jars-only: start-make @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk sign-jars) @$(call TargetExit) -bootcycle-images: - @$(ECHO) Boot cycle build step 1: Building the JDK image normally - @($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(SPEC) images) +bootcycle-images: images bootcycle-images-only +bootcycle-images-only: start-make @$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image @($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images) From 3231305a340c893ede3698a466e4d171a1c52cb0 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 4 Apr 2013 09:25:58 +0200 Subject: [PATCH 122/155] 8011372: Remove -p from cp in IdleCompilation.gmk Reviewed-by: pliden, tbell --- common/makefiles/IdlCompilation.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/makefiles/IdlCompilation.gmk b/common/makefiles/IdlCompilation.gmk index 2eb77dd3beb..b03ea43a9e5 100644 --- a/common/makefiles/IdlCompilation.gmk +++ b/common/makefiles/IdlCompilation.gmk @@ -70,7 +70,7 @@ define add_idl_package $(PREFIXES) \ $4 $(RM) -f $$(addprefix $3/$$($4_TMPDIR)/,$6) - $(CP) -rp $3/$$($4_TMPDIR)/* $3 + $(CP) -r $3/$$($4_TMPDIR)/* $3 ($(CD) $3/$$($4_TMPDIR) && $(FIND) . -type f | $(SED) 's!\./!$3/!g' | $(NAWK) '{ print $$$$1 ": $4" }' > $5) $(RM) -rf $3/$$($4_TMPDIR) endef From 02a014996bb81f76573ac914723d8e34f3b8f0d0 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Thu, 4 Apr 2013 09:33:24 +0200 Subject: [PATCH 123/155] 8010399: Test8009761.java "Failed: init recursive calls: 5498. After deopt 5494" Test from 8009761 shouldn't be run with -Xcomp Reviewed-by: kvn --- hotspot/test/compiler/8009761/Test8009761.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/compiler/8009761/Test8009761.java b/hotspot/test/compiler/8009761/Test8009761.java index c897ab40069..f588b82cd23 100644 --- a/hotspot/test/compiler/8009761/Test8009761.java +++ b/hotspot/test/compiler/8009761/Test8009761.java @@ -25,7 +25,7 @@ * @test * @bug 8009761 * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates - * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8009761 + * @run main/othervm -Xmixed -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8009761 * */ From 5548661d72b8a11c8bdad43d2d9a9a2649f8cdbd Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Thu, 4 Apr 2013 09:30:06 +0200 Subject: [PATCH 124/155] 8006014: Memory leak in hotspot/src/share/vm/adlc/dfa.cpp Reviewed-by: kvn, roland --- hotspot/src/share/vm/adlc/dfa.cpp | 41 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/hotspot/src/share/vm/adlc/dfa.cpp b/hotspot/src/share/vm/adlc/dfa.cpp index 5333c152cea..6b15911a067 100644 --- a/hotspot/src/share/vm/adlc/dfa.cpp +++ b/hotspot/src/share/vm/adlc/dfa.cpp @@ -191,12 +191,19 @@ static void cost_check(FILE *fp, const char *spaces, // Macro equivalent to: _kids[0]->valid(FOO) && _kids[1]->valid(BAR) // static void child_test(FILE *fp, MatchList &mList) { - if( mList._lchild ) // If left child, check it - fprintf(fp, "STATE__VALID_CHILD(_kids[0], %s)", ArchDesc::getMachOperEnum(mList._lchild)); - if( mList._lchild && mList._rchild ) // If both, add the "&&" - fprintf(fp, " && " ); - if( mList._rchild ) // If right child, check it - fprintf(fp, "STATE__VALID_CHILD(_kids[1], %s)", ArchDesc::getMachOperEnum(mList._rchild)); + if (mList._lchild) { // If left child, check it + const char* lchild_to_upper = ArchDesc::getMachOperEnum(mList._lchild); + fprintf(fp, "STATE__VALID_CHILD(_kids[0], %s)", lchild_to_upper); + delete[] lchild_to_upper; + } + if (mList._lchild && mList._rchild) { // If both, add the "&&" + fprintf(fp, " && "); + } + if (mList._rchild) { // If right child, check it + const char* rchild_to_upper = ArchDesc::getMachOperEnum(mList._rchild); + fprintf(fp, "STATE__VALID_CHILD(_kids[1], %s)", rchild_to_upper); + delete[] rchild_to_upper; + } } //---------------------------calc_cost----------------------------------------- @@ -206,13 +213,17 @@ static void child_test(FILE *fp, MatchList &mList) { Expr *ArchDesc::calc_cost(FILE *fp, const char *spaces, MatchList &mList, ProductionState &status) { fprintf(fp, "%sunsigned int c = ", spaces); Expr *c = new Expr("0"); - if (mList._lchild ) { // If left child, add it in - sprintf(Expr::buffer(), "_kids[0]->_cost[%s]", ArchDesc::getMachOperEnum(mList._lchild)); + if (mList._lchild) { // If left child, add it in + const char* lchild_to_upper = ArchDesc::getMachOperEnum(mList._lchild); + sprintf(Expr::buffer(), "_kids[0]->_cost[%s]", lchild_to_upper); c->add(Expr::buffer()); + delete[] lchild_to_upper; } - if (mList._rchild) { // If right child, add it in - sprintf(Expr::buffer(), "_kids[1]->_cost[%s]", ArchDesc::getMachOperEnum(mList._rchild)); + if (mList._rchild) { // If right child, add it in + const char* rchild_to_upper = ArchDesc::getMachOperEnum(mList._rchild); + sprintf(Expr::buffer(), "_kids[1]->_cost[%s]", rchild_to_upper); c->add(Expr::buffer()); + delete[] rchild_to_upper; } // Add in cost of this rule const char *mList_cost = mList.get_cost(); @@ -232,15 +243,17 @@ void ArchDesc::gen_match(FILE *fp, MatchList &mList, ProductionState &status, Di fprintf(fp, "%s", spaces4); // Only generate child tests if this is not a leaf node bool has_child_constraints = mList._lchild || mList._rchild; - const char *predicate_test = mList.get_pred(); - if( has_child_constraints || predicate_test ) { + const char *predicate_test = mList.get_pred(); + if (has_child_constraints || predicate_test) { // Open the child-and-predicate-test braces fprintf(fp, "if( "); status.set_constraint(hasConstraint); child_test(fp, mList); // Only generate predicate test if one exists for this match - if( predicate_test ) { - if( has_child_constraints ) { fprintf(fp," &&\n"); } + if (predicate_test) { + if (has_child_constraints) { + fprintf(fp," &&\n"); + } fprintf(fp, "%s %s", spaces6, predicate_test); } // End of outer tests From c68fa92e4b77f9b16f5e5802b1ccbd2b58ba809d Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Thu, 4 Apr 2013 12:18:46 -0700 Subject: [PATCH 125/155] 8011198: LP64 setting is not preserved on Solaris after 8006965 Fixed incremental build makefiles generated by buildtree.make. Consolidated unix build.sh. Reviewed-by: twisti --- hotspot/make/bsd/makefiles/buildtree.make | 14 +- hotspot/make/{bsd => }/build.sh | 81 ++++++----- hotspot/make/linux/build.sh | 98 -------------- hotspot/make/linux/makefiles/buildtree.make | 16 ++- hotspot/make/solaris/build.sh | 127 ------------------ hotspot/make/solaris/makefiles/buildtree.make | 15 ++- hotspot/src/os/posix/launcher/launcher.script | 2 +- 7 files changed, 82 insertions(+), 271 deletions(-) rename hotspot/make/{bsd => }/build.sh (50%) delete mode 100644 hotspot/make/linux/build.sh delete mode 100644 hotspot/make/solaris/build.sh diff --git a/hotspot/make/bsd/makefiles/buildtree.make b/hotspot/make/bsd/makefiles/buildtree.make index 71bb04b9811..752e0febb76 100644 --- a/hotspot/make/bsd/makefiles/buildtree.make +++ b/hotspot/make/bsd/makefiles/buildtree.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2013, 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,17 @@ $(SIMPLE_DIRS): # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) +# This bit is needed to enable local rebuilds. +# Unless the makefile itself sets LP64, any environmental +# setting of LP64 will interfere with the build. +LP64_SETTING/32 = LP64 = \#empty +LP64_SETTING/64 = LP64 = 1 + +DATA_MODE/i486 = 32 +DATA_MODE/amd64 = 64 + +DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst @echo Creating $@ ... $(QUIETLY) ( \ @@ -212,6 +223,7 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ echo "OPENJDK = $(OPENJDK)"; \ + echo "$(LP64_SETTING/$(DATA_MODE))"; \ echo; \ echo "# Used for platform dispatching"; \ echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ diff --git a/hotspot/make/bsd/build.sh b/hotspot/make/build.sh similarity index 50% rename from hotspot/make/bsd/build.sh rename to hotspot/make/build.sh index ddb07e54129..d05ce4474ac 100644 --- a/hotspot/make/bsd/build.sh +++ b/hotspot/make/build.sh @@ -1,6 +1,6 @@ #! /bin/sh # -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2013, 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 @@ -28,44 +28,38 @@ set -u -if [ $# != 2 ]; then - echo "Usage : $0 Build_Options Location" - echo "Build Options : debug or optimized or basicdebug or basic or clean" - echo "Location : specify any workspace which has gamma sources" +if [ $# -lt 1 ]; then + echo "Usage : $0 BuildTarget [LP64=1] [BuildOptions]" + echo " Server VM | Client VM" + echo "BuildTarget : debug | debug1" + echo " fastdebug | fastdebug1" + echo " jvmg | jvmg1" + echo " optimized | optimized1" + echo " profiled | profiled1" + echo " product | product1" + exit 1 +fi + +if [ "${JAVA_HOME-}" = "" -o ! -d "${JAVA_HOME-}" -o ! -d ${JAVA_HOME-}/jre/lib/ ]; then + echo "JAVA_HOME needs to be set to a valid JDK path" + echo "JAVA_HOME: ${JAVA_HOME-}" exit 1 fi # Just in case: -case ${JAVA_HOME} in -/*) true;; -?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;; -esac +JAVA_HOME=`( cd $JAVA_HOME; pwd )` -case `uname -m` in - i386|i486|i586|i686) - mach=i386 - ;; - *) - echo "Unsupported machine: " `uname -m` - exit 1 - ;; -esac - -if [ "${JAVA_HOME}" = "" -o ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/${mach} ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/bsd" - echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/bsd" - exit 1 +if [ "${ALT_BOOTDIR-}" = "" -o ! -d "${ALT_BOOTDIR-}" -o ! -d ${ALT_BOOTDIR-}/jre/lib/ ]; then + ALT_BOOTDIR=${JAVA_HOME} fi +# build in current directory by default +if [ "${ALT_OUTPUTDIR-}" = "" -o ! -d "${ALT_OUTPUTDIR-}" ]; then + ALT_OUTPUTDIR=`(pwd)` +fi -LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\ -${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.} - -# This is necessary as long as we are using the old launcher -# with the new distribution format: -CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.} - +HOTSPOT_SRC=`(dirname $0)`/.. +HOTSPOT_SRC=`(cd ${HOTSPOT_SRC}; pwd)` for gm in gmake gnumake do @@ -74,22 +68,25 @@ do done : ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} +# quiet build by default +Quiet="MAKE_VERBOSE=" + +# no debug info by default +NoDebugInfo="ENABLE_FULL_DEBUG_SYMBOLS=" + +LANG=C echo "### ENVIRONMENT SETTINGS:" +export HOTSPOT_SRC ; echo "HOTSPOT_SRC=$HOTSPOT_SRC" export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export LD_LIBRARY_PATH ; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -export CLASSPATH ; echo "CLASSPATH=$CLASSPATH" +export ALT_BOOTDIR ; echo "ALT_BOOTDIR=$ALT_BOOTDIR" +export ALT_OUTPUTDIR ; echo "ALT_OUTPUTDIR=$ALT_OUTPUTDIR" export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" +export LANG ; echo "LANG=$LANG" echo "###" -Build_Options=$1 -Location=$2 - -case ${Location} in -/*) true;; -?*) Location=`(cd ${Location}; pwd)`;; -esac +BuildOptions="$Quiet $NoDebugInfo $*" echo \ -${GNUMAKE} -f ${Location}/make/bsd/Makefile $Build_Options GAMMADIR=${Location} -${GNUMAKE} -f ${Location}/make/bsd/Makefile $Build_Options GAMMADIR=${Location} +${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC} +${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC} diff --git a/hotspot/make/linux/build.sh b/hotspot/make/linux/build.sh deleted file mode 100644 index 79844c51e1e..00000000000 --- a/hotspot/make/linux/build.sh +++ /dev/null @@ -1,98 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# 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. -# -# - -# Make sure the variable JAVA_HOME is set before running this script. - -set -u - - -if [ $# != 2 ]; then - echo "Usage : $0 Build_Options Location" - echo "Build Options : debug or optimized or basicdebug or basic or clean" - echo "Location : specify any workspace which has gamma sources" - exit 1 -fi - -# Just in case: -case ${JAVA_HOME} in -/*) true;; -?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;; -esac - -case `uname -m` in - i386|i486|i586|i686) - mach=i386 - ;; - x86_64) - mach=amd64 - ;; - *) - echo "Unsupported machine: " `uname -m` - exit 1 - ;; -esac - -if [ "${JAVA_HOME}" = "" -o ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/${mach} ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/linux" - echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/linux" - exit 1 -fi - - -LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\ -${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.} - -# This is necessary as long as we are using the old launcher -# with the new distribution format: -CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.} - - -for gm in gmake gnumake -do - if [ "${GNUMAKE-}" != "" ]; then break; fi - ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm -done -: ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} - - -echo "### ENVIRONMENT SETTINGS:" -export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export LD_LIBRARY_PATH ; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -export CLASSPATH ; echo "CLASSPATH=$CLASSPATH" -export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" -echo "###" - -Build_Options=$1 -Location=$2 - -case ${Location} in -/*) true;; -?*) Location=`(cd ${Location}; pwd)`;; -esac - -echo \ -${GNUMAKE} -f ${Location}/make/linux/Makefile $Build_Options GAMMADIR=${Location} -${GNUMAKE} -f ${Location}/make/linux/Makefile $Build_Options GAMMADIR=${Location} diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make index b75b4d57876..f980dcdafe0 100644 --- a/hotspot/make/linux/makefiles/buildtree.make +++ b/hotspot/make/linux/makefiles/buildtree.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2013, 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 @@ -183,6 +183,19 @@ $(SIMPLE_DIRS): # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) +# This bit is needed to enable local rebuilds. +# Unless the makefile itself sets LP64, any environmental +# setting of LP64 will interfere with the build. +LP64_SETTING/32 = LP64 = \#empty +LP64_SETTING/64 = LP64 = 1 + +DATA_MODE/i486 = 32 +DATA_MODE/sparc = 32 +DATA_MODE/sparcv9 = 64 +DATA_MODE/amd64 = 64 + +DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst @echo Creating $@ ... $(QUIETLY) ( \ @@ -205,6 +218,7 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ echo "OPENJDK = $(OPENJDK)"; \ + echo "$(LP64_SETTING/$(DATA_MODE))"; \ echo; \ echo "# Used for platform dispatching"; \ echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ diff --git a/hotspot/make/solaris/build.sh b/hotspot/make/solaris/build.sh deleted file mode 100644 index 9a8326ac67e..00000000000 --- a/hotspot/make/solaris/build.sh +++ /dev/null @@ -1,127 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1998, 2008, 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. -# -# - -# Make sure the variable JAVA_HOME is set before running this script. - -set -u - - -usage() { - ( - echo "Usage : $0 [-sb | -sbfast] config ws_path" - echo "" - echo "Where:" - echo " -sb ::= enable source browser info generation for" - echo " all configs during compilation" - echo "" - echo " -sbfast ::= enable source browser info generation for" - echo " all configs without compilation" - echo "" - echo " config ::= debug | debug1 | debugcore" - echo " fastdebug | fastdebug1 | fastdebugcore" - echo " jvmg | jvmg1 | jvmgcore" - echo " optimized | optimized1 | optimizedcore" - echo " profiled | profiled1 | profiledcore" - echo " product | product1 | productcore" - echo "" - echo " ws_path ::= path to HotSpot workspace" - ) >&2 - exit 1 -} - -# extract possible options -options="" -if [ $# -gt 2 ]; then - case "$1" in - -sb) - options="CFLAGS_BROWSE=-xsb" - shift - ;; - -sbfast) - options="CFLAGS_BROWSE=-xsbfast" - shift - ;; - *) - echo "Unknown option: '$1'" >&2 - usage - ;; - esac -fi - -# should be just two args left at this point -if [ $# != 2 ]; then - usage -fi - -# Just in case: -case ${JAVA_HOME} in -/*) true;; -?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;; -esac - -if [ "${JAVA_HOME}" = "" -o ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/`uname -p` ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/solaris" - echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/solaris" - exit 1 -fi - - -LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\ -${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.} - -# This is necessary as long as we are using the old launcher -# with the new distribution format: -CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.} - - -for gm in gmake gnumake -do - if [ "${GNUMAKE-}" != "" ]; then break; fi - ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm -done -: ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} - - -echo "### ENVIRONMENT SETTINGS:" -export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export LD_LIBRARY_PATH ; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -export CLASSPATH ; echo "CLASSPATH=$CLASSPATH" -export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" -echo "###" - -config=$1 -ws_path=$2 - -case ${ws_path} in -/*) true;; -?*) ws_path=`(cd ${ws_path}; pwd)`;; -esac - -echo \ -${GNUMAKE} -f ${ws_path}/make/solaris/Makefile \ - $config GAMMADIR=${ws_path} $options -${GNUMAKE} -f ${ws_path}/make/solaris/Makefile \ - $config GAMMADIR=${ws_path} $options diff --git a/hotspot/make/solaris/makefiles/buildtree.make b/hotspot/make/solaris/makefiles/buildtree.make index 707d5f36a8d..a3ab0b5e52c 100644 --- a/hotspot/make/solaris/makefiles/buildtree.make +++ b/hotspot/make/solaris/makefiles/buildtree.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2013, 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 @@ -176,6 +176,19 @@ $(SIMPLE_DIRS): # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) +# This bit is needed to enable local rebuilds. +# Unless the makefile itself sets LP64, any environmental +# setting of LP64 will interfere with the build. +LP64_SETTING/32 = LP64 = \#empty +LP64_SETTING/64 = LP64 = 1 + +DATA_MODE/i486 = 32 +DATA_MODE/sparc = 32 +DATA_MODE/sparcv9 = 64 +DATA_MODE/amd64 = 64 + +DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst @echo Creating $@ ... $(QUIETLY) ( \ diff --git a/hotspot/src/os/posix/launcher/launcher.script b/hotspot/src/os/posix/launcher/launcher.script index 0a2ae5f4d6b..e8d4281808a 100644 --- a/hotspot/src/os/posix/launcher/launcher.script +++ b/hotspot/src/os/posix/launcher/launcher.script @@ -199,7 +199,7 @@ case "$MODE" in rm -f $GDBSCR ;; dbx) - $DBX -s $MYDIR/.dbxrc $LAUNCHER $JPARAMS + $DBX -s $HOME/.dbxrc $LAUNCHER $JPARMS ;; valgrind) echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap From 209e92f4fec64ad78cbb76b2050ede794b25a84d Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Thu, 4 Apr 2013 15:39:17 -0700 Subject: [PATCH 126/155] 8000406: change files using @GenerateNativeHeader to use @Native Use @Native annotation to mark constants interested by native codes Reviewed-by: alanb, anthony, prr --- .../classes/apple/laf/JRSUIConstants.java | 534 ++++++++---------- .../com/apple/eawt/FullScreenHandler.java | 14 +- .../com/apple/eawt/event/GestureHandler.java | 14 +- .../classes/sun/java2d/OSXSurfaceData.java | 228 ++++---- .../sun/lwawt/macosx/CocoaConstants.java | 5 +- .../native/jobjc/src/core/PrimitiveCoder.hs | 9 +- .../src/core/java/com/apple/jobjc/CFType.java | 5 +- .../src/core/java/com/apple/jobjc/Coder.java | 46 +- .../core/java/com/apple/jobjc/FFIType.java | 5 +- .../core/java/com/apple/jobjc/Function.java | 5 +- .../src/core/java/com/apple/jobjc/ID.java | 5 +- .../src/core/java/com/apple/jobjc/Invoke.java | 11 +- .../java/com/apple/jobjc/JObjCRuntime.java | 7 +- .../java/com/apple/jobjc/MacOSXFramework.java | 5 +- .../core/java/com/apple/jobjc/NSClass.java | 7 +- .../com/apple/jobjc/NativeArgumentBuffer.java | 5 +- .../java/com/apple/jobjc/NativeBuffer.java | 5 +- .../jobjc/NativeObjectLifecycleManager.java | 11 +- .../src/core/java/com/apple/jobjc/Opaque.java | 5 +- .../core/java/com/apple/jobjc/Pointer.java | 5 +- .../java/com/apple/jobjc/PrimitiveCoder.java | 31 +- .../src/core/java/com/apple/jobjc/SEL.java | 5 +- .../src/core/java/com/apple/jobjc/Struct.java | 5 +- .../java/com/apple/jobjc/Subclassing.java | 5 +- .../native/jobjc/src/core/native/Invoke.m | 4 +- .../jobjc/src/core/native/JObjCRuntime.m | 3 +- jdk/src/macosx/native/sun/awt/PrinterView.m | 3 +- .../share/classes/java/awt/Adjustable.java | 12 +- .../classes/java/awt/AlphaComposite.java | 34 +- .../share/classes/java/awt/BasicStroke.java | 18 +- jdk/src/share/classes/java/awt/Choice.java | 5 +- .../share/classes/java/awt/DisplayMode.java | 10 +- jdk/src/share/classes/java/awt/Image.java | 5 +- jdk/src/share/classes/java/awt/List.java | 5 +- jdk/src/share/classes/java/awt/PopupMenu.java | 5 +- .../share/classes/java/awt/SystemColor.java | 60 +- .../share/classes/java/awt/TextComponent.java | 5 +- .../share/classes/java/awt/Transparency.java | 12 +- .../classes/java/awt/color/ColorSpace.java | 66 ++- .../classes/java/awt/color/ICC_Profile.java | 5 +- .../awt/datatransfer/StringSelection.java | 5 +- .../classes/java/awt/dnd/DnDConstants.java | 18 +- .../classes/java/awt/event/ActionEvent.java | 8 +- .../java/awt/event/AdjustmentEvent.java | 17 +- .../java/awt/event/ComponentEvent.java | 14 +- .../classes/java/awt/event/FocusEvent.java | 5 +- .../java/awt/event/InputMethodEvent.java | 14 +- .../java/awt/event/MouseWheelEvent.java | 10 +- .../classes/java/awt/event/WindowEvent.java | 26 +- .../classes/java/awt/geom/PathIterator.java | 20 +- .../java/awt/image/AffineTransformOp.java | 12 +- .../classes/java/awt/image/ConvolveOp.java | 10 +- .../classes/java/awt/image/DataBuffer.java | 20 +- .../classes/java/awt/image/ImageConsumer.java | 5 +- .../classes/java/awt/image/ImageObserver.java | 5 +- .../classes/java/awt/peer/ComponentPeer.java | 5 +- .../classes/java/awt/print/PageFormat.java | 12 +- .../classes/java/awt/print/Pageable.java | 8 +- .../classes/java/awt/print/Printable.java | 5 +- .../share/classes/sun/awt/EmbeddedFrame.java | 5 +- jdk/src/share/classes/sun/awt/SunHints.java | 90 ++- .../sun/awt/dnd/SunDragSourceContextPeer.java | 5 +- .../sun/awt/image/BufImgSurfaceData.java | 5 +- .../share/classes/sun/font/FontManager.java | 5 +- .../classes/sun/java2d/SunGraphics2D.java | 29 +- .../sun/java2d/opengl/OGLBlitLoops.java | 18 +- .../classes/sun/java2d/opengl/OGLContext.java | 20 +- .../sun/java2d/pipe/BufferedContext.java | 12 +- .../sun/java2d/pipe/BufferedOpCodes.java | 108 ++-- .../sun/java2d/pipe/BufferedPaints.java | 8 +- .../sun/java2d/pipe/BufferedTextPipe.java | 18 +- .../classes/sun/java2d/pipe/RenderBuffer.java | 5 +- .../pipe/hw/AccelDeviceEventNotifier.java | 11 +- .../sun/java2d/pipe/hw/AccelSurface.java | 18 +- .../java2d/pipe/hw/ContextCapabilities.java | 5 +- .../sun/nio/ch/DatagramChannelImpl.java | 5 +- .../sun/nio/ch/sctp/SctpStdSocketOption.java | 20 +- .../classes/sun/security/pkcs11/Secmod.java | 5 +- .../sun/security/pkcs11/wrapper/PKCS11.java | 5 +- .../classes/sun/awt/X11/XComponentPeer.java | 5 +- .../sun/nio/ch/sctp/AssociationChange.java | 16 +- .../sun/nio/ch/sctp/PeerAddrChange.java | 18 +- .../sun/nio/ch/sctp/ResultContainer.java | 18 +- .../solaris/native/sun/awt/awt_InputMethod.c | 3 +- jdk/src/solaris/native/sun/awt/fontpath.c | 1 - .../classes/sun/java2d/d3d/D3DBlitLoops.java | 18 +- .../classes/sun/java2d/d3d/D3DContext.java | 16 +- .../classes/sun/java2d/d3d/D3DPaints.java | 8 +- .../native/sun/java2d/d3d/D3DContext.h | 3 +- .../native/sun/windows/awt_Component.h | 1 - .../windows/native/sun/windows/awt_DnDDS.cpp | 3 +- .../windows/native/sun/windows/awt_Frame.cpp | 3 +- jdk/src/windows/native/sun/windows/awt_List.h | 1 - .../native/sun/windows/awt_PopupMenu.cpp | 1 - .../native/sun/windows/awt_PopupMenu.h | 1 - .../native/sun/windows/awt_TextComponent.h | 1 - .../native/sun/windows/awt_Toolkit.cpp | 3 +- 97 files changed, 825 insertions(+), 1140 deletions(-) diff --git a/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java b/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java index 8e71a50c658..40b2fc2db44 100644 --- a/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java +++ b/jdk/src/macosx/classes/apple/laf/JRSUIConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -28,27 +28,25 @@ package apple.laf; import java.lang.reflect.Field; import java.nio.ByteBuffer; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; public final class JRSUIConstants { private static native long getPtrForConstant(final int constant); - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader static class Key { - protected static final int _value = 20; + @Native protected static final int _value = 20; public static final Key VALUE = new Key(_value); - protected static final int _thumbProportion = 24; + @Native protected static final int _thumbProportion = 24; public static final Key THUMB_PROPORTION = new Key(_thumbProportion); - protected static final int _thumbStart = 25; + @Native protected static final int _thumbStart = 25; public static final Key THUMB_START = new Key(_thumbStart); - protected static final int _windowTitleBarHeight = 28; + @Native protected static final int _windowTitleBarHeight = 28; public static final Key WINDOW_TITLE_BAR_HEIGHT = new Key(_windowTitleBarHeight); - protected static final int _animationFrame = 23; + @Native protected static final int _animationFrame = 23; public static final Key ANIMATION_FRAME = new Key(_animationFrame); final int constant; @@ -70,10 +68,8 @@ public final class JRSUIConstants { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader static class DoubleValue { - protected static final byte TYPE_CODE = 1; + @Native protected static final byte TYPE_CODE = 1; final double doubleValue; @@ -139,684 +135,634 @@ public final class JRSUIConstants { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Size extends Property { - private static final byte SHIFT = 0; - private static final byte SIZE = 3; - private static final long MASK = (long)0x7 << SHIFT; + @Native private static final byte SHIFT = 0; + @Native private static final byte SIZE = 3; + @Native private static final long MASK = (long)0x7 << SHIFT; private static final PropertyEncoding size = new PropertyEncoding(MASK, SHIFT); Size(final byte value) { super(size, value); } - private static final byte _mini = 1; + @Native private static final byte _mini = 1; public static final Size MINI = new Size(_mini); - private static final byte _small = 2; + @Native private static final byte _small = 2; public static final Size SMALL = new Size(_small); - private static final byte _regular = 3; + @Native private static final byte _regular = 3; public static final Size REGULAR = new Size(_regular); - private static final byte _large = 4; + @Native private static final byte _large = 4; public static final Size LARGE = new Size(_large); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class State extends Property { - private static final byte SHIFT = Size.SHIFT + Size.SIZE; - private static final byte SIZE = 4; - private static final long MASK = (long)0xF << SHIFT; + @Native private static final byte SHIFT = Size.SHIFT + Size.SIZE; + @Native private static final byte SIZE = 4; + @Native private static final long MASK = (long)0xF << SHIFT; private static final PropertyEncoding state = new PropertyEncoding(MASK, SHIFT); State(final byte value) { super(state, value); } - private static final byte _active = 1; + @Native private static final byte _active = 1; public static final State ACTIVE = new State(_active); - private static final byte _inactive = 2; + @Native private static final byte _inactive = 2; public static final State INACTIVE = new State(_inactive); - private static final byte _disabled = 3; + @Native private static final byte _disabled = 3; public static final State DISABLED = new State(_disabled); - private static final byte _pressed = 4; + @Native private static final byte _pressed = 4; public static final State PRESSED = new State(_pressed); - private static final byte _pulsed = 5; + @Native private static final byte _pulsed = 5; public static final State PULSED = new State(_pulsed); - private static final byte _rollover = 6; + @Native private static final byte _rollover = 6; public static final State ROLLOVER = new State(_rollover); - private static final byte _drag = 7; + @Native private static final byte _drag = 7; public static final State DRAG = new State(_drag); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Direction extends Property { - private static final byte SHIFT = State.SHIFT + State.SIZE; - private static final byte SIZE = 4; - private static final long MASK = (long)0xF << SHIFT; + @Native private static final byte SHIFT = State.SHIFT + State.SIZE; + @Native private static final byte SIZE = 4; + @Native private static final long MASK = (long)0xF << SHIFT; private static final PropertyEncoding direction = new PropertyEncoding(MASK, SHIFT); Direction(final byte value) { super(direction, value); } - private static final byte _none = 1; + @Native private static final byte _none = 1; public static final Direction NONE = new Direction(_none); - private static final byte _up = 2; + @Native private static final byte _up = 2; public static final Direction UP = new Direction(_up); - private static final byte _down = 3; + @Native private static final byte _down = 3; public static final Direction DOWN = new Direction(_down); - private static final byte _left = 4; + @Native private static final byte _left = 4; public static final Direction LEFT = new Direction(_left); - private static final byte _right = 5; + @Native private static final byte _right = 5; public static final Direction RIGHT = new Direction(_right); - private static final byte _north = 6; + @Native private static final byte _north = 6; public static final Direction NORTH = new Direction(_north); - private static final byte _south = 7; + @Native private static final byte _south = 7; public static final Direction SOUTH = new Direction(_south); - private static final byte _east = 8; + @Native private static final byte _east = 8; public static final Direction EAST = new Direction(_east); - private static final byte _west = 9; + @Native private static final byte _west = 9; public static final Direction WEST = new Direction(_west); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Orientation extends Property { - private static final byte SHIFT = Direction.SHIFT + Direction.SIZE; - private static final byte SIZE = 2; - private static final long MASK = (long)0x3 << SHIFT; + @Native private static final byte SHIFT = Direction.SHIFT + Direction.SIZE; + @Native private static final byte SIZE = 2; + @Native private static final long MASK = (long)0x3 << SHIFT; private static final PropertyEncoding orientation = new PropertyEncoding(MASK, SHIFT); Orientation(final byte value) { super(orientation, value); } - private static final byte _horizontal = 1; + @Native private static final byte _horizontal = 1; public static final Orientation HORIZONTAL = new Orientation(_horizontal); - private static final byte _vertical = 2; + @Native private static final byte _vertical = 2; public static final Orientation VERTICAL = new Orientation(_vertical); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class AlignmentVertical extends Property { - private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE; - private static final byte SIZE = 2; - private static final long MASK = (long)0x3 << SHIFT; + @Native private static final byte SHIFT = Orientation.SHIFT + Orientation.SIZE; + @Native private static final byte SIZE = 2; + @Native private static final long MASK = (long)0x3 << SHIFT; private static final PropertyEncoding alignmentVertical = new PropertyEncoding(MASK, SHIFT); AlignmentVertical(final byte value){ super(alignmentVertical, value); } - private static final byte _top = 1; + @Native private static final byte _top = 1; public static final AlignmentVertical TOP = new AlignmentVertical(_top); - private static final byte _center = 2; + @Native private static final byte _center = 2; public static final AlignmentVertical CENTER = new AlignmentVertical(_center); - private static final byte _bottom = 3; + @Native private static final byte _bottom = 3; public static final AlignmentVertical BOTTOM = new AlignmentVertical(_bottom); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class AlignmentHorizontal extends Property { - private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE; - private static final byte SIZE = 2; - private static final long MASK = (long)0x3 << SHIFT; + @Native private static final byte SHIFT = AlignmentVertical.SHIFT + AlignmentVertical.SIZE; + @Native private static final byte SIZE = 2; + @Native private static final long MASK = (long)0x3 << SHIFT; private static final PropertyEncoding alignmentHorizontal = new PropertyEncoding(MASK, SHIFT); AlignmentHorizontal(final byte value){ super(alignmentHorizontal, value); } - private static final byte _left = 1; + @Native private static final byte _left = 1; public static final AlignmentHorizontal LEFT = new AlignmentHorizontal(_left); - private static final byte _center = 2; + @Native private static final byte _center = 2; public static final AlignmentHorizontal CENTER = new AlignmentHorizontal(_center); - private static final byte _right = 3; + @Native private static final byte _right = 3; public static final AlignmentHorizontal RIGHT = new AlignmentHorizontal(_right); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class SegmentPosition extends Property { - private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE; - private static final byte SIZE = 3; - private static final long MASK = (long)0x7 << SHIFT; + @Native private static final byte SHIFT = AlignmentHorizontal.SHIFT + AlignmentHorizontal.SIZE; + @Native private static final byte SIZE = 3; + @Native private static final long MASK = (long)0x7 << SHIFT; private static final PropertyEncoding segmentPosition = new PropertyEncoding(MASK, SHIFT); SegmentPosition(final byte value) { super(segmentPosition, value); } - private static final byte _first = 1; + @Native private static final byte _first = 1; public static final SegmentPosition FIRST = new SegmentPosition(_first); - private static final byte _middle = 2; + @Native private static final byte _middle = 2; public static final SegmentPosition MIDDLE = new SegmentPosition(_middle); - private static final byte _last = 3; + @Native private static final byte _last = 3; public static final SegmentPosition LAST = new SegmentPosition(_last); - private static final byte _only = 4; + @Native private static final byte _only = 4; public static final SegmentPosition ONLY = new SegmentPosition(_only); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class ScrollBarPart extends Property { - private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE; - private static final byte SIZE = 4; - private static final long MASK = (long)0xF << SHIFT; + @Native private static final byte SHIFT = SegmentPosition.SHIFT + SegmentPosition.SIZE; + @Native private static final byte SIZE = 4; + @Native private static final long MASK = (long)0xF << SHIFT; private static final PropertyEncoding scrollBarPart = new PropertyEncoding(MASK, SHIFT); ScrollBarPart(final byte value) { super(scrollBarPart, value); } - private static final byte _none = 1; + @Native private static final byte _none = 1; public static final ScrollBarPart NONE = new ScrollBarPart(_none); - private static final byte _thumb = 2; + @Native private static final byte _thumb = 2; public static final ScrollBarPart THUMB = new ScrollBarPart(_thumb); - private static final byte _arrowMin = 3; + @Native private static final byte _arrowMin = 3; public static final ScrollBarPart ARROW_MIN = new ScrollBarPart(_arrowMin); - private static final byte _arrowMax = 4; + @Native private static final byte _arrowMax = 4; public static final ScrollBarPart ARROW_MAX = new ScrollBarPart(_arrowMax); - private static final byte _arrowMaxInside = 5; + @Native private static final byte _arrowMaxInside = 5; public static final ScrollBarPart ARROW_MAX_INSIDE = new ScrollBarPart(_arrowMaxInside); - private static final byte _arrowMinInside = 6; + @Native private static final byte _arrowMinInside = 6; public static final ScrollBarPart ARROW_MIN_INSIDE = new ScrollBarPart(_arrowMinInside); - private static final byte _trackMin = 7; + @Native private static final byte _trackMin = 7; public static final ScrollBarPart TRACK_MIN = new ScrollBarPart(_trackMin); - private static final byte _trackMax = 8; + @Native private static final byte _trackMax = 8; public static final ScrollBarPart TRACK_MAX = new ScrollBarPart(_trackMax); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Variant extends Property { - private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE; - private static final byte SIZE = 4; - private static final long MASK = (long)0xF << SHIFT; + @Native private static final byte SHIFT = ScrollBarPart.SHIFT + ScrollBarPart.SIZE; + @Native private static final byte SIZE = 4; + @Native private static final long MASK = (long)0xF << SHIFT; private static final PropertyEncoding variant = new PropertyEncoding(MASK, SHIFT); Variant(final byte value) { super(variant, value); } - private static final byte _menuGlyph = 1; + @Native private static final byte _menuGlyph = 1; public static final Variant MENU_GLYPH = new Variant(_menuGlyph); - private static final byte _menuPopup = Variant._menuGlyph + 1; + @Native private static final byte _menuPopup = Variant._menuGlyph + 1; public static final Variant MENU_POPUP = new Variant(_menuPopup); - private static final byte _menuPulldown = Variant._menuPopup + 1; + @Native private static final byte _menuPulldown = Variant._menuPopup + 1; public static final Variant MENU_PULLDOWN = new Variant(_menuPulldown); - private static final byte _menuHierarchical = Variant._menuPulldown + 1; + @Native private static final byte _menuHierarchical = Variant._menuPulldown + 1; public static final Variant MENU_HIERARCHICAL = new Variant(_menuHierarchical); - private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1; + @Native private static final byte _gradientListBackgroundEven = Variant._menuHierarchical + 1; public static final Variant GRADIENT_LIST_BACKGROUND_EVEN = new Variant(_gradientListBackgroundEven); - private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1; + @Native private static final byte _gradientListBackgroundOdd = Variant._gradientListBackgroundEven + 1; public static final Variant GRADIENT_LIST_BACKGROUND_ODD = new Variant(_gradientListBackgroundOdd); - private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1; + @Native private static final byte _gradientSideBar = Variant._gradientListBackgroundOdd + 1; public static final Variant GRADIENT_SIDE_BAR = new Variant(_gradientSideBar); - private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1; + @Native private static final byte _gradientSideBarSelection = Variant._gradientSideBar + 1; public static final Variant GRADIENT_SIDE_BAR_SELECTION = new Variant(_gradientSideBarSelection); - private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1; + @Native private static final byte _gradientSideBarFocusedSelection = Variant._gradientSideBarSelection + 1; public static final Variant GRADIENT_SIDE_BAR_FOCUSED_SELECTION = new Variant(_gradientSideBarFocusedSelection); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class WindowType extends Property { - private static final byte SHIFT = Variant.SHIFT + Variant.SIZE; - private static final byte SIZE = 2; - private static final long MASK = (long)0x3 << SHIFT; + @Native private static final byte SHIFT = Variant.SHIFT + Variant.SIZE; + @Native private static final byte SIZE = 2; + @Native private static final long MASK = (long)0x3 << SHIFT; private static final PropertyEncoding windowType = new PropertyEncoding(MASK, SHIFT); WindowType(final byte value){ super(windowType, value); } - private static final byte _document = 1; + @Native private static final byte _document = 1; public static final WindowType DOCUMENT = new WindowType(_document); - private static final byte _utility = 2; + @Native private static final byte _utility = 2; public static final WindowType UTILITY = new WindowType(_utility); - private static final byte _titlelessUtility = 3; + @Native private static final byte _titlelessUtility = 3; public static final WindowType TITLELESS_UTILITY = new WindowType(_titlelessUtility); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Focused extends Property { - private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = WindowType.SHIFT + WindowType.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); Focused(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final Focused NO = new Focused(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final Focused YES = new Focused(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class IndicatorOnly extends Property { - private static final byte SHIFT = Focused.SHIFT + Focused.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = Focused.SHIFT + Focused.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding indicatorOnly = new PropertyEncoding(MASK, SHIFT); IndicatorOnly(final byte value) { super(indicatorOnly, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final IndicatorOnly NO = new IndicatorOnly(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final IndicatorOnly YES = new IndicatorOnly(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class NoIndicator extends Property { - private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = IndicatorOnly.SHIFT + IndicatorOnly.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding noIndicator = new PropertyEncoding(MASK, SHIFT); NoIndicator(final byte value) { super(noIndicator, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final NoIndicator NO = new NoIndicator(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final NoIndicator YES = new NoIndicator(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class ArrowsOnly extends Property { - private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = NoIndicator.SHIFT + NoIndicator.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); ArrowsOnly(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final ArrowsOnly NO = new ArrowsOnly(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final ArrowsOnly YES = new ArrowsOnly(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class FrameOnly extends Property { - private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = ArrowsOnly.SHIFT + ArrowsOnly.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); FrameOnly(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final FrameOnly NO = new FrameOnly(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final FrameOnly YES = new FrameOnly(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class SegmentTrailingSeparator extends Property { - private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = FrameOnly.SHIFT + FrameOnly.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); SegmentTrailingSeparator(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final SegmentTrailingSeparator NO = new SegmentTrailingSeparator(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final SegmentTrailingSeparator YES = new SegmentTrailingSeparator(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class SegmentLeadingSeparator extends Property { - private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = SegmentTrailingSeparator.SHIFT + SegmentTrailingSeparator.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding leadingSeparator = new PropertyEncoding(MASK, SHIFT); SegmentLeadingSeparator(final byte value) { super(leadingSeparator, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final SegmentLeadingSeparator NO = new SegmentLeadingSeparator(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final SegmentLeadingSeparator YES = new SegmentLeadingSeparator(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class NothingToScroll extends Property { - private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = SegmentLeadingSeparator.SHIFT + SegmentLeadingSeparator.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); NothingToScroll(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final NothingToScroll NO = new NothingToScroll(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final NothingToScroll YES = new NothingToScroll(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class WindowTitleBarSeparator extends Property { - private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = NothingToScroll.SHIFT + NothingToScroll.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); WindowTitleBarSeparator(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final WindowTitleBarSeparator NO = new WindowTitleBarSeparator(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final WindowTitleBarSeparator YES = new WindowTitleBarSeparator(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class WindowClipCorners extends Property { - private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = WindowTitleBarSeparator.SHIFT + WindowTitleBarSeparator.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding focused = new PropertyEncoding(MASK, SHIFT); WindowClipCorners(final byte value) { super(focused, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final WindowClipCorners NO = new WindowClipCorners(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final WindowClipCorners YES = new WindowClipCorners(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class ShowArrows extends Property { - private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = WindowClipCorners.SHIFT + WindowClipCorners.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding showArrows = new PropertyEncoding(MASK, SHIFT); ShowArrows(final byte value) { super(showArrows, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final ShowArrows NO = new ShowArrows(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final ShowArrows YES = new ShowArrows(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class BooleanValue extends Property { - private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = ShowArrows.SHIFT + ShowArrows.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding booleanValue = new PropertyEncoding(MASK, SHIFT); BooleanValue(final byte value) { super(booleanValue, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final BooleanValue NO = new BooleanValue(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final BooleanValue YES = new BooleanValue(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Animating extends Property { - private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE; - private static final byte SIZE = 1; - private static final long MASK = (long)0x1 << SHIFT; + @Native private static final byte SHIFT = BooleanValue.SHIFT + BooleanValue.SIZE; + @Native private static final byte SIZE = 1; + @Native private static final long MASK = (long)0x1 << SHIFT; private static final PropertyEncoding animating = new PropertyEncoding(MASK, SHIFT); Animating(final byte value) { super(animating, value); } - private static final byte _no = 0; + @Native private static final byte _no = 0; public static final Animating NO = new Animating(_no); - private static final byte _yes = 1; + @Native private static final byte _yes = 1; public static final Animating YES = new Animating(_yes); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Widget extends Property { - private static final byte SHIFT = Animating.SHIFT + Animating.SIZE; - private static final byte SIZE = 7; - private static final long MASK = (long)0x7F << SHIFT; + @Native private static final byte SHIFT = Animating.SHIFT + Animating.SIZE; + @Native private static final byte SIZE = 7; + @Native private static final long MASK = (long)0x7F << SHIFT; private static final PropertyEncoding widget = new PropertyEncoding(MASK, SHIFT); Widget(final byte constant) { super(widget, constant); } - private static final byte _background = 1; + @Native private static final byte _background = 1; public static final Widget BACKGROUND = new Widget(_background); - private static final byte _buttonBevel = _background + 1; + @Native private static final byte _buttonBevel = _background + 1; public static final Widget BUTTON_BEVEL = new Widget(_buttonBevel); - private static final byte _buttonBevelInset = _buttonBevel + 1; + @Native private static final byte _buttonBevelInset = _buttonBevel + 1; public static final Widget BUTTON_BEVEL_INSET = new Widget(_buttonBevelInset); - private static final byte _buttonBevelRound = _buttonBevelInset + 1; + @Native private static final byte _buttonBevelRound = _buttonBevelInset + 1; public static final Widget BUTTON_BEVEL_ROUND = new Widget(_buttonBevelRound); - private static final byte _buttonCheckBox = _buttonBevelRound + 1; + @Native private static final byte _buttonCheckBox = _buttonBevelRound + 1; public static final Widget BUTTON_CHECK_BOX = new Widget(_buttonCheckBox); - private static final byte _buttonComboBox = _buttonCheckBox + 1; + @Native private static final byte _buttonComboBox = _buttonCheckBox + 1; public static final Widget BUTTON_COMBO_BOX = new Widget(_buttonComboBox); - private static final byte _buttonComboBoxInset = _buttonComboBox + 1; + @Native private static final byte _buttonComboBoxInset = _buttonComboBox + 1; public static final Widget BUTTON_COMBO_BOX_INSET = new Widget(_buttonComboBoxInset); // not hooked up in JRSUIConstants.m - private static final byte _buttonDisclosure = _buttonComboBoxInset + 1; + @Native private static final byte _buttonDisclosure = _buttonComboBoxInset + 1; public static final Widget BUTTON_DISCLOSURE = new Widget(_buttonDisclosure); - private static final byte _buttonListHeader = _buttonDisclosure + 1; + @Native private static final byte _buttonListHeader = _buttonDisclosure + 1; public static final Widget BUTTON_LIST_HEADER = new Widget(_buttonListHeader); - private static final byte _buttonLittleArrows = _buttonListHeader + 1; + @Native private static final byte _buttonLittleArrows = _buttonListHeader + 1; public static final Widget BUTTON_LITTLE_ARROWS = new Widget(_buttonLittleArrows); - private static final byte _buttonPopDown = _buttonLittleArrows + 1; + @Native private static final byte _buttonPopDown = _buttonLittleArrows + 1; public static final Widget BUTTON_POP_DOWN = new Widget(_buttonPopDown); - private static final byte _buttonPopDownInset = _buttonPopDown + 1; + @Native private static final byte _buttonPopDownInset = _buttonPopDown + 1; public static final Widget BUTTON_POP_DOWN_INSET = new Widget(_buttonPopDownInset); - private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1; + @Native private static final byte _buttonPopDownSquare = _buttonPopDownInset + 1; public static final Widget BUTTON_POP_DOWN_SQUARE = new Widget(_buttonPopDownSquare); - private static final byte _buttonPopUp = _buttonPopDownSquare + 1; + @Native private static final byte _buttonPopUp = _buttonPopDownSquare + 1; public static final Widget BUTTON_POP_UP = new Widget(_buttonPopUp); - private static final byte _buttonPopUpInset = _buttonPopUp + 1; + @Native private static final byte _buttonPopUpInset = _buttonPopUp + 1; public static final Widget BUTTON_POP_UP_INSET = new Widget(_buttonPopUpInset); - private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1; + @Native private static final byte _buttonPopUpSquare = _buttonPopUpInset + 1; public static final Widget BUTTON_POP_UP_SQUARE = new Widget(_buttonPopUpSquare); - private static final byte _buttonPush = _buttonPopUpSquare + 1; + @Native private static final byte _buttonPush = _buttonPopUpSquare + 1; public static final Widget BUTTON_PUSH = new Widget(_buttonPush); - private static final byte _buttonPushScope = _buttonPush + 1; + @Native private static final byte _buttonPushScope = _buttonPush + 1; public static final Widget BUTTON_PUSH_SCOPE = new Widget(_buttonPushScope); - private static final byte _buttonPushScope2 = _buttonPushScope + 1; + @Native private static final byte _buttonPushScope2 = _buttonPushScope + 1; public static final Widget BUTTON_PUSH_SCOPE2 = new Widget(_buttonPushScope2); - private static final byte _buttonPushTextured = _buttonPushScope2 + 1; + @Native private static final byte _buttonPushTextured = _buttonPushScope2 + 1; public static final Widget BUTTON_PUSH_TEXTURED = new Widget(_buttonPushTextured); - private static final byte _buttonPushInset = _buttonPushTextured + 1; + @Native private static final byte _buttonPushInset = _buttonPushTextured + 1; public static final Widget BUTTON_PUSH_INSET = new Widget(_buttonPushInset); - private static final byte _buttonPushInset2 = _buttonPushInset + 1; + @Native private static final byte _buttonPushInset2 = _buttonPushInset + 1; public static final Widget BUTTON_PUSH_INSET2 = new Widget(_buttonPushInset2); - private static final byte _buttonRadio = _buttonPushInset2 + 1; + @Native private static final byte _buttonRadio = _buttonPushInset2 + 1; public static final Widget BUTTON_RADIO = new Widget(_buttonRadio); - private static final byte _buttonRound = _buttonRadio + 1; + @Native private static final byte _buttonRound = _buttonRadio + 1; public static final Widget BUTTON_ROUND = new Widget(_buttonRound); - private static final byte _buttonRoundHelp = _buttonRound + 1; + @Native private static final byte _buttonRoundHelp = _buttonRound + 1; public static final Widget BUTTON_ROUND_HELP = new Widget(_buttonRoundHelp); - private static final byte _buttonRoundInset = _buttonRoundHelp + 1; + @Native private static final byte _buttonRoundInset = _buttonRoundHelp + 1; public static final Widget BUTTON_ROUND_INSET = new Widget(_buttonRoundInset); - private static final byte _buttonRoundInset2 =_buttonRoundInset + 1; + @Native private static final byte _buttonRoundInset2 =_buttonRoundInset + 1; public static final Widget BUTTON_ROUND_INSET2 = new Widget(_buttonRoundInset2); - private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1; + @Native private static final byte _buttonSearchFieldCancel = _buttonRoundInset2 + 1; public static final Widget BUTTON_SEARCH_FIELD_CANCEL = new Widget(_buttonSearchFieldCancel); - private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1; + @Native private static final byte _buttonSearchFieldFind = _buttonSearchFieldCancel + 1; public static final Widget BUTTON_SEARCH_FIELD_FIND = new Widget(_buttonSearchFieldFind); - private static final byte _buttonSegmented = _buttonSearchFieldFind + 1; + @Native private static final byte _buttonSegmented = _buttonSearchFieldFind + 1; public static final Widget BUTTON_SEGMENTED = new Widget(_buttonSegmented); - private static final byte _buttonSegmentedInset = _buttonSegmented + 1; + @Native private static final byte _buttonSegmentedInset = _buttonSegmented + 1; public static final Widget BUTTON_SEGMENTED_INSET = new Widget(_buttonSegmentedInset); - private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1; + @Native private static final byte _buttonSegmentedInset2 = _buttonSegmentedInset + 1; public static final Widget BUTTON_SEGMENTED_INSET2 = new Widget(_buttonSegmentedInset2); - private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1; + @Native private static final byte _buttonSegmentedSCurve = _buttonSegmentedInset2 + 1; public static final Widget BUTTON_SEGMENTED_SCURVE = new Widget(_buttonSegmentedSCurve); - private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1; + @Native private static final byte _buttonSegmentedTextured = _buttonSegmentedSCurve + 1; public static final Widget BUTTON_SEGMENTED_TEXTURED = new Widget(_buttonSegmentedTextured); - private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1; + @Native private static final byte _buttonSegmentedToolbar = _buttonSegmentedTextured + 1; public static final Widget BUTTON_SEGMENTED_TOOLBAR = new Widget(_buttonSegmentedToolbar); - private static final byte _dial = _buttonSegmentedToolbar + 1; + @Native private static final byte _dial = _buttonSegmentedToolbar + 1; public static final Widget DIAL = new Widget(_dial); - private static final byte _disclosureTriangle = _dial + 1; + @Native private static final byte _disclosureTriangle = _dial + 1; public static final Widget DISCLOSURE_TRIANGLE = new Widget(_disclosureTriangle); - private static final byte _dividerGrabber = _disclosureTriangle + 1; + @Native private static final byte _dividerGrabber = _disclosureTriangle + 1; public static final Widget DIVIDER_GRABBER = new Widget(_dividerGrabber); - private static final byte _dividerSeparatorBar = _dividerGrabber + 1; + @Native private static final byte _dividerSeparatorBar = _dividerGrabber + 1; public static final Widget DIVIDER_SEPARATOR_BAR = new Widget(_dividerSeparatorBar); - private static final byte _dividerSplitter = _dividerSeparatorBar + 1; + @Native private static final byte _dividerSplitter = _dividerSeparatorBar + 1; public static final Widget DIVIDER_SPLITTER = new Widget(_dividerSplitter); - private static final byte _focus = _dividerSplitter + 1; + @Native private static final byte _focus = _dividerSplitter + 1; public static final Widget FOCUS = new Widget(_focus); - private static final byte _frameGroupBox = _focus + 1; + @Native private static final byte _frameGroupBox = _focus + 1; public static final Widget FRAME_GROUP_BOX = new Widget(_frameGroupBox); - private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1; + @Native private static final byte _frameGroupBoxSecondary = _frameGroupBox + 1; public static final Widget FRAME_GROUP_BOX_SECONDARY = new Widget(_frameGroupBoxSecondary); - private static final byte _frameListBox = _frameGroupBoxSecondary + 1; + @Native private static final byte _frameListBox = _frameGroupBoxSecondary + 1; public static final Widget FRAME_LIST_BOX = new Widget(_frameListBox); - private static final byte _framePlacard = _frameListBox + 1; + @Native private static final byte _framePlacard = _frameListBox + 1; public static final Widget FRAME_PLACARD = new Widget(_framePlacard); - private static final byte _frameTextField = _framePlacard + 1; + @Native private static final byte _frameTextField = _framePlacard + 1; public static final Widget FRAME_TEXT_FIELD = new Widget(_frameTextField); - private static final byte _frameTextFieldRound = _frameTextField + 1; + @Native private static final byte _frameTextFieldRound = _frameTextField + 1; public static final Widget FRAME_TEXT_FIELD_ROUND = new Widget(_frameTextFieldRound); - private static final byte _frameWell = _frameTextFieldRound + 1; + @Native private static final byte _frameWell = _frameTextFieldRound + 1; public static final Widget FRAME_WELL = new Widget(_frameWell); - private static final byte _growBox = _frameWell + 1; + @Native private static final byte _growBox = _frameWell + 1; public static final Widget GROW_BOX = new Widget(_growBox); - private static final byte _growBoxTextured = _growBox + 1; + @Native private static final byte _growBoxTextured = _growBox + 1; public static final Widget GROW_BOX_TEXTURED = new Widget(_growBoxTextured); - private static final byte _gradient = _growBoxTextured + 1; + @Native private static final byte _gradient = _growBoxTextured + 1; public static final Widget GRADIENT = new Widget(_gradient); - private static final byte _menu = _gradient + 1; + @Native private static final byte _menu = _gradient + 1; public static final Widget MENU = new Widget(_menu); - private static final byte _menuItem = _menu + 1; + @Native private static final byte _menuItem = _menu + 1; public static final Widget MENU_ITEM = new Widget(_menuItem); - private static final byte _menuBar = _menuItem + 1; + @Native private static final byte _menuBar = _menuItem + 1; public static final Widget MENU_BAR = new Widget(_menuBar); - private static final byte _menuTitle = _menuBar + 1; + @Native private static final byte _menuTitle = _menuBar + 1; public static final Widget MENU_TITLE = new Widget(_menuTitle); - private static final byte _progressBar = _menuTitle + 1; + @Native private static final byte _progressBar = _menuTitle + 1; public static final Widget PROGRESS_BAR = new Widget(_progressBar); - private static final byte _progressIndeterminateBar = _progressBar + 1; + @Native private static final byte _progressIndeterminateBar = _progressBar + 1; public static final Widget PROGRESS_INDETERMINATE_BAR = new Widget(_progressIndeterminateBar); - private static final byte _progressRelevance = _progressIndeterminateBar + 1; + @Native private static final byte _progressRelevance = _progressIndeterminateBar + 1; public static final Widget PROGRESS_RELEVANCE = new Widget(_progressRelevance); - private static final byte _progressSpinner = _progressRelevance + 1; + @Native private static final byte _progressSpinner = _progressRelevance + 1; public static final Widget PROGRESS_SPINNER = new Widget(_progressSpinner); - private static final byte _scrollBar = _progressSpinner + 1; + @Native private static final byte _scrollBar = _progressSpinner + 1; public static final Widget SCROLL_BAR = new Widget(_scrollBar); - private static final byte _scrollColumnSizer = _scrollBar + 1; + @Native private static final byte _scrollColumnSizer = _scrollBar + 1; public static final Widget SCROLL_COLUMN_SIZER = new Widget(_scrollColumnSizer); - private static final byte _slider = _scrollColumnSizer + 1; + @Native private static final byte _slider = _scrollColumnSizer + 1; public static final Widget SLIDER = new Widget(_slider); - private static final byte _sliderThumb = _slider + 1; + @Native private static final byte _sliderThumb = _slider + 1; public static final Widget SLIDER_THUMB = new Widget(_sliderThumb); - private static final byte _synchronization = _sliderThumb + 1; + @Native private static final byte _synchronization = _sliderThumb + 1; public static final Widget SYNCHRONIZATION = new Widget(_synchronization); - private static final byte _tab = _synchronization + 1; + @Native private static final byte _tab = _synchronization + 1; public static final Widget TAB = new Widget(_tab); - private static final byte _titleBarCloseBox = _tab + 1; + @Native private static final byte _titleBarCloseBox = _tab + 1; public static final Widget TITLE_BAR_CLOSE_BOX = new Widget(_titleBarCloseBox); - private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1; + @Native private static final byte _titleBarCollapseBox = _titleBarCloseBox + 1; public static final Widget TITLE_BAR_COLLAPSE_BOX = new Widget(_titleBarCollapseBox); - private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1; + @Native private static final byte _titleBarZoomBox = _titleBarCollapseBox + 1; public static final Widget TITLE_BAR_ZOOM_BOX = new Widget(_titleBarZoomBox); - private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1; + @Native private static final byte _titleBarToolbarButton = _titleBarZoomBox + 1; public static final Widget TITLE_BAR_TOOLBAR_BUTTON = new Widget(_titleBarToolbarButton); - private static final byte _toolbarItemWell = _titleBarToolbarButton + 1; + @Native private static final byte _toolbarItemWell = _titleBarToolbarButton + 1; public static final Widget TOOLBAR_ITEM_WELL = new Widget(_toolbarItemWell); - private static final byte _windowFrame = _toolbarItemWell + 1; + @Native private static final byte _windowFrame = _toolbarItemWell + 1; public static final Widget WINDOW_FRAME = new Widget(_windowFrame); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Hit { - private static final int _unknown = -1; + @Native private static final int _unknown = -1; public static final Hit UNKNOWN = new Hit(_unknown); - private static final int _none = 0; + @Native private static final int _none = 0; public static final Hit NONE = new Hit(_none); - private static final int _hit = 1; + @Native private static final int _hit = 1; public static final Hit HIT = new Hit(_hit); final int hit; @@ -831,24 +777,22 @@ public final class JRSUIConstants { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class ScrollBarHit extends Hit { - private static final int _thumb = 2; + @Native private static final int _thumb = 2; public static final ScrollBarHit THUMB = new ScrollBarHit(_thumb); - private static final int _trackMin = 3; + @Native private static final int _trackMin = 3; public static final ScrollBarHit TRACK_MIN = new ScrollBarHit(_trackMin); - private static final int _trackMax = 4; + @Native private static final int _trackMax = 4; public static final ScrollBarHit TRACK_MAX = new ScrollBarHit(_trackMax); - private static final int _arrowMin = 5; + @Native private static final int _arrowMin = 5; public static final ScrollBarHit ARROW_MIN = new ScrollBarHit(_arrowMin); - private static final int _arrowMax = 6; + @Native private static final int _arrowMax = 6; public static final ScrollBarHit ARROW_MAX = new ScrollBarHit(_arrowMax); - private static final int _arrowMaxInside = 7; + @Native private static final int _arrowMaxInside = 7; public static final ScrollBarHit ARROW_MAX_INSIDE = new ScrollBarHit(_arrowMaxInside); - private static final int _arrowMinInside = 8; + @Native private static final int _arrowMinInside = 8; public static final ScrollBarHit ARROW_MIN_INSIDE = new ScrollBarHit(_arrowMinInside); ScrollBarHit(final int hit) { super(hit); } diff --git a/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java b/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java index 7ad93640215..f5a843bcdbf 100644 --- a/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java +++ b/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -33,17 +33,15 @@ import javax.swing.RootPaneContainer; import com.apple.eawt.AppEvent.FullScreenEvent; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader final class FullScreenHandler { private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalFullScreenHandler"; - static final int FULLSCREEN_WILL_ENTER = 1; - static final int FULLSCREEN_DID_ENTER = 2; - static final int FULLSCREEN_WILL_EXIT = 3; - static final int FULLSCREEN_DID_EXIT = 4; + @Native static final int FULLSCREEN_WILL_ENTER = 1; + @Native static final int FULLSCREEN_DID_ENTER = 2; + @Native static final int FULLSCREEN_WILL_EXIT = 3; + @Native static final int FULLSCREEN_DID_EXIT = 4; // installs a private instance of the handler, if necessary static void addFullScreenListenerTo(final RootPaneContainer window, final FullScreenListener listener) { diff --git a/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java b/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java index 3b4d54f4287..1378a2c808e 100644 --- a/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java +++ b/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -31,18 +31,16 @@ import java.util.List; import javax.swing.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader final class GestureHandler { private static final String CLIENT_PROPERTY = "com.apple.eawt.event.internalGestureHandler"; // native constants for the supported types of high-level gestures - static final int PHASE = 1; - static final int ROTATE = 2; - static final int MAGNIFY = 3; - static final int SWIPE = 4; + @Native static final int PHASE = 1; + @Native static final int ROTATE = 2; + @Native static final int MAGNIFY = 3; + @Native static final int SWIPE = 4; // installs a private instance of GestureHandler, if necessary static void addGestureListenerTo(final JComponent component, final GestureListener listener) { diff --git a/jdk/src/macosx/classes/sun/java2d/OSXSurfaceData.java b/jdk/src/macosx/classes/sun/java2d/OSXSurfaceData.java index 8844d5aa194..2592b6524f0 100644 --- a/jdk/src/macosx/classes/sun/java2d/OSXSurfaceData.java +++ b/jdk/src/macosx/classes/sun/java2d/OSXSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,13 +37,11 @@ import sun.java2d.loops.*; import sun.java2d.pipe.*; import sun.lwawt.macosx.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /* * This is the SurfaceData for a CGContextRef. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class OSXSurfaceData extends BufImgSurfaceData { final static float UPPER_BND = Float.MAX_VALUE / 2.0f; final static float LOWER_BND = -UPPER_BND; @@ -198,147 +196,147 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData { // graphics primitives drawing implementation: // certain primitives don't care about all the states (ex. drawing an image needs not involve setting current paint) - static final int kPrimitive = 0; - static final int kImage = 1; - static final int kText = 2; - static final int kCopyArea = 3; - static final int kExternal = 4; + @Native static final int kPrimitive = 0; + @Native static final int kImage = 1; + @Native static final int kText = 2; + @Native static final int kCopyArea = 3; + @Native static final int kExternal = 4; - static final int kLine = 5; // belongs to kPrimitive - static final int kRect = 6; // belongs to kPrimitive - static final int kRoundRect = 7; // belongs to kPrimitive - static final int kOval = 8; // belongs to kPrimitive - static final int kArc = 9; // belongs to kPrimitive - static final int kPolygon = 10; // belongs to kPrimitive - static final int kShape = 11; // belongs to kPrimitive + @Native static final int kLine = 5; // belongs to kPrimitive + @Native static final int kRect = 6; // belongs to kPrimitive + @Native static final int kRoundRect = 7; // belongs to kPrimitive + @Native static final int kOval = 8; // belongs to kPrimitive + @Native static final int kArc = 9; // belongs to kPrimitive + @Native static final int kPolygon = 10; // belongs to kPrimitive + @Native static final int kShape = 11; // belongs to kPrimitive // static final int kImage = 12; // belongs to kImage - static final int kString = 13; // belongs to kText - static final int kGlyphs = 14; // belongs to kText - static final int kUnicodes = 15; // belongs to kText + @Native static final int kString = 13; // belongs to kText + @Native static final int kGlyphs = 14; // belongs to kText + @Native static final int kUnicodes = 15; // belongs to kText // static final int kCopyArea = 16; // belongs to kCopyArea // static final int kExternal = 17; // belongs to kExternal - static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and + @Native static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and // value(2)) + parameters ((x1, y1, x2, y2) OR (x, y, w, h)) - static final int kLineParametersCount = kCommonParameterCount; // kCommonParameterCount - static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill - static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH + + @Native static final int kLineParametersCount = kCommonParameterCount; // kCommonParameterCount + @Native static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill + @Native static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH + // isfill - static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill - static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle + + @Native static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill + @Native static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle + // arcAngle + isfill + type - static final int kPolygonParametersCount = 0; // not supported - static final int kShapeParametersCount = 0; // not supported - static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst - static final int kStringParametersCount = 0; // not supported - static final int kGlyphsParametersCount = 0; // not supported - static final int kUnicodesParametersCount = 0; // not supported - static final int kPixelParametersCount = 0; // not supported - static final int kExternalParametersCount = 0; // not supported + @Native static final int kPolygonParametersCount = 0; // not supported + @Native static final int kShapeParametersCount = 0; // not supported + @Native static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst + @Native static final int kStringParametersCount = 0; // not supported + @Native static final int kGlyphsParametersCount = 0; // not supported + @Native static final int kUnicodesParametersCount = 0; // not supported + @Native static final int kPixelParametersCount = 0; // not supported + @Native static final int kExternalParametersCount = 0; // not supported // for intParameters // states info - static final int kChangeFlagIndex = 0; // kBoundsChangedBit | .. | kFontChangedBit + @Native static final int kChangeFlagIndex = 0; // kBoundsChangedBit | .. | kFontChangedBit // bounds info - static final int kBoundsXIndex = 1; - static final int kBoundsYIndex = 2; - static final int kBoundsWidthIndex = 3; - static final int kBoundsHeightIndex = 4; + @Native static final int kBoundsXIndex = 1; + @Native static final int kBoundsYIndex = 2; + @Native static final int kBoundsWidthIndex = 3; + @Native static final int kBoundsHeightIndex = 4; // clip info - static final int kClipStateIndex = 5; - static final int kClipNumTypesIndex = 6; - static final int kClipNumCoordsIndex = 7; - static final int kClipWindingRuleIndex = 8; - static final int kClipXIndex = 9; - static final int kClipYIndex = 10; - static final int kClipWidthIndex = 11; - static final int kClipHeightIndex = 12; + @Native static final int kClipStateIndex = 5; + @Native static final int kClipNumTypesIndex = 6; + @Native static final int kClipNumCoordsIndex = 7; + @Native static final int kClipWindingRuleIndex = 8; + @Native static final int kClipXIndex = 9; + @Native static final int kClipYIndex = 10; + @Native static final int kClipWidthIndex = 11; + @Native static final int kClipHeightIndex = 12; // ctm info - static final int kCTMaIndex = 13; - static final int kCTMbIndex = 14; - static final int kCTMcIndex = 15; - static final int kCTMdIndex = 16; - static final int kCTMtxIndex = 17; - static final int kCTMtyIndex = 18; + @Native static final int kCTMaIndex = 13; + @Native static final int kCTMbIndex = 14; + @Native static final int kCTMcIndex = 15; + @Native static final int kCTMdIndex = 16; + @Native static final int kCTMtxIndex = 17; + @Native static final int kCTMtyIndex = 18; // color info - static final int kColorStateIndex = 19; // kColorSimple or kColorGradient or kColorTexture - static final int kColorRGBValueIndex = 20; // if kColorSimple - static final int kColorIndexValueIndex = 21; // if kColorSystem - static final int kColorPointerIndex = 22; // - static final int kColorPointerIndex2 = 23; // - static final int kColorRGBValue1Index = 24; // if kColorGradient - static final int kColorWidthIndex = 25; // if kColorTexture - static final int kColorRGBValue2Index = 26; // if kColorGradient - static final int kColorHeightIndex = 27; // if kColorTexture - static final int kColorIsCyclicIndex = 28; // if kColorGradient (kColorNonCyclic or kColorCyclic) - static final int kColorx1Index = 29; - static final int kColortxIndex = 30; - static final int kColory1Index = 31; - static final int kColortyIndex = 32; - static final int kColorx2Index = 33; - static final int kColorsxIndex = 34; - static final int kColory2Index = 35; - static final int kColorsyIndex = 36; + @Native static final int kColorStateIndex = 19; // kColorSimple or kColorGradient or kColorTexture + @Native static final int kColorRGBValueIndex = 20; // if kColorSimple + @Native static final int kColorIndexValueIndex = 21; // if kColorSystem + @Native static final int kColorPointerIndex = 22; // + @Native static final int kColorPointerIndex2 = 23; // + @Native static final int kColorRGBValue1Index = 24; // if kColorGradient + @Native static final int kColorWidthIndex = 25; // if kColorTexture + @Native static final int kColorRGBValue2Index = 26; // if kColorGradient + @Native static final int kColorHeightIndex = 27; // if kColorTexture + @Native static final int kColorIsCyclicIndex = 28; // if kColorGradient (kColorNonCyclic or kColorCyclic) + @Native static final int kColorx1Index = 29; + @Native static final int kColortxIndex = 30; + @Native static final int kColory1Index = 31; + @Native static final int kColortyIndex = 32; + @Native static final int kColorx2Index = 33; + @Native static final int kColorsxIndex = 34; + @Native static final int kColory2Index = 35; + @Native static final int kColorsyIndex = 36; // composite info - static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor - static final int kCompositeValueIndex = 38; + @Native static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor + @Native static final int kCompositeValueIndex = 38; // stroke info - static final int kStrokeJoinIndex = 39; // see BasicStroke.java - static final int kStrokeCapIndex = 40; // see BasicStroke.java - static final int kStrokeWidthIndex = 41; - static final int kStrokeDashPhaseIndex = 42; - static final int kStrokeLimitIndex = 43; + @Native static final int kStrokeJoinIndex = 39; // see BasicStroke.java + @Native static final int kStrokeCapIndex = 40; // see BasicStroke.java + @Native static final int kStrokeWidthIndex = 41; + @Native static final int kStrokeDashPhaseIndex = 42; + @Native static final int kStrokeLimitIndex = 43; // hints info - static final int kHintsAntialiasIndex = 44; - static final int kHintsTextAntialiasIndex = 45; - static final int kHintsFractionalMetricsIndex = 46; - static final int kHintsRenderingIndex = 47; - static final int kHintsInterpolationIndex = 48; + @Native static final int kHintsAntialiasIndex = 44; + @Native static final int kHintsTextAntialiasIndex = 45; + @Native static final int kHintsFractionalMetricsIndex = 46; + @Native static final int kHintsRenderingIndex = 47; + @Native static final int kHintsInterpolationIndex = 48; // live resizing info - static final int kCanDrawDuringLiveResizeIndex = 49; + @Native static final int kCanDrawDuringLiveResizeIndex = 49; - static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1; + @Native static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1; // for objectParameters - static final int kClipCoordinatesIndex = 0; - static final int kClipTypesIndex = 1; - static final int kTextureImageIndex = 2; - static final int kStrokeDashArrayIndex = 3; - static final int kFontIndex = 4; - static final int kFontPaintIndex = 5; + @Native static final int kClipCoordinatesIndex = 0; + @Native static final int kClipTypesIndex = 1; + @Native static final int kTextureImageIndex = 2; + @Native static final int kStrokeDashArrayIndex = 3; + @Native static final int kFontIndex = 4; + @Native static final int kFontPaintIndex = 5; // possible state changes - static final int kBoundsChangedBit = 1 << 0; - static final int kBoundsNotChangedBit = ~kBoundsChangedBit; - static final int kClipChangedBit = 1 << 1; - static final int kClipNotChangedBit = ~kClipChangedBit; - static final int kCTMChangedBit = 1 << 2; - static final int kCTMNotChangedBit = ~kCTMChangedBit; - static final int kColorChangedBit = 1 << 3; - static final int kColorNotChangedBit = ~kColorChangedBit; - static final int kCompositeChangedBit = 1 << 4; - static final int kCompositeNotChangedBit = ~kCompositeChangedBit; - static final int kStrokeChangedBit = 1 << 5; - static final int kStrokeNotChangedBit = ~kStrokeChangedBit; - static final int kHintsChangedBit = 1 << 6; - static final int kHintsNotChangedBit = ~kHintsChangedBit; - static final int kFontChangedBit = 1 << 7; - static final int kFontNotChangedBit = ~kFontChangedBit; - static final int kEverythingChangedFlag = 0xffffffff; + @Native static final int kBoundsChangedBit = 1 << 0; + @Native static final int kBoundsNotChangedBit = ~kBoundsChangedBit; + @Native static final int kClipChangedBit = 1 << 1; + @Native static final int kClipNotChangedBit = ~kClipChangedBit; + @Native static final int kCTMChangedBit = 1 << 2; + @Native static final int kCTMNotChangedBit = ~kCTMChangedBit; + @Native static final int kColorChangedBit = 1 << 3; + @Native static final int kColorNotChangedBit = ~kColorChangedBit; + @Native static final int kCompositeChangedBit = 1 << 4; + @Native static final int kCompositeNotChangedBit = ~kCompositeChangedBit; + @Native static final int kStrokeChangedBit = 1 << 5; + @Native static final int kStrokeNotChangedBit = ~kStrokeChangedBit; + @Native static final int kHintsChangedBit = 1 << 6; + @Native static final int kHintsNotChangedBit = ~kHintsChangedBit; + @Native static final int kFontChangedBit = 1 << 7; + @Native static final int kFontNotChangedBit = ~kFontChangedBit; + @Native static final int kEverythingChangedFlag = 0xffffffff; // possible color states - static final int kColorSimple = 0; - static final int kColorSystem = 1; - static final int kColorGradient = 2; - static final int kColorTexture = 3; + @Native static final int kColorSimple = 0; + @Native static final int kColorSystem = 1; + @Native static final int kColorGradient = 2; + @Native static final int kColorTexture = 3; // possible gradient color states - static final int kColorNonCyclic = 0; - static final int kColorCyclic = 1; + @Native static final int kColorNonCyclic = 0; + @Native static final int kColorCyclic = 1; // possible clip states - static final int kClipRect = 0; - static final int kClipShape = 1; + @Native static final int kClipRect = 0; + @Native static final int kClipShape = 1; static int getRendererTypeForPrimitive(int primitiveType) { switch (primitiveType) { diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java index a3c48517f59..e94f512b0fb 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CocoaConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,10 +25,7 @@ package sun.lwawt.macosx; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class CocoaConstants { private CocoaConstants(){} diff --git a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs b/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs index 2759733ec6f..b9b0070fcb4 100644 --- a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs +++ b/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs @@ -2,7 +2,7 @@ {- /* - * Copyright (c) 2011,2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -34,7 +34,7 @@ Otherwise, see http://www.haskell.org/ghc/ import Data.List import Data.Maybe -import Char +import Data.Char data Width = W32 | W64 deriving (Show, Eq, Bounded, Enum) @@ -196,8 +196,6 @@ sizeofRet nt = c2java ntype = unlines [ "// native " ++ ntypeS ++ " -> java " ++ jprimS, - "/* No native methods here, but the constants are needed in the supporting JNI code */", - "@GenerateNativeHeader", "public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{", "\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();", "\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }", @@ -248,13 +246,10 @@ main = do putStrLn "package com.apple.jobjc;" putStrLn "import com.apple.jobjc.JObjCRuntime.Width;" - putStrLn "import javax.tools.annotation.GenerateNativeHeader;" putStrLn "// Auto generated by PrimitiveCoder.hs" putStrLn "// Do not edit by hand." - putStrLn "/* No native methods here, but the constants are needed in the supporting JNI code */" - putStrLn "@GenerateNativeHeader" putStrLn "public abstract class PrimitiveCoder extends Coder{" putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){" diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java index 9f05ed7b0e0..5207cf81d57 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,10 +24,7 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class CFType extends Pointer { protected CFType(long ptr) { super(ptr); } protected CFType(Pointer ptr) { super(ptr.ptr); } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java index eb8387ae4a2..6087f1fd076 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,26 +35,26 @@ import com.apple.jobjc.PrimitiveCoder.SCharCoder; import com.apple.jobjc.PrimitiveCoder.SIntCoder; import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; import com.apple.jobjc.PrimitiveCoder.SShortCoder; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; public abstract class Coder { private static native long getNativeFFITypePtrForCode(final int code); - static final int FFI_VOID = 0; - static final int FFI_PTR = FFI_VOID+1; + @Native static final int FFI_VOID = 0; + @Native static final int FFI_PTR = FFI_VOID+1; - static final int FFI_SINT8 = FFI_PTR+1; - static final int FFI_UINT8 = FFI_SINT8+1; - static final int FFI_SINT16 = FFI_UINT8+1; - static final int FFI_UINT16 = FFI_SINT16+1; - static final int FFI_SINT32 = FFI_UINT16+1; - static final int FFI_UINT32 = FFI_SINT32+1; - static final int FFI_SINT64 = FFI_UINT32+1; - static final int FFI_UINT64 = FFI_SINT64+1; + @Native static final int FFI_SINT8 = FFI_PTR+1; + @Native static final int FFI_UINT8 = FFI_SINT8+1; + @Native static final int FFI_SINT16 = FFI_UINT8+1; + @Native static final int FFI_UINT16 = FFI_SINT16+1; + @Native static final int FFI_SINT32 = FFI_UINT16+1; + @Native static final int FFI_UINT32 = FFI_SINT32+1; + @Native static final int FFI_SINT64 = FFI_UINT32+1; + @Native static final int FFI_UINT64 = FFI_SINT64+1; - static final int FFI_FLOAT = FFI_UINT64+1; - static final int FFI_DOUBLE = FFI_FLOAT+1; - static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; + @Native static final int FFI_FLOAT = FFI_UINT64+1; + @Native static final int FFI_DOUBLE = FFI_FLOAT+1; + @Native static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; private static long[] ffiCodesToFFITypePtrs; static{ @@ -143,8 +143,6 @@ public abstract class Coder { // - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class VoidCoder extends Coder{ public static final VoidCoder INST = new VoidCoder(); public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); } @@ -153,8 +151,6 @@ public abstract class Coder { @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class UnknownCoder extends Coder { public static final UnknownCoder INST = new UnknownCoder(); public UnknownCoder(){ super(-1, "?", null, null); } @@ -163,8 +159,6 @@ public abstract class Coder { @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class PrimitivePointerCoder extends Coder { public static final PrimitivePointerCoder INST = new PrimitivePointerCoder(); public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); } @@ -194,8 +188,6 @@ public abstract class Coder { @Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class PointerCoder extends Coder { public static final PointerCoder INST = new PointerCoder(); public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); } @@ -209,8 +201,6 @@ public abstract class Coder { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class SELCoder extends Coder { public static final SELCoder INST = new SELCoder(); public SELCoder(){ super(FFI_PTR, ":", SEL.class); } @@ -224,8 +214,6 @@ public abstract class Coder { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static abstract class StructCoder extends Coder { private final FFIType ffiType; final int sizeof; @@ -267,8 +255,6 @@ public abstract class Coder { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class IDCoder extends Coder{ public static final IDCoder INST = new IDCoder(); public IDCoder(){ super(FFI_PTR, "@", ID.class); } @@ -287,8 +273,6 @@ public abstract class Coder { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class NSClassCoder extends Coder{ public static final NSClassCoder INST = new NSClassCoder(); public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java index 9927edf55f3..dcff0035587 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,7 @@ package com.apple.jobjc; import com.apple.jobjc.Coder.PrimitivePointerCoder; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader class FFIType{ private static native void makeFFIType(long ffi_type_buf, long elements_buf); private static native int getFFITypeSizeof(); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java index cbbc35900ae..413d8fafe76 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,10 +24,7 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class Function { private static native long getFxnPtrForFunctionName(final String functionName); private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java index 084a55f2cd4..aa202cf0943 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,10 +29,7 @@ import java.lang.reflect.Constructor; import java.util.LinkedHashMap; import java.util.Map; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ID extends Pointer{ static native String getNativeDescription(final long objPtr); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java index 58518434230..48ffc98663f 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -30,18 +30,13 @@ import com.apple.jobjc.Coder.PrimitivePointerCoder; import com.apple.jobjc.Coder.SELCoder; import com.apple.jobjc.Coder.StructCoder; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class Invoke { public abstract void invoke(NativeArgumentBuffer argBuf); public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct); // - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class FunCall extends Invoke{ static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr); @@ -78,8 +73,6 @@ public abstract class Invoke { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class MsgSend extends Invoke{ static{ System.load("/usr/lib/libobjc.dylib"); } @@ -165,8 +158,6 @@ public abstract class Invoke { } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static final class MsgSendSuper extends Invoke{ static{ System.load("/usr/lib/libobjc.dylib"); } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java index e6757ceb63e..5bc01bc4e97 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -31,16 +31,11 @@ import java.util.List; import sun.misc.Unsafe; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class JObjCRuntime { static { System.loadLibrary("JObjC"); } - @GenerateNativeHeader public static enum Arch{ ppc, i386, x86_64 }; - @GenerateNativeHeader public static enum Width{ W32, W64 }; public static final Arch ARCH = getArch(); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java index bb70553b0a9..bd776688f7d 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,10 +25,7 @@ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class MacOSXFramework { private static native long retainFramework(final String frameworkName); private static native void releaseFramework(final long frameworkPtr); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java index c116bc69309..dfda99acf35 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,13 +27,8 @@ package com.apple.jobjc; import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class NSClass extends ID { - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class NSClassNotFoundException extends RuntimeException{ public NSClassNotFoundException(String m){ super(m); } public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java index be6a009abf6..7f8949a2b40 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -28,10 +28,7 @@ import java.nio.ByteOrder; import com.apple.jobjc.Coder.PrimitivePointerCoder; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class NativeArgumentBuffer{ private static final ThreadLocal threadLocal = new ThreadLocal(); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java index 229a2455995..8630971c206 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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,13 +27,10 @@ package com.apple.jobjc; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import javax.tools.annotation.GenerateNativeHeader; /** * A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class NativeBuffer { static native long getPtrOfBuffer(final ByteBuffer byteBuffer); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java index 78f4ca56bba..993be3337fe 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,10 +24,7 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class NativeObjectLifecycleManager { private static native void retainNativeObject(final long ptr); private static native void releaseNativeObject(final long ptr); @@ -37,8 +34,6 @@ public abstract class NativeObjectLifecycleManager { abstract void end(final long ptr); boolean shouldPreRetain() { return false; } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class CFRetainRelease extends NativeObjectLifecycleManager { public static final NativeObjectLifecycleManager INST = new CFRetainRelease(); @Override void begin(final long ptr) { retainNativeObject(ptr); } @@ -46,16 +41,12 @@ public abstract class NativeObjectLifecycleManager { @Override boolean shouldPreRetain() { return true; } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Free extends NativeObjectLifecycleManager { public static final NativeObjectLifecycleManager INST = new Free(); @Override void begin(final long ptr) { } @Override void end(final long ptr) { freeNativeObject(ptr); } } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader public static class Nothing extends NativeObjectLifecycleManager { public static final NativeObjectLifecycleManager INST = new Nothing(); @Override void begin(final long ptr) { } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java index 1a362d6741c..fe6684833e0 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,10 +24,7 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class Opaque extends Pointer { protected Opaque(long ptr) { super(ptr); } protected Opaque(Pointer ptr) { super(ptr.ptr); } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java index 1cd728cce1f..d5b83b93930 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,10 +24,7 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class Pointer implements Comparable>{ long ptr; diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java index 975b88848d5..eab34a7e6af 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,11 +24,8 @@ */ package com.apple.jobjc; import com.apple.jobjc.JObjCRuntime.Width; -import javax.tools.annotation.GenerateNativeHeader; // Auto generated by PrimitiveCoder.hs // Do not edit by hand. -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class PrimitiveCoder extends Coder{ public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){ super(ffiTypeCode, objCEncoding, jclass, jprim); @@ -130,8 +127,6 @@ public abstract class PrimitiveCoder extends Coder{ // native BOOL -> java boolean -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class BoolCoder extends PrimitiveCoder{ public static final BoolCoder INST = new BoolCoder(); public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); } @@ -175,8 +170,6 @@ public static final class BoolCoder extends PrimitiveCoder{ } // native schar -> java byte -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class SCharCoder extends PrimitiveCoder{ public static final SCharCoder INST = new SCharCoder(); public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); } @@ -220,8 +213,6 @@ public static final class SCharCoder extends PrimitiveCoder{ } // native uchar -> java byte -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class UCharCoder extends PrimitiveCoder{ public static final UCharCoder INST = new UCharCoder(); public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); } @@ -265,8 +256,6 @@ public static final class UCharCoder extends PrimitiveCoder{ } // native sshort -> java short -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class SShortCoder extends PrimitiveCoder{ public static final SShortCoder INST = new SShortCoder(); public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); } @@ -310,8 +299,6 @@ public static final class SShortCoder extends PrimitiveCoder{ } // native ushort -> java short -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class UShortCoder extends PrimitiveCoder{ public static final UShortCoder INST = new UShortCoder(); public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); } @@ -355,8 +342,6 @@ public static final class UShortCoder extends PrimitiveCoder{ } // native sint -> java int -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class SIntCoder extends PrimitiveCoder{ public static final SIntCoder INST = new SIntCoder(); public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); } @@ -400,8 +385,6 @@ public static final class SIntCoder extends PrimitiveCoder{ } // native uint -> java int -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class UIntCoder extends PrimitiveCoder{ public static final UIntCoder INST = new UIntCoder(); public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); } @@ -445,8 +428,6 @@ public static final class UIntCoder extends PrimitiveCoder{ } // native slong -> java long -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class SLongCoder extends PrimitiveCoder{ public static final SLongCoder INST = new SLongCoder(); public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); } @@ -496,8 +477,6 @@ public static final class SLongCoder extends PrimitiveCoder{ } // native ulong -> java long -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class ULongCoder extends PrimitiveCoder{ public static final ULongCoder INST = new ULongCoder(); public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); } @@ -547,8 +526,6 @@ public static final class ULongCoder extends PrimitiveCoder{ } // native slonglong -> java long -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class SLongLongCoder extends PrimitiveCoder{ public static final SLongLongCoder INST = new SLongLongCoder(); public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); } @@ -592,8 +569,6 @@ public static final class SLongLongCoder extends PrimitiveCoder{ } // native ulonglong -> java long -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class ULongLongCoder extends PrimitiveCoder{ public static final ULongLongCoder INST = new ULongLongCoder(); public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); } @@ -637,8 +612,6 @@ public static final class ULongLongCoder extends PrimitiveCoder{ } // native float -> java float -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class FloatCoder extends PrimitiveCoder{ public static final FloatCoder INST = new FloatCoder(); public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); } @@ -682,8 +655,6 @@ public static final class FloatCoder extends PrimitiveCoder{ } // native double -> java double -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public static final class DoubleCoder extends PrimitiveCoder{ public static final DoubleCoder INST = new DoubleCoder(); public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); } diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java index 0dfcf3f7e6e..7e085f8d54d 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,10 +24,7 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class SEL { static native long getSelectorPtr(String selectorName); static native String getSelectorName(long ptr); diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java index 1d1ddfff7d7..b14e84dcaca 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,13 +24,10 @@ */ package com.apple.jobjc; -import javax.tools.annotation.GenerateNativeHeader; /** * A struct is malloced on the C heap and accessed in Java through a ByteBuffer. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class Struct{ protected final NativeBuffer raw; private final JObjCRuntime runtime; diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java index 04961a3d014..c0e72b13e33 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -33,10 +33,7 @@ import com.apple.jobjc.Coder.PrimitivePointerCoder; import com.apple.jobjc.Coder.VoidCoder; import com.apple.jobjc.Invoke.MsgSend; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader final class Subclassing { static native long allocateClassPair(long superClass, String name); static native boolean addIVarForJObj(long clazz); diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m b/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m index f756034bd2c..28a11d92d80 100644 --- a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m +++ b/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -24,8 +24,6 @@ */ #include "com_apple_jobjc_Invoke_FunCall.h" -#include "com_apple_jobjc_Invoke_MsgSend.h" -#include "com_apple_jobjc_Invoke_MsgSendSuper.h" #include #include #include diff --git a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m b/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m index cd4cdddc067..dfb5b48676a 100644 --- a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m +++ b/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -23,6 +23,5 @@ * questions. */ -#include "com_apple_jobjc_JObjCRuntime.h" #include "Cocoa/Cocoa.h" diff --git a/jdk/src/macosx/native/sun/awt/PrinterView.m b/jdk/src/macosx/native/sun/awt/PrinterView.m index b7134090c73..0400f5e9cbb 100644 --- a/jdk/src/macosx/native/sun/awt/PrinterView.m +++ b/jdk/src/macosx/native/sun/awt/PrinterView.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #import "PrinterView.h" #import "java_awt_print_Pageable.h" -#import "java_awt_print_Printable.h" #import "java_awt_print_PageFormat.h" #import diff --git a/jdk/src/share/classes/java/awt/Adjustable.java b/jdk/src/share/classes/java/awt/Adjustable.java index 53d5152d0fb..6193a07c965 100644 --- a/jdk/src/share/classes/java/awt/Adjustable.java +++ b/jdk/src/share/classes/java/awt/Adjustable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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,7 +27,7 @@ package java.awt; import java.awt.event.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The interface for objects which have an adjustable numeric value @@ -36,24 +36,22 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Amy Fowler * @author Tim Prinzing */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface Adjustable { /** * Indicates that the Adjustable has horizontal orientation. */ - public static final int HORIZONTAL = 0; + @Native public static final int HORIZONTAL = 0; /** * Indicates that the Adjustable has vertical orientation. */ - public static final int VERTICAL = 1; + @Native public static final int VERTICAL = 1; /** * Indicates that the Adjustable has no orientation. */ - public static final int NO_ORIENTATION = 2; + @Native public static final int NO_ORIENTATION = 2; /** * Gets the orientation of the adjustable object. diff --git a/jdk/src/share/classes/java/awt/AlphaComposite.java b/jdk/src/share/classes/java/awt/AlphaComposite.java index 0889642dd59..6903e7ec712 100644 --- a/jdk/src/share/classes/java/awt/AlphaComposite.java +++ b/jdk/src/share/classes/java/awt/AlphaComposite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package java.awt; import java.awt.image.ColorModel; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.java2d.SunCompositeContext; /** @@ -350,8 +350,6 @@ import sun.java2d.SunCompositeContext; * @see CompositeContext */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class AlphaComposite implements Composite { /** * Both the color and the alpha of the destination are cleared @@ -364,7 +362,7 @@ public final class AlphaComposite implements Composite { * Cr = 0 * */ - public static final int CLEAR = 1; + @Native public static final int CLEAR = 1; /** * The source is copied to the destination @@ -377,7 +375,7 @@ public final class AlphaComposite implements Composite { * Cr = Cs * */ - public static final int SRC = 2; + @Native public static final int SRC = 2; /** * The destination is left untouched @@ -390,7 +388,7 @@ public final class AlphaComposite implements Composite { * * @since 1.4 */ - public static final int DST = 9; + @Native public static final int DST = 9; // Note that DST was added in 1.4 so it is numbered out of order... /** @@ -403,7 +401,7 @@ public final class AlphaComposite implements Composite { * Cr = Cs + Cd*(1-As) * */ - public static final int SRC_OVER = 3; + @Native public static final int SRC_OVER = 3; /** * The destination is composited over the source and @@ -416,7 +414,7 @@ public final class AlphaComposite implements Composite { * Cr = Cs*(1-Ad) + Cd * */ - public static final int DST_OVER = 4; + @Native public static final int DST_OVER = 4; /** * The part of the source lying inside of the destination replaces @@ -429,7 +427,7 @@ public final class AlphaComposite implements Composite { * Cr = Cs*Ad * */ - public static final int SRC_IN = 5; + @Native public static final int SRC_IN = 5; /** * The part of the destination lying inside of the source @@ -442,7 +440,7 @@ public final class AlphaComposite implements Composite { * Cr = Cd*As * */ - public static final int DST_IN = 6; + @Native public static final int DST_IN = 6; /** * The part of the source lying outside of the destination @@ -455,7 +453,7 @@ public final class AlphaComposite implements Composite { * Cr = Cs*(1-Ad) * */ - public static final int SRC_OUT = 7; + @Native public static final int SRC_OUT = 7; /** * The part of the destination lying outside of the source @@ -468,7 +466,7 @@ public final class AlphaComposite implements Composite { * Cr = Cd*(1-As) * */ - public static final int DST_OUT = 8; + @Native public static final int DST_OUT = 8; // Rule 9 is DST which is defined above where it fits into the // list logically, rather than numerically @@ -487,7 +485,7 @@ public final class AlphaComposite implements Composite { * * @since 1.4 */ - public static final int SRC_ATOP = 10; + @Native public static final int SRC_ATOP = 10; /** * The part of the destination lying inside of the source @@ -501,7 +499,7 @@ public final class AlphaComposite implements Composite { * * @since 1.4 */ - public static final int DST_ATOP = 11; + @Native public static final int DST_ATOP = 11; /** * The part of the source that lies outside of the destination @@ -516,7 +514,7 @@ public final class AlphaComposite implements Composite { * * @since 1.4 */ - public static final int XOR = 12; + @Native public static final int XOR = 12; /** * AlphaComposite object that implements the opaque CLEAR rule @@ -606,8 +604,8 @@ public final class AlphaComposite implements Composite { */ public static final AlphaComposite Xor = new AlphaComposite(XOR); - private static final int MIN_RULE = CLEAR; - private static final int MAX_RULE = XOR; + @Native private static final int MIN_RULE = CLEAR; + @Native private static final int MAX_RULE = XOR; float extraAlpha; int rule; diff --git a/jdk/src/share/classes/java/awt/BasicStroke.java b/jdk/src/share/classes/java/awt/BasicStroke.java index 2e5c8de2c5b..55d59d4224f 100644 --- a/jdk/src/share/classes/java/awt/BasicStroke.java +++ b/jdk/src/share/classes/java/awt/BasicStroke.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,7 +27,7 @@ package java.awt; import java.beans.ConstructorProperties; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The BasicStroke class defines a basic set of rendering @@ -111,47 +111,45 @@ import javax.tools.annotation.GenerateNativeHeader; * @see Graphics2D * @author Jim Graham */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class BasicStroke implements Stroke { /** * Joins path segments by extending their outside edges until * they meet. */ - public final static int JOIN_MITER = 0; + @Native public final static int JOIN_MITER = 0; /** * Joins path segments by rounding off the corner at a radius * of half the line width. */ - public final static int JOIN_ROUND = 1; + @Native public final static int JOIN_ROUND = 1; /** * Joins path segments by connecting the outer corners of their * wide outlines with a straight segment. */ - public final static int JOIN_BEVEL = 2; + @Native public final static int JOIN_BEVEL = 2; /** * Ends unclosed subpaths and dash segments with no added * decoration. */ - public final static int CAP_BUTT = 0; + @Native public final static int CAP_BUTT = 0; /** * Ends unclosed subpaths and dash segments with a round * decoration that has a radius equal to half of the width * of the pen. */ - public final static int CAP_ROUND = 1; + @Native public final static int CAP_ROUND = 1; /** * Ends unclosed subpaths and dash segments with a square * projection that extends beyond the end of the segment * to a distance equal to half of the line width. */ - public final static int CAP_SQUARE = 2; + @Native public final static int CAP_SQUARE = 2; float width; diff --git a/jdk/src/share/classes/java/awt/Choice.java b/jdk/src/share/classes/java/awt/Choice.java index 9ef765818dc..e026953b203 100644 --- a/jdk/src/share/classes/java/awt/Choice.java +++ b/jdk/src/share/classes/java/awt/Choice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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 @@ -34,7 +34,6 @@ import java.io.IOException; import javax.accessibility.*; -import javax.tools.annotation.GenerateNativeHeader; /** * The Choice class presents a pop-up menu of choices. @@ -71,8 +70,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Arthur van Hoff * @since JDK1.0 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class Choice extends Component implements ItemSelectable, Accessible { /** * The items for the Choice. diff --git a/jdk/src/share/classes/java/awt/DisplayMode.java b/jdk/src/share/classes/java/awt/DisplayMode.java index a4ca0f18a42..c4bd09530e0 100644 --- a/jdk/src/share/classes/java/awt/DisplayMode.java +++ b/jdk/src/share/classes/java/awt/DisplayMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, 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,7 +25,7 @@ package java.awt; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The DisplayMode class encapsulates the bit depth, height, @@ -46,8 +46,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @since 1.4 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class DisplayMode { private Dimension size; @@ -94,7 +92,7 @@ public final class DisplayMode { * display mode. * @see #getBitDepth */ - public final static int BIT_DEPTH_MULTI = -1; + @Native public final static int BIT_DEPTH_MULTI = -1; /** * Returns the bit depth of the display, in bits per pixel. This may be @@ -112,7 +110,7 @@ public final class DisplayMode { * Value of the refresh rate if not known. * @see #getRefreshRate */ - public final static int REFRESH_RATE_UNKNOWN = 0; + @Native public final static int REFRESH_RATE_UNKNOWN = 0; /** * Returns the refresh rate of the display, in hertz. This may be diff --git a/jdk/src/share/classes/java/awt/Image.java b/jdk/src/share/classes/java/awt/Image.java index 521509d2e15..ce23169ea3c 100644 --- a/jdk/src/share/classes/java/awt/Image.java +++ b/jdk/src/share/classes/java/awt/Image.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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 @@ -33,7 +33,6 @@ import java.awt.image.ReplicateScaleFilter; import sun.awt.image.SurfaceManager; -import javax.tools.annotation.GenerateNativeHeader; /** * The abstract class Image is the superclass of all @@ -44,8 +43,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Arthur van Hoff * @since JDK1.0 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class Image { /** diff --git a/jdk/src/share/classes/java/awt/List.java b/jdk/src/share/classes/java/awt/List.java index 562f4000c88..92a1867d882 100644 --- a/jdk/src/share/classes/java/awt/List.java +++ b/jdk/src/share/classes/java/awt/List.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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 @@ -33,7 +33,6 @@ import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.IOException; import javax.accessibility.*; -import javax.tools.annotation.GenerateNativeHeader; /** @@ -107,8 +106,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @see java.awt.event.ActionListener * @since JDK1.0 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class List extends Component implements ItemSelectable, Accessible { /** * A vector created to contain items which will become diff --git a/jdk/src/share/classes/java/awt/PopupMenu.java b/jdk/src/share/classes/java/awt/PopupMenu.java index 1c700a181aa..0e700638240 100644 --- a/jdk/src/share/classes/java/awt/PopupMenu.java +++ b/jdk/src/share/classes/java/awt/PopupMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -28,7 +28,6 @@ package java.awt; import java.awt.peer.PopupMenuPeer; import javax.accessibility.*; -import javax.tools.annotation.GenerateNativeHeader; import sun.awt.AWTAccessor; @@ -44,8 +43,6 @@ import sun.awt.AWTAccessor; * * @author Amy Fowler */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class PopupMenu extends Menu { private static final String base = "popup"; diff --git a/jdk/src/share/classes/java/awt/SystemColor.java b/jdk/src/share/classes/java/awt/SystemColor.java index a5e245663e8..931cf326fb5 100644 --- a/jdk/src/share/classes/java/awt/SystemColor.java +++ b/jdk/src/share/classes/java/awt/SystemColor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package java.awt; import java.io.ObjectStreamException; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * A class to encapsulate symbolic colors representing the color of @@ -49,8 +49,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Carl Quinn * @author Amy Fowler */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class SystemColor extends Color implements java.io.Serializable { /** @@ -58,187 +56,187 @@ public final class SystemColor extends Color implements java.io.Serializable { * {@link #desktop} system color. * @see SystemColor#desktop */ - public final static int DESKTOP = 0; + @Native public final static int DESKTOP = 0; /** * The array index for the * {@link #activeCaption} system color. * @see SystemColor#activeCaption */ - public final static int ACTIVE_CAPTION = 1; + @Native public final static int ACTIVE_CAPTION = 1; /** * The array index for the * {@link #activeCaptionText} system color. * @see SystemColor#activeCaptionText */ - public final static int ACTIVE_CAPTION_TEXT = 2; + @Native public final static int ACTIVE_CAPTION_TEXT = 2; /** * The array index for the * {@link #activeCaptionBorder} system color. * @see SystemColor#activeCaptionBorder */ - public final static int ACTIVE_CAPTION_BORDER = 3; + @Native public final static int ACTIVE_CAPTION_BORDER = 3; /** * The array index for the * {@link #inactiveCaption} system color. * @see SystemColor#inactiveCaption */ - public final static int INACTIVE_CAPTION = 4; + @Native public final static int INACTIVE_CAPTION = 4; /** * The array index for the * {@link #inactiveCaptionText} system color. * @see SystemColor#inactiveCaptionText */ - public final static int INACTIVE_CAPTION_TEXT = 5; + @Native public final static int INACTIVE_CAPTION_TEXT = 5; /** * The array index for the * {@link #inactiveCaptionBorder} system color. * @see SystemColor#inactiveCaptionBorder */ - public final static int INACTIVE_CAPTION_BORDER = 6; + @Native public final static int INACTIVE_CAPTION_BORDER = 6; /** * The array index for the * {@link #window} system color. * @see SystemColor#window */ - public final static int WINDOW = 7; + @Native public final static int WINDOW = 7; /** * The array index for the * {@link #windowBorder} system color. * @see SystemColor#windowBorder */ - public final static int WINDOW_BORDER = 8; + @Native public final static int WINDOW_BORDER = 8; /** * The array index for the * {@link #windowText} system color. * @see SystemColor#windowText */ - public final static int WINDOW_TEXT = 9; + @Native public final static int WINDOW_TEXT = 9; /** * The array index for the * {@link #menu} system color. * @see SystemColor#menu */ - public final static int MENU = 10; + @Native public final static int MENU = 10; /** * The array index for the * {@link #menuText} system color. * @see SystemColor#menuText */ - public final static int MENU_TEXT = 11; + @Native public final static int MENU_TEXT = 11; /** * The array index for the * {@link #text} system color. * @see SystemColor#text */ - public final static int TEXT = 12; + @Native public final static int TEXT = 12; /** * The array index for the * {@link #textText} system color. * @see SystemColor#textText */ - public final static int TEXT_TEXT = 13; + @Native public final static int TEXT_TEXT = 13; /** * The array index for the * {@link #textHighlight} system color. * @see SystemColor#textHighlight */ - public final static int TEXT_HIGHLIGHT = 14; + @Native public final static int TEXT_HIGHLIGHT = 14; /** * The array index for the * {@link #textHighlightText} system color. * @see SystemColor#textHighlightText */ - public final static int TEXT_HIGHLIGHT_TEXT = 15; + @Native public final static int TEXT_HIGHLIGHT_TEXT = 15; /** * The array index for the * {@link #textInactiveText} system color. * @see SystemColor#textInactiveText */ - public final static int TEXT_INACTIVE_TEXT = 16; + @Native public final static int TEXT_INACTIVE_TEXT = 16; /** * The array index for the * {@link #control} system color. * @see SystemColor#control */ - public final static int CONTROL = 17; + @Native public final static int CONTROL = 17; /** * The array index for the * {@link #controlText} system color. * @see SystemColor#controlText */ - public final static int CONTROL_TEXT = 18; + @Native public final static int CONTROL_TEXT = 18; /** * The array index for the * {@link #controlHighlight} system color. * @see SystemColor#controlHighlight */ - public final static int CONTROL_HIGHLIGHT = 19; + @Native public final static int CONTROL_HIGHLIGHT = 19; /** * The array index for the * {@link #controlLtHighlight} system color. * @see SystemColor#controlLtHighlight */ - public final static int CONTROL_LT_HIGHLIGHT = 20; + @Native public final static int CONTROL_LT_HIGHLIGHT = 20; /** * The array index for the * {@link #controlShadow} system color. * @see SystemColor#controlShadow */ - public final static int CONTROL_SHADOW = 21; + @Native public final static int CONTROL_SHADOW = 21; /** * The array index for the * {@link #controlDkShadow} system color. * @see SystemColor#controlDkShadow */ - public final static int CONTROL_DK_SHADOW = 22; + @Native public final static int CONTROL_DK_SHADOW = 22; /** * The array index for the * {@link #scrollbar} system color. * @see SystemColor#scrollbar */ - public final static int SCROLLBAR = 23; + @Native public final static int SCROLLBAR = 23; /** * The array index for the * {@link #info} system color. * @see SystemColor#info */ - public final static int INFO = 24; + @Native public final static int INFO = 24; /** * The array index for the * {@link #infoText} system color. * @see SystemColor#infoText */ - public final static int INFO_TEXT = 25; + @Native public final static int INFO_TEXT = 25; /** * The number of system colors in the array. */ - public final static int NUM_COLORS = 26; + @Native public final static int NUM_COLORS = 26; /******************************************************************************************/ diff --git a/jdk/src/share/classes/java/awt/TextComponent.java b/jdk/src/share/classes/java/awt/TextComponent.java index 0a2fe254fc3..7a6cd26bbf3 100644 --- a/jdk/src/share/classes/java/awt/TextComponent.java +++ b/jdk/src/share/classes/java/awt/TextComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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,7 +35,6 @@ import java.text.BreakIterator; import javax.swing.text.AttributeSet; import javax.accessibility.*; import java.awt.im.InputMethodRequests; -import javax.tools.annotation.GenerateNativeHeader; /** * The TextComponent class is the superclass of @@ -57,8 +56,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Arthur van Hoff * @since JDK1.0 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class TextComponent extends Component implements Accessible { /** diff --git a/jdk/src/share/classes/java/awt/Transparency.java b/jdk/src/share/classes/java/awt/Transparency.java index e968ebbf6d1..2c8f845a473 100644 --- a/jdk/src/share/classes/java/awt/Transparency.java +++ b/jdk/src/share/classes/java/awt/Transparency.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,34 +25,32 @@ package java.awt; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The Transparency interface defines the common transparency * modes for implementing classes. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface Transparency { /** * Represents image data that is guaranteed to be completely opaque, * meaning that all pixels have an alpha value of 1.0. */ - public final static int OPAQUE = 1; + @Native public final static int OPAQUE = 1; /** * Represents image data that is guaranteed to be either completely * opaque, with an alpha value of 1.0, or completely transparent, * with an alpha value of 0.0. */ - public final static int BITMASK = 2; + @Native public final static int BITMASK = 2; /** * Represents image data that contains or might contain arbitrary * alpha values between and including 0.0 and 1.0. */ - public final static int TRANSLUCENT = 3; + @Native public final static int TRANSLUCENT = 3; /** * Returns the type of this Transparency. diff --git a/jdk/src/share/classes/java/awt/color/ColorSpace.java b/jdk/src/share/classes/java/awt/color/ColorSpace.java index f4ca58b37af..c0bcb4938c3 100644 --- a/jdk/src/share/classes/java/awt/color/ColorSpace.java +++ b/jdk/src/share/classes/java/awt/color/ColorSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,7 +35,7 @@ package java.awt.color; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.java2d.cmm.PCMM; import sun.java2d.cmm.CMSManager; @@ -95,8 +95,6 @@ import sun.java2d.cmm.CMSManager; * @see ICC_ColorSpace */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class ColorSpace implements java.io.Serializable { static final long serialVersionUID = -409452704308689724L; @@ -115,127 +113,127 @@ public abstract class ColorSpace implements java.io.Serializable { /** * Any of the family of XYZ color spaces. */ - public static final int TYPE_XYZ = 0; + @Native public static final int TYPE_XYZ = 0; /** * Any of the family of Lab color spaces. */ - public static final int TYPE_Lab = 1; + @Native public static final int TYPE_Lab = 1; /** * Any of the family of Luv color spaces. */ - public static final int TYPE_Luv = 2; + @Native public static final int TYPE_Luv = 2; /** * Any of the family of YCbCr color spaces. */ - public static final int TYPE_YCbCr = 3; + @Native public static final int TYPE_YCbCr = 3; /** * Any of the family of Yxy color spaces. */ - public static final int TYPE_Yxy = 4; + @Native public static final int TYPE_Yxy = 4; /** * Any of the family of RGB color spaces. */ - public static final int TYPE_RGB = 5; + @Native public static final int TYPE_RGB = 5; /** * Any of the family of GRAY color spaces. */ - public static final int TYPE_GRAY = 6; + @Native public static final int TYPE_GRAY = 6; /** * Any of the family of HSV color spaces. */ - public static final int TYPE_HSV = 7; + @Native public static final int TYPE_HSV = 7; /** * Any of the family of HLS color spaces. */ - public static final int TYPE_HLS = 8; + @Native public static final int TYPE_HLS = 8; /** * Any of the family of CMYK color spaces. */ - public static final int TYPE_CMYK = 9; + @Native public static final int TYPE_CMYK = 9; /** * Any of the family of CMY color spaces. */ - public static final int TYPE_CMY = 11; + @Native public static final int TYPE_CMY = 11; /** * Generic 2 component color spaces. */ - public static final int TYPE_2CLR = 12; + @Native public static final int TYPE_2CLR = 12; /** * Generic 3 component color spaces. */ - public static final int TYPE_3CLR = 13; + @Native public static final int TYPE_3CLR = 13; /** * Generic 4 component color spaces. */ - public static final int TYPE_4CLR = 14; + @Native public static final int TYPE_4CLR = 14; /** * Generic 5 component color spaces. */ - public static final int TYPE_5CLR = 15; + @Native public static final int TYPE_5CLR = 15; /** * Generic 6 component color spaces. */ - public static final int TYPE_6CLR = 16; + @Native public static final int TYPE_6CLR = 16; /** * Generic 7 component color spaces. */ - public static final int TYPE_7CLR = 17; + @Native public static final int TYPE_7CLR = 17; /** * Generic 8 component color spaces. */ - public static final int TYPE_8CLR = 18; + @Native public static final int TYPE_8CLR = 18; /** * Generic 9 component color spaces. */ - public static final int TYPE_9CLR = 19; + @Native public static final int TYPE_9CLR = 19; /** * Generic 10 component color spaces. */ - public static final int TYPE_ACLR = 20; + @Native public static final int TYPE_ACLR = 20; /** * Generic 11 component color spaces. */ - public static final int TYPE_BCLR = 21; + @Native public static final int TYPE_BCLR = 21; /** * Generic 12 component color spaces. */ - public static final int TYPE_CCLR = 22; + @Native public static final int TYPE_CCLR = 22; /** * Generic 13 component color spaces. */ - public static final int TYPE_DCLR = 23; + @Native public static final int TYPE_DCLR = 23; /** * Generic 14 component color spaces. */ - public static final int TYPE_ECLR = 24; + @Native public static final int TYPE_ECLR = 24; /** * Generic 15 component color spaces. */ - public static final int TYPE_FCLR = 25; + @Native public static final int TYPE_FCLR = 25; /** * The sRGB color space defined at @@ -243,28 +241,28 @@ public abstract class ColorSpace implements java.io.Serializable { * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html * . */ - public static final int CS_sRGB = 1000; + @Native public static final int CS_sRGB = 1000; /** * A built-in linear RGB color space. This space is based on the * same RGB primaries as CS_sRGB, but has a linear tone reproduction curve. */ - public static final int CS_LINEAR_RGB = 1004; + @Native public static final int CS_LINEAR_RGB = 1004; /** * The CIEXYZ conversion color space defined above. */ - public static final int CS_CIEXYZ = 1001; + @Native public static final int CS_CIEXYZ = 1001; /** * The Photo YCC conversion color space. */ - public static final int CS_PYCC = 1002; + @Native public static final int CS_PYCC = 1002; /** * The built-in linear gray scale color space. */ - public static final int CS_GRAY = 1003; + @Native public static final int CS_GRAY = 1003; /** diff --git a/jdk/src/share/classes/java/awt/color/ICC_Profile.java b/jdk/src/share/classes/java/awt/color/ICC_Profile.java index 321db6ca664..b459f63b16d 100644 --- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java +++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -58,7 +58,6 @@ import java.util.StringTokenizer; import java.security.AccessController; import java.security.PrivilegedAction; -import javax.tools.annotation.GenerateNativeHeader; /** * A representation of color profile data for device independent and @@ -90,8 +89,6 @@ import javax.tools.annotation.GenerateNativeHeader; */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ICC_Profile implements Serializable { private static final long serialVersionUID = -3938515861990936766L; diff --git a/jdk/src/share/classes/java/awt/datatransfer/StringSelection.java b/jdk/src/share/classes/java/awt/datatransfer/StringSelection.java index c646015da3a..6036bd821da 100644 --- a/jdk/src/share/classes/java/awt/datatransfer/StringSelection.java +++ b/jdk/src/share/classes/java/awt/datatransfer/StringSelection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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,7 +27,6 @@ package java.awt.datatransfer; import java.io.*; -import javax.tools.annotation.GenerateNativeHeader; /** * A Transferable which implements the capability required @@ -43,8 +42,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @see java.awt.datatransfer.DataFlavor#stringFlavor * @see java.awt.datatransfer.DataFlavor#plainTextFlavor */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class StringSelection implements Transferable, ClipboardOwner { private static final int STRING = 0; diff --git a/jdk/src/share/classes/java/awt/dnd/DnDConstants.java b/jdk/src/share/classes/java/awt/dnd/DnDConstants.java index f49733203c6..e4c5fb42206 100644 --- a/jdk/src/share/classes/java/awt/dnd/DnDConstants.java +++ b/jdk/src/share/classes/java/awt/dnd/DnDConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,15 +25,13 @@ package java.awt.dnd; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * This class contains constant values representing * the type of action(s) to be performed by a Drag and Drop operation. * @since 1.2 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class DnDConstants { private DnDConstants() {} // define null private constructor. @@ -41,23 +39,23 @@ public final class DnDConstants { /** * An int representing no action. */ - public static final int ACTION_NONE = 0x0; + @Native public static final int ACTION_NONE = 0x0; /** * An int representing a "copy" action. */ - public static final int ACTION_COPY = 0x1; + @Native public static final int ACTION_COPY = 0x1; /** * An int representing a "move" action. */ - public static final int ACTION_MOVE = 0x2; + @Native public static final int ACTION_MOVE = 0x2; /** * An int representing a "copy" or * "move" action. */ - public static final int ACTION_COPY_OR_MOVE = ACTION_COPY | ACTION_MOVE; + @Native public static final int ACTION_COPY_OR_MOVE = ACTION_COPY | ACTION_MOVE; /** * An int representing a "link" action. @@ -75,12 +73,12 @@ public final class DnDConstants { * results for the user. */ - public static final int ACTION_LINK = 0x40000000; + @Native public static final int ACTION_LINK = 0x40000000; /** * An int representing a "reference" * action (synonym for ACTION_LINK). */ - public static final int ACTION_REFERENCE = ACTION_LINK; + @Native public static final int ACTION_REFERENCE = ACTION_LINK; } diff --git a/jdk/src/share/classes/java/awt/event/ActionEvent.java b/jdk/src/share/classes/java/awt/event/ActionEvent.java index 755de2b31e5..08bd8db95b0 100644 --- a/jdk/src/share/classes/java/awt/event/ActionEvent.java +++ b/jdk/src/share/classes/java/awt/event/ActionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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,7 +27,7 @@ package java.awt.event; import java.awt.AWTEvent; import java.awt.Event; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * A semantic event which indicates that a component-defined action occurred. @@ -57,8 +57,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Carl Quinn * @since 1.1 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ActionEvent extends AWTEvent { /** @@ -99,7 +97,7 @@ public class ActionEvent extends AWTEvent { /** * This event id indicates that a meaningful action occured. */ - public static final int ACTION_PERFORMED = ACTION_FIRST; //Event.ACTION_EVENT + @Native public static final int ACTION_PERFORMED = ACTION_FIRST; //Event.ACTION_EVENT /** * The nonlocalized string that gives more details diff --git a/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java b/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java index 669d292be7e..66d54c3c247 100644 --- a/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java +++ b/jdk/src/share/classes/java/awt/event/AdjustmentEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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,9 +27,8 @@ package java.awt.event; import java.awt.Adjustable; import java.awt.AWTEvent; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -import javax.tools.annotation.GenerateNativeHeader; /** * The adjustment event emitted by Adjustable objects like @@ -57,8 +56,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Amy Fowler * @since 1.1 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class AdjustmentEvent extends AWTEvent { /** @@ -79,27 +76,27 @@ public class AdjustmentEvent extends AWTEvent { /** * The unit increment adjustment type. */ - public static final int UNIT_INCREMENT = 1; + @Native public static final int UNIT_INCREMENT = 1; /** * The unit decrement adjustment type. */ - public static final int UNIT_DECREMENT = 2; + @Native public static final int UNIT_DECREMENT = 2; /** * The block decrement adjustment type. */ - public static final int BLOCK_DECREMENT = 3; + @Native public static final int BLOCK_DECREMENT = 3; /** * The block increment adjustment type. */ - public static final int BLOCK_INCREMENT = 4; + @Native public static final int BLOCK_INCREMENT = 4; /** * The absolute tracking adjustment type. */ - public static final int TRACK = 5; + @Native public static final int TRACK = 5; /** * The adjustable object that fired the event. diff --git a/jdk/src/share/classes/java/awt/event/ComponentEvent.java b/jdk/src/share/classes/java/awt/event/ComponentEvent.java index 51c2b68192d..67149a7a3af 100644 --- a/jdk/src/share/classes/java/awt/event/ComponentEvent.java +++ b/jdk/src/share/classes/java/awt/event/ComponentEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -28,7 +28,7 @@ package java.awt.event; import java.awt.AWTEvent; import java.awt.Component; import java.awt.Rectangle; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * A low-level event which indicates that a component moved, changed @@ -65,8 +65,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Carl Quinn * @since 1.1 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ComponentEvent extends AWTEvent { /** @@ -82,22 +80,22 @@ public class ComponentEvent extends AWTEvent { /** * This event indicates that the component's position changed. */ - public static final int COMPONENT_MOVED = COMPONENT_FIRST; + @Native public static final int COMPONENT_MOVED = COMPONENT_FIRST; /** * This event indicates that the component's size changed. */ - public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST; + @Native public static final int COMPONENT_RESIZED = 1 + COMPONENT_FIRST; /** * This event indicates that the component was made visible. */ - public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST; + @Native public static final int COMPONENT_SHOWN = 2 + COMPONENT_FIRST; /** * This event indicates that the component was rendered invisible. */ - public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST; + @Native public static final int COMPONENT_HIDDEN = 3 + COMPONENT_FIRST; /* * JDK 1.1 serialVersionUID diff --git a/jdk/src/share/classes/java/awt/event/FocusEvent.java b/jdk/src/share/classes/java/awt/event/FocusEvent.java index f9b1c8d6c9e..e70b9684bdc 100644 --- a/jdk/src/share/classes/java/awt/event/FocusEvent.java +++ b/jdk/src/share/classes/java/awt/event/FocusEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package java.awt.event; import java.awt.Component; -import javax.tools.annotation.GenerateNativeHeader; import sun.awt.AppContext; import sun.awt.SunToolkit; @@ -64,8 +63,6 @@ import sun.awt.SunToolkit; * @author Amy Fowler * @since 1.1 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class FocusEvent extends ComponentEvent { /** diff --git a/jdk/src/share/classes/java/awt/event/InputMethodEvent.java b/jdk/src/share/classes/java/awt/event/InputMethodEvent.java index 339078cf9c0..ec5548a8be7 100644 --- a/jdk/src/share/classes/java/awt/event/InputMethodEvent.java +++ b/jdk/src/share/classes/java/awt/event/InputMethodEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -33,7 +33,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.text.AttributedCharacterIterator; import java.text.CharacterIterator; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * Input method events contain information about text that is being @@ -56,8 +56,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author JavaSoft Asia/Pacific * @since 1.2 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class InputMethodEvent extends AWTEvent { /** @@ -68,25 +66,25 @@ public class InputMethodEvent extends AWTEvent { /** * Marks the first integer id for the range of input method event ids. */ - public static final int INPUT_METHOD_FIRST = 1100; + @Native public static final int INPUT_METHOD_FIRST = 1100; /** * The event type indicating changed input method text. This event is * generated by input methods while processing input. */ - public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST; + @Native public static final int INPUT_METHOD_TEXT_CHANGED = INPUT_METHOD_FIRST; /** * The event type indicating a changed insertion point in input method text. * This event is * generated by input methods while processing input if only the caret changed. */ - public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1; + @Native public static final int CARET_POSITION_CHANGED = INPUT_METHOD_FIRST + 1; /** * Marks the last integer id for the range of input method event ids. */ - public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1; + @Native public static final int INPUT_METHOD_LAST = INPUT_METHOD_FIRST + 1; /** * The time stamp that indicates when the event was created. diff --git a/jdk/src/share/classes/java/awt/event/MouseWheelEvent.java b/jdk/src/share/classes/java/awt/event/MouseWheelEvent.java index 2d0228ae44c..b33c723d485 100644 --- a/jdk/src/share/classes/java/awt/event/MouseWheelEvent.java +++ b/jdk/src/share/classes/java/awt/event/MouseWheelEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, 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,7 +27,7 @@ package java.awt.event; import java.awt.Component; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * An event which indicates that the mouse wheel was rotated in a component. @@ -99,8 +99,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @since 1.4 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class MouseWheelEvent extends MouseEvent { /** @@ -109,7 +107,7 @@ public class MouseWheelEvent extends MouseEvent { * * @see #getScrollType */ - public static final int WHEEL_UNIT_SCROLL = 0; + @Native public static final int WHEEL_UNIT_SCROLL = 0; /** * Constant representing scrolling by a "block" (like scrolling @@ -117,7 +115,7 @@ public class MouseWheelEvent extends MouseEvent { * * @see #getScrollType */ - public static final int WHEEL_BLOCK_SCROLL = 1; + @Native public static final int WHEEL_BLOCK_SCROLL = 1; /** * Indicates what sort of scrolling should take place in response to this diff --git a/jdk/src/share/classes/java/awt/event/WindowEvent.java b/jdk/src/share/classes/java/awt/event/WindowEvent.java index 1fee1547ce4..49e45f3991b 100644 --- a/jdk/src/share/classes/java/awt/event/WindowEvent.java +++ b/jdk/src/share/classes/java/awt/event/WindowEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package java.awt.event; import java.awt.Window; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.awt.AppContext; import sun.awt.SunToolkit; @@ -56,8 +56,6 @@ import sun.awt.SunToolkit; * * @since JDK1.1 */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class WindowEvent extends ComponentEvent { /** @@ -69,7 +67,7 @@ public class WindowEvent extends ComponentEvent { * The window opened event. This event is delivered only * the first time a window is made visible. */ - public static final int WINDOW_OPENED = WINDOW_FIRST; // 200 + @Native public static final int WINDOW_OPENED = WINDOW_FIRST; // 200 /** * The "window is closing" event. This event is delivered when @@ -78,13 +76,13 @@ public class WindowEvent extends ComponentEvent { * while processing this event, the window close operation will be * cancelled. */ - public static final int WINDOW_CLOSING = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY + @Native public static final int WINDOW_CLOSING = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY /** * The window closed event. This event is delivered after * the window has been closed as the result of a call to dispose. */ - public static final int WINDOW_CLOSED = 2 + WINDOW_FIRST; + @Native public static final int WINDOW_CLOSED = 2 + WINDOW_FIRST; /** * The window iconified event. This event is delivered when @@ -93,13 +91,13 @@ public class WindowEvent extends ComponentEvent { * the icon specified in the window's iconImage property. * @see java.awt.Frame#setIconImage */ - public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY + @Native public static final int WINDOW_ICONIFIED = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY /** * The window deiconified event type. This event is delivered when * the window has been changed from a minimized to a normal state. */ - public static final int WINDOW_DEICONIFIED = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY + @Native public static final int WINDOW_DEICONIFIED = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY /** * The window-activated event type. This event is delivered when the Window @@ -109,7 +107,7 @@ public class WindowEvent extends ComponentEvent { * active Window is always either the focused Window, or the first Frame or * Dialog that is an owner of the focused Window. */ - public static final int WINDOW_ACTIVATED = 5 + WINDOW_FIRST; + @Native public static final int WINDOW_ACTIVATED = 5 + WINDOW_FIRST; /** * The window-deactivated event type. This event is delivered when the @@ -119,21 +117,21 @@ public class WindowEvent extends ComponentEvent { * title bar. The active Window is always either the focused Window, or the * first Frame or Dialog that is an owner of the focused Window. */ - public static final int WINDOW_DEACTIVATED = 6 + WINDOW_FIRST; + @Native public static final int WINDOW_DEACTIVATED = 6 + WINDOW_FIRST; /** * The window-gained-focus event type. This event is delivered when the * Window becomes the focused Window, which means that the Window, or one * of its subcomponents, will receive keyboard events. */ - public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST; + @Native public static final int WINDOW_GAINED_FOCUS = 7 + WINDOW_FIRST; /** * The window-lost-focus event type. This event is delivered when a Window * is no longer the focused Window, which means keyboard events will no * longer be delivered to the Window or any of its subcomponents. */ - public static final int WINDOW_LOST_FOCUS = 8 + WINDOW_FIRST; + @Native public static final int WINDOW_LOST_FOCUS = 8 + WINDOW_FIRST; /** * The window-state-changed event type. This event is delivered @@ -141,7 +139,7 @@ public class WindowEvent extends ComponentEvent { * iconified, maximized etc. * @since 1.4 */ - public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST; + @Native public static final int WINDOW_STATE_CHANGED = 9 + WINDOW_FIRST; /** * The last number in the range of ids used for window events. diff --git a/jdk/src/share/classes/java/awt/geom/PathIterator.java b/jdk/src/share/classes/java/awt/geom/PathIterator.java index 84eb219839c..75cb2286b4d 100644 --- a/jdk/src/share/classes/java/awt/geom/PathIterator.java +++ b/jdk/src/share/classes/java/awt/geom/PathIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,7 +25,7 @@ package java.awt.geom; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The PathIterator interface provides the mechanism @@ -59,8 +59,6 @@ import javax.tools.annotation.GenerateNativeHeader; * * @author Jim Graham */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface PathIterator { /** * The winding rule constant for specifying an even-odd rule @@ -69,7 +67,7 @@ public interface PathIterator { * path if a ray drawn in any direction from that point to * infinity is crossed by path segments an odd number of times. */ - public static final int WIND_EVEN_ODD = 0; + @Native public static final int WIND_EVEN_ODD = 0; /** * The winding rule constant for specifying a non-zero rule @@ -80,20 +78,20 @@ public interface PathIterator { * of times in the counter-clockwise direction than the * clockwise direction. */ - public static final int WIND_NON_ZERO = 1; + @Native public static final int WIND_NON_ZERO = 1; /** * The segment type constant for a point that specifies the * starting location for a new subpath. */ - public static final int SEG_MOVETO = 0; + @Native public static final int SEG_MOVETO = 0; /** * The segment type constant for a point that specifies the * end point of a line to be drawn from the most recently * specified point. */ - public static final int SEG_LINETO = 1; + @Native public static final int SEG_LINETO = 1; /** * The segment type constant for the pair of points that specify @@ -115,7 +113,7 @@ public interface PathIterator { * = n! / (m! * (n-m)!) * */ - public static final int SEG_QUADTO = 2; + @Native public static final int SEG_QUADTO = 2; /** * The segment type constant for the set of 3 points that specify @@ -139,14 +137,14 @@ public interface PathIterator { * * This form of curve is commonly known as a Bézier curve. */ - public static final int SEG_CUBICTO = 3; + @Native public static final int SEG_CUBICTO = 3; /** * The segment type constant that specifies that * the preceding subpath should be closed by appending a line segment * back to the point corresponding to the most recent SEG_MOVETO. */ - public static final int SEG_CLOSE = 4; + @Native public static final int SEG_CLOSE = 4; /** * Returns the winding rule for determining the interior of the diff --git a/jdk/src/share/classes/java/awt/image/AffineTransformOp.java b/jdk/src/share/classes/java/awt/image/AffineTransformOp.java index b3f090a4084..30819ba8897 100644 --- a/jdk/src/share/classes/java/awt/image/AffineTransformOp.java +++ b/jdk/src/share/classes/java/awt/image/AffineTransformOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -34,7 +34,7 @@ import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Transparency; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.awt.image.ImagingLib; /** @@ -63,8 +63,6 @@ import sun.awt.image.ImagingLib; * @see java.awt.RenderingHints#KEY_COLOR_RENDERING * @see java.awt.RenderingHints#KEY_DITHERING */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class AffineTransformOp implements BufferedImageOp, RasterOp { private AffineTransform xform; RenderingHints hints; @@ -72,17 +70,17 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp { /** * Nearest-neighbor interpolation type. */ - public static final int TYPE_NEAREST_NEIGHBOR = 1; + @Native public static final int TYPE_NEAREST_NEIGHBOR = 1; /** * Bilinear interpolation type. */ - public static final int TYPE_BILINEAR = 2; + @Native public static final int TYPE_BILINEAR = 2; /** * Bicubic interpolation type. */ - public static final int TYPE_BICUBIC = 3; + @Native public static final int TYPE_BICUBIC = 3; int interpolationType = TYPE_NEAREST_NEIGHBOR; diff --git a/jdk/src/share/classes/java/awt/image/ConvolveOp.java b/jdk/src/share/classes/java/awt/image/ConvolveOp.java index 20f1c31a5a2..1c5e20e9785 100644 --- a/jdk/src/share/classes/java/awt/image/ConvolveOp.java +++ b/jdk/src/share/classes/java/awt/image/ConvolveOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -30,7 +30,7 @@ import java.awt.geom.Rectangle2D; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.geom.Point2D; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.awt.image.ImagingLib; /** @@ -66,8 +66,6 @@ import sun.awt.image.ImagingLib; * @see java.awt.RenderingHints#KEY_COLOR_RENDERING * @see java.awt.RenderingHints#KEY_DITHERING */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ConvolveOp implements BufferedImageOp, RasterOp { Kernel kernel; int edgeHint; @@ -81,13 +79,13 @@ public class ConvolveOp implements BufferedImageOp, RasterOp { * is the default. */ - public static final int EDGE_ZERO_FILL = 0; + @Native public static final int EDGE_ZERO_FILL = 0; /** * Pixels at the edge of the source image are copied to * the corresponding pixels in the destination without modification. */ - public static final int EDGE_NO_OP = 1; + @Native public static final int EDGE_NO_OP = 1; /** * Constructs a ConvolveOp given a Kernel, an edge condition, and a diff --git a/jdk/src/share/classes/java/awt/image/DataBuffer.java b/jdk/src/share/classes/java/awt/image/DataBuffer.java index b0e70f2f134..5bf9652080c 100644 --- a/jdk/src/share/classes/java/awt/image/DataBuffer.java +++ b/jdk/src/share/classes/java/awt/image/DataBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -41,7 +41,7 @@ import sun.java2d.StateTrackableDelegate; import sun.awt.image.SunWritableRaster; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * This class exists to wrap one or more data arrays. Each data array in @@ -67,30 +67,28 @@ import javax.tools.annotation.GenerateNativeHeader; * @see java.awt.image.Raster * @see java.awt.image.SampleModel */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class DataBuffer { /** Tag for unsigned byte data. */ - public static final int TYPE_BYTE = 0; + @Native public static final int TYPE_BYTE = 0; /** Tag for unsigned short data. */ - public static final int TYPE_USHORT = 1; + @Native public static final int TYPE_USHORT = 1; /** Tag for signed short data. Placeholder for future use. */ - public static final int TYPE_SHORT = 2; + @Native public static final int TYPE_SHORT = 2; /** Tag for int data. */ - public static final int TYPE_INT = 3; + @Native public static final int TYPE_INT = 3; /** Tag for float data. Placeholder for future use. */ - public static final int TYPE_FLOAT = 4; + @Native public static final int TYPE_FLOAT = 4; /** Tag for double data. Placeholder for future use. */ - public static final int TYPE_DOUBLE = 5; + @Native public static final int TYPE_DOUBLE = 5; /** Tag for undefined data. */ - public static final int TYPE_UNDEFINED = 32; + @Native public static final int TYPE_UNDEFINED = 32; /** The data type of this DataBuffer. */ protected int dataType; diff --git a/jdk/src/share/classes/java/awt/image/ImageConsumer.java b/jdk/src/share/classes/java/awt/image/ImageConsumer.java index c14d50aebbd..da2231008d3 100644 --- a/jdk/src/share/classes/java/awt/image/ImageConsumer.java +++ b/jdk/src/share/classes/java/awt/image/ImageConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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,7 +27,6 @@ package java.awt.image; import java.util.Hashtable; -import javax.tools.annotation.GenerateNativeHeader; /** * The interface for objects expressing interest in image data through @@ -39,8 +38,6 @@ import javax.tools.annotation.GenerateNativeHeader; * * @author Jim Graham */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface ImageConsumer { /** * The dimensions of the source image are reported using the diff --git a/jdk/src/share/classes/java/awt/image/ImageObserver.java b/jdk/src/share/classes/java/awt/image/ImageObserver.java index 60db15b4291..1790309f32c 100644 --- a/jdk/src/share/classes/java/awt/image/ImageObserver.java +++ b/jdk/src/share/classes/java/awt/image/ImageObserver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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,7 +27,6 @@ package java.awt.image; import java.awt.Image; -import javax.tools.annotation.GenerateNativeHeader; /** * An asynchronous update interface for receiving notifications about @@ -35,8 +34,6 @@ import javax.tools.annotation.GenerateNativeHeader; * * @author Jim Graham */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface ImageObserver { /** * This method is called when information about an image which was diff --git a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java index 43ef8e51269..40f310d4b1f 100644 --- a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java +++ b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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 @@ -32,7 +32,6 @@ import java.awt.image.ImageObserver; import java.awt.image.ColorModel; import java.awt.image.VolatileImage; import java.awt.GraphicsConfiguration; -import javax.tools.annotation.GenerateNativeHeader; import sun.awt.CausedFocusEvent; import sun.java2d.pipe.Region; @@ -50,8 +49,6 @@ import sun.java2d.pipe.Region; * nor invoke any of the peer methods directly on the peer * instances. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface ComponentPeer { /** diff --git a/jdk/src/share/classes/java/awt/print/PageFormat.java b/jdk/src/share/classes/java/awt/print/PageFormat.java index 8a19b667055..0b25201c6c7 100644 --- a/jdk/src/share/classes/java/awt/print/PageFormat.java +++ b/jdk/src/share/classes/java/awt/print/PageFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,14 +29,12 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The PageFormat class describes the size and * orientation of a page to be printed. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class PageFormat implements Cloneable { @@ -48,21 +46,21 @@ public class PageFormat implements Cloneable * Note that this is not the Macintosh landscape but * is the Window's and PostScript landscape. */ - public static final int LANDSCAPE = 0; + @Native public static final int LANDSCAPE = 0; /** * The origin is at the top left of the paper with * x running to the right and y running down the * paper. */ - public static final int PORTRAIT = 1; + @Native public static final int PORTRAIT = 1; /** * The origin is at the top right of the paper with x * running top to bottom and y running right to left. * Note that this is the Macintosh landscape. */ - public static final int REVERSE_LANDSCAPE = 2; + @Native public static final int REVERSE_LANDSCAPE = 2; /* Instance Variables */ diff --git a/jdk/src/share/classes/java/awt/print/Pageable.java b/jdk/src/share/classes/java/awt/print/Pageable.java index e98f6f44547..b87cc7b6759 100644 --- a/jdk/src/share/classes/java/awt/print/Pageable.java +++ b/jdk/src/share/classes/java/awt/print/Pageable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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,7 +25,7 @@ package java.awt.print; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * The Pageable implementation represents a set of @@ -35,8 +35,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @see java.awt.print.PageFormat * @see java.awt.print.Printable */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface Pageable { /** @@ -45,7 +43,7 @@ public interface Pageable { * method if a Pageable implementation does not know * the number of pages in its set. */ - int UNKNOWN_NUMBER_OF_PAGES = -1; + @Native int UNKNOWN_NUMBER_OF_PAGES = -1; /** * Returns the number of pages in the set. diff --git a/jdk/src/share/classes/java/awt/print/Printable.java b/jdk/src/share/classes/java/awt/print/Printable.java index dacf917da86..6737aec6194 100644 --- a/jdk/src/share/classes/java/awt/print/Printable.java +++ b/jdk/src/share/classes/java/awt/print/Printable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,7 +27,6 @@ package java.awt.print; import java.awt.Graphics; -import javax.tools.annotation.GenerateNativeHeader; /** * The Printable interface is implemented @@ -100,8 +99,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @see java.awt.print.PageFormat * @see java.awt.print.PrinterJob */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface Printable { /** diff --git a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java index 0ae1ec762df..aacd8c0d7fe 100644 --- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java +++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -34,7 +34,6 @@ import java.beans.PropertyChangeEvent; import java.util.Set; import java.awt.AWTKeyStroke; import java.applet.Applet; -import javax.tools.annotation.GenerateNativeHeader; import sun.applet.AppletPanel; /** @@ -54,8 +53,6 @@ import sun.applet.AppletPanel; * * @author Thomas Ball */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class EmbeddedFrame extends Frame implements KeyEventDispatcher, PropertyChangeListener { diff --git a/jdk/src/share/classes/sun/awt/SunHints.java b/jdk/src/share/classes/sun/awt/SunHints.java index 1d8cb54e9b6..3e0dff5ac1e 100644 --- a/jdk/src/share/classes/sun/awt/SunHints.java +++ b/jdk/src/share/classes/sun/awt/SunHints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package sun.awt; import java.awt.RenderingHints; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * This class contains rendering hints that can be used by the @@ -34,8 +34,6 @@ import javax.tools.annotation.GenerateNativeHeader; * {@link java.awt.image.BufferedImageOp} and * {@link java.awt.image.Raster}. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class SunHints { /** * Defines the type of all keys used to control various @@ -180,86 +178,86 @@ public class SunHints { /** * Rendering hint key and values */ - public static final int INTKEY_RENDERING = 0; - public static final int INTVAL_RENDER_DEFAULT = 0; - public static final int INTVAL_RENDER_SPEED = 1; - public static final int INTVAL_RENDER_QUALITY = 2; + @Native public static final int INTKEY_RENDERING = 0; + @Native public static final int INTVAL_RENDER_DEFAULT = 0; + @Native public static final int INTVAL_RENDER_SPEED = 1; + @Native public static final int INTVAL_RENDER_QUALITY = 2; /** * Antialiasing hint key and values */ - public static final int INTKEY_ANTIALIASING = 1; - public static final int INTVAL_ANTIALIAS_DEFAULT = 0; - public static final int INTVAL_ANTIALIAS_OFF = 1; - public static final int INTVAL_ANTIALIAS_ON = 2; + @Native public static final int INTKEY_ANTIALIASING = 1; + @Native public static final int INTVAL_ANTIALIAS_DEFAULT = 0; + @Native public static final int INTVAL_ANTIALIAS_OFF = 1; + @Native public static final int INTVAL_ANTIALIAS_ON = 2; /** * Text antialiasing hint key and values */ - public static final int INTKEY_TEXT_ANTIALIASING = 2; - public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0; - public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1; - public static final int INTVAL_TEXT_ANTIALIAS_ON = 2; - public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3; - public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4; - public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5; - public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6; - public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7; + @Native public static final int INTKEY_TEXT_ANTIALIASING = 2; + @Native public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0; + @Native public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1; + @Native public static final int INTVAL_TEXT_ANTIALIAS_ON = 2; + @Native public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3; + @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4; + @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5; + @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6; + @Native public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7; /** * Font fractional metrics hint key and values */ - public static final int INTKEY_FRACTIONALMETRICS = 3; - public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0; - public static final int INTVAL_FRACTIONALMETRICS_OFF = 1; - public static final int INTVAL_FRACTIONALMETRICS_ON = 2; + @Native public static final int INTKEY_FRACTIONALMETRICS = 3; + @Native public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0; + @Native public static final int INTVAL_FRACTIONALMETRICS_OFF = 1; + @Native public static final int INTVAL_FRACTIONALMETRICS_ON = 2; /** * Dithering hint key and values */ - public static final int INTKEY_DITHERING = 4; - public static final int INTVAL_DITHER_DEFAULT = 0; - public static final int INTVAL_DITHER_DISABLE = 1; - public static final int INTVAL_DITHER_ENABLE = 2; + @Native public static final int INTKEY_DITHERING = 4; + @Native public static final int INTVAL_DITHER_DEFAULT = 0; + @Native public static final int INTVAL_DITHER_DISABLE = 1; + @Native public static final int INTVAL_DITHER_ENABLE = 2; /** * Interpolation hint key and values */ - public static final int INTKEY_INTERPOLATION = 5; - public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0; - public static final int INTVAL_INTERPOLATION_BILINEAR = 1; - public static final int INTVAL_INTERPOLATION_BICUBIC = 2; + @Native public static final int INTKEY_INTERPOLATION = 5; + @Native public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0; + @Native public static final int INTVAL_INTERPOLATION_BILINEAR = 1; + @Native public static final int INTVAL_INTERPOLATION_BICUBIC = 2; /** * Alpha interpolation hint key and values */ - public static final int INTKEY_ALPHA_INTERPOLATION = 6; - public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0; - public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1; - public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2; + @Native public static final int INTKEY_ALPHA_INTERPOLATION = 6; + @Native public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0; + @Native public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1; + @Native public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2; /** * Color rendering hint key and values */ - public static final int INTKEY_COLOR_RENDERING = 7; - public static final int INTVAL_COLOR_RENDER_DEFAULT = 0; - public static final int INTVAL_COLOR_RENDER_SPEED = 1; - public static final int INTVAL_COLOR_RENDER_QUALITY = 2; + @Native public static final int INTKEY_COLOR_RENDERING = 7; + @Native public static final int INTVAL_COLOR_RENDER_DEFAULT = 0; + @Native public static final int INTVAL_COLOR_RENDER_SPEED = 1; + @Native public static final int INTVAL_COLOR_RENDER_QUALITY = 2; /** * Stroke normalization control hint key and values */ - public static final int INTKEY_STROKE_CONTROL = 8; - public static final int INTVAL_STROKE_DEFAULT = 0; - public static final int INTVAL_STROKE_NORMALIZE = 1; - public static final int INTVAL_STROKE_PURE = 2; + @Native public static final int INTKEY_STROKE_CONTROL = 8; + @Native public static final int INTVAL_STROKE_DEFAULT = 0; + @Native public static final int INTVAL_STROKE_NORMALIZE = 1; + @Native public static final int INTVAL_STROKE_PURE = 2; /** * LCD text contrast control hint key. * Value is "100" to make discontiguous with the others which * are all enumerative and are of a different class. */ - public static final int INTKEY_AATEXT_LCD_CONTRAST = 100; + @Native public static final int INTKEY_AATEXT_LCD_CONTRAST = 100; /** * Rendering hint key and value objects diff --git a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java index c5e80b2a695..a893c9de591 100644 --- a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java +++ b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, 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 @@ -54,7 +54,6 @@ import sun.awt.SunToolkit; import sun.awt.datatransfer.DataTransferer; import java.awt.datatransfer.DataFlavor; -import javax.tools.annotation.GenerateNativeHeader; /** *

    @@ -64,8 +63,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @since JDK1.3.1 * */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class SunDragSourceContextPeer implements DragSourceContextPeer { private DragGestureEvent trigger; diff --git a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java index 2f8732e3173..efc4bc97ec4 100644 --- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java +++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -45,10 +45,7 @@ import sun.java2d.loops.SurfaceType; import sun.java2d.loops.CompositeType; import sun.java2d.loops.RenderLoops; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class BufImgSurfaceData extends SurfaceData { BufferedImage bufImg; private BufferedImageGraphicsConfig graphicsConfig; diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java index 4238cfa558e..cace22ebe4b 100644 --- a/jdk/src/share/classes/sun/font/FontManager.java +++ b/jdk/src/share/classes/sun/font/FontManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -32,14 +32,11 @@ import java.util.TreeMap; import javax.swing.plaf.FontUIResource; -import javax.tools.annotation.GenerateNativeHeader; /** * Interface between Java Fonts (java.awt.Font) and the underlying * font files/native font resources and the Java and native font scalers. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface FontManager { // These constants are used in findFont(). diff --git a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java index 1b2d3d6cba2..ba246046e72 100644 --- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java +++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -92,7 +92,7 @@ import java.util.Iterator; import sun.java2d.DestSurfaceProvider; import sun.misc.PerformanceLogger; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * This is a the master Graphics2D superclass for all of the Sun @@ -103,8 +103,6 @@ import javax.tools.annotation.GenerateNativeHeader; * * @author Jim Graham */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class SunGraphics2D extends Graphics2D implements ConstrainableGraphics, Cloneable, DestSurfaceProvider @@ -113,18 +111,29 @@ public final class SunGraphics2D * Attribute States */ /* Paint */ + @Native public static final int PAINT_CUSTOM = 6; /* Any other Paint object */ + @Native public static final int PAINT_TEXTURE = 5; /* Tiled Image */ + @Native public static final int PAINT_RAD_GRADIENT = 4; /* Color RadialGradient */ + @Native public static final int PAINT_LIN_GRADIENT = 3; /* Color LinearGradient */ + @Native public static final int PAINT_GRADIENT = 2; /* Color Gradient */ + @Native public static final int PAINT_ALPHACOLOR = 1; /* Non-opaque Color */ + @Native public static final int PAINT_OPAQUECOLOR = 0; /* Opaque Color */ /* Composite*/ + @Native public static final int COMP_CUSTOM = 3;/* Custom Composite */ + @Native public static final int COMP_XOR = 2;/* XOR Mode Composite */ + @Native public static final int COMP_ALPHA = 1;/* AlphaComposite */ + @Native public static final int COMP_ISCOPY = 0;/* simple stores into destination, * i.e. Src, SrcOverNoEa, and other * alpha modes which replace @@ -132,21 +141,33 @@ public final class SunGraphics2D */ /* Stroke */ + @Native public static final int STROKE_CUSTOM = 3; /* custom Stroke */ + @Native public static final int STROKE_WIDE = 2; /* BasicStroke */ + @Native public static final int STROKE_THINDASHED = 1; /* BasicStroke */ + @Native public static final int STROKE_THIN = 0; /* BasicStroke */ /* Transform */ + @Native public static final int TRANSFORM_GENERIC = 4; /* any 3x2 */ + @Native public static final int TRANSFORM_TRANSLATESCALE = 3; /* scale XY */ + @Native public static final int TRANSFORM_ANY_TRANSLATE = 2; /* non-int translate */ + @Native public static final int TRANSFORM_INT_TRANSLATE = 1; /* int translate */ + @Native public static final int TRANSFORM_ISIDENT = 0; /* Identity */ /* Clipping */ + @Native public static final int CLIP_SHAPE = 2; /* arbitrary clip */ + @Native public static final int CLIP_RECTANGULAR = 1; /* rectangular clip */ + @Native public static final int CLIP_DEVICE = 0; /* no clipping set */ /* The following fields are used when the current Paint is a Color. */ diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java index 684f6fc56cc..ef78a819a6a 100644 --- a/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java +++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -45,10 +45,8 @@ import sun.java2d.pipe.Region; import sun.java2d.pipe.RenderBuffer; import sun.java2d.pipe.RenderQueue; import static sun.java2d.pipe.BufferedOpCodes.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader class OGLBlitLoops { static void register() { @@ -190,12 +188,12 @@ class OGLBlitLoops { * createPackedParams(). (They are also used at the native level when * unpacking the params.) */ - private static final int OFFSET_SRCTYPE = 16; - private static final int OFFSET_HINT = 8; - private static final int OFFSET_TEXTURE = 3; - private static final int OFFSET_RTT = 2; - private static final int OFFSET_XFORM = 1; - private static final int OFFSET_ISOBLIT = 0; + @Native private static final int OFFSET_SRCTYPE = 16; + @Native private static final int OFFSET_HINT = 8; + @Native private static final int OFFSET_TEXTURE = 3; + @Native private static final int OFFSET_RTT = 2; + @Native private static final int OFFSET_XFORM = 1; + @Native private static final int OFFSET_ISOBLIT = 0; /** * Packs the given parameters into a single int value in order to save diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java b/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java index 17c4f8a3541..be1e27f34a3 100644 --- a/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java +++ b/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, 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 @@ -32,7 +32,7 @@ import sun.java2d.pipe.hw.ContextCapabilities; import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.pipe.hw.ContextCapabilities.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * Note that the RenderQueue lock must be acquired before calling any of @@ -155,40 +155,38 @@ public class OGLContext extends BufferedContext { rq.flushNow(); } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader static class OGLContextCaps extends ContextCapabilities { /** * Indicates the presence of the GL_EXT_framebuffer_object extension. * This cap will only be set if the fbobject system property has been * enabled and we are able to create an FBO with depth buffer. */ - static final int CAPS_EXT_FBOBJECT = + @Native static final int CAPS_EXT_FBOBJECT = (CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE); /** Indicates that the context supports a stored alpha channel. */ - static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA; + @Native static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA; /** Indicates that the context is doublebuffered. */ - static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0); + @Native static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0); /** * Indicates the presence of the GL_ARB_fragment_shader extension. * This cap will only be set if the lcdshader system property has been * enabled and the hardware supports the minimum number of texture units */ - static final int CAPS_EXT_LCD_SHADER = (FIRST_PRIVATE_CAP << 1); + @Native static final int CAPS_EXT_LCD_SHADER = (FIRST_PRIVATE_CAP << 1); /** * Indicates the presence of the GL_ARB_fragment_shader extension. * This cap will only be set if the biopshader system property has been * enabled and the hardware meets our minimum requirements. */ - static final int CAPS_EXT_BIOP_SHADER = (FIRST_PRIVATE_CAP << 2); + @Native static final int CAPS_EXT_BIOP_SHADER = (FIRST_PRIVATE_CAP << 2); /** * Indicates the presence of the GL_ARB_fragment_shader extension. * This cap will only be set if the gradshader system property has been * enabled and the hardware meets our minimum requirements. */ - static final int CAPS_EXT_GRAD_SHADER = (FIRST_PRIVATE_CAP << 3); + @Native static final int CAPS_EXT_GRAD_SHADER = (FIRST_PRIVATE_CAP << 3); /** Indicates the presence of the GL_ARB_texture_rectangle extension. */ - static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4); + @Native static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4); OGLContextCaps(int caps, String adapterId) { super(caps, adapterId); diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java index 6bc3039714f..75b18bef3bd 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java +++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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,7 +37,7 @@ import sun.java2d.loops.XORComposite; import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * Base context class for managing state in a single-threaded rendering @@ -49,8 +49,6 @@ import javax.tools.annotation.GenerateNativeHeader; * * @see RenderQueue */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class BufferedContext { /* @@ -63,19 +61,19 @@ public abstract class BufferedContext { /** * Indicates that no flags are needed; take all default code paths. */ - public static final int NO_CONTEXT_FLAGS = (0 << 0); + @Native public static final int NO_CONTEXT_FLAGS = (0 << 0); /** * Indicates that the source surface (or color value, if it is a simple * rendering operation) is opaque (has an alpha value of 1.0). If this * flag is present, it allows us to disable blending in certain * situations in order to improve performance. */ - public static final int SRC_IS_OPAQUE = (1 << 0); + @Native public static final int SRC_IS_OPAQUE = (1 << 0); /** * Indicates that the operation uses an alpha mask, which may determine * the code path that is used when setting up the current paint state. */ - public static final int USE_MASK = (1 << 1); + @Native public static final int USE_MASK = (1 << 1); protected RenderQueue rq; protected RenderBuffer buf; diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java index 78ee323c9e4..89acfdfa63e 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java +++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedOpCodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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,79 +25,77 @@ package sun.java2d.pipe; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class BufferedOpCodes { // draw ops - public static final int DRAW_LINE = 10; - public static final int DRAW_RECT = 11; - public static final int DRAW_POLY = 12; - public static final int DRAW_PIXEL = 13; - public static final int DRAW_SCANLINES = 14; - public static final int DRAW_PARALLELOGRAM = 15; - public static final int DRAW_AAPARALLELOGRAM = 16; + @Native public static final int DRAW_LINE = 10; + @Native public static final int DRAW_RECT = 11; + @Native public static final int DRAW_POLY = 12; + @Native public static final int DRAW_PIXEL = 13; + @Native public static final int DRAW_SCANLINES = 14; + @Native public static final int DRAW_PARALLELOGRAM = 15; + @Native public static final int DRAW_AAPARALLELOGRAM = 16; // fill ops - public static final int FILL_RECT = 20; - public static final int FILL_SPANS = 21; - public static final int FILL_PARALLELOGRAM = 22; - public static final int FILL_AAPARALLELOGRAM = 23; + @Native public static final int FILL_RECT = 20; + @Native public static final int FILL_SPANS = 21; + @Native public static final int FILL_PARALLELOGRAM = 22; + @Native public static final int FILL_AAPARALLELOGRAM = 23; // copy-related ops - public static final int COPY_AREA = 30; - public static final int BLIT = 31; - public static final int MASK_FILL = 32; - public static final int MASK_BLIT = 33; - public static final int SURFACE_TO_SW_BLIT = 34; + @Native public static final int COPY_AREA = 30; + @Native public static final int BLIT = 31; + @Native public static final int MASK_FILL = 32; + @Native public static final int MASK_BLIT = 33; + @Native public static final int SURFACE_TO_SW_BLIT = 34; // text-related ops - public static final int DRAW_GLYPH_LIST = 40; + @Native public static final int DRAW_GLYPH_LIST = 40; // state-related ops - public static final int SET_RECT_CLIP = 51; - public static final int BEGIN_SHAPE_CLIP = 52; - public static final int SET_SHAPE_CLIP_SPANS = 53; - public static final int END_SHAPE_CLIP = 54; - public static final int RESET_CLIP = 55; - public static final int SET_ALPHA_COMPOSITE = 56; - public static final int SET_XOR_COMPOSITE = 57; - public static final int RESET_COMPOSITE = 58; - public static final int SET_TRANSFORM = 59; - public static final int RESET_TRANSFORM = 60; + @Native public static final int SET_RECT_CLIP = 51; + @Native public static final int BEGIN_SHAPE_CLIP = 52; + @Native public static final int SET_SHAPE_CLIP_SPANS = 53; + @Native public static final int END_SHAPE_CLIP = 54; + @Native public static final int RESET_CLIP = 55; + @Native public static final int SET_ALPHA_COMPOSITE = 56; + @Native public static final int SET_XOR_COMPOSITE = 57; + @Native public static final int RESET_COMPOSITE = 58; + @Native public static final int SET_TRANSFORM = 59; + @Native public static final int RESET_TRANSFORM = 60; // context-related ops - public static final int SET_SURFACES = 70; - public static final int SET_SCRATCH_SURFACE = 71; - public static final int FLUSH_SURFACE = 72; - public static final int DISPOSE_SURFACE = 73; - public static final int DISPOSE_CONFIG = 74; - public static final int INVALIDATE_CONTEXT = 75; - public static final int SYNC = 76; - public static final int RESTORE_DEVICES = 77; - public static final int SAVE_STATE = 78; - public static final int RESTORE_STATE = 79; + @Native public static final int SET_SURFACES = 70; + @Native public static final int SET_SCRATCH_SURFACE = 71; + @Native public static final int FLUSH_SURFACE = 72; + @Native public static final int DISPOSE_SURFACE = 73; + @Native public static final int DISPOSE_CONFIG = 74; + @Native public static final int INVALIDATE_CONTEXT = 75; + @Native public static final int SYNC = 76; + @Native public static final int RESTORE_DEVICES = 77; + @Native public static final int SAVE_STATE = 78; + @Native public static final int RESTORE_STATE = 79; // multibuffering ops - public static final int SWAP_BUFFERS = 80; + @Native public static final int SWAP_BUFFERS = 80; // special no-op op code (mainly used for achieving 8-byte alignment) - public static final int NOOP = 90; + @Native public static final int NOOP = 90; // paint-related ops - public static final int RESET_PAINT = 100; - public static final int SET_COLOR = 101; - public static final int SET_GRADIENT_PAINT = 102; - public static final int SET_LINEAR_GRADIENT_PAINT = 103; - public static final int SET_RADIAL_GRADIENT_PAINT = 104; - public static final int SET_TEXTURE_PAINT = 105; + @Native public static final int RESET_PAINT = 100; + @Native public static final int SET_COLOR = 101; + @Native public static final int SET_GRADIENT_PAINT = 102; + @Native public static final int SET_LINEAR_GRADIENT_PAINT = 103; + @Native public static final int SET_RADIAL_GRADIENT_PAINT = 104; + @Native public static final int SET_TEXTURE_PAINT = 105; // BufferedImageOp-related ops - public static final int ENABLE_CONVOLVE_OP = 120; - public static final int DISABLE_CONVOLVE_OP = 121; - public static final int ENABLE_RESCALE_OP = 122; - public static final int DISABLE_RESCALE_OP = 123; - public static final int ENABLE_LOOKUP_OP = 124; - public static final int DISABLE_LOOKUP_OP = 125; + @Native public static final int ENABLE_CONVOLVE_OP = 120; + @Native public static final int DISABLE_CONVOLVE_OP = 121; + @Native public static final int ENABLE_RESCALE_OP = 122; + @Native public static final int DISABLE_RESCALE_OP = 123; + @Native public static final int ENABLE_LOOKUP_OP = 124; + @Native public static final int DISABLE_LOOKUP_OP = 125; } diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java index 5737e408af3..84394e29e3a 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java +++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -46,10 +46,8 @@ import sun.java2d.loops.CompositeType; import sun.java2d.loops.SurfaceType; import static sun.java2d.pipe.BufferedOpCodes.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class BufferedPaints { static void setPaint(RenderQueue rq, SunGraphics2D sg2d, @@ -304,7 +302,7 @@ public class BufferedPaints { * shaders. So for now we will cap this value at 12, but we can * re-evaluate this in the future as hardware becomes more capable. */ - public static final int MULTI_MAX_FRACTIONS = 12; + @Native public static final int MULTI_MAX_FRACTIONS = 12; /** * Helper function to convert a color component in sRGB space to diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java index 8f4a2bfafd6..ce388258c5a 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java +++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedTextPipe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -32,24 +32,22 @@ import sun.java2d.SunGraphics2D; import sun.java2d.SurfaceData; import static sun.java2d.pipe.BufferedOpCodes.*; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public abstract class BufferedTextPipe extends GlyphListPipe { - private static final int BYTES_PER_GLYPH_IMAGE = 8; - private static final int BYTES_PER_GLYPH_POSITION = 8; + @Native private static final int BYTES_PER_GLYPH_IMAGE = 8; + @Native private static final int BYTES_PER_GLYPH_POSITION = 8; /** * The following offsets are used to pack the parameters in * createPackedParams(). (They are also used at the native level when * unpacking the params.) */ - private static final int OFFSET_CONTRAST = 8; - private static final int OFFSET_RGBORDER = 2; - private static final int OFFSET_SUBPIXPOS = 1; - private static final int OFFSET_POSITIONS = 0; + @Native private static final int OFFSET_CONTRAST = 8; + @Native private static final int OFFSET_RGBORDER = 2; + @Native private static final int OFFSET_SUBPIXPOS = 1; + @Native private static final int OFFSET_POSITIONS = 0; /** * Packs the given parameters into a single int value in order to save diff --git a/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java b/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java index 353c8d1fa1a..5f5118a8767 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java +++ b/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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,7 +27,6 @@ package sun.java2d.pipe; import sun.misc.Unsafe; -import javax.tools.annotation.GenerateNativeHeader; /** * The RenderBuffer class is a simplified, high-performance, Unsafe wrapper @@ -44,8 +43,6 @@ import javax.tools.annotation.GenerateNativeHeader; * single-threaded rendering. For example, there is no put(double[]) method * because we currently have no need for such a method in the STR classes. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class RenderBuffer { /** diff --git a/jdk/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java b/jdk/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java index 1a3b7916e17..44d4115602a 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java +++ b/jdk/src/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,16 +30,13 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -import javax.tools.annotation.GenerateNativeHeader; /** * This class is used to notify listeners about accelerated device's * events such as device reset or dispose that are about to occur. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class AccelDeviceEventNotifier { private static AccelDeviceEventNotifier theInstance; @@ -49,13 +46,13 @@ public class AccelDeviceEventNotifier { * resources associated with the device which are required for the device * to be reset. */ - public static final int DEVICE_RESET = 0; + @Native public static final int DEVICE_RESET = 0; /** * A device is about to be disposed. The listeners have to release all * resources associated with the device. */ - public static final int DEVICE_DISPOSED = 1; + @Native public static final int DEVICE_DISPOSED = 1; private final Map listeners; diff --git a/jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java b/jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java index 6dd51379ec5..8f4e5a3d166 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java +++ b/jdk/src/share/classes/sun/java2d/pipe/hw/AccelSurface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -28,41 +28,39 @@ package sun.java2d.pipe.hw; import java.awt.Rectangle; import sun.java2d.Surface; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * Abstraction for a hardware accelerated surface. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public interface AccelSurface extends BufferedContextProvider, Surface { /** * Undefined */ - public static final int UNDEFINED = 0; + @Native public static final int UNDEFINED = 0; /** * Window (or window substitute) surface */ - public static final int WINDOW = 1; + @Native public static final int WINDOW = 1; /** * Render-To Plain surface (pbuffer for OpenGL, Render Target surface * for Direct3D) */ - public static final int RT_PLAIN = 2; + @Native public static final int RT_PLAIN = 2; /** * Texture surface */ - public static final int TEXTURE = 3; + @Native public static final int TEXTURE = 3; /** * A back-buffer surface (SwapChain surface for Direct3D, backbuffer for * OpenGL) */ - public static final int FLIP_BACKBUFFER = 4; + @Native public static final int FLIP_BACKBUFFER = 4; /** * Render-To Texture surface (fbobject for OpenGL, texture with render-to * attribute for Direct3D) */ - public static final int RT_TEXTURE = 5; + @Native public static final int RT_TEXTURE = 5; /** * Returns {@code int} representing surface's type as defined by constants diff --git a/jdk/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java b/jdk/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java index 0a6ab7988c8..86a9a25a22d 100644 --- a/jdk/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java +++ b/jdk/src/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +25,6 @@ package sun.java2d.pipe.hw; -import javax.tools.annotation.GenerateNativeHeader; /** * Represents a set of capabilities of a BufferedContext and associated @@ -33,8 +32,6 @@ import javax.tools.annotation.GenerateNativeHeader; * * @see AccelGraphicsConfig */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ContextCapabilities { /** Indicates that the context has no capabilities. */ public static final int CAPS_EMPTY = (0 << 0); diff --git a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java index ff2ee589600..cdd5b3c2a80 100644 --- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java +++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, 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 @@ -32,15 +32,12 @@ import java.nio.ByteBuffer; import java.nio.channels.*; import java.nio.channels.spi.*; import java.util.*; -import javax.tools.annotation.GenerateNativeHeader; import sun.net.ResourceManager; /** * An implementation of DatagramChannels. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader class DatagramChannelImpl extends DatagramChannel implements SelChImpl diff --git a/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java b/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java index a7779b02cd2..8bcc1c48c1e 100644 --- a/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java +++ b/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, 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,21 +25,19 @@ package sun.nio.ch.sctp; import com.sun.nio.sctp.SctpSocketOption; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class SctpStdSocketOption implements SctpSocketOption { /* for native mapping of int options */ - public static final int SCTP_DISABLE_FRAGMENTS = 1; - public static final int SCTP_EXPLICIT_COMPLETE = 2; - public static final int SCTP_FRAGMENT_INTERLEAVE = 3; - public static final int SCTP_NODELAY = 4; - public static final int SO_SNDBUF = 5; - public static final int SO_RCVBUF = 6; - public static final int SO_LINGER = 7; + @Native public static final int SCTP_DISABLE_FRAGMENTS = 1; + @Native public static final int SCTP_EXPLICIT_COMPLETE = 2; + @Native public static final int SCTP_FRAGMENT_INTERLEAVE = 3; + @Native public static final int SCTP_NODELAY = 4; + @Native public static final int SO_SNDBUF = 5; + @Native public static final int SO_RCVBUF = 6; + @Native public static final int SO_LINGER = 7; private final String name; private final Class type; diff --git a/jdk/src/share/classes/sun/security/pkcs11/Secmod.java b/jdk/src/share/classes/sun/security/pkcs11/Secmod.java index de4d12ef33f..07651fe39ca 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/Secmod.java +++ b/jdk/src/share/classes/sun/security/pkcs11/Secmod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, 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,7 +35,6 @@ import java.security.cert.X509Certificate; import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; -import javax.tools.annotation.GenerateNativeHeader; /** * The Secmod class defines the interface to the native NSS @@ -57,8 +56,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @since 1.6 * @author Andreas Sterbenz */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public final class Secmod { private final static boolean DEBUG = false; diff --git a/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java b/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java index 0284244b3a9..0ada8947776 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java +++ b/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -55,7 +55,6 @@ import java.security.AccessController; import java.security.PrivilegedAction; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; -import javax.tools.annotation.GenerateNativeHeader; /** * This is the default implementation of the PKCS11 interface. IT connects to @@ -68,8 +67,6 @@ import javax.tools.annotation.GenerateNativeHeader; * @author Martin Schlaeffer * @invariants (pkcs11ModulePath_ <> null) */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class PKCS11 { /** diff --git a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java index 906e9a862a0..b5c20861904 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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 @@ -70,10 +70,7 @@ import sun.awt.image.ToolkitImage; import sun.java2d.BackBufferCapsProvider; import sun.java2d.pipe.Region; -import javax.tools.annotation.GenerateNativeHeader; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class XComponentPeer extends XWindow implements ComponentPeer, DropTargetPeer, BackBufferCapsProvider { diff --git a/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java index 2399a38b384..79a0805ea04 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java +++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,22 +26,20 @@ package sun.nio.ch.sctp; import com.sun.nio.sctp.Association; import com.sun.nio.sctp.AssociationChangeNotification; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * An implementation of AssociationChangeNotification */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class AssociationChange extends AssociationChangeNotification implements SctpNotification { /* static final ints so that they can be referenced from native */ - private final static int SCTP_COMM_UP = 1; - private final static int SCTP_COMM_LOST = 2; - private final static int SCTP_RESTART = 3; - private final static int SCTP_SHUTDOWN = 4; - private final static int SCTP_CANT_START = 5; + @Native private final static int SCTP_COMM_UP = 1; + @Native private final static int SCTP_COMM_LOST = 2; + @Native private final static int SCTP_RESTART = 3; + @Native private final static int SCTP_SHUTDOWN = 4; + @Native private final static int SCTP_CANT_START = 5; private Association association; diff --git a/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java b/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java index 2dac583ace5..55ee10fe644 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java +++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, 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,23 +27,21 @@ package sun.nio.ch.sctp; import java.net.SocketAddress; import com.sun.nio.sctp.Association; import com.sun.nio.sctp.PeerAddressChangeNotification; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * An implementation of PeerAddressChangeNotification */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class PeerAddrChange extends PeerAddressChangeNotification implements SctpNotification { /* static final ints so that they can be referenced from native */ - private final static int SCTP_ADDR_AVAILABLE = 1; - private final static int SCTP_ADDR_UNREACHABLE = 2; - private final static int SCTP_ADDR_REMOVED = 3; - private final static int SCTP_ADDR_ADDED = 4; - private final static int SCTP_ADDR_MADE_PRIM = 5; - private final static int SCTP_ADDR_CONFIRMED =6; + @Native private final static int SCTP_ADDR_AVAILABLE = 1; + @Native private final static int SCTP_ADDR_UNREACHABLE = 2; + @Native private final static int SCTP_ADDR_REMOVED = 3; + @Native private final static int SCTP_ADDR_ADDED = 4; + @Native private final static int SCTP_ADDR_MADE_PRIM = 5; + @Native private final static int SCTP_ADDR_CONFIRMED =6; private Association association; diff --git a/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java b/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java index dee2f989d11..229899f4dea 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java +++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, 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 @@ -24,22 +24,20 @@ */ package sun.nio.ch.sctp; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; /** * Wraps the actual message or notification so that it can be * set and returned from the native receive implementation. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader public class ResultContainer { /* static final ints so that they can be referenced from native */ - static final int NOTHING = 0; - static final int MESSAGE = 1; - static final int SEND_FAILED = 2; - static final int ASSOCIATION_CHANGED = 3; - static final int PEER_ADDRESS_CHANGED = 4; - static final int SHUTDOWN = 5; + @Native static final int NOTHING = 0; + @Native static final int MESSAGE = 1; + @Native static final int SEND_FAILED = 2; + @Native static final int ASSOCIATION_CHANGED = 3; + @Native static final int PEER_ADDRESS_CHANGED = 4; + @Native static final int SHUTDOWN = 5; private Object value; private int type; diff --git a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c index 80da504ad1d..5a9545550b8 100644 --- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c +++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,7 +36,6 @@ #include "awt_p.h" #include -#include #include #define THROW_OUT_OF_MEMORY_ERROR() \ diff --git a/jdk/src/solaris/native/sun/awt/fontpath.c b/jdk/src/solaris/native/sun/awt/fontpath.c index 412c6317a1c..24146b962e4 100644 --- a/jdk/src/solaris/native/sun/awt/fontpath.c +++ b/jdk/src/solaris/native/sun/awt/fontpath.c @@ -41,7 +41,6 @@ #include #include #include -#include #ifndef HEADLESS #include #include diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java index 636dd790ff8..9d05ddb96ae 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -32,7 +32,7 @@ import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.lang.ref.WeakReference; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.java2d.ScreenUpdateManager; import sun.java2d.SurfaceData; import sun.java2d.loops.Blit; @@ -48,8 +48,6 @@ import sun.java2d.pipe.RenderQueue; import static sun.java2d.pipe.BufferedOpCodes.*; import sun.java2d.windows.GDIWindowSurfaceData; -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader class D3DBlitLoops { static void register() { @@ -179,12 +177,12 @@ class D3DBlitLoops { * createPackedParams(). (They are also used at the native level when * unpacking the params.) */ - private static final int OFFSET_SRCTYPE = 16; - private static final int OFFSET_HINT = 8; - private static final int OFFSET_TEXTURE = 3; - private static final int OFFSET_RTT = 2; - private static final int OFFSET_XFORM = 1; - private static final int OFFSET_ISOBLIT = 0; + @Native private static final int OFFSET_SRCTYPE = 16; + @Native private static final int OFFSET_HINT = 8; + @Native private static final int OFFSET_TEXTURE = 3; + @Native private static final int OFFSET_RTT = 2; + @Native private static final int OFFSET_XFORM = 1; + @Native private static final int OFFSET_ISOBLIT = 0; /** * Packs the given parameters into a single int value in order to save diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DContext.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DContext.java index 9eb26b87da4..4de986cb8ec 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DContext.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +25,7 @@ package sun.java2d.d3d; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.RenderBuffer; import sun.java2d.pipe.RenderQueue; @@ -38,8 +38,6 @@ import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; * Note that the RenderQueue lock must be acquired before calling any of * the methods in this class. */ -/* No native methods here, but the constants are needed in the supporting JNI code */ -@GenerateNativeHeader class D3DContext extends BufferedContext { private final D3DGraphicsDevice device; @@ -143,31 +141,29 @@ class D3DContext extends BufferedContext { return device; } - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader static class D3DContextCaps extends ContextCapabilities { /** * Indicates the presence of pixel shaders (v2.0 or greater). * This cap will only be set if the hardware supports the minimum number * of texture units. */ - static final int CAPS_LCD_SHADER = (FIRST_PRIVATE_CAP << 0); + @Native static final int CAPS_LCD_SHADER = (FIRST_PRIVATE_CAP << 0); /** * Indicates the presence of pixel shaders (v2.0 or greater). * This cap will only be set if the hardware meets our * minimum requirements. */ - static final int CAPS_BIOP_SHADER = (FIRST_PRIVATE_CAP << 1); + @Native static final int CAPS_BIOP_SHADER = (FIRST_PRIVATE_CAP << 1); /** * Indicates that the device was successfully initialized and can * be safely used. */ - static final int CAPS_DEVICE_OK = (FIRST_PRIVATE_CAP << 2); + @Native static final int CAPS_DEVICE_OK = (FIRST_PRIVATE_CAP << 2); /** * Indicates that the device has all of the necessary capabilities * to support the Antialiasing Pixel Shader program. */ - static final int CAPS_AA_SHADER = (FIRST_PRIVATE_CAP << 3); + @Native static final int CAPS_AA_SHADER = (FIRST_PRIVATE_CAP << 3); D3DContextCaps(int caps, String adapterId) { super(caps, adapterId); diff --git a/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java b/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java index a5661bd60c9..53e59762c23 100644 --- a/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java +++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DPaints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,7 +33,7 @@ import java.awt.TexturePaint; import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Map; -import javax.tools.annotation.GenerateNativeHeader; +import java.lang.annotation.Native; import sun.java2d.SunGraphics2D; import sun.java2d.SurfaceData; import sun.java2d.loops.CompositeType; @@ -158,8 +158,6 @@ abstract class D3DPaints { /****************** Shared MultipleGradientPaint support ********************/ - /* No native methods here, but the constants are needed in the supporting JNI code */ - @GenerateNativeHeader private static abstract class MultiGradient extends D3DPaints { /** @@ -170,7 +168,7 @@ abstract class D3DPaints { * all versions of the shader can be compiled for PS 2.0 hardware, * we need to cap this maximum value at 8. */ - public static final int MULTI_MAX_FRACTIONS_D3D = 8; + @Native public static final int MULTI_MAX_FRACTIONS_D3D = 8; protected MultiGradient() {} diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.h b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.h index 8075c41a5bf..48defe17b47 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DContext.h +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -28,7 +28,6 @@ #include "java_awt_Transparency.h" #include "sun_java2d_pipe_BufferedContext.h" -#include "sun_java2d_d3d_D3DContext.h" #include "sun_java2d_d3d_D3DContext_D3DContextCaps.h" #include "sun_java2d_d3d_D3DSurfaceData.h" #include "sun_java2d_pipe_hw_AccelDeviceEventNotifier.h" diff --git a/jdk/src/windows/native/sun/windows/awt_Component.h b/jdk/src/windows/native/sun/windows/awt_Component.h index 8ce8fa39112..815843f1ad1 100644 --- a/jdk/src/windows/native/sun/windows/awt_Component.h +++ b/jdk/src/windows/native/sun/windows/awt_Component.h @@ -37,7 +37,6 @@ #include "java_awt_Component.h" #include "sun_awt_windows_WComponentPeer.h" #include "java_awt_event_KeyEvent.h" -#include "java_awt_event_FocusEvent.h" #include "java_awt_event_MouseEvent.h" #include "java_awt_event_WindowEvent.h" #include "java_awt_Dimension.h" diff --git a/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp b/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp index 2d585e0330a..21c3b17f84a 100644 --- a/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp +++ b/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -52,7 +52,6 @@ void * operator new(size_t size) {return operator new(size, "stl", 1);} #include "java_awt_event_InputEvent.h" #include "java_awt_dnd_DnDConstants.h" -#include "sun_awt_dnd_SunDragSourceContextPeer.h" #include "sun_awt_windows_WDragSourceContextPeer.h" #include "awt_ole.h" diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.cpp b/jdk/src/windows/native/sun/windows/awt_Frame.cpp index 41c5624f001..5d344e71474 100644 --- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/jdk/src/windows/native/sun/windows/awt_List.h b/jdk/src/windows/native/sun/windows/awt_List.h index 3751b02f3dc..585eed9eb54 100644 --- a/jdk/src/windows/native/sun/windows/awt_List.h +++ b/jdk/src/windows/native/sun/windows/awt_List.h @@ -28,7 +28,6 @@ #include "awt_Component.h" -#include "java_awt_List.h" #include "sun_awt_windows_WListPeer.h" diff --git a/jdk/src/windows/native/sun/windows/awt_PopupMenu.cpp b/jdk/src/windows/native/sun/windows/awt_PopupMenu.cpp index dee95e21692..05fc30d7518 100644 --- a/jdk/src/windows/native/sun/windows/awt_PopupMenu.cpp +++ b/jdk/src/windows/native/sun/windows/awt_PopupMenu.cpp @@ -28,7 +28,6 @@ #include "awt_Event.h" #include "awt_Window.h" -#include #include #include diff --git a/jdk/src/windows/native/sun/windows/awt_PopupMenu.h b/jdk/src/windows/native/sun/windows/awt_PopupMenu.h index ab82768d8e5..112645e56f6 100644 --- a/jdk/src/windows/native/sun/windows/awt_PopupMenu.h +++ b/jdk/src/windows/native/sun/windows/awt_PopupMenu.h @@ -30,7 +30,6 @@ #include #include -#include #include diff --git a/jdk/src/windows/native/sun/windows/awt_TextComponent.h b/jdk/src/windows/native/sun/windows/awt_TextComponent.h index cc0fc97f780..e293e0964af 100644 --- a/jdk/src/windows/native/sun/windows/awt_TextComponent.h +++ b/jdk/src/windows/native/sun/windows/awt_TextComponent.h @@ -28,7 +28,6 @@ #include "awt_Component.h" -#include "java_awt_TextComponent.h" #include "sun_awt_windows_WTextComponentPeer.h" #include diff --git a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp index e8b2d51931a..8a3ed22c17d 100644 --- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -62,7 +62,6 @@ #include #include -#include extern void initScreens(JNIEnv *env); extern "C" void awt_dnd_initialize(); From 2c9fb2de3ee303ec34681133ef2337f5359cb34a Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:04 -0700 Subject: [PATCH 127/155] Added tag jdk8-b84 for changeset aec7eec37b03 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index db8b4550f1e..0896e836000 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -205,3 +205,4 @@ fd1a5574cf68af24bfd52decc37ac6361afb278a jdk8-b78 145dbc56f931c134e837b675b9e6e7bf08902e93 jdk8-b81 29153d0df68f84162ffe8c2cf4f402a3f2245e85 jdk8-b82 466685ba01bfb7bc1e1ac61490fd8c0f3cc18763 jdk8-b83 +01f631f89fa392b4e484d0812c40ea8f9d2353aa jdk8-b84 From 3cf1973527813a586ad6b7eb7c993b62958c5f74 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:06 -0700 Subject: [PATCH 128/155] Added tag jdk8-b84 for changeset 8d11dc7a1d97 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 5a2a5cfc102..1558a0bafe8 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -205,3 +205,4 @@ e41fb1aa0329767b2737303c994e38bede1baa07 jdk8-b79 2a00aeeb466b9dee22508f6261f63b70f9c696fe jdk8-b81 48e1bc77004d9af575b733c04637b98fd17603c2 jdk8-b82 a45bb25a67c7517b45f00c9682e317f46fecbba9 jdk8-b83 +928f8b888deb785cbd7bbd5f951cd6880f11f14e jdk8-b84 From c8755701efcf8560b6b4a757c4d4c2d1844a10a4 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:12 -0700 Subject: [PATCH 129/155] Added tag jdk8-b84 for changeset df190a3da0e2 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 40fd36ae97f..ea220e83592 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -328,3 +328,4 @@ dd6350b4abc4a6c19c89dd982cc0e4f3d119885c hs25-b22 e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24 1c8db54ee9f315e20d6d5d9bf0b5c10349e9d301 jdk8-b83 8d0f263a370c5f3e61791bb06054560804117288 hs25-b25 +af788b85010ebabbc1e8f52c6766e08c7a95cf99 jdk8-b84 From 0f87989600ab810735f37b7ce33df52198ced482 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:21 -0700 Subject: [PATCH 130/155] Added tag jdk8-b84 for changeset 545ba3c9bf47 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 21b40f387ac..ea02757c9b6 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -205,3 +205,4 @@ ff0b73a6b3f6cea644d37d56d746a37743419fa7 jdk8-b75 ef3495555a4c6e706a3058c18aa229b14220de0b jdk8-b81 d5a58291f09a5081eaf22c2a6ab2f9ced4b78882 jdk8-b82 a46d69a1a8ec9652a48114823535372e1c980799 jdk8-b83 +f5f40094ffcc1230e2a5f76ea4c968645369be6c jdk8-b84 From 188c36b378fcba61298deaecba9cb1b8195d017c Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:24 -0700 Subject: [PATCH 131/155] Added tag jdk8-b84 for changeset 0ee966fccbc1 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 7bfa0ebd9f6..50c6a136c6e 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -205,3 +205,4 @@ b0224010e2f0c2474055ac592c8d3f37b9264690 jdk8-b80 c88bb21560ccf1a9e6d2a2ba08ed2045a002676f jdk8-b81 d8d8032d02d77fbf5f9b3bb8df73663f42fd4dd0 jdk8-b82 a1dcc0d83da1e07f3ada60ef110dd105d95d3554 jdk8-b83 +5773e3fc83803f392234ba54c3a437ba176f1ead jdk8-b84 From 1234f8529cfe499153dedeaf5e046f2bd094faa9 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:32 -0700 Subject: [PATCH 132/155] Added tag jdk8-b84 for changeset 9c96ead03162 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 787670c7d60..5548c0a383e 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -205,3 +205,4 @@ dfb40f066c6ce129822f0f5dc2ac89173808781a jdk8-b80 c0f8022eba536dcdc8aae659005b33f3982b9368 jdk8-b81 624bcb4800065c6656171948e31ebb2925f25c7a jdk8-b82 ac519af51769e92c51b597a730974e8607357709 jdk8-b83 +7b4721e4edb4e1c65e9c839a70d7cc67f81c7632 jdk8-b84 From f4cf1435ed37a53cffb6f175a0aca18657012371 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:42 -0700 Subject: [PATCH 133/155] Added tag jdk8-b84 for changeset 5e63bda2ec36 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 359cd5e1440..193803775a3 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -205,3 +205,4 @@ a8227c61768499dac847ea718af6719027c949f2 jdk8-b80 ed69d087fdfd394491657a28ba9bc58e7849b7db jdk8-b81 825da6847791994a8f405ee397df9e7fa638a458 jdk8-b82 22ba3f92d4ae43bbc19793e854171cae2586f644 jdk8-b83 +cfb65ca92082b2412aed66c8422c2466bde544ef jdk8-b84 From 403f66ad1ddaf72eb6b8ea006b08f493e90995c0 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:46 -0700 Subject: [PATCH 134/155] Added tag jdk8-b84 for changeset c3a8125548f0 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index d182815a343..9886903b721 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -193,3 +193,4 @@ b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b68 b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b69 5759f600fcf7b51ccc6cc8229be980e2153f8675 jdk8-b82 053d7c55dc8272b58b8bb870dc92a4acf896d52a jdk8-b83 +999cc1bf55203f51b2985feae6378932667ecff2 jdk8-b84 From 4ce74c065ed3aa0407857013130a92ee68aecfb9 Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Thu, 4 Apr 2013 20:05:47 -0700 Subject: [PATCH 135/155] 7155720: PKCS11 minor issues in native code Added OOM handling to address the two issues found by parfait. Reviewed-by: weijun --- .../native/sun/security/pkcs11/wrapper/p11_md.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c index 12a4f24ef0a..3d805c5029d 100644 --- a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c +++ b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -104,6 +104,10 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect if (hModule == NULL) { systemErrorMessage = dlerror(); exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1)); + if (exceptionMessage == NULL) { + throwOutOfMemoryError(env, 0); + return; + } strcpy(exceptionMessage, systemErrorMessage); strcat(exceptionMessage, libraryNameStr); throwIOException(env, exceptionMessage); @@ -134,6 +138,11 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect * Get function pointers to all PKCS #11 functions */ moduleData = (ModuleData *) malloc(sizeof(ModuleData)); + if (moduleData == NULL) { + dlclose(hModule); + throwOutOfMemoryError(env, 0); + return; + } moduleData->hModule = hModule; moduleData->applicationMutexHandler = NULL; rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr)); From fe9ae80e5dcc098d5feb4e5e05ed8d0ea7a6731c Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Thu, 4 Apr 2013 21:06:39 -0700 Subject: [PATCH 136/155] Added tag hs25-b26 for changeset 7d026deaf1db --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index ea220e83592..b76e841cb82 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -329,3 +329,4 @@ e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24 1c8db54ee9f315e20d6d5d9bf0b5c10349e9d301 jdk8-b83 8d0f263a370c5f3e61791bb06054560804117288 hs25-b25 af788b85010ebabbc1e8f52c6766e08c7a95cf99 jdk8-b84 +a947f40fb536e5b9e0aa210cf26abb430f80887a hs25-b26 From 6cb72b3aabbbda5009471bd5e7d02dfbdb99ae33 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 5 Apr 2013 09:38:54 +0200 Subject: [PATCH 137/155] 8008373: JFR JTReg tests fail with CompilationError on MacOSX; missing '._sunec.jar' Reviewed-by: tbell --- common/autoconf/basics.m4 | 4 + common/autoconf/generated-configure.sh | 542 +++++++++++++------------ common/autoconf/spec.gmk.in | 1 + common/makefiles/MakeBase.gmk | 11 +- 4 files changed, 306 insertions(+), 252 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index c713d22a804..20f444ff702 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -602,6 +602,10 @@ AC_PATH_PROG(TIME, time) if test "x$OPENJDK_TARGET_OS" = "xwindows"; then BASIC_REQUIRE_PROG(COMM, comm) fi + +if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + BASIC_REQUIRE_PROG(XATTR, xattr) +fi ]) # Check if build directory is on local disk. If not possible to determine, diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 2293c92d133..259b93866fb 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. # # Report bugs to . # @@ -91,7 +91,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -217,18 +216,11 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -794,6 +786,7 @@ OS_VERSION_MICRO OS_VERSION_MINOR OS_VERSION_MAJOR PKG_CONFIG +XATTR TIME STAT HG @@ -1451,7 +1444,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac @@ -1885,7 +1878,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1931,7 +1924,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1969,7 +1962,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -2007,7 +2000,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_objc_try_compile @@ -2044,7 +2037,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2081,7 +2074,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -2094,10 +2087,10 @@ fi ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -2164,7 +2157,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -2173,7 +2166,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_mongrel @@ -2214,7 +2207,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -2228,7 +2221,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2246,7 +2239,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_compile @@ -2423,7 +2416,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_compute_int @@ -2469,7 +2462,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -2482,7 +2475,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2537,7 +2530,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_func @@ -2550,7 +2543,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2568,7 +2561,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF @@ -2576,7 +2569,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2834,7 +2827,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi done @@ -3756,7 +3749,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1364922883 +DATE_WHEN_GENERATED=1365147397 ############################################################################### # @@ -3794,7 +3787,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASENAME+:} false; then : +if test "${ac_cv_path_BASENAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3853,7 +3846,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASH+:} false; then : +if test "${ac_cv_path_BASH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3912,7 +3905,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CAT+:} false; then : +if test "${ac_cv_path_CAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -3971,7 +3964,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHMOD+:} false; then : +if test "${ac_cv_path_CHMOD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -4030,7 +4023,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CMP+:} false; then : +if test "${ac_cv_path_CMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -4089,7 +4082,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -4148,7 +4141,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CP+:} false; then : +if test "${ac_cv_path_CP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -4207,7 +4200,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : +if test "${ac_cv_path_CPIO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CPIO in @@ -4266,7 +4259,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CUT+:} false; then : +if test "${ac_cv_path_CUT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -4325,7 +4318,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DATE+:} false; then : +if test "${ac_cv_path_DATE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -4384,7 +4377,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIFF+:} false; then : +if test "${ac_cv_path_DIFF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -4443,7 +4436,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIRNAME+:} false; then : +if test "${ac_cv_path_DIRNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -4502,7 +4495,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ECHO+:} false; then : +if test "${ac_cv_path_ECHO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -4561,7 +4554,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_EXPR+:} false; then : +if test "${ac_cv_path_EXPR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -4620,7 +4613,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FILE+:} false; then : +if test "${ac_cv_path_FILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -4679,7 +4672,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FIND+:} false; then : +if test "${ac_cv_path_FIND+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -4738,7 +4731,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HEAD+:} false; then : +if test "${ac_cv_path_HEAD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -4797,7 +4790,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LN+:} false; then : +if test "${ac_cv_path_LN+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4856,7 +4849,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LS+:} false; then : +if test "${ac_cv_path_LS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4915,7 +4908,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKDIR+:} false; then : +if test "${ac_cv_path_MKDIR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -4974,7 +4967,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKTEMP+:} false; then : +if test "${ac_cv_path_MKTEMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -5033,7 +5026,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MV+:} false; then : +if test "${ac_cv_path_MV+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -5092,7 +5085,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PRINTF+:} false; then : +if test "${ac_cv_path_PRINTF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -5151,7 +5144,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_THEPWDCMD+:} false; then : +if test "${ac_cv_path_THEPWDCMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $THEPWDCMD in @@ -5210,7 +5203,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_RM+:} false; then : +if test "${ac_cv_path_RM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -5269,7 +5262,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SH+:} false; then : +if test "${ac_cv_path_SH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -5328,7 +5321,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SORT+:} false; then : +if test "${ac_cv_path_SORT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -5387,7 +5380,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAIL+:} false; then : +if test "${ac_cv_path_TAIL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -5446,7 +5439,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAR+:} false; then : +if test "${ac_cv_path_TAR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -5505,7 +5498,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TEE+:} false; then : +if test "${ac_cv_path_TEE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -5564,7 +5557,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOUCH+:} false; then : +if test "${ac_cv_path_TOUCH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -5623,7 +5616,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TR+:} false; then : +if test "${ac_cv_path_TR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -5682,7 +5675,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNAME+:} false; then : +if test "${ac_cv_path_UNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -5741,7 +5734,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNIQ+:} false; then : +if test "${ac_cv_path_UNIQ+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5800,7 +5793,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WC+:} false; then : +if test "${ac_cv_path_WC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5859,7 +5852,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WHICH+:} false; then : +if test "${ac_cv_path_WHICH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5918,7 +5911,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XARGS+:} false; then : +if test "${ac_cv_path_XARGS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5978,7 +5971,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : +if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -6028,7 +6021,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -6103,7 +6096,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -6182,7 +6175,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : +if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -6261,7 +6254,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : +if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -6347,7 +6340,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NAWK+:} false; then : +if test "${ac_cv_path_NAWK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -6407,7 +6400,7 @@ RM="$RM -f" set dummy cygpath; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGPATH+:} false; then : +if test "${ac_cv_path_CYGPATH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -6447,7 +6440,7 @@ fi set dummy readlink; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READLINK+:} false; then : +if test "${ac_cv_path_READLINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -6487,7 +6480,7 @@ fi set dummy df; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DF+:} false; then : +if test "${ac_cv_path_DF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -6527,7 +6520,7 @@ fi set dummy SetFile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SETFILE+:} false; then : +if test "${ac_cv_path_SETFILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -6573,7 +6566,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -6589,7 +6582,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -6607,7 +6600,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -6622,7 +6615,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -6640,7 +6633,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then @@ -6655,7 +6648,7 @@ fi $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -8121,7 +8114,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PKGHANDLER+:} false; then : +if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -8486,7 +8479,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -8840,7 +8833,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -9199,7 +9192,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -9552,7 +9545,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -9948,7 +9941,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNZIP+:} false; then : +if test "${ac_cv_path_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -10007,7 +10000,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ZIP+:} false; then : +if test "${ac_cv_path_ZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -10066,7 +10059,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LDD+:} false; then : +if test "${ac_cv_path_LDD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -10112,7 +10105,7 @@ fi set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_OTOOL+:} false; then : +if test "${ac_cv_path_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -10157,7 +10150,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READELF+:} false; then : +if test "${ac_cv_path_READELF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -10200,7 +10193,7 @@ done set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HG+:} false; then : +if test "${ac_cv_path_HG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -10240,7 +10233,7 @@ fi set dummy stat; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STAT+:} false; then : +if test "${ac_cv_path_STAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -10280,7 +10273,7 @@ fi set dummy time; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TIME+:} false; then : +if test "${ac_cv_path_TIME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -10325,7 +10318,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -10377,6 +10370,68 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} fi +fi + +if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + + for ac_prog in xattr +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_XATTR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $XATTR in + [\\/]* | ?:[\\/]*) + ac_cv_path_XATTR="$XATTR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_XATTR="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +XATTR=$ac_cv_path_XATTR +if test -n "$XATTR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XATTR" >&5 +$as_echo "$XATTR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$XATTR" && break +done + + + if test "x$XATTR" = x; then + if test "xxattr" = x; then + PROG_NAME=xattr + else + PROG_NAME=xattr + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 +$as_echo "$as_me: Could not find $PROG_NAME!" >&6;} + as_fn_error $? "Cannot continue" "$LINENO" 5 + fi + + fi @@ -10389,7 +10444,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -10432,7 +10487,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -10605,7 +10660,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_UNZIP+:} false; then : +if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -10651,7 +10706,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_FTP+:} false; then : +if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -11924,7 +11979,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVAC_CHECK+:} false; then : +if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -11964,7 +12019,7 @@ fi set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVA_CHECK+:} false; then : +if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -16038,7 +16093,7 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGWIN_LINK+:} false; then : +if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -17453,7 +17508,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CC+:} false; then : +if test "${ac_cv_path_BUILD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -17764,7 +17819,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CXX+:} false; then : +if test "${ac_cv_path_BUILD_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -18073,7 +18128,7 @@ $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} set dummy ld; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_LD+:} false; then : +if test "${ac_cv_path_BUILD_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -18589,7 +18644,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CC+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CC in @@ -18641,7 +18696,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CC+:} false; then : +if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -19054,7 +19109,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -19098,7 +19153,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -19548,7 +19603,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -19592,7 +19647,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -19645,7 +19700,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -19760,7 +19815,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -19803,7 +19858,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -19862,7 +19917,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi @@ -19873,7 +19928,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19914,7 +19969,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -19924,7 +19979,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19961,7 +20016,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -20039,7 +20094,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -20162,7 +20217,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CXX+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CXX in @@ -20214,7 +20269,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CXX+:} false; then : +if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -20627,7 +20682,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -20671,7 +20726,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -21125,7 +21180,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -21169,7 +21224,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -21247,7 +21302,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21284,7 +21339,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : +if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -21382,7 +21437,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJC+:} false; then : +if test "${ac_cv_prog_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -21426,7 +21481,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJC+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -21502,7 +21557,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if ${ac_cv_objc_compiler_gnu+:} false; then : +if test "${ac_cv_objc_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21539,7 +21594,7 @@ ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if ${ac_cv_prog_objc_g+:} false; then : +if test "${ac_cv_prog_objc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag @@ -21915,7 +21970,7 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : +if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -21955,7 +22010,7 @@ if test -z "$ac_cv_prog_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -22297,7 +22352,7 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then : set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINLD+:} false; then : +if test "${ac_cv_prog_WINLD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -22636,7 +22691,7 @@ $as_echo "yes" >&6; } set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MT+:} false; then : +if test "${ac_cv_prog_MT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -22957,7 +23012,7 @@ $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} set dummy rc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RC+:} false; then : +if test "${ac_cv_prog_RC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -23348,7 +23403,7 @@ fi set dummy lib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINAR+:} false; then : +if test "${ac_cv_prog_WINAR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -23654,7 +23709,7 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} set dummy dumpbin; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -23973,7 +24028,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -24089,7 +24144,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -24373,7 +24428,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : + if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -24489,7 +24544,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -24791,7 +24846,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_AS+:} false; then : +if test "${ac_cv_path_AS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -25105,7 +25160,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NM+:} false; then : +if test "${ac_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -25414,7 +25469,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STRIP+:} false; then : +if test "${ac_cv_path_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -25720,7 +25775,7 @@ $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} set dummy mcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MCS+:} false; then : +if test "${ac_cv_path_MCS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -26028,7 +26083,7 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NM+:} false; then : +if test "${ac_cv_prog_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -26068,7 +26123,7 @@ if test -z "$ac_cv_prog_NM"; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NM+:} false; then : +if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -26386,7 +26441,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -26426,7 +26481,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -26751,7 +26806,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJCOPY+:} false; then : +if test "${ac_cv_prog_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -26795,7 +26850,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -27122,7 +27177,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : +if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -27166,7 +27221,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -27490,7 +27545,7 @@ if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LIPO+:} false; then : +if test "${ac_cv_path_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -27805,7 +27860,7 @@ PATH="$OLD_PATH" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27981,7 +28036,7 @@ fi for ac_header in stdio.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = xyes; then : +if test "x$ac_cv_header_stdio_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDIO_H 1 _ACEOF @@ -28010,7 +28065,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if ${ac_cv_sizeof_int_p+:} false; then : +if test "${ac_cv_sizeof_int_p+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : @@ -28020,7 +28075,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int *) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_int_p=0 fi @@ -28067,7 +28122,7 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -29079,8 +29134,8 @@ if test "x$with_x" = xno; then have_x=disabled else case $x_includes,$x_libraries in #( - *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -29357,7 +29412,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29391,14 +29446,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29432,7 +29487,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi @@ -29451,14 +29506,14 @@ rm -f core conftest.err conftest.$ac_objext \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes; then : +if test "x$ac_cv_func_gethostbyname" = x""yes; then : fi if test $ac_cv_func_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_gethostbyname+:} false; then : +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29492,14 +29547,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_gethostbyname+:} false; then : +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29533,7 +29588,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -29548,14 +29603,14 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = xyes; then : +if test "x$ac_cv_func_connect" = x""yes; then : fi if test $ac_cv_func_connect = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if ${ac_cv_lib_socket_connect+:} false; then : +if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29589,7 +29644,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = xyes; then : +if test "x$ac_cv_lib_socket_connect" = x""yes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -29597,14 +29652,14 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = xyes; then : +if test "x$ac_cv_func_remove" = x""yes; then : fi if test $ac_cv_func_remove = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if ${ac_cv_lib_posix_remove+:} false; then : +if test "${ac_cv_lib_posix_remove+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29638,7 +29693,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = xyes; then : +if test "x$ac_cv_lib_posix_remove" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -29646,14 +29701,14 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = xyes; then : +if test "x$ac_cv_func_shmat" = x""yes; then : fi if test $ac_cv_func_shmat = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if ${ac_cv_lib_ipc_shmat+:} false; then : +if test "${ac_cv_lib_ipc_shmat+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29687,7 +29742,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = xyes; then : +if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -29705,7 +29760,7 @@ fi # John Interrante, Karl Berry { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29739,7 +29794,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -30752,7 +30807,7 @@ $as_echo "$FREETYPE2_FOUND" >&6; } LDFLAGS="$FREETYPE2_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then : +if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30786,7 +30841,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then : +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : FREETYPE2_FOUND=true else as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 @@ -31074,7 +31129,7 @@ fi for ac_header in alsa/asoundlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" -if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : +if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF @@ -31133,7 +31188,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_main+:} false; then : +if test "${ac_cv_lib_jpeg_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31161,7 +31216,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = xyes; then : +if test "x$ac_cv_lib_jpeg_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -31210,7 +31265,7 @@ if test "x${with_giflib}" = "xbundled"; then USE_EXTERNAL_LIBGIF=false elif test "x${with_giflib}" = "xsystem"; then ac_fn_cxx_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default" -if test "x$ac_cv_header_gif_lib_h" = xyes; then : +if test "x$ac_cv_header_gif_lib_h" = x""yes; then : else as_fn_error $? "--with-giflib=system specified, but gif_lib.h not found!" "$LINENO" 5 @@ -31219,7 +31274,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifGetCode in -lgif" >&5 $as_echo_n "checking for DGifGetCode in -lgif... " >&6; } -if ${ac_cv_lib_gif_DGifGetCode+:} false; then : +if test "${ac_cv_lib_gif_DGifGetCode+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31253,7 +31308,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifGetCode" >&5 $as_echo "$ac_cv_lib_gif_DGifGetCode" >&6; } -if test "x$ac_cv_lib_gif_DGifGetCode" = xyes; then : +if test "x$ac_cv_lib_gif_DGifGetCode" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -31285,7 +31340,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if ${ac_cv_lib_z_compress+:} false; then : +if test "${ac_cv_lib_z_compress+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31319,7 +31374,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = xyes; then : +if test "x$ac_cv_lib_z_compress" = x""yes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no @@ -31412,7 +31467,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if ${ac_cv_lib_m_cos+:} false; then : +if test "${ac_cv_lib_m_cos+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31446,7 +31501,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = xyes; then : +if test "x$ac_cv_lib_m_cos" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -31470,7 +31525,7 @@ save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31504,7 +31559,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -32194,7 +32249,7 @@ fi set dummy ccache; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CCACHE+:} false; then : +if test "${ac_cv_path_CCACHE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -32455,21 +32510,10 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then + test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi + cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -32501,7 +32545,7 @@ LTLIBOBJS=$ac_ltlibobjs -: "${CONFIG_STATUS=./config.status}" +: ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -32602,7 +32646,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -32910,7 +32953,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -32973,7 +33016,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -33102,7 +33145,7 @@ do "$OUTPUT_ROOT/spec.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in" ;; "$OUTPUT_ROOT/Makefile") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -33124,10 +33167,9 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= ac_tmp= + tmp= trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -33135,13 +33177,12 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" + test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -33163,7 +33204,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF @@ -33191,7 +33232,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -33239,7 +33280,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && +cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -33271,7 +33312,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -33305,7 +33346,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || +cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -33317,8 +33358,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -33419,7 +33460,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -33438,7 +33479,7 @@ do for ac_f do case $ac_f in - -) ac_f="$ac_tmp/stdin";; + -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -33447,7 +33488,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -33473,8 +33514,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -33599,22 +33640,21 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$ac_tmp/stdin" + rm -f "$tmp/stdin" case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -33625,20 +33665,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ + mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 4e5b7b48ca1..11d19a342d7 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -523,6 +523,7 @@ FILE:=@FILE@ HG:=@HG@ OBJCOPY:=@OBJCOPY@ SETFILE:=@SETFILE@ +XATTR:=@XATTR@ FIXPATH:=@FIXPATH@ diff --git a/common/makefiles/MakeBase.gmk b/common/makefiles/MakeBase.gmk index 708cbada085..5a54e38a0ea 100644 --- a/common/makefiles/MakeBase.gmk +++ b/common/makefiles/MakeBase.gmk @@ -374,15 +374,24 @@ endef ifeq ($(OPENJDK_TARGET_OS),solaris) # On Solaris, if the target is a symlink and exists, cp won't overwrite. +# Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the +# name of the target file differs from the source file, rename after copy. define install-file $(MKDIR) -p $(@D) $(RM) '$@' $(CP) -f -r -P '$<' '$(@D)' + if [ "$(@F)" != "$( Date: Fri, 5 Apr 2013 09:39:10 +0200 Subject: [PATCH 138/155] 8008373: JFR JTReg tests fail with CompilationError on MacOSX; missing '._sunec.jar' Reviewed-by: tbell --- jdk/makefiles/CompileDemos.gmk | 67 +++++------- jdk/makefiles/CompileJavaClasses.gmk | 3 +- jdk/makefiles/CompileLaunchers.gmk | 6 +- jdk/makefiles/CompileNativeLibraries.gmk | 10 +- jdk/makefiles/CopyFiles.gmk | 132 ++++++----------------- jdk/makefiles/CopyIntoClasses.gmk | 4 +- jdk/makefiles/CopySamples.gmk | 12 +-- jdk/makefiles/GendataFontConfig.gmk | 4 +- jdk/makefiles/GensrcCharacterData.gmk | 3 +- jdk/makefiles/GensrcMisc.gmk | 11 +- jdk/makefiles/GensrcSwing.gmk | 6 +- jdk/makefiles/SignJars.gmk | 3 +- jdk/makefiles/Tools.gmk | 10 +- 13 files changed, 84 insertions(+), 187 deletions(-) diff --git a/jdk/makefiles/CompileDemos.gmk b/jdk/makefiles/CompileDemos.gmk index f3100b10ab3..f61d9404020 100644 --- a/jdk/makefiles/CompileDemos.gmk +++ b/jdk/makefiles/CompileDemos.gmk @@ -136,8 +136,7 @@ define SetupDemo $$(wildcard $$(addprefix $(JDK_TOPDIR)/src/$6share/demo/$2/$1/,$7))) ifneq ($7,) $(JDK_OUTPUTDIR)/demo/$2/$1/% : $(JDK_TOPDIR)/src/$6share/demo/$2/$1/% - $(MKDIR) -p $$(@D) - $(CP) $$< $$@ + $$(call install-file) $(CHMOD) -f ug+w $$@ BUILD_DEMOS += $$($1_COPY_TARGETS) @@ -190,8 +189,7 @@ ifndef OPENJDK $(JDK_OUTPUTDIR)/demo/nbproject/%,\ $(call CacheFind,$(JDK_TOPDIR)/src/closed/share/demo/nbproject)) $(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/closed/share/demo/nbproject/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(CHMOD) -f ug+w $@ endif @@ -268,8 +266,7 @@ define SetupJVMTIDemo ZIP:=$(JDK_OUTPUTDIR)/demo/jvmti/$1/src.zip)) $(JDK_OUTPUTDIR)/demo/jvmti/$1/README.txt : $(JDK_TOPDIR)/src/share/demo/jvmti/$1/README.txt - $(MKDIR) -p $$(@D) - $(CP) $$< $$@ + $$(call install-file) $(CHMOD) -f ug+w $$@ ifneq (,$$(wildcard $(JDK_TOPDIR)/src/share/demo/jvmti/$1/*.java)) @@ -325,23 +322,22 @@ JPDA_SOURCES:=$(call CacheFind,$(JDK_TOPDIR)/src/share/classes/com/sun/tools/exa JPDA_FILES:=$(subst $(JDK_TOPDIR)/src/share/classes/,,$(JPDA_SOURCES)) $(JDK_OUTPUTDIR)/demo/jpda/src.zip : $(JPDA_SOURCES) - $(MKDIR) -p $(@D) - (cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*") + $(MKDIR) -p $(@D) + (cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*") $(JDK_OUTPUTDIR)/demo/jpda/examples.jar : $(JPDA_SOURCES) - $(MKDIR) -p $(@D) - $(RM) $(@D)/_the.sources - $(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources) - $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ - -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $(JDK_TOPDIR)/make/tools/manifest.mf > $(@D)/_the.manifest - $(ECHO) "Main-Class: " >> $(@D)/_the.manifest - (cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm $@ $(@D)/_the.manifest @$(@D)/_the.sources) - (cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README) + $(MKDIR) -p $(@D) + $(RM) $(@D)/_the.sources + $(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources) + $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ + -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $(JDK_TOPDIR)/make/tools/manifest.mf > $(@D)/_the.manifest + $(ECHO) "Main-Class: " >> $(@D)/_the.manifest + (cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm $@ $(@D)/_the.manifest @$(@D)/_the.sources) + (cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README) $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README : $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example/README - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jpda/src.zip $(JDK_OUTPUTDIR)/demo/jpda/examples.jar \ $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README @@ -349,14 +345,12 @@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jpda/src.zip $(JDK_OUTPUTDIR)/demo/jpda/exa ################################################################################################## $(JDK_OUTPUTDIR)/demo/management/index.html : $(JDK_TOPDIR)/src/share/demo/management/index.html - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ $(JDK_OUTPUTDIR)/demo/jvmti/index.html : $(JDK_TOPDIR)/src/share/demo/jvmti/index.html - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/management/index.html \ $(JDK_OUTPUTDIR)/demo/jvmti/index.html @@ -369,15 +363,13 @@ BUILD_DEMOS += $(patsubst $(JDK_TOPDIR)/src/share/demo/nbproject/%,\ $(call CacheFind,$(JDK_TOPDIR)/src/share/demo/nbproject)) $(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/share/demo/nbproject/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(CHMOD) -f ug+w $@ ################################################################################################## $(JDK_OUTPUTDIR)/demo/README: $(JDK_TOPDIR)/src/share/demo/README - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/README @@ -386,14 +378,12 @@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/README ifeq ($(OPENJDK_TARGET_OS), solaris) $(JDK_OUTPUTDIR)/democlasses/jni/Poller/% : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/% - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ $(JDK_OUTPUTDIR)/demo/jni/Poller/README.txt : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/README.txt - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ $(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar : \ $(JDK_OUTPUTDIR)/democlasses/jni/Poller/README.txt $(JDK_OUTPUTDIR)/democlasses/jni/Poller/Poller.c @@ -433,8 +423,7 @@ $(JDK_OUTPUTDIR)/demoobjs/jni/Poller/Poller.o : $(JDK_OUTPUTDIR)/demo/jni/Poller $(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) : \ $(JDK_OUTPUTDIR)/demoobjs/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) @@ -456,8 +445,8 @@ ifndef OPENJDK $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html: \ $(JDK_TOPDIR)/src/closed/share/db/README-JDK-DEMOS.html \ | $(JDK_OUTPUTDIR)/demo/_the.db.unzipped - $(MKDIR) -p $(@D) - $(CP) '$<' '$@' + $(call install-file) + BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/_the.db.unzipped $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html endif diff --git a/jdk/makefiles/CompileJavaClasses.gmk b/jdk/makefiles/CompileJavaClasses.gmk index 584458c00c4..24ce0d922f0 100644 --- a/jdk/makefiles/CompileJavaClasses.gmk +++ b/jdk/makefiles/CompileJavaClasses.gmk @@ -281,8 +281,7 @@ endif # These resources violates the convention of having code and resources together under # $(JDK_TOPDIR)/src/.../classes directories $(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: $(JDK_TOPDIR)/make/tools/swing-beans/beaninfo/images/%.gif - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying # JDK_FILTER at the make command line, only a subset of the JDK java files will diff --git a/jdk/makefiles/CompileLaunchers.gmk b/jdk/makefiles/CompileLaunchers.gmk index 501c986082e..7ecad956fbb 100644 --- a/jdk/makefiles/CompileLaunchers.gmk +++ b/jdk/makefiles/CompileLaunchers.gmk @@ -489,8 +489,7 @@ endif # -link -incremental:no # like all other launchers. $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX): $(BUILD_UNPACKEXE) - $(MKDIR) -p $(@D) - $(CP) '$<' '$@' + $(call install-file) BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX) @@ -588,8 +587,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows) $(call SET_SHARED_LIBRARY_MAPFILE,$(JDK_TOPDIR)/makefiles/java/main/java/mapfile-$(OPENJDK_TARGET_CPU)))) else $(JAVA_RMI_CGI): $(JDK_TOPDIR)/src/solaris/bin/java-rmi.cgi.sh - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(CHMOD) a+x $@ endif diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index e73c91f3adb..0158000c130 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -109,7 +109,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM_MAC,\ BUILD_LIBFDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) $(BUILD_LIBFDLIBM) : $(BUILD_LIBFDLIBM_MAC) - $(CP) -a $< $@ + $(call install-file) endif BUILD_LIBRARIES += $(BUILD_LIBFDLIBM) @@ -1838,16 +1838,14 @@ BUILD_LIBRARIES += $(BUILD_LIBNET) $(JDK_OUTPUTDIR)/lib/net.properties: $(JDK_TOPDIR)/src/share/lib/net.properties $(ECHO) $(LOG_INFO) Copying $(@F) - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) COPY_FILES += $(JDK_OUTPUTDIR)/lib/net.properties ifeq ($(OPENJDK_TARGET_OS), solaris) $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${OPENJDK_TARGET_OS_API_DIR}/lib/sdp/sdp.conf.template $(ECHO) $(LOG_INFO) Copying $(@F) - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) COPY_FILES += $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template endif @@ -2168,7 +2166,7 @@ else ifeq ($(OPENJDK_TARGET_OS),macosx) OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static)) $(JDK_OUTPUTDIR)/objs/libjli_static.a : $(BUILD_LIBJLI_STATIC) - $(CP) -a $< $@ + $(call install-file) BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a endif diff --git a/jdk/makefiles/CopyFiles.gmk b/jdk/makefiles/CopyFiles.gmk index 0b4bbfd68ce..6b15e677b32 100644 --- a/jdk/makefiles/CopyFiles.gmk +++ b/jdk/makefiles/CopyFiles.gmk @@ -46,14 +46,10 @@ H_TARGET_FILES =$(INCLUDEDIR)/jdwpTransport.h \ $(OPENJDK_TARGET_OS_INCLUDE)/jawt_md.h $(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/share/javavm/export/%.h - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export/%.h - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES = $(H_TARGET_FILES) @@ -88,22 +84,16 @@ MGMT_SRC_FILES = $(wildcard $(MGMT_LIB_SRC)/*) MGMT_TARGET_FILES = $(subst $(MGMT_LIB_SRC),$(MGMT_LIBDIR),$(MGMT_SRC_FILES)) $(MGMT_LIBDIR)/management.properties: $(MGMT_LIB_SRC)/management.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 644 $@ # this file has different permissions...don't know why... $(MGMT_LIBDIR)/jmxremote.access: $(MGMT_LIB_SRC)/jmxremote.access - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 644 $@ $(MGMT_LIBDIR)/%: $(MGMT_LIB_SRC)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 444 $@ COPY_FILES += $(MGMT_TARGET_FILES) @@ -113,9 +103,7 @@ COPY_FILES += $(MGMT_TARGET_FILES) LOGGING_LIB_SRC = $(JDK_TOPDIR)/src/share/lib $(LIBDIR)/logging.properties: $(LOGGING_LIB_SRC)/logging.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/logging.properties @@ -128,9 +116,7 @@ PSFONTPROPFILE_SRCS = $(wildcard $(PSFONTPROPFILE_SRC_DIR)/*.properties*) PSFONTPROPFILE_TARGET_FILES = $(subst $(PSFONTPROPFILE_SRC_DIR),$(LIBDIR),$(PSFONTPROPFILE_SRCS)) $(LIBDIR)/%: $(PSFONTPROPFILE_SRC_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(PSFONTPROPFILE_TARGET_FILES) @@ -145,9 +131,7 @@ OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/macosx/lib endif $(LIBDIR)/flavormap.properties: $(OPENJDK_TARGET_OS_LIB_SRC)/flavormap.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/flavormap.properties @@ -155,9 +139,7 @@ CURSORS_DEST_DIR = $(LIBDIR)/images/cursors CURSORS_OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib/images/cursors $(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(CURSORS_DEST_DIR)/cursors.properties @@ -170,9 +152,7 @@ endif # OPENJDK_TARGET_OS CURSORS_TARGET_FILES = $(subst $(CURSORS_LIB_SRC),$(CURSORS_DEST_DIR),$(CURSORS_SRC_FILES)) $(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(CURSORS_TARGET_FILES) @@ -181,9 +161,7 @@ COPY_FILES += $(CURSORS_TARGET_FILES) CONTENT_TYPES_SRC=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib $(LIBDIR)/content-types.properties: $(CONTENT_TYPES_SRC)/content-types.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/content-types.properties @@ -192,9 +170,7 @@ COPY_FILES += $(LIBDIR)/content-types.properties CALENDARS_SRC := $(JDK_TOPDIR)/src/share/lib $(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/calendars.properties @@ -205,9 +181,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows) TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib $(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/tzmappings @@ -227,9 +201,7 @@ ICCPROFILE_SRCS:=$(wildcard $(ICCPROFILE_SRC_DIR)/*.pf) ICCPROFILE_TARGET_FILES:=$(subst $(ICCPROFILE_SRC_DIR),$(ICCPROFILE_DEST_DIR),$(ICCPROFILE_SRCS)) $(ICCPROFILE_DEST_DIR)%.pf: $(ICCPROFILE_SRC_DIR)%.pf - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 444 $@ COPY_FILES += $(ICCPROFILE_TARGET_FILES) @@ -279,9 +251,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows) MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL)) # Chmod to avoid permission issues if bundles are unpacked on unix platforms. $(MSVCR_TARGET): $(MSVCR_DLL) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) a+rx $@ COPY_FILES += $(MSVCR_TARGET) @@ -292,9 +262,7 @@ endif HPROF_SRC=$(JDK_TOPDIR)/src/share/demo/jvmti/hprof/jvm.hprof.txt $(LIBDIR)/jvm.hprof.txt : $(HPROF_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/jvm.hprof.txt @@ -351,17 +319,13 @@ ifeq ($(OPENJDK_TARGET_CPU_BITS),32) else # Use the default jvm.cfg for this 32 bit setup. $(JVMCFG): $(JVMCFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif endif else # Use the default jvm.cfg for this 64 bit setup. $(JVMCFG): $(JVMCFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif COPY_FILES += $(JVMCFG) @@ -372,9 +336,7 @@ PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security-$(OPENJDK_TARGET PROPS_DST := $(JDK_OUTPUTDIR)/lib/security/java.security $(PROPS_DST): $(PROPS_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(PROPS_DST) @@ -384,9 +346,7 @@ POLICY_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.policy POLICY_DST := $(JDK_OUTPUTDIR)/lib/security/java.policy $(POLICY_DST): $(POLICY_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(POLICY_DST) @@ -396,9 +356,7 @@ CACERTS_SRC := $(CACERTS_FILE) CACERTS_DST := $(JDK_OUTPUTDIR)/lib/security/cacerts $(CACERTS_DST): $(CACERTS_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(CACERTS_DST) @@ -413,16 +371,12 @@ TRUSTEDLIBS_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/trusted.libraries TRUSTEDLIBS_DST := $(JDK_OUTPUTDIR)/lib/security/trusted.libraries $(BLACKLIST_DST): $(BLACKLIST_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(BLACKLIST_DST) $(TRUSTEDLIBS_DST): $(TRUSTEDLIBS_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(TRUSTEDLIBS_DST) @@ -448,14 +402,10 @@ SHARED_FONTS_SRC := $(foreach F,$(SHARED_FONTS_FILES),$(SHARED_FONTS_SRC_DIR)/$( SHARED_FONTS_DST := $(foreach F,$(SHARED_FONTS_FILES),$(SHARED_FONTS_DST_DIR)/$(F)) $(SHARED_FONTS_DST_DIR)/%.ttf : $(SHARED_FONTS_SRC_DIR)/%.ttf - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(SHARED_FONTS_DST_DIR)/fonts.dir : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/motif/java.fonts.dir - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(SHARED_FONTS_DST) @@ -476,14 +426,10 @@ OBL_FONTS_SRC := $(foreach F,$(OBL_FONTS_FILES),$(OBL_FONTS_SRC_DIR)/$(F)) OBL_FONTS_DST := $(foreach F,$(OBL_FONTS_FILES),$(OBL_FONTS_DST_DIR)/$(F)) $(OBL_FONTS_DST_DIR)/%.ttf : $(OBL_FONTS_SRC_DIR)/%.ttf - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(OBL_FONTS_DST_DIR)/fonts.dir : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/motif/java.oblique-fonts.dir - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(OBL_FONTS_DST) $(OBL_FONTS_DST_DIR)/fonts.dir @@ -502,9 +448,7 @@ JS_RESOURCES_SRC := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_SRC_DIR)/$( JS_RESOURCES_DST := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_DST_DIR)/$(F)) $(JS_RESOURCES_DST_DIR)/% : $(JS_RESOURCES_SRC_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(JS_RESOURCES_DST) @@ -539,15 +483,11 @@ _DGALIBS_amd64 = # no amd64 library yet DGALIBS = $(_DGALIBS_$(OPENJDK_TARGET_CPU_LEGACY):%=$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/%) $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libxinerama.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libxinerama.so - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 755 $@ $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNW%.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libjdgaSUNW%.so - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 755 $@ $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWafb.so: $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWffb.so @@ -567,9 +507,7 @@ SUNPKCS11_CFG_SRC := $(JDK_TOPDIR)/src/share/lib/security/sunpkcs11-solaris.cfg SUNPKCS11_CFG_DST := $(JDK_OUTPUTDIR)/lib/security/sunpkcs11-solaris.cfg $(SUNPKCS11_CFG_DST) : $(SUNPKCS11_CFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(SUNPKCS11_CFG_DST) @@ -584,9 +522,7 @@ UCRYPTO_CFG_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/ucrypto-solaris.c UCRYPTO_CFG_DST := $(JDK_OUTPUTDIR)/lib/security/ucrypto-solaris.cfg $(UCRYPTO_CFG_DST) : $(UCRYPTO_CFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(UCRYPTO_CFG_DST) @@ -596,9 +532,7 @@ endif ########################################################################################## $(JDK_OUTPUTDIR)/lib/sound.properties : $(JDK_TOPDIR)/src/share/lib/sound.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $(@) + $(call install-file) COPY_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties diff --git a/jdk/makefiles/CopyIntoClasses.gmk b/jdk/makefiles/CopyIntoClasses.gmk index 549a58efd68..d4df3424b6e 100644 --- a/jdk/makefiles/CopyIntoClasses.gmk +++ b/jdk/makefiles/CopyIntoClasses.gmk @@ -223,9 +223,7 @@ COPY_EXTRA += $(OUT_SERVICES_FILES_PRINT) ### $(JDK_OUTPUTDIR)/classes/sun/nio/cs/ext/sjis0213.dat : $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs/ext/sjis0213.dat - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $(@) + $(call install-file) COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/sun/nio/cs/ext/sjis0213.dat diff --git a/jdk/makefiles/CopySamples.gmk b/jdk/makefiles/CopySamples.gmk index 7f432f8693b..1f6b3bfb893 100644 --- a/jdk/makefiles/CopySamples.gmk +++ b/jdk/makefiles/CopySamples.gmk @@ -53,19 +53,13 @@ ifneq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx)) endif $(SAMPLE_TARGET_DIR)/dtrace/%: $(SAMPLE_SOLARIS_SOURCE_DIR)/dtrace/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(SAMPLE_TARGET_DIR)/webservices/%: $(SAMPLE_CLOSED_SOURCE_DIR)/webservices/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(SAMPLE_TARGET_DIR)/%: $(SAMPLE_SOURCE_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(SAMPLE_TARGET) diff --git a/jdk/makefiles/GendataFontConfig.gmk b/jdk/makefiles/GendataFontConfig.gmk index 7f539083c9d..189a7327a1d 100644 --- a/jdk/makefiles/GendataFontConfig.gmk +++ b/jdk/makefiles/GendataFontConfig.gmk @@ -72,9 +72,7 @@ endif $(GENDATA_FONT_CONFIG_DST)/%.src : \ $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)% - $(RM) $@ - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(GENDATA_FONT_CONFIG_DST)/%.bfc : \ $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%.properties diff --git a/jdk/makefiles/GensrcCharacterData.gmk b/jdk/makefiles/GensrcCharacterData.gmk index e720ab860ed..f64edbab85c 100644 --- a/jdk/makefiles/GensrcCharacterData.gmk +++ b/jdk/makefiles/GensrcCharacterData.gmk @@ -55,9 +55,8 @@ $(eval $(call SetupCharacterData,CharacterData0E,-plane 14,11 4 1)) # Copy two Java files that need no preprocessing. $(JDK_OUTPUTDIR)/gensrc/java/lang/%.java : $(CHARACTERDATA)/%.java.template - $(MKDIR) -p $(@D) $(ECHO) $(LOG_INFO) Generating $(@F) - $(CP) -f $< $@ + $(call install-file) GENSRC_CHARACTERDATA += $(JDK_OUTPUTDIR)/gensrc/java/lang/CharacterDataUndefined.java \ $(JDK_OUTPUTDIR)/gensrc/java/lang/CharacterDataPrivateUse.java diff --git a/jdk/makefiles/GensrcMisc.gmk b/jdk/makefiles/GensrcMisc.gmk index 72a789b452c..812b2cee6c7 100644 --- a/jdk/makefiles/GensrcMisc.gmk +++ b/jdk/makefiles/GensrcMisc.gmk @@ -72,9 +72,8 @@ ifeq ($(OPENJDK_TARGET_OS_API),posix) $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java : \ $(JDK_TOPDIR)/src/solaris/classes/java/lang/UNIXProcess.java.$(UPSUFFIX) - $(MKDIR) -p $(@D) $(ECHO) $(LOG_INFO) Copying UNIXProcess.java.$(OPENJDK_TARGET_OS) to java/lang/UNIXProcess.java - $(CP) $< $@ + $(call install-file) $(CHMOD) u+rw $@ GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java @@ -114,9 +113,7 @@ $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java : $(BUILD_GENSRC_SO $(MV) $@.tmp $@ else $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif ########################################################################################## @@ -156,9 +153,7 @@ $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java : $(BUILD_GENSRC_UC_EXE) $(MV) $@.tmp $@ else $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif endif diff --git a/jdk/makefiles/GensrcSwing.gmk b/jdk/makefiles/GensrcSwing.gmk index 9f3bff1ba41..f5741ae5f46 100644 --- a/jdk/makefiles/GensrcSwing.gmk +++ b/jdk/makefiles/GensrcSwing.gmk @@ -85,14 +85,12 @@ $(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) $(JDK_OU # For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/javax/swing # Should it be moved under $(JDK_TOPDIR)/src/share/classes/javax/swing instead? $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java: $(DOCLETSRC_DIR)/javax/swing/SwingBeanInfoBase.java - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) # This file is the part of dt.jar # For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/sun/swing # Should it be moved under $(JDK_TOPDIR)/src/share/classes/sun/swing instead? $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java: $(DOCLETSRC_DIR)/sun/swing/BeanInfoUtils.java - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) GENSRC_SWING_BEANINFO = $(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo diff --git a/jdk/makefiles/SignJars.gmk b/jdk/makefiles/SignJars.gmk index 99caa99cc22..6e84d14844a 100644 --- a/jdk/makefiles/SignJars.gmk +++ b/jdk/makefiles/SignJars.gmk @@ -79,8 +79,7 @@ check-keystore: fi $(JCE_OUTPUTDIR)/%: $(IMAGES_OUTPUTDIR)/unsigned/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(JARSIGNER) -keystore $(SIGNING_KEYSTORE) \ $@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE) @$(PRINTF) "\nJar codesigning finished.\n" diff --git a/jdk/makefiles/Tools.gmk b/jdk/makefiles/Tools.gmk index 360cbe4092e..66d08b49be3 100644 --- a/jdk/makefiles/Tools.gmk +++ b/jdk/makefiles/Tools.gmk @@ -47,17 +47,15 @@ $(eval $(call SetupJavaCompilation,BUILD_TOOLS,\ endif $(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/%.template : \ - $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/%.template - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/%.template + $(call install-file) BUILD_TOOLS += $(foreach i,$(wildcard $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/*.template),$(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/$(notdir $i)) # Resources used by CheckDeps tool $(JDK_OUTPUTDIR)/btclasses/build/tools/deps/% : \ - $(JDK_TOPDIR)/make/tools/src/build/tools/deps/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(JDK_TOPDIR)/make/tools/src/build/tools/deps/% + $(call install-file) BUILD_TOOLS += $(JDK_OUTPUTDIR)/btclasses/build/tools/deps/refs.allowed From efdece0bc7d3329480646b98f8dde5adf8741655 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 5 Apr 2013 10:41:46 -0700 Subject: [PATCH 139/155] 8011380: FX dependency on PlatformLogger broken by 8010309 Reviewed-by: alanb --- .../java/util/logging/LoggingProxyImpl.java | 5 + .../sun/util/logging/LoggingProxy.java | 2 + .../sun/util/logging/LoggingSupport.java | 5 + .../sun/util/logging/PlatformLogger.java | 185 ++++++++++++------ .../sun/util/logging/PlatformLoggerTest.java | 108 ++++++---- 5 files changed, 206 insertions(+), 99 deletions(-) diff --git a/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java b/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java index a207d1f8409..736e0c32945 100644 --- a/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java +++ b/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java @@ -105,6 +105,11 @@ class LoggingProxyImpl implements LoggingProxy { return ((Level) level).getLevelName(); } + @Override + public int getLevelValue(Object level) { + return ((Level) level).intValue(); + } + @Override public String getProperty(String key) { return LogManager.getLogManager().getProperty(key); diff --git a/jdk/src/share/classes/sun/util/logging/LoggingProxy.java b/jdk/src/share/classes/sun/util/logging/LoggingProxy.java index 5d8e99982c5..41fb7c85da9 100644 --- a/jdk/src/share/classes/sun/util/logging/LoggingProxy.java +++ b/jdk/src/share/classes/sun/util/logging/LoggingProxy.java @@ -61,6 +61,8 @@ public interface LoggingProxy { public String getLevelName(Object level); + public int getLevelValue(Object level); + // return the logging property public String getProperty(String key); } diff --git a/jdk/src/share/classes/sun/util/logging/LoggingSupport.java b/jdk/src/share/classes/sun/util/logging/LoggingSupport.java index 27f010928ae..eed1c8f1881 100644 --- a/jdk/src/share/classes/sun/util/logging/LoggingSupport.java +++ b/jdk/src/share/classes/sun/util/logging/LoggingSupport.java @@ -140,6 +140,11 @@ public class LoggingSupport { return proxy.getLevelName(level); } + public static int getLevelValue(Object level) { + ensureAvailable(); + return proxy.getLevelValue(level); + } + private static final String DEFAULT_FORMAT = "%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n"; diff --git a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java index ef9789b7bf1..9a1b8930477 100644 --- a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java +++ b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java @@ -32,6 +32,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -84,31 +85,38 @@ import sun.misc.SharedSecrets; * @since 1.7 */ public class PlatformLogger { - // shortcut to PlatformLogger.Level enums - public static final Level OFF = Level.OFF; - public static final Level SEVERE = Level.SEVERE; - public static final Level WARNING = Level.WARNING; - public static final Level INFO = Level.INFO; - public static final Level CONFIG = Level.CONFIG; - public static final Level FINE = Level.FINE; - public static final Level FINER = Level.FINER; - public static final Level FINEST = Level.FINEST; - public static final Level ALL = Level.ALL; + /* + * These constants should be shortcuts to Level enum constants that + * the clients of sun.util.logging.PlatformLogger require no source + * modification and avoid the conversion from int to Level enum. + * + * This can be done when JavaFX is converted to use the new PlatformLogger.Level API. + */ + public static final int OFF = Integer.MAX_VALUE; + public static final int SEVERE = 1000; + public static final int WARNING = 900; + public static final int INFO = 800; + public static final int CONFIG = 700; + public static final int FINE = 500; + public static final int FINER = 400; + public static final int FINEST = 300; + public static final int ALL = Integer.MIN_VALUE; /** * PlatformLogger logging levels. */ public static enum Level { - // The name and value must match that of {@code java.util.logging.Level} objects. - ALL(Integer.MIN_VALUE), - FINEST(300), - FINER(400), - FINE(500), - CONFIG(700), - INFO(800), - WARNING(900), - SEVERE(1000), - OFF(Integer.MAX_VALUE); + // The name and value must match that of {@code java.util.logging.Level}s. + // Declare in ascending order of the given value for binary search. + ALL, + FINEST, + FINER, + FINE, + CONFIG, + INFO, + WARNING, + SEVERE, + OFF; /** * Associated java.util.logging.Level lazily initialized in @@ -118,17 +126,39 @@ public class PlatformLogger { */ /* java.util.logging.Level */ Object javaLevel; - private final int value; + // ascending order for binary search matching the list of enum constants + private static final int[] levelValues = new int[] { + PlatformLogger.ALL, PlatformLogger.FINEST, PlatformLogger.FINER, + PlatformLogger.FINE, PlatformLogger.CONFIG, PlatformLogger.INFO, + PlatformLogger.WARNING, PlatformLogger.SEVERE, PlatformLogger.OFF + }; + public int intValue() { - return value; + return levelValues[this.ordinal()]; } - Level(int value) { - this.value = value; + static Level valueOf(int level) { + switch (level) { + // ordering per the highest occurences in the jdk source + // finest, fine, finer, info first + case PlatformLogger.FINEST : return Level.FINEST; + case PlatformLogger.FINE : return Level.FINE; + case PlatformLogger.FINER : return Level.FINER; + case PlatformLogger.INFO : return Level.INFO; + case PlatformLogger.WARNING : return Level.WARNING; + case PlatformLogger.CONFIG : return Level.CONFIG; + case PlatformLogger.SEVERE : return Level.SEVERE; + case PlatformLogger.OFF : return Level.OFF; + case PlatformLogger.ALL : return Level.ALL; + } + // return the nearest Level value >= the given level, + // for level > SEVERE, return SEVERE and exclude OFF + int i = Arrays.binarySearch(levelValues, 0, levelValues.length-2, level); + return values()[i >= 0 ? i : (-i-1)]; } } - private static final Level DEFAULT_LEVEL = INFO; + private static final Level DEFAULT_LEVEL = Level.INFO; private static boolean loggingEnabled; static { loggingEnabled = AccessController.doPrivileged( @@ -231,11 +261,47 @@ public class PlatformLogger { return loggerProxy.name; } + /** + * Returns true if a message of the given level would actually + * be logged by this logger. + * + * @deprecated Use isLoggable(Level) instead. + */ + @Deprecated + public boolean isLoggable(int levelValue) { + return isLoggable(Level.valueOf(levelValue)); + } + + /** + * Gets the current log level. Returns 0 if the current effective level is + * not set (equivalent to Logger.getLevel() returns null). + * + * @deprecated Use level() instead + */ + @Deprecated + public int getLevel() { + Level level = loggerProxy.getLevel(); + return level != null ? level.intValue() : 0; + } + + /** + * Sets the log level. + * + * @deprecated Use setLevel(Level) instead + */ + @Deprecated + public void setLevel(int newLevel) { + loggerProxy.setLevel(newLevel == 0 ? null : Level.valueOf(newLevel)); + } + /** * Returns true if a message of the given level would actually * be logged by this logger. */ public boolean isLoggable(Level level) { + if (level == null) { + throw new NullPointerException(); + } // performance-sensitive method: use two monomorphic call-sites JavaLoggerProxy jlp = javaLoggerProxy; return jlp != null ? jlp.isLoggable(level) : loggerProxy.isLoggable(level); @@ -246,15 +312,9 @@ public class PlatformLogger { * The result may be null, which means that this logger's * effective level will be inherited from its parent. * - * This method is primarily for testing purpose and not recommended - * to be used at runtime since it does not support custom j.u.l.Level. - * * @return this PlatformLogger's level - * - * @throw IllegalArgumentException if j.u.l.Logger is set to - * a custom j.u.l.Level when java.util.logging facility is enabled */ - public Level getLevel() { + public Level level() { return loggerProxy.getLevel(); } @@ -278,105 +338,105 @@ public class PlatformLogger { * Logs a SEVERE message. */ public void severe(String msg) { - loggerProxy.doLog(SEVERE, msg); + loggerProxy.doLog(Level.SEVERE, msg); } public void severe(String msg, Throwable t) { - loggerProxy.doLog(SEVERE, msg, t); + loggerProxy.doLog(Level.SEVERE, msg, t); } public void severe(String msg, Object... params) { - loggerProxy.doLog(SEVERE, msg, params); + loggerProxy.doLog(Level.SEVERE, msg, params); } /** * Logs a WARNING message. */ public void warning(String msg) { - loggerProxy.doLog(WARNING, msg); + loggerProxy.doLog(Level.WARNING, msg); } public void warning(String msg, Throwable t) { - loggerProxy.doLog(WARNING, msg, t); + loggerProxy.doLog(Level.WARNING, msg, t); } public void warning(String msg, Object... params) { - loggerProxy.doLog(WARNING, msg, params); + loggerProxy.doLog(Level.WARNING, msg, params); } /** * Logs an INFO message. */ public void info(String msg) { - loggerProxy.doLog(INFO, msg); + loggerProxy.doLog(Level.INFO, msg); } public void info(String msg, Throwable t) { - loggerProxy.doLog(INFO, msg, t); + loggerProxy.doLog(Level.INFO, msg, t); } public void info(String msg, Object... params) { - loggerProxy.doLog(INFO, msg, params); + loggerProxy.doLog(Level.INFO, msg, params); } /** * Logs a CONFIG message. */ public void config(String msg) { - loggerProxy.doLog(CONFIG, msg); + loggerProxy.doLog(Level.CONFIG, msg); } public void config(String msg, Throwable t) { - loggerProxy.doLog(CONFIG, msg, t); + loggerProxy.doLog(Level.CONFIG, msg, t); } public void config(String msg, Object... params) { - loggerProxy.doLog(CONFIG, msg, params); + loggerProxy.doLog(Level.CONFIG, msg, params); } /** * Logs a FINE message. */ public void fine(String msg) { - loggerProxy.doLog(FINE, msg); + loggerProxy.doLog(Level.FINE, msg); } public void fine(String msg, Throwable t) { - loggerProxy.doLog(FINE, msg, t); + loggerProxy.doLog(Level.FINE, msg, t); } public void fine(String msg, Object... params) { - loggerProxy.doLog(FINE, msg, params); + loggerProxy.doLog(Level.FINE, msg, params); } /** * Logs a FINER message. */ public void finer(String msg) { - loggerProxy.doLog(FINER, msg); + loggerProxy.doLog(Level.FINER, msg); } public void finer(String msg, Throwable t) { - loggerProxy.doLog(FINER, msg, t); + loggerProxy.doLog(Level.FINER, msg, t); } public void finer(String msg, Object... params) { - loggerProxy.doLog(FINER, msg, params); + loggerProxy.doLog(Level.FINER, msg, params); } /** * Logs a FINEST message. */ public void finest(String msg) { - loggerProxy.doLog(FINEST, msg); + loggerProxy.doLog(Level.FINEST, msg); } public void finest(String msg, Throwable t) { - loggerProxy.doLog(FINEST, msg, t); + loggerProxy.doLog(Level.FINEST, msg, t); } public void finest(String msg, Object... params) { - loggerProxy.doLog(FINEST, msg, params); + loggerProxy.doLog(Level.FINEST, msg, params); } /** @@ -421,7 +481,7 @@ public class PlatformLogger { } boolean isEnabled() { - return effectiveLevel != OFF; + return effectiveLevel != Level.OFF; } Level getLevel() { @@ -457,7 +517,7 @@ public class PlatformLogger { boolean isLoggable(Level level) { Level effectiveLevel = this.effectiveLevel; - return level.intValue() >= effectiveLevel.intValue() && effectiveLevel != OFF; + return level.intValue() >= effectiveLevel.intValue() && effectiveLevel != Level.OFF; } // derive effective level (could do inheritance search like j.u.l.Logger) @@ -611,15 +671,18 @@ public class PlatformLogger { /** * Returns the PlatformLogger.Level mapped from j.u.l.Level - * set in the logger. - * @throw IllegalArgumentException if j.u.l.Logger is set to - * a custom j.u.l.Level + * set in the logger. If the j.u.l.Logger is set to a custom Level, + * this method will return the nearest Level. */ Level getLevel() { Object javaLevel = LoggingSupport.getLevel(javaLogger); - return javaLevel == null - ? null - : Level.valueOf(LoggingSupport.getLevelName(javaLevel)); + if (javaLevel == null) return null; + + try { + return Level.valueOf(LoggingSupport.getLevelName(javaLevel)); + } catch (IllegalArgumentException e) { + return Level.valueOf(LoggingSupport.getLevelValue(javaLevel)); + } } void setLevel(Level level) { diff --git a/jdk/test/sun/util/logging/PlatformLoggerTest.java b/jdk/test/sun/util/logging/PlatformLoggerTest.java index 7fc007aae0f..ac399c097e4 100644 --- a/jdk/test/sun/util/logging/PlatformLoggerTest.java +++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java @@ -36,6 +36,7 @@ import java.lang.reflect.Field; import java.util.logging.*; import sun.util.logging.PlatformLogger; +import static sun.util.logging.PlatformLogger.Level.*; public class PlatformLoggerTest { public static void main(String[] args) throws Exception { @@ -69,42 +70,65 @@ public class PlatformLoggerTest { checkLogger(GOO_PLATFORM_LOGGER, null); checkLogger(BAR_LOGGER, Level.WARNING); - foo.setLevel(PlatformLogger.SEVERE); + foo.setLevel(PlatformLogger.Level.SEVERE); checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE); checkPlatformLoggerLevels(foo, bar); } + // don't use java.util.logging here to prevent it from initialized private static void checkPlatformLogger(PlatformLogger logger, String name) { if (!logger.getName().equals(name)) { throw new RuntimeException("Invalid logger's name " + logger.getName() + " but expected " + name); } - if (logger.getLevel() != null) { + if (logger.level() != null) { throw new RuntimeException("Invalid default level for logger " + - logger.getName() + ": " + logger.getLevel()); + logger.getName() + ": " + logger.level()); } - if (logger.isLoggable(PlatformLogger.FINE) != false) { - throw new RuntimeException("isLoggerable(FINE) returns true for logger " + - logger.getName() + " but expected false"); - } + checkLoggable(logger, FINE, false); - logger.setLevel(PlatformLogger.FINER); - if (logger.getLevel() != PlatformLogger.FINER) { - throw new RuntimeException("Invalid level for logger " + - logger.getName() + " " + logger.getLevel()); - } - - if (logger.isLoggable(PlatformLogger.FINE) != true) { - throw new RuntimeException("isLoggerable(FINE) returns false for logger " + - logger.getName() + " but expected true"); - } + logger.setLevel(FINER); + checkLevel(logger, FINER); + checkLoggable(logger, FINER, true); + checkLoggable(logger, FINE, true); + checkLoggable(logger, FINEST, false); logger.info("OK: Testing log message"); } + private static void checkLoggable(PlatformLogger logger, PlatformLogger.Level level, boolean expected) { + if (logger.isLoggable(level) != expected) { + throw new RuntimeException("logger " + logger.getName() + ": " + level + + (expected ? " not loggable" : " loggable")); + } + + if (logger.isLoggable(level.intValue()) != expected) { + throw new RuntimeException("logger " + logger.getName() + ": " + level.intValue() + + (expected ? " not loggable" : " loggable")); + } + + int value = level.intValue() + 5; // custom level value + if (expected && !logger.isLoggable(value)) { + throw new RuntimeException("logger " + logger.getName() + ": " + value + + " not loggable"); + } + } + + private static void checkLevel(PlatformLogger logger, PlatformLogger.Level level) { + if (logger.level() != level) { + throw new RuntimeException("Invalid level for logger " + + logger.getName() + ": " + logger.level() + " != " + level); + } + + if (logger.getLevel() != level.intValue()) { + throw new RuntimeException("Invalid level for logger " + + logger.getName() + ": " + logger.getLevel() + " != " + level.intValue()); + } + } + private static void checkLogger(String name, Level level) { Logger logger = LogManager.getLogManager().getLogger(name); if (logger == null) { @@ -146,26 +170,32 @@ public class PlatformLoggerTest { for (Level level : levels) { PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName()); for (PlatformLogger logger : loggers) { - // verify PlatformLogger.setLevel to a given level - logger.setLevel(platformLevel); - PlatformLogger.Level retrievedPlatformLevel = logger.getLevel(); - if (platformLevel != retrievedPlatformLevel) { - throw new RuntimeException("Retrieved PlatformLogger level " + - retrievedPlatformLevel + - " is not the same as set level " + platformLevel); - } + logger.setLevel(platformLevel); // setLevel(PlatformLogger.Level) + checkLoggerLevel(logger, level); - // check the level set in java.util.logging.Logger - Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName()); - Level javaLevel = javaLogger.getLevel(); - if (javaLogger.getLevel() != level) { - throw new RuntimeException("Retrieved backing java.util.logging.Logger level " + - javaLevel + " is not the expected " + level); - } + logger.setLevel(ALL); // setLevel(int) + checkLoggerLevel(logger, Level.ALL); } } } + private static void checkLoggerLevel(PlatformLogger logger, Level level) { + PlatformLogger.Level plevel = PlatformLogger.Level.valueOf(level.getName()); + if (plevel != logger.level()) { + throw new RuntimeException("Retrieved PlatformLogger level " + + logger.level() + + " is not the same as set level " + plevel); + } + + // check the level set in java.util.logging.Logger + Logger javaLogger = LogManager.getLogManager().getLogger(logger.getName()); + Level javaLevel = javaLogger.getLevel(); + if (javaLogger.getLevel() != level) { + throw new RuntimeException("Retrieved backing java.util.logging.Logger level " + + javaLevel + " is not the expected " + level); + } + } + private static void checkPlatformLoggerLevelMapping(Level level) { // map the given level to PlatformLogger.Level of the same name and value PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName()); @@ -174,21 +204,23 @@ public class PlatformLoggerTest { + " PlatformLogger.Level" + platformLevel); } - PlatformLogger.Level plevel; try { // validate if there is a public static final field in PlatformLogger - // matching the level name - Field platformLevelField = PlatformLogger.class.getField(level.getName()); - plevel = (PlatformLogger.Level) platformLevelField.get(null); + Field constantField = PlatformLogger.class.getField(level.getName()); + int l = (int) constantField.get(null); + if (l != platformLevel.intValue()) { + throw new RuntimeException("static final " + level.getName() + " (" + + l + ") != " + platformLevel.intValue()); + } } catch (Exception e) { throw new RuntimeException("No public static PlatformLogger." + level.getName() + " field", e); } - if (!plevel.name().equals(level.getName())) + if (!platformLevel.name().equals(level.getName())) throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is " + platformLevel.name() + " but expected " + level.getName()); - if (plevel.intValue() != level.intValue()) + if (platformLevel.intValue() != level.intValue()) throw new RuntimeException("The value of PlatformLogger." + level.intValue() + ".intValue() is " + platformLevel.intValue() + " but expected " + level.intValue()); } From a7b0073f5aeae1771219f0133c8c476b055aeb0b Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 5 Apr 2013 12:12:34 -0700 Subject: [PATCH 140/155] 5001942: Missings SOCKS support for direct connections Add support for socksNonProxyHosts Reviewed-by: chegar, khazra --- .../classes/sun/net/spi/DefaultProxySelector.java | 3 +++ jdk/test/java/net/Socks/SocksProxyVersion.java | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java b/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java index 37fb6c71142..0e786fe72e6 100644 --- a/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java +++ b/jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java @@ -124,6 +124,7 @@ public class DefaultProxySelector extends ProxySelector { final String defaultVal; static NonProxyInfo ftpNonProxyInfo = new NonProxyInfo("ftp.nonProxyHosts", null, null, defStringVal); static NonProxyInfo httpNonProxyInfo = new NonProxyInfo("http.nonProxyHosts", null, null, defStringVal); + static NonProxyInfo socksNonProxyInfo = new NonProxyInfo("socksNonProxyHosts", null, null, defStringVal); NonProxyInfo(String p, String s, RegexpPool pool, String d) { property = p; @@ -186,6 +187,8 @@ public class DefaultProxySelector extends ProxySelector { pinfo = NonProxyInfo.httpNonProxyInfo; } else if ("ftp".equalsIgnoreCase(protocol)) { pinfo = NonProxyInfo.ftpNonProxyInfo; + } else if ("socket".equalsIgnoreCase(protocol)) { + pinfo = NonProxyInfo.socksNonProxyInfo; } /** diff --git a/jdk/test/java/net/Socks/SocksProxyVersion.java b/jdk/test/java/net/Socks/SocksProxyVersion.java index fe4f1c65b72..bc46c423a09 100644 --- a/jdk/test/java/net/Socks/SocksProxyVersion.java +++ b/jdk/test/java/net/Socks/SocksProxyVersion.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6964547 + * @bug 6964547 5001942 * @run main/othervm SocksProxyVersion * @summary test socksProxyVersion system property */ @@ -34,6 +34,7 @@ import java.net.Socket; import java.net.SocketException; import java.io.DataInputStream; import java.io.IOException; +import java.net.InetAddress; public class SocksProxyVersion implements Runnable { final ServerSocket ss; @@ -56,13 +57,19 @@ public class SocksProxyVersion implements Runnable { Thread serverThread = new Thread(this); serverThread.start(); - System.setProperty("socksProxyHost", "localhost"); + /* + * Retreving the IP Address of the machine + * since "localhost" is bypassed as a non-proxy host + */ + String addr = InetAddress.getLocalHost().getHostAddress(); + + System.setProperty("socksProxyHost", addr); System.setProperty("socksProxyPort", Integer.toString(port)); // SOCKS V4 System.setProperty("socksProxyVersion", Integer.toString(4)); try (Socket s = new Socket()) { - s.connect(new InetSocketAddress("localhost", port)); + s.connect(new InetSocketAddress(addr, port)); } catch (SocketException e) { // java.net.SocketException: Malformed reply from SOCKS server // This exception is OK, since the "server" does not implement @@ -72,7 +79,7 @@ public class SocksProxyVersion implements Runnable { // SOCKS V5 System.setProperty("socksProxyVersion", Integer.toString(5)); try (Socket s = new Socket()) { - s.connect(new InetSocketAddress("localhost", port)); + s.connect(new InetSocketAddress(addr, port)); } catch (SocketException e) { /* OK */ } serverThread.join(); From 963eb2f9d7f034c9a1466af5553ce0b0f0022c94 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Fri, 5 Apr 2013 17:15:59 -0700 Subject: [PATCH 141/155] 8011602: jobjc build failure on Mac Remove @Native annotation from macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java Reviewed-by: mchung, dholmes --- .../src/core/java/com/apple/jobjc/Coder.java | 27 +++++++++---------- .../classes/sun/java2d/opengl/OGLContext.java | 21 ++++++++++----- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java index 6087f1fd076..9efc76e9c05 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java +++ b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java @@ -35,26 +35,25 @@ import com.apple.jobjc.PrimitiveCoder.SCharCoder; import com.apple.jobjc.PrimitiveCoder.SIntCoder; import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; import com.apple.jobjc.PrimitiveCoder.SShortCoder; -import java.lang.annotation.Native; public abstract class Coder { private static native long getNativeFFITypePtrForCode(final int code); - @Native static final int FFI_VOID = 0; - @Native static final int FFI_PTR = FFI_VOID+1; + static final int FFI_VOID = 0; + static final int FFI_PTR = FFI_VOID+1; - @Native static final int FFI_SINT8 = FFI_PTR+1; - @Native static final int FFI_UINT8 = FFI_SINT8+1; - @Native static final int FFI_SINT16 = FFI_UINT8+1; - @Native static final int FFI_UINT16 = FFI_SINT16+1; - @Native static final int FFI_SINT32 = FFI_UINT16+1; - @Native static final int FFI_UINT32 = FFI_SINT32+1; - @Native static final int FFI_SINT64 = FFI_UINT32+1; - @Native static final int FFI_UINT64 = FFI_SINT64+1; + static final int FFI_SINT8 = FFI_PTR+1; + static final int FFI_UINT8 = FFI_SINT8+1; + static final int FFI_SINT16 = FFI_UINT8+1; + static final int FFI_UINT16 = FFI_SINT16+1; + static final int FFI_SINT32 = FFI_UINT16+1; + static final int FFI_UINT32 = FFI_SINT32+1; + static final int FFI_SINT64 = FFI_UINT32+1; + static final int FFI_UINT64 = FFI_SINT64+1; - @Native static final int FFI_FLOAT = FFI_UINT64+1; - @Native static final int FFI_DOUBLE = FFI_FLOAT+1; - @Native static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; + static final int FFI_FLOAT = FFI_UINT64+1; + static final int FFI_DOUBLE = FFI_FLOAT+1; + static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; private static long[] ffiCodesToFFITypePtrs; static{ diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java b/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java index be1e27f34a3..e3ac65f92c2 100644 --- a/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java +++ b/jdk/src/share/classes/sun/java2d/opengl/OGLContext.java @@ -161,32 +161,39 @@ public class OGLContext extends BufferedContext { * This cap will only be set if the fbobject system property has been * enabled and we are able to create an FBO with depth buffer. */ - @Native static final int CAPS_EXT_FBOBJECT = + @Native + static final int CAPS_EXT_FBOBJECT = (CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE); /** Indicates that the context supports a stored alpha channel. */ - @Native static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA; + @Native + static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA; /** Indicates that the context is doublebuffered. */ - @Native static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0); + @Native + static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0); /** * Indicates the presence of the GL_ARB_fragment_shader extension. * This cap will only be set if the lcdshader system property has been * enabled and the hardware supports the minimum number of texture units */ - @Native static final int CAPS_EXT_LCD_SHADER = (FIRST_PRIVATE_CAP << 1); + @Native + static final int CAPS_EXT_LCD_SHADER = (FIRST_PRIVATE_CAP << 1); /** * Indicates the presence of the GL_ARB_fragment_shader extension. * This cap will only be set if the biopshader system property has been * enabled and the hardware meets our minimum requirements. */ - @Native static final int CAPS_EXT_BIOP_SHADER = (FIRST_PRIVATE_CAP << 2); + @Native + static final int CAPS_EXT_BIOP_SHADER = (FIRST_PRIVATE_CAP << 2); /** * Indicates the presence of the GL_ARB_fragment_shader extension. * This cap will only be set if the gradshader system property has been * enabled and the hardware meets our minimum requirements. */ - @Native static final int CAPS_EXT_GRAD_SHADER = (FIRST_PRIVATE_CAP << 3); + @Native + static final int CAPS_EXT_GRAD_SHADER = (FIRST_PRIVATE_CAP << 3); /** Indicates the presence of the GL_ARB_texture_rectangle extension. */ - @Native static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4); + @Native + static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4); OGLContextCaps(int caps, String adapterId) { super(caps, adapterId); From 76a59cf150ce8bbfe018a25471792df24c15e64a Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 5 Apr 2013 18:20:12 -0700 Subject: [PATCH 142/155] 8011590: More tests for core reflection modeling of default methods Reviewed-by: mduigou --- .../reflect/Method/DefaultMethodModeling.java | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java diff --git a/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java b/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java new file mode 100644 index 00000000000..f05dd023f9a --- /dev/null +++ b/jdk/test/java/lang/reflect/Method/DefaultMethodModeling.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2013 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 8011590 + * @summary Check modeling of default methods + * @author Joseph D. Darcy + */ + +import java.util.Objects; +import java.lang.reflect.*; +import java.lang.annotation.*; + +import static java.lang.reflect.Modifier.*; + +public class DefaultMethodModeling { + public static void main(String... args) { + int failures = 0; + + Class[] classes = {SuperC.class, SuperCchild.class, + SuperI.class, SuperIchild.class, + SuperIwithDefault.class, SuperIwithDefaultChild.class, + Base.class, Combo1.class, Combo2.class, + SonSuperIwithDefault.class, DaughterSuperIwithDefault.class, GrandchildSuperIwithDefault.class, D.class, + B.class, C.class + }; + + for(Class clazz : classes) { + System.err.println(clazz.toString()); + for(Method m : clazz.getMethods()) { + if (m.getDeclaringClass() != java.lang.Object.class) + failures += testMethod(m); + } + } + + if (failures > 0) + throw new RuntimeException(); + } + + private static int testMethod(Method m) { + ExpectedModel em = Objects.requireNonNull(m.getAnnotation(ExpectedModel.class)); + boolean failed = false; + + if (m.getModifiers() != em.modifiers()) { + failed = true; + System.err.printf("Unexpected modifiers %d; expected %d%n", m.getModifiers(), em.modifiers()); + } + + if (m.isDefault() != em.isDefault()) { + failed = true; + System.err.printf("Unexpected isDefualt %b; expected b%n", m.isDefault(), em.isDefault()); + } + + if (!m.getDeclaringClass().equals(em.declaringClass())) { + failed = true; + System.err.printf("Unexpected isDefualt %s; expected %s%n", + m.getDeclaringClass().toString(), em.declaringClass().toString()); + } + + return (!failed) ? 0 :1; + } +} + +@Retention(RetentionPolicy.RUNTIME) +@interface ExpectedModel { + boolean isDefault() default false; + int modifiers() default PUBLIC; + Class declaringClass(); +} + +abstract class SuperC { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperC.class) + public abstract void foo(); + + @ExpectedModel(declaringClass=SuperC.class) + public void bar() { + ; + } +} + +class SuperCchild extends SuperC { + @ExpectedModel(declaringClass=SuperCchild.class) + @Override + public void foo() {;} +} + +// -=-=-=- + +interface SuperI { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperI.class) + void foo(); + + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperI.class) + void bar(); +} + +class SuperIchild implements SuperI { + @ExpectedModel(declaringClass=SuperIchild.class) + public void foo() {;} + + @ExpectedModel(declaringClass=SuperIchild.class) + public void bar() {;} +} + +// -=-=-=- + +interface SuperIwithDefault { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SuperIwithDefault.class) + void foo(); + + @ExpectedModel(isDefault=true, declaringClass=SuperIwithDefault.class) + default void bar() { + ; + } +} + +class SuperIwithDefaultChild implements SuperIwithDefault { + @ExpectedModel(declaringClass=SuperIwithDefaultChild.class) + @Override + public void foo() {;} +} + +// -=-=-=- + +abstract class Base { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=Base.class) + abstract public void baz(); + + @ExpectedModel(declaringClass=Base.class) + public void quux() {;} +} + +abstract class Combo1 extends Base implements SuperI { + @ExpectedModel(declaringClass=Combo1.class) + public void wombat() {} +} + +abstract class Combo2 extends Base implements SuperIwithDefault { + @ExpectedModel(declaringClass=Combo2.class) + public void wombat() {} +} + +// -=-=-=- + +interface SonSuperIwithDefault extends SuperIwithDefault { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=SonSuperIwithDefault.class) + void baz(); + + @ExpectedModel(isDefault=true, declaringClass=SonSuperIwithDefault.class) + default void bazD() {;} +} + +interface DaughterSuperIwithDefault extends SuperIwithDefault { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=DaughterSuperIwithDefault.class) + void quux(); + + @ExpectedModel(isDefault=true, declaringClass=DaughterSuperIwithDefault.class) + default void quuxD() {;} +} + +interface GrandchildSuperIwithDefault extends SonSuperIwithDefault, DaughterSuperIwithDefault { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=GrandchildSuperIwithDefault.class) + void wombat(); + + @ExpectedModel(isDefault=true, declaringClass=GrandchildSuperIwithDefault.class) + default void wombatD() {;} + +} + +class D implements GrandchildSuperIwithDefault { + @ExpectedModel(declaringClass=D.class) + public void wombat(){} + + @ExpectedModel(declaringClass=D.class) + public void baz(){} + + @ExpectedModel(declaringClass=D.class) + public void foo(){} + + @ExpectedModel(declaringClass=D.class) + public void quux(){} +} + +// -=-=-=- + +// What does re-abstraction look like? + +class A implements SuperIwithDefault { + @ExpectedModel(declaringClass=A.class) + @Override + public void foo(){;} +} + +abstract class B extends A { + @ExpectedModel(modifiers=PUBLIC|ABSTRACT, declaringClass=B.class) + @Override + public abstract void bar(); +} + +class C extends B implements SuperIwithDefault { + @ExpectedModel(declaringClass=C.class) + public void bar(){} +} From ca98a33db4fdac3607e62b8baf784bd068facca5 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 8 Apr 2013 14:07:32 -0400 Subject: [PATCH 143/155] 8011388: Support building zero and zeroshark with the new build Co-authored-by: Roman Kennke Reviewed-by: andrew, dholmes, erikj --- common/autoconf/generated-configure.sh | 224 ++++++++++++++++++++++++- common/autoconf/hotspot-spec.gmk.in | 13 ++ common/autoconf/jdk-options.m4 | 9 + common/autoconf/libraries.m4 | 55 +++++- common/autoconf/platform.m4 | 23 +++ common/autoconf/spec.gmk.in | 2 + 6 files changed, 323 insertions(+), 3 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 259b93866fb..20953b32231 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -609,6 +609,12 @@ SALIB_NAME HOTSPOT_MAKE_ARGS FIXPATH LIBCXX +LLVM_LIBS +LLVM_LDFLAGS +LLVM_CFLAGS +LLVM_CONFIG +LIBFFI_LIBS +LIBFFI_CFLAGS STATIC_CXX_SETTING LIBDL LIBM @@ -811,6 +817,7 @@ FASTDEBUG VARIANT DEBUG_LEVEL MACOSX_UNIVERSAL +INCLUDE_SA JVM_VARIANT_ZEROSHARK JVM_VARIANT_ZERO JVM_VARIANT_KERNEL @@ -826,6 +833,8 @@ BUILD_LOG SYS_ROOT PATH_SEP SRC_ROOT +ZERO_ARCHDEF +ZERO_ARCHFLAG DEFINE_CROSS_COMPILE_ARCH LP64 OPENJDK_TARGET_OS_API_DIR @@ -1039,7 +1048,9 @@ XMKMF FREETYPE2_CFLAGS FREETYPE2_LIBS ALSA_CFLAGS -ALSA_LIBS' +ALSA_LIBS +LIBFFI_CFLAGS +LIBFFI_LIBS' # Initialize some variables set by options. @@ -1809,6 +1820,9 @@ Some influential environment variables: linker flags for FREETYPE2, overriding pkg-config ALSA_CFLAGS C compiler flags for ALSA, overriding pkg-config ALSA_LIBS linker flags for ALSA, overriding pkg-config + LIBFFI_CFLAGS + C compiler flags for LIBFFI, overriding pkg-config + LIBFFI_LIBS linker flags for LIBFFI, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -7084,6 +7098,29 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + # Some Zero and Shark settings. + # ZERO_ARCHFLAG tells the compiler which mode to build for + case "${OPENJDK_TARGET_CPU}" in + s390) + ZERO_ARCHFLAG="-m31" + ;; + *) + ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}" + esac + + + # ZERO_ARCHDEF is used to enable architecture-specific code + case "${OPENJDK_TARGET_CPU}" in + ppc*) ZERO_ARCHDEF=PPC ;; + s390*) ZERO_ARCHDEF=S390 ;; + sparc*) ZERO_ARCHDEF=SPARC ;; + x86_64*) ZERO_ARCHDEF=AMD64 ;; + x86) ZERO_ARCHDEF=IA32 ;; + *) ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z) + esac + + + # Continue setting up basic stuff. Most remaining code require fundamental tools. @@ -7694,6 +7731,15 @@ fi +INCLUDE_SA=true +if test "x$JVM_VARIANT_ZERO" = xtrue ; then + INCLUDE_SA=false +fi +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then + INCLUDE_SA=false +fi + + if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then MACOSX_UNIVERSAL="true" fi @@ -31693,7 +31739,7 @@ $as_echo "$has_static_libstdcxx" >&6; } $as_echo_n "checking how to link with libstdc++... " >&6; } # If dynamic was requested, it's available since it would fail above otherwise. # If dynamic wasn't requested, go with static unless it isn't available. - if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then + if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" @@ -31709,6 +31755,180 @@ $as_echo "static" >&6; } fi +if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBFFI" >&5 +$as_echo_n "checking for LIBFFI... " >&6; } + +if test -n "$LIBFFI_CFLAGS"; then + pkg_cv_LIBFFI_CFLAGS="$LIBFFI_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libffi\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libffi") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBFFI_CFLAGS=`$PKG_CONFIG --cflags "libffi" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBFFI_LIBS"; then + pkg_cv_LIBFFI_LIBS="$LIBFFI_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libffi\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libffi") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBFFI_LIBS=`$PKG_CONFIG --libs "libffi" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBFFI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libffi" 2>&1` + else + LIBFFI_PKG_ERRORS=`$PKG_CONFIG --print-errors "libffi" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBFFI_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libffi) were not met: + +$LIBFFI_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables LIBFFI_CFLAGS +and LIBFFI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" "$LINENO" 5 +elif test $pkg_failed = untried; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables LIBFFI_CFLAGS +and LIBFFI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS + LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + : +fi + +fi + +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + # Extract the first word of "llvm-config", so it can be a program name with args. +set dummy llvm-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_LLVM_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LLVM_CONFIG"; then + ac_cv_prog_LLVM_CONFIG="$LLVM_CONFIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_LLVM_CONFIG="llvm-config" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LLVM_CONFIG=$ac_cv_prog_LLVM_CONFIG +if test -n "$LLVM_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5 +$as_echo "$LLVM_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + if test "x$LLVM_CONFIG" != xllvm-config; then + as_fn_error $? "llvm-config not found in $PATH." "$LINENO" 5 + fi + + llvm_components="jit mcjit engine nativecodegen native" + unset LLVM_CFLAGS + for flag in $("$LLVM_CONFIG" --cxxflags); do + if echo "${flag}" | grep -q '^-[ID]'; then + if test "${flag}" != "-D_DEBUG" ; then + if test "${LLVM_CFLAGS}" != "" ; then + LLVM_CFLAGS="${LLVM_CFLAGS} " + fi + LLVM_CFLAGS="${LLVM_CFLAGS}${flag}" + fi + fi + done + llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//') + LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}" + + unset LLVM_LDFLAGS + for flag in $("${LLVM_CONFIG}" --ldflags); do + if echo "${flag}" | grep -q '^-L'; then + if test "${LLVM_LDFLAGS}" != ""; then + LLVM_LDFLAGS="${LLVM_LDFLAGS} " + fi + LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}" + fi + done + + unset LLVM_LIBS + for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do + if echo "${flag}" | grep -q '^-l'; then + if test "${LLVM_LIBS}" != ""; then + LLVM_LIBS="${LLVM_LIBS} " + fi + LLVM_LIBS="${LLVM_LIBS}${flag}" + fi + done + + + + +fi + # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so) if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1" diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in index 5b120e73335..17b404a5902 100644 --- a/common/autoconf/hotspot-spec.gmk.in +++ b/common/autoconf/hotspot-spec.gmk.in @@ -75,6 +75,19 @@ ARCH=$(OPENJDK_TARGET_CPU_LEGACY) # If yes then this expands to _LP64:=1 @LP64@ +# Legacy settings for zero +ZERO_ENDIANNESS=$(OPENJDK_TARGET_CPU_ENDIAN) +ZERO_LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB) +ZERO_ARCHDEF=@ZERO_ARCHDEF@ +ZERO_ARCHFLAG=@ZERO_ARCHFLAG@ +LIBFFI_CFLAGS=@LIBFFI_CFLAGS@ +LIBFFI_LIBS=@LIBFFI_LIBS@ + +# Legacy settings for zeroshark +LLVM_CFLAGS=@LLVM_CFLAGS@ +LLVM_LIBS=@LLVM_LIBS@ +LLVM_LDFLAGS=@LLVM_LDFLAGS@ + ALT_OUTPUTDIR=$(HOTSPOT_OUTPUTDIR) ALT_EXPORT_PATH=$(HOTSPOT_DIST) diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 7e286036c51..268bd842f10 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -121,6 +121,15 @@ AC_SUBST(JVM_VARIANT_KERNEL) AC_SUBST(JVM_VARIANT_ZERO) AC_SUBST(JVM_VARIANT_ZEROSHARK) +INCLUDE_SA=true +if test "x$JVM_VARIANT_ZERO" = xtrue ; then + INCLUDE_SA=false +fi +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then + INCLUDE_SA=false +fi +AC_SUBST(INCLUDE_SA) + if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then MACOSX_UNIVERSAL="true" fi diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 21c5a96f292..58c9c783b2b 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -687,7 +687,7 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then AC_MSG_CHECKING([how to link with libstdc++]) # If dynamic was requested, it's available since it would fail above otherwise. # If dynamic wasn't requested, go with static unless it isn't available. - if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then + if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" @@ -701,6 +701,59 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then fi AC_SUBST(STATIC_CXX_SETTING) +if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS + PKG_CHECK_MODULES([LIBFFI], [libffi]) + +fi + +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config]) + + if test "x$LLVM_CONFIG" != xllvm-config; then + AC_MSG_ERROR([llvm-config not found in $PATH.]) + fi + + llvm_components="jit mcjit engine nativecodegen native" + unset LLVM_CFLAGS + for flag in $("$LLVM_CONFIG" --cxxflags); do + if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then + if test "${flag}" != "-D_DEBUG" ; then + if test "${LLVM_CFLAGS}" != "" ; then + LLVM_CFLAGS="${LLVM_CFLAGS} " + fi + LLVM_CFLAGS="${LLVM_CFLAGS}${flag}" + fi + fi + done + llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//') + LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}" + + unset LLVM_LDFLAGS + for flag in $("${LLVM_CONFIG}" --ldflags); do + if echo "${flag}" | grep -q '^-L'; then + if test "${LLVM_LDFLAGS}" != ""; then + LLVM_LDFLAGS="${LLVM_LDFLAGS} " + fi + LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}" + fi + done + + unset LLVM_LIBS + for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do + if echo "${flag}" | grep -q '^-l'; then + if test "${LLVM_LIBS}" != ""; then + LLVM_LIBS="${LLVM_LIBS} " + fi + LLVM_LIBS="${LLVM_LIBS}${flag}" + fi + done + + AC_SUBST(LLVM_CFLAGS) + AC_SUBST(LLVM_LDFLAGS) + AC_SUBST(LLVM_LIBS) +fi + # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so) if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1" diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 2977606ba79..067650688c3 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -332,6 +332,29 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS], DEFINE_CROSS_COMPILE_ARCH="" fi AC_SUBST(DEFINE_CROSS_COMPILE_ARCH) + + # Some Zero and Shark settings. + # ZERO_ARCHFLAG tells the compiler which mode to build for + case "${OPENJDK_TARGET_CPU}" in + s390) + ZERO_ARCHFLAG="-m31" + ;; + *) + ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}" + esac + AC_SUBST(ZERO_ARCHFLAG) + + # ZERO_ARCHDEF is used to enable architecture-specific code + case "${OPENJDK_TARGET_CPU}" in + ppc*) ZERO_ARCHDEF=PPC ;; + s390*) ZERO_ARCHDEF=S390 ;; + sparc*) ZERO_ARCHDEF=SPARC ;; + x86_64*) ZERO_ARCHDEF=AMD64 ;; + x86) ZERO_ARCHDEF=IA32 ;; + *) ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z) + esac + AC_SUBST(ZERO_ARCHDEF) + ]) AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES], diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 11d19a342d7..e84b0749b48 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -636,6 +636,8 @@ INSTALL_SYSCONFDIR=@sysconfdir@ # Name of Service Agent library SALIB_NAME=@SALIB_NAME@ +INCLUDE_SA=@INCLUDE_SA@ + OS_VERSION_MAJOR:=@OS_VERSION_MAJOR@ OS_VERSION_MINOR:=@OS_VERSION_MINOR@ OS_VERSION_MICRO:=@OS_VERSION_MICRO@ From 7f1fd4ecb92638fb0b62f0e794fc9be64548b472 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 8 Apr 2013 14:09:01 -0400 Subject: [PATCH 144/155] 8011388: Support building zero and zeroshark with the new build Co-authored-by: Roman Kennke Reviewed-by: andrew, dholmes, erikj --- jdk/makefiles/Profiles.gmk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jdk/makefiles/Profiles.gmk b/jdk/makefiles/Profiles.gmk index 316d2d34329..47fadcc9df9 100644 --- a/jdk/makefiles/Profiles.gmk +++ b/jdk/makefiles/Profiles.gmk @@ -93,8 +93,11 @@ ALL_JARS := $(FULL_JRE_JARS) \ $(IMAGES_OUTPUTDIR)/lib/dt.jar \ $(IMAGES_OUTPUTDIR)/lib/tools.jar \ $(IMAGES_OUTPUTDIR)/lib/ct.sym \ - $(IMAGES_OUTPUTDIR)/src.zip \ - $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar + $(IMAGES_OUTPUTDIR)/src.zip + +ifeq ($(INCLUDE_SA),true) + ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar +endif ifeq ($(OPENJDK_TARGET_OS),solaris) ifndef OPENJDK From 4b5d81c5106df183356ff0d9f9b7db4fa6c722af Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Mon, 8 Apr 2013 15:29:24 -0400 Subject: [PATCH 145/155] 8006036: (process) cleanup code in java/lang/Runtime/exec/WinCommand.java Reviewed-by: lancea --- .../java/lang/Runtime/exec/WinCommand.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/jdk/test/java/lang/Runtime/exec/WinCommand.java b/jdk/test/java/lang/Runtime/exec/WinCommand.java index a812bffd135..6d34a1e433c 100644 --- a/jdk/test/java/lang/Runtime/exec/WinCommand.java +++ b/jdk/test/java/lang/Runtime/exec/WinCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013 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 @@ -135,19 +135,24 @@ public class WinCommand { // Win9x systems don't have a cmd.exe if (new File(systemDirW, "cmd.exe").exists()) { - out.println("Running cmd.exe tests..."); - writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n"); - writeFile("cdbat.bat", "@echo off\r\nCD\r\n"); - checkCD("cmd", - "cmd.exe", - systemDirW + "\\cmd.exe", - // Only the ".exe" extension can be omitted - systemDirW + "\\cmd", - systemDirM + "/cmd.exe", - systemDirM + "/cmd", - "/" + systemDirM + "/cmd", - "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd", - "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat"); + try { + out.println("Running cmd.exe tests..."); + writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n"); + writeFile("cdbat.bat", "@echo off\r\nCD\r\n"); + checkCD("cmd", + "cmd.exe", + systemDirW + "\\cmd.exe", + // Only the ".exe" extension can be omitted + systemDirW + "\\cmd", + systemDirM + "/cmd.exe", + systemDirM + "/cmd", + "/" + systemDirM + "/cmd", + "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd", + "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat"); + } finally { + new File("cdcmd.cmd").delete(); + new File("cdbat.bat").delete(); + } } // 16-bit apps like command.com must have a console; From 35d38242d26e7d4407455242d9ad3728b4831637 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Mon, 8 Apr 2013 16:37:35 -0700 Subject: [PATCH 146/155] 8010849: (str) Optimize StringBuilder.append(null) Append 4 chars instead of the string "null" Reviewed-by: mduigou, forax, jgish --- .../java/lang/AbstractStringBuilder.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java index 2d71795a5ca..c319fa4da6e 100644 --- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java +++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java @@ -415,7 +415,8 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * @return a reference to this object. */ public AbstractStringBuilder append(String str) { - if (str == null) str = "null"; + if (str == null) + return appendNull(); int len = str.length(); ensureCapacityInternal(count + len); str.getChars(0, len, value, count); @@ -426,7 +427,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { // Documentation in subclasses because of synchro difference public AbstractStringBuilder append(StringBuffer sb) { if (sb == null) - return append("null"); + return appendNull(); int len = sb.length(); ensureCapacityInternal(count + len); sb.getChars(0, len, value, count); @@ -439,7 +440,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { */ AbstractStringBuilder append(AbstractStringBuilder asb) { if (asb == null) - return append("null"); + return appendNull(); int len = asb.length(); ensureCapacityInternal(count + len); asb.getChars(0, len, value, count); @@ -451,7 +452,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { @Override public AbstractStringBuilder append(CharSequence s) { if (s == null) - s = "null"; + return appendNull(); if (s instanceof String) return this.append((String)s); if (s instanceof AbstractStringBuilder) @@ -460,6 +461,18 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { return this.append(s, 0, s.length()); } + private AbstractStringBuilder appendNull() { + int c = count; + ensureCapacityInternal(c + 4); + final char[] value = this.value; + value[c++] = 'n'; + value[c++] = 'u'; + value[c++] = 'l'; + value[c++] = 'l'; + count = c; + return this; + } + /** * Appends a subsequence of the specified {@code CharSequence} to this * sequence. From 2c7f3d292f358928104a8d95ec38b15d879d2ade Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 8 Apr 2013 17:06:20 -0700 Subject: [PATCH 147/155] 6298888: Add toGenericString to j.l.Class and getTypeName to j.l.reflect.Type 6992705: Include modifiers in Class.toGenericString() Class.toGenericString and supporting changes; additional reviews by Peter Levart Reviewed-by: alanb --- jdk/src/share/classes/java/lang/Class.java | 98 ++++++++++++++++++- .../java/lang/reflect/Constructor.java | 2 +- .../classes/java/lang/reflect/Executable.java | 6 +- .../classes/java/lang/reflect/Field.java | 32 +----- .../classes/java/lang/reflect/Method.java | 24 ++--- .../classes/java/lang/reflect/Modifier.java | 7 +- .../classes/java/lang/reflect/Parameter.java | 8 +- .../share/classes/java/lang/reflect/Type.java | 13 ++- .../java/lang/Class/GenericStringTest.java | 90 +++++++++++++++++ 9 files changed, 220 insertions(+), 60 deletions(-) create mode 100644 jdk/test/java/lang/Class/GenericStringTest.java diff --git a/jdk/src/share/classes/java/lang/Class.java b/jdk/src/share/classes/java/lang/Class.java index f0ab8b24edc..5fd388d657d 100644 --- a/jdk/src/share/classes/java/lang/Class.java +++ b/jdk/src/share/classes/java/lang/Class.java @@ -113,8 +113,7 @@ import sun.reflect.misc.ReflectUtil; * @see java.lang.ClassLoader#defineClass(byte[], int, int) * @since JDK1.0 */ -public final - class Class implements java.io.Serializable, +public final class Class implements java.io.Serializable, java.lang.reflect.GenericDeclaration, java.lang.reflect.Type, java.lang.reflect.AnnotatedElement { @@ -150,6 +149,75 @@ public final + getName(); } + /** + * Returns a string describing this {@code Class}, including + * information about modifiers and type parameters. + * + * The string is formatted as a list of type modifiers, if any, + * followed by the kind of type (empty string for primitive types + * and {@code class}, {@code enum}, {@code interface}, or {@code + * @interface}, as appropriate), followed by the type's name, + * followed by an angle-bracketed comma-separated list of the + * type's type parameters, if any. + * + * A space is used to separate modifiers from one another and to + * separate any modifiers from the kind of type. The modifiers + * occur in canonical order. If there are no type parameters, the + * type parameter list is elided. + * + *

    Note that since information about the runtime representation + * of a type is being generated, modifiers not present on the + * originating source code or illegal on the originating source + * code may be present. + * + * @return a string describing this {@code Class}, including + * information about modifiers and type parameters + * + * @since 1.8 + */ + public String toGenericString() { + if (isPrimitive()) { + return toString(); + } else { + StringBuilder sb = new StringBuilder(); + + // Class modifiers are a superset of interface modifiers + int modifiers = getModifiers() & Modifier.classModifiers(); + if (modifiers != 0) { + sb.append(Modifier.toString(modifiers)); + sb.append(' '); + } + + if (isAnnotation()) { + sb.append('@'); + } + if (isInterface()) { // Note: all annotation types are interfaces + sb.append("interface"); + } else { + if (isEnum()) + sb.append("enum"); + else + sb.append("class"); + } + sb.append(' '); + sb.append(getName()); + + TypeVariable[] typeparms = getTypeParameters(); + if (typeparms.length > 0) { + boolean first = true; + sb.append('<'); + for(TypeVariable typeparm: typeparms) { + if (!first) + sb.append(','); + sb.append(typeparm.getTypeName()); + first = false; + } + sb.append('>'); + } + + return sb.toString(); + } + } /** * Returns the {@code Class} object associated with the class or @@ -1163,6 +1231,32 @@ public final return simpleName.substring(index); } + /** + * Return an informative string for the name of this type. + * + * @return an informative string for the name of this type + * @since 1.8 + */ + public String getTypeName() { + if (isArray()) { + try { + Class cl = this; + int dimensions = 0; + while (cl.isArray()) { + dimensions++; + cl = cl.getComponentType(); + } + StringBuilder sb = new StringBuilder(); + sb.append(cl.getName()); + for (int i = 0; i < dimensions; i++) { + sb.append("[]"); + } + return sb.toString(); + } catch (Throwable e) { /*FALLTHRU*/ } + } + return getName(); + } + /** * Character.isDigit answers {@code true} to some non-ascii * digits. This one does not. diff --git a/jdk/src/share/classes/java/lang/reflect/Constructor.java b/jdk/src/share/classes/java/lang/reflect/Constructor.java index 9d865cb6aaa..14a515fe949 100644 --- a/jdk/src/share/classes/java/lang/reflect/Constructor.java +++ b/jdk/src/share/classes/java/lang/reflect/Constructor.java @@ -297,7 +297,7 @@ public final class Constructor extends Executable { @Override void specificToStringHeader(StringBuilder sb) { - sb.append(Field.getTypeName(getDeclaringClass())); + sb.append(getDeclaringClass().getTypeName()); } /** diff --git a/jdk/src/share/classes/java/lang/reflect/Executable.java b/jdk/src/share/classes/java/lang/reflect/Executable.java index 51e15f08363..bd8bac3a8ed 100644 --- a/jdk/src/share/classes/java/lang/reflect/Executable.java +++ b/jdk/src/share/classes/java/lang/reflect/Executable.java @@ -82,7 +82,7 @@ public abstract class Executable extends AccessibleObject void separateWithCommas(Class[] types, StringBuilder sb) { for (int j = 0; j < types.length; j++) { - sb.append(Field.getTypeName(types[j])); + sb.append(types[j].getTypeName()); if (j < (types.length - 1)) sb.append(","); } @@ -161,9 +161,7 @@ public abstract class Executable extends AccessibleObject sb.append('('); Type[] params = getGenericParameterTypes(); for (int j = 0; j < params.length; j++) { - String param = (params[j] instanceof Class)? - Field.getTypeName((Class)params[j]): - (params[j].toString()); + String param = params[j].getTypeName(); if (isVarArgs() && (j == params.length - 1)) // replace T[] with T... param = param.replaceFirst("\\[\\]$", "..."); sb.append(param); diff --git a/jdk/src/share/classes/java/lang/reflect/Field.java b/jdk/src/share/classes/java/lang/reflect/Field.java index 947d042e17b..bd2b9ef929f 100644 --- a/jdk/src/share/classes/java/lang/reflect/Field.java +++ b/jdk/src/share/classes/java/lang/reflect/Field.java @@ -295,8 +295,8 @@ class Field extends AccessibleObject implements Member { public String toString() { int mod = getModifiers(); return (((mod == 0) ? "" : (Modifier.toString(mod) + " ")) - + getTypeName(getType()) + " " - + getTypeName(getDeclaringClass()) + "." + + getType().getTypeName() + " " + + getDeclaringClass().getTypeName() + "." + getName()); } @@ -324,9 +324,8 @@ class Field extends AccessibleObject implements Member { int mod = getModifiers(); Type fieldType = getGenericType(); return (((mod == 0) ? "" : (Modifier.toString(mod) + " ")) - + ((fieldType instanceof Class) ? - getTypeName((Class)fieldType): fieldType.toString())+ " " - + getTypeName(getDeclaringClass()) + "." + + fieldType.getTypeName() + " " + + getDeclaringClass().getTypeName() + "." + getName()); } @@ -996,29 +995,6 @@ class Field extends AccessibleObject implements Member { } } - /* - * Utility routine to paper over array type names - */ - static String getTypeName(Class type) { - if (type.isArray()) { - try { - Class cl = type; - int dimensions = 0; - while (cl.isArray()) { - dimensions++; - cl = cl.getComponentType(); - } - StringBuffer sb = new StringBuffer(); - sb.append(cl.getName()); - for (int i = 0; i < dimensions; i++) { - sb.append("[]"); - } - return sb.toString(); - } catch (Throwable e) { /*FALLTHRU*/ } - } - return type.getName(); - } - /** * @throws NullPointerException {@inheritDoc} * @since 1.5 diff --git a/jdk/src/share/classes/java/lang/reflect/Method.java b/jdk/src/share/classes/java/lang/reflect/Method.java index 0dc3b244f9a..1caddd6f522 100644 --- a/jdk/src/share/classes/java/lang/reflect/Method.java +++ b/jdk/src/share/classes/java/lang/reflect/Method.java @@ -342,9 +342,8 @@ public final class Method extends Executable { * specified by "The Java Language Specification". This is * {@code public}, {@code protected} or {@code private} first, * and then other modifiers in the following order: - * {@code abstract}, {@code static}, {@code final}, - * {@code synchronized}, {@code native}, {@code strictfp}, - * {@code default}. + * {@code abstract}, {@code default}, {@code static}, {@code final}, + * {@code synchronized}, {@code native}, {@code strictfp}. * * @return a string describing this {@code Method} * @@ -359,8 +358,8 @@ public final class Method extends Executable { @Override void specificToStringHeader(StringBuilder sb) { - sb.append(Field.getTypeName(getReturnType())).append(' '); - sb.append(Field.getTypeName(getDeclaringClass())).append('.'); + sb.append(getReturnType().getTypeName()).append(' '); + sb.append(getDeclaringClass().getTypeName()).append('.'); sb.append(getName()); } @@ -387,16 +386,14 @@ public final class Method extends Executable { * class name. If the method is declared to throw exceptions, the * parameter list is followed by a space, followed by the word * throws followed by a comma-separated list of the generic thrown - * exception types. If there are no type parameters, the type - * parameter list is elided. + * exception types. * *

    The access modifiers are placed in canonical order as * specified by "The Java Language Specification". This is * {@code public}, {@code protected} or {@code private} first, * and then other modifiers in the following order: - * {@code abstract}, {@code static}, {@code final}, - * {@code synchronized}, {@code native}, {@code strictfp}, - * {@code default}. + * {@code abstract}, {@code default}, {@code static}, {@code final}, + * {@code synchronized}, {@code native}, {@code strictfp}. * * @return a string describing this {@code Method}, * include type parameters @@ -413,11 +410,8 @@ public final class Method extends Executable { @Override void specificToGenericStringHeader(StringBuilder sb) { Type genRetType = getGenericReturnType(); - sb.append( ((genRetType instanceof Class)? - Field.getTypeName((Class)genRetType):genRetType.toString())) - .append(' '); - - sb.append(Field.getTypeName(getDeclaringClass())).append('.'); + sb.append(genRetType.getTypeName()).append(' '); + sb.append(getDeclaringClass().getTypeName()).append('.'); sb.append(getName()); } diff --git a/jdk/src/share/classes/java/lang/reflect/Modifier.java b/jdk/src/share/classes/java/lang/reflect/Modifier.java index 9c0b2f40909..227beeedd79 100644 --- a/jdk/src/share/classes/java/lang/reflect/Modifier.java +++ b/jdk/src/share/classes/java/lang/reflect/Modifier.java @@ -43,8 +43,7 @@ import sun.reflect.ReflectionFactory; * @author Nakul Saraiya * @author Kenneth Russell */ -public -class Modifier { +public class Modifier { /* * Bootstrapping protocol between java.lang and java.lang.reflect @@ -233,7 +232,7 @@ class Modifier { * represented by {@code mod} */ public static String toString(int mod) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int len; if ((mod & PUBLIC) != 0) sb.append("public "); @@ -393,7 +392,7 @@ class Modifier { * */ static final int ACCESS_MODIFIERS = - Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE; + Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE; /** * Return an {@code int} value OR-ing together the source language diff --git a/jdk/src/share/classes/java/lang/reflect/Parameter.java b/jdk/src/share/classes/java/lang/reflect/Parameter.java index e479bfd9326..af104315e7d 100644 --- a/jdk/src/share/classes/java/lang/reflect/Parameter.java +++ b/jdk/src/share/classes/java/lang/reflect/Parameter.java @@ -110,21 +110,19 @@ public final class Parameter implements AnnotatedElement { public String toString() { final StringBuilder sb = new StringBuilder(); final Type type = getParameterizedType(); - final String typename = (type instanceof Class)? - Field.getTypeName((Class)type): - (type.toString()); + final String typename = type.getTypeName(); sb.append(Modifier.toString(getModifiers())); if(0 != modifiers) - sb.append(" "); + sb.append(' '); if(isVarArgs()) sb.append(typename.replaceFirst("\\[\\]$", "...")); else sb.append(typename); - sb.append(" "); + sb.append(' '); sb.append(getName()); return sb.toString(); diff --git a/jdk/src/share/classes/java/lang/reflect/Type.java b/jdk/src/share/classes/java/lang/reflect/Type.java index 76b40d66e2a..ecd35279542 100644 --- a/jdk/src/share/classes/java/lang/reflect/Type.java +++ b/jdk/src/share/classes/java/lang/reflect/Type.java @@ -32,6 +32,17 @@ package java.lang.reflect; * * @since 1.5 */ - public interface Type { + /** + * Returns a string describing this type, including information + * about any type parameters. + * + * @implSpec The default implementation calls {@code toString}. + * + * @return a string describing this type + * @since 1.8 + */ + default String getTypeName() { + return toString(); + } } diff --git a/jdk/test/java/lang/Class/GenericStringTest.java b/jdk/test/java/lang/Class/GenericStringTest.java new file mode 100644 index 00000000000..cdd8c1ab4f6 --- /dev/null +++ b/jdk/test/java/lang/Class/GenericStringTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, 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 6298888 6992705 + * @summary Check Class.toGenericString() + * @author Joseph D. Darcy + */ + +import java.lang.reflect.*; +import java.lang.annotation.*; +import java.util.*; + +@ExpectedGenericString("public class GenericStringTest") +public class GenericStringTest { + public static void main(String... args){ + int failures = 0; + + failures += checkToGenericString(int.class, "int"); + + Class[] types = { + GenericStringTest.class, + AnInterface.class, + LocalMap.class, + AnEnum.class, + AnotherEnum.class, + }; + + for(Class clazz : types) { + failures += checkToGenericString(clazz, clazz.getAnnotation(ExpectedGenericString.class).value()); + } + + if (failures > 0) { + throw new RuntimeException(); + } + } + + private static int checkToGenericString(Class clazz, String expected) { + String genericString = clazz.toGenericString(); + if (!genericString.equals(expected)) { + System.err.printf("Unexpected Class.toGenericString output; expected '%s', got '%s'.%n", + expected, + genericString); + return 1; + } else + return 0; + } +} + +@Retention(RetentionPolicy.RUNTIME) +@interface ExpectedGenericString { + String value(); +} + +@ExpectedGenericString("abstract interface AnInterface") +strictfp interface AnInterface {} + +@ExpectedGenericString("abstract interface LocalMap") +interface LocalMap {} + +@ExpectedGenericString("final enum AnEnum") +enum AnEnum { + FOO; +} + +@ExpectedGenericString("enum AnotherEnum") +enum AnotherEnum { + BAR{}; +} From 21711140e2e497d9736eae750d7e44cd5b6ee869 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 9 Apr 2013 09:42:20 +0200 Subject: [PATCH 148/155] 8006288: build-infra: Use solaris nm and not gnm on solaris Reviewed-by: tbell --- common/autoconf/compare.sh.in | 2 +- common/autoconf/generated-configure.sh | 324 ++++++++++++++++++++++++- common/autoconf/spec.gmk.in | 1 + common/autoconf/toolchain.m4 | 6 +- 4 files changed, 321 insertions(+), 12 deletions(-) diff --git a/common/autoconf/compare.sh.in b/common/autoconf/compare.sh.in index b8fa8b85d8a..2b344aac4d8 100644 --- a/common/autoconf/compare.sh.in +++ b/common/autoconf/compare.sh.in @@ -49,7 +49,7 @@ JAVAP="@FIXPATH@ @BOOT_JDK@/bin/javap" LDD="@LDD@" MKDIR="@MKDIR@" NAWK="@NAWK@" -NM="@NM@" +NM="@GNM@" OBJDUMP="@OBJDUMP@" OTOOL="@OTOOL@" PRINTF="@PRINTF@" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 20953b32231..ece735837c6 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -686,6 +686,7 @@ ac_ct_OBJCOPY OBJCOPY MCS STRIP +GNM NM AS CXXCPP @@ -3763,7 +3764,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1365147397 +DATE_WHEN_GENERATED=1365493306 ############################################################################### # @@ -25200,10 +25201,8 @@ fi if test "x$OPENJDK_TARGET_OS" = xsolaris; then - for ac_prog in gnm nm -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 + # Extract the first word of "nm", so it can be a program name with args. +set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_NM+set}" = set; then : @@ -25242,9 +25241,6 @@ $as_echo "no" >&6; } fi - test -n "$NM" && break -done - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -25511,6 +25507,312 @@ $as_echo "$as_me: This might be caused by spaces in the path, which is not allow $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} fi + # Extract the first word of "gnm", so it can be a program name with args. +set dummy gnm; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_GNM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $GNM in + [\\/]* | ?:[\\/]*) + ac_cv_path_GNM="$GNM" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_GNM="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GNM=$ac_cv_path_GNM +if test -n "$GNM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNM" >&5 +$as_echo "$GNM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # First separate the path from the arguments. This will split at the first + # space. + complete="$GNM" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path=`$CYGPATH -u "$path"` + + # Now try to locate executable using which + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in cygwin causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path=`$CYGPATH -u "$path"` + fi + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path=`$CYGPATH -u "$path"` + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in cygwin causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path=`$CYGPATH -u "$path"` + fi + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 +$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + fi + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + # Short path failed, file does not exist as specified. + # Try adding .exe or .cmd + if test -f "${new_path}.exe"; then + input_to_shortpath="${new_path}.exe" + elif test -f "${new_path}.cmd"; then + input_to_shortpath="${new_path}.cmd" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$new_path\", is invalid." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$new_path\", is invalid." >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 +$as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + else + input_to_shortpath="$new_path" + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + new_path="$input_to_shortpath" + + input_path="$input_to_shortpath" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $input_to_shortpath | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + # remove trailing .exe if any + new_path="${new_path/%.exe/}" + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + # First separate the path from the arguments. This will split at the first + # space. + complete="$GNM" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + + # Now try to locate executable using which + new_path=`$WHICH "$new_path" 2> /dev/null` + + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + + new_path=`$WHICH "$new_path" 2> /dev/null` + + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 +$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + fi + + # Now new_path has a complete unix path to the binary + if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then + # Keep paths in /bin as-is, but remove trailing .exe if any + new_path="${new_path/%.exe/}" + # Do not save /bin paths to all_fixpath_prefixes! + else + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $new_path` + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + # Output is in $new_path + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + # remove trailing .exe if any + new_path="${new_path/%.exe/}" + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + fi + + else + # We're on a posix platform. Hooray! :) + # First separate the path from the arguments. This will split at the first + # space. + complete="$GNM" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Cannot rely on the command "which" here since it doesn't always work. + is_absolute_path=`$ECHO "$path" | $GREP ^/` + if test -z "$is_absolute_path"; then + # Path to executable is not absolute. Find it. + IFS_save="$IFS" + IFS=: + for p in $PATH; do + if test -f "$p/$path" && test -x "$p/$path"; then + new_path="$p/$path" + break + fi + done + IFS="$IFS_save" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving GNM (as $path) failed, using $path directly." >&5 +$as_echo "$as_me: Resolving GNM (as $path) failed, using $path directly." >&6;} + new_path="$path" + fi + + if test "x$new_path" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 +$as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + fi + + # Now join together the path and the arguments once again + if test "x$arguments" != xEOL; then + new_complete="$new_path ${arguments% *}" + else + new_complete="$new_path" + fi + + if test "x$complete" != "x$new_complete"; then + GNM="$new_complete" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting GNM to \"$new_complete\"" >&5 +$as_echo "$as_me: Rewriting GNM to \"$new_complete\"" >&6;} + fi + # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -26482,6 +26784,8 @@ $as_echo "$as_me: This might be caused by spaces in the path, which is not allow $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} fi + GNM="$NM" + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 @@ -31835,7 +32139,7 @@ and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS @@ -31851,7 +32155,7 @@ if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then set dummy llvm-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LLVM_CONFIG+:} false; then : +if test "${ac_cv_prog_LLVM_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LLVM_CONFIG"; then diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index e84b0749b48..92b0c83017e 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -377,6 +377,7 @@ AR:=@FIXPATH@ @AR@ ARFLAGS:=@ARFLAGS@ NM:=@NM@ +GNM:=@GNM@ STRIP:=@STRIP@ MCS:=@MCS@ diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index bacff783414..893fb16d674 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -441,8 +441,10 @@ fi AC_SUBST(AS) if test "x$OPENJDK_TARGET_OS" = xsolaris; then - AC_PATH_PROGS(NM, [gnm nm]) + AC_PATH_PROG(NM, nm) BASIC_FIXUP_EXECUTABLE(NM) + AC_PATH_PROG(GNM, gnm) + BASIC_FIXUP_EXECUTABLE(GNM) AC_PATH_PROG(STRIP, strip) BASIC_FIXUP_EXECUTABLE(STRIP) AC_PATH_PROG(MCS, mcs) @@ -450,6 +452,8 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then elif test "x$OPENJDK_TARGET_OS" != xwindows; then AC_CHECK_TOOL(NM, nm) BASIC_FIXUP_EXECUTABLE(NM) + GNM="$NM" + AC_SUBST(GNM) AC_CHECK_TOOL(STRIP, strip) BASIC_FIXUP_EXECUTABLE(STRIP) fi From 80b7d8cf9905d5afa404ed7af32beb8aa836b1ed Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 9 Apr 2013 09:45:48 +0200 Subject: [PATCH 149/155] 8010465: Can't enable sjavac when building in jprt Reviewed-by: ohair, tbell --- common/makefiles/JavaCompilation.gmk | 4 ++-- common/makefiles/Jprt.gmk | 3 +++ common/makefiles/MakeBase.gmk | 10 +++++----- common/makefiles/MakeHelpers.gmk | 22 +++++++++++++++------- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/common/makefiles/JavaCompilation.gmk b/common/makefiles/JavaCompilation.gmk index bc13da5357b..4301cee1f0b 100644 --- a/common/makefiles/JavaCompilation.gmk +++ b/common/makefiles/JavaCompilation.gmk @@ -86,7 +86,7 @@ define SetupArchive # NOTE: $2 is dependencies, not a named argument! $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) $(call LogSetupMacroEntry,SetupArchive($1),,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) - $(if $(findstring $(LOG),debug trace), $(info *[2] = $(strip $2))) + $(if $(findstring $(LOG_LEVEL),debug trace), $(info *[2] = $(strip $2))) $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) $1_JARMAIN:=$(strip $$($1_JARMAIN)) @@ -505,7 +505,7 @@ define SetupJavaCompilation --permit-unidentified-artifacts \ --permit-sources-without-package \ --compare-found-sources $$($1_BIN)/_the.batch.tmp \ - --log=$(LOG) \ + --log=$(LOG_LEVEL) \ $$($1_SJAVAC_ARGS) \ $$($1_FLAGS) \ $$($1_HEADERS_ARG) \ diff --git a/common/makefiles/Jprt.gmk b/common/makefiles/Jprt.gmk index 938d4362e29..c38dedce1f5 100644 --- a/common/makefiles/Jprt.gmk +++ b/common/makefiles/Jprt.gmk @@ -103,6 +103,9 @@ endif ifdef ALT_FREETYPE_HEADERS_PATH @$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp endif +ifdef ENABLE_SJAVAC + @$(ECHO) " --enable-sjavac" >> $@.tmp +endif ifeq ($(HOTSPOT_AVAILABLE),false) ifdef ALT_JDK_IMPORT_PATH @$(ECHO) " --with-import-hotspot=$(call UnixPath,$(ALT_JDK_IMPORT_PATH)) " >> $@.tmp diff --git a/common/makefiles/MakeBase.gmk b/common/makefiles/MakeBase.gmk index 5a54e38a0ea..3cbdf79bae9 100644 --- a/common/makefiles/MakeBase.gmk +++ b/common/makefiles/MakeBase.gmk @@ -328,7 +328,7 @@ $(ECHO) $1/$(HGTIP_FILENAME) endef define SetupLogging - ifeq ($$(LOG), trace) + ifeq ($$(LOG_LEVEL),trace) # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make # For each target executed, will print # Building (from ) ( newer) @@ -339,17 +339,17 @@ define SetupLogging endif # Never remove warning messages; this is just for completeness LOG_WARN= - ifneq ($$(findstring $$(LOG),info debug trace),) + ifneq ($$(findstring $$(LOG_LEVEL),info debug trace),) LOG_INFO= else LOG_INFO=> /dev/null endif - ifneq ($$(findstring $$(LOG),debug trace),) + ifneq ($$(findstring $$(LOG_LEVEL),debug trace),) LOG_DEBUG= else LOG_DEBUG=> /dev/null endif - ifneq ($$(findstring $$(LOG),trace),) + ifneq ($$(findstring $$(LOG_LEVEL),trace),) LOG_TRACE= else LOG_TRACE=> /dev/null @@ -362,7 +362,7 @@ $(eval $(call SetupLogging)) # This is to be called by all SetupFoo macros define LogSetupMacroEntry $(if $(26),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk)) - $(if $(findstring $(LOG),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25,$(if $($i),$(NEWLINE) $(strip [$i] $($i)))))) + $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25,$(if $($i),$(NEWLINE) $(strip [$i] $($i)))))) endef # Make directory without forking mkdir if not needed diff --git a/common/makefiles/MakeHelpers.gmk b/common/makefiles/MakeHelpers.gmk index 81e1d697e11..aa495323b5d 100644 --- a/common/makefiles/MakeHelpers.gmk +++ b/common/makefiles/MakeHelpers.gmk @@ -184,26 +184,34 @@ define ParseLogLevel LOG_STRIPPED2=$$(subst nofile,,$$(LOG_STRIPPED1)) # We might have ended up with a leading comma. Remove it LOG_STRIPPED3=$$(strip $$(patsubst $$(COMMA)%,%,$$(LOG_STRIPPED2))) - override LOG:=$$(LOG_STRIPPED3) + LOG_LEVEL:=$$(LOG_STRIPPED3) + else + LOG_LEVEL:=$$(LOG) endif - ifeq ($$(LOG),) + ifeq ($$(LOG_LEVEL),) # Set LOG to "warn" as default if not set (and no VERBOSE given) - override LOG=warn + override LOG_LEVEL=warn endif - ifeq ($$(LOG),warn) + ifeq ($$(LOG_LEVEL),warn) VERBOSE=-s - else ifeq ($$(LOG),info) + else ifeq ($$(LOG_LEVEL),info) VERBOSE=-s - else ifeq ($$(LOG),debug) + else ifeq ($$(LOG_LEVEL),debug) VERBOSE= - else ifeq ($$(LOG),trace) + else ifeq ($$(LOG_LEVEL),trace) VERBOSE= else $$(info Error: LOG must be one of: warn, info, debug or trace.) $$(eval $$(call FatalError)) endif else + # Provide resonable interpretations of LOG_LEVEL if VERBOSE is given. + ifeq ($(VERBOSE),) + LOG_LEVEL:=debug + else + LOG_LEVEL:=warn + endif ifneq ($$(LOG),) # We have both a VERBOSE and a LOG argument. This is OK only if this is a repeated call by ourselves, # but complain if this is the top-level make call. From cce2911c1914b056f55d9dd2400d598465ca2df8 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 9 Apr 2013 15:51:50 +0100 Subject: [PATCH 150/155] 8010393: Update JAX-WS RI to 2.2.9-b12941 Reviewed-by: mullan --- jdk/src/share/lib/security/java.security-linux | 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, 16 insertions(+) diff --git a/jdk/src/share/lib/security/java.security-linux b/jdk/src/share/lib/security/java.security-linux index ba0f305ffad..849c0242377 100644 --- a/jdk/src/share/lib/security/java.security-linux +++ b/jdk/src/share/lib/security/java.security-linux @@ -157,6 +157,8 @@ package.access=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools. @@ -183,6 +185,8 @@ package.definition=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools. diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx index f3d10a4b682..c81128c5e1a 100644 --- a/jdk/src/share/lib/security/java.security-macosx +++ b/jdk/src/share/lib/security/java.security-macosx @@ -158,6 +158,8 @@ package.access=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ @@ -185,6 +187,8 @@ package.definition=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris index e51581e8c3a..25581ba0d2c 100644 --- a/jdk/src/share/lib/security/java.security-solaris +++ b/jdk/src/share/lib/security/java.security-solaris @@ -159,6 +159,8 @@ package.access=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools. @@ -185,6 +187,8 @@ package.definition=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools. diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows index a7d74c90554..a9b1c38596f 100644 --- a/jdk/src/share/lib/security/java.security-windows +++ b/jdk/src/share/lib/security/java.security-windows @@ -158,6 +158,8 @@ package.access=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools. @@ -184,6 +186,8 @@ package.definition=sun.,\ com.sun.org.apache.xalan.internal.utils.,\ com.sun.org.glassfish.external.,\ com.sun.org.glassfish.gmbal.,\ + com.oracle.xmlns.internal.,\ + com.oracle.webservices.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools. From dc6fd2d5dd2443d281ba6f7fb022e9fbca4466b2 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 9 Apr 2013 17:27:47 +0100 Subject: [PATCH 151/155] 8005696: Add CompletableFuture Reviewed-by: chegar, martin --- jdk/make/java/java/FILES_java.gmk | 2 + .../util/concurrent/CompletableFuture.java | 3305 +++++++++++++++++ .../util/concurrent/CompletionException.java | 90 + .../concurrent/CompletableFuture/Basic.java | 761 ++++ 4 files changed, 4158 insertions(+) create mode 100644 jdk/src/share/classes/java/util/concurrent/CompletableFuture.java create mode 100644 jdk/src/share/classes/java/util/concurrent/CompletionException.java create mode 100644 jdk/test/java/util/concurrent/CompletableFuture/Basic.java diff --git a/jdk/make/java/java/FILES_java.gmk b/jdk/make/java/java/FILES_java.gmk index 8122bdf1aef..47184e3dd7b 100644 --- a/jdk/make/java/java/FILES_java.gmk +++ b/jdk/make/java/java/FILES_java.gmk @@ -316,6 +316,8 @@ JAVA_JAVA_java = \ java/util/concurrent/BrokenBarrierException.java \ java/util/concurrent/Callable.java \ java/util/concurrent/CancellationException.java \ + java/util/concurrent/CompletableFuture.java \ + java/util/concurrent/CompletionException.java \ java/util/concurrent/CompletionService.java \ java/util/concurrent/ConcurrentHashMap.java \ java/util/concurrent/ConcurrentLinkedDeque.java \ diff --git a/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java new file mode 100644 index 00000000000..dfcba20acb4 --- /dev/null +++ b/jdk/src/share/classes/java/util/concurrent/CompletableFuture.java @@ -0,0 +1,3305 @@ +/* + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +package java.util.concurrent; +import java.util.function.Supplier; +import java.util.function.Consumer; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.BiFunction; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.CancellationException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.LockSupport; + +/** + * A {@link Future} that may be explicitly completed (setting its + * value and status), and may include dependent functions and actions + * that trigger upon its completion. + * + *

    When two or more threads attempt to + * {@link #complete complete}, + * {@link #completeExceptionally completeExceptionally}, or + * {@link #cancel cancel} + * a CompletableFuture, only one of them succeeds. + * + *

    Methods are available for adding dependents based on + * user-provided Functions, Consumers, or Runnables. The appropriate + * form to use depends on whether actions require arguments and/or + * produce results. Completion of a dependent action will trigger the + * completion of another CompletableFuture. Actions may also be + * triggered after either or both the current and another + * CompletableFuture complete. Multiple CompletableFutures may also + * be grouped as one using {@link #anyOf(CompletableFuture...)} and + * {@link #allOf(CompletableFuture...)}. + * + *

    CompletableFutures themselves do not execute asynchronously. + * However, actions supplied for dependent completions of another + * CompletableFuture may do so, depending on whether they are provided + * via one of the async methods (that is, methods with names + * of the form xxxAsync). The async + * methods provide a way to commence asynchronous processing of an + * action using either a given {@link Executor} or by default the + * {@link ForkJoinPool#commonPool()}. To simplify monitoring, + * debugging, and tracking, all generated asynchronous tasks are + * instances of the marker interface {@link AsynchronousCompletionTask}. + * + *

    Actions supplied for dependent completions of non-async + * methods may be performed by the thread that completes the current + * CompletableFuture, or by any other caller of these methods. There + * are no guarantees about the order of processing completions unless + * constrained by these methods. + * + *

    Since (unlike {@link FutureTask}) this class has no direct + * control over the computation that causes it to be completed, + * cancellation is treated as just another form of exceptional completion. + * Method {@link #cancel cancel} has the same effect as + * {@code completeExceptionally(new CancellationException())}. + * + *

    Upon exceptional completion (including cancellation), or when a + * completion entails an additional computation which terminates + * abruptly with an (unchecked) exception or error, then all of their + * dependent completions (and their dependents in turn) generally act + * as {@code completeExceptionally} with a {@link CompletionException} + * holding that exception as its cause. However, the {@link + * #exceptionally exceptionally} and {@link #handle handle} + * completions are able to handle exceptional completions of + * the CompletableFutures they depend on. + * + *

    In case of exceptional completion with a CompletionException, + * methods {@link #get()} and {@link #get(long, TimeUnit)} throw an + * {@link ExecutionException} with the same cause as held in the + * corresponding CompletionException. However, in these cases, + * methods {@link #join()} and {@link #getNow} throw the + * CompletionException, which simplifies usage. + * + *

    Arguments used to pass a completion result (that is, for parameters + * of type {@code T}) may be null, but passing a null value for any other + * parameter will result in a {@link NullPointerException} being thrown. + * + * @author Doug Lea + * @since 1.8 + */ +public class CompletableFuture implements Future { + + /* + * Overview: + * + * 1. Non-nullness of field result (set via CAS) indicates done. + * An AltResult is used to box null as a result, as well as to + * hold exceptions. Using a single field makes completion fast + * and simple to detect and trigger, at the expense of a lot of + * encoding and decoding that infiltrates many methods. One minor + * simplification relies on the (static) NIL (to box null results) + * being the only AltResult with a null exception field, so we + * don't usually need explicit comparisons with NIL. The CF + * exception propagation mechanics surrounding decoding rely on + * unchecked casts of decoded results really being unchecked, + * where user type errors are caught at point of use, as is + * currently the case in Java. These are highlighted by using + * SuppressWarnings-annotated temporaries. + * + * 2. Waiters are held in a Treiber stack similar to the one used + * in FutureTask, Phaser, and SynchronousQueue. See their + * internal documentation for algorithmic details. + * + * 3. Completions are also kept in a list/stack, and pulled off + * and run when completion is triggered. (We could even use the + * same stack as for waiters, but would give up the potential + * parallelism obtained because woken waiters help release/run + * others -- see method postComplete). Because post-processing + * may race with direct calls, class Completion opportunistically + * extends AtomicInteger so callers can claim the action via + * compareAndSet(0, 1). The Completion.run methods are all + * written a boringly similar uniform way (that sometimes includes + * unnecessary-looking checks, kept to maintain uniformity). + * There are enough dimensions upon which they differ that + * attempts to factor commonalities while maintaining efficiency + * require more lines of code than they would save. + * + * 4. The exported then/and/or methods do support a bit of + * factoring (see doThenApply etc). They must cope with the + * intrinsic races surrounding addition of a dependent action + * versus performing the action directly because the task is + * already complete. For example, a CF may not be complete upon + * entry, so a dependent completion is added, but by the time it + * is added, the target CF is complete, so must be directly + * executed. This is all done while avoiding unnecessary object + * construction in safe-bypass cases. + */ + + // preliminaries + + static final class AltResult { + final Throwable ex; // null only for NIL + AltResult(Throwable ex) { this.ex = ex; } + } + + static final AltResult NIL = new AltResult(null); + + // Fields + + volatile Object result; // Either the result or boxed AltResult + volatile WaitNode waiters; // Treiber stack of threads blocked on get() + volatile CompletionNode completions; // list (Treiber stack) of completions + + // Basic utilities for triggering and processing completions + + /** + * Removes and signals all waiting threads and runs all completions. + */ + final void postComplete() { + WaitNode q; Thread t; + while ((q = waiters) != null) { + if (UNSAFE.compareAndSwapObject(this, WAITERS, q, q.next) && + (t = q.thread) != null) { + q.thread = null; + LockSupport.unpark(t); + } + } + + CompletionNode h; Completion c; + while ((h = completions) != null) { + if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, h, h.next) && + (c = h.completion) != null) + c.run(); + } + } + + /** + * Triggers completion with the encoding of the given arguments: + * if the exception is non-null, encodes it as a wrapped + * CompletionException unless it is one already. Otherwise uses + * the given result, boxed as NIL if null. + */ + final void internalComplete(T v, Throwable ex) { + if (result == null) + UNSAFE.compareAndSwapObject + (this, RESULT, null, + (ex == null) ? (v == null) ? NIL : v : + new AltResult((ex instanceof CompletionException) ? ex : + new CompletionException(ex))); + postComplete(); // help out even if not triggered + } + + /** + * If triggered, helps release and/or process completions. + */ + final void helpPostComplete() { + if (result != null) + postComplete(); + } + + /* ------------- waiting for completions -------------- */ + + /** Number of processors, for spin control */ + static final int NCPU = Runtime.getRuntime().availableProcessors(); + + /** + * Heuristic spin value for waitingGet() before blocking on + * multiprocessors + */ + static final int SPINS = (NCPU > 1) ? 1 << 8 : 0; + + /** + * Linked nodes to record waiting threads in a Treiber stack. See + * other classes such as Phaser and SynchronousQueue for more + * detailed explanation. This class implements ManagedBlocker to + * avoid starvation when blocking actions pile up in + * ForkJoinPools. + */ + static final class WaitNode implements ForkJoinPool.ManagedBlocker { + long nanos; // wait time if timed + final long deadline; // non-zero if timed + volatile int interruptControl; // > 0: interruptible, < 0: interrupted + volatile Thread thread; + volatile WaitNode next; + WaitNode(boolean interruptible, long nanos, long deadline) { + this.thread = Thread.currentThread(); + this.interruptControl = interruptible ? 1 : 0; + this.nanos = nanos; + this.deadline = deadline; + } + public boolean isReleasable() { + if (thread == null) + return true; + if (Thread.interrupted()) { + int i = interruptControl; + interruptControl = -1; + if (i > 0) + return true; + } + if (deadline != 0L && + (nanos <= 0L || (nanos = deadline - System.nanoTime()) <= 0L)) { + thread = null; + return true; + } + return false; + } + public boolean block() { + if (isReleasable()) + return true; + else if (deadline == 0L) + LockSupport.park(this); + else if (nanos > 0L) + LockSupport.parkNanos(this, nanos); + return isReleasable(); + } + } + + /** + * Returns raw result after waiting, or null if interruptible and + * interrupted. + */ + private Object waitingGet(boolean interruptible) { + WaitNode q = null; + boolean queued = false; + int spins = SPINS; + for (Object r;;) { + if ((r = result) != null) { + if (q != null) { // suppress unpark + q.thread = null; + if (q.interruptControl < 0) { + if (interruptible) { + removeWaiter(q); + return null; + } + Thread.currentThread().interrupt(); + } + } + postComplete(); // help release others + return r; + } + else if (spins > 0) { + int rnd = ThreadLocalRandom.nextSecondarySeed(); + if (rnd == 0) + rnd = ThreadLocalRandom.current().nextInt(); + if (rnd >= 0) + --spins; + } + else if (q == null) + q = new WaitNode(interruptible, 0L, 0L); + else if (!queued) + queued = UNSAFE.compareAndSwapObject(this, WAITERS, + q.next = waiters, q); + else if (interruptible && q.interruptControl < 0) { + removeWaiter(q); + return null; + } + else if (q.thread != null && result == null) { + try { + ForkJoinPool.managedBlock(q); + } catch (InterruptedException ex) { + q.interruptControl = -1; + } + } + } + } + + /** + * Awaits completion or aborts on interrupt or timeout. + * + * @param nanos time to wait + * @return raw result + */ + private Object timedAwaitDone(long nanos) + throws InterruptedException, TimeoutException { + WaitNode q = null; + boolean queued = false; + for (Object r;;) { + if ((r = result) != null) { + if (q != null) { + q.thread = null; + if (q.interruptControl < 0) { + removeWaiter(q); + throw new InterruptedException(); + } + } + postComplete(); + return r; + } + else if (q == null) { + if (nanos <= 0L) + throw new TimeoutException(); + long d = System.nanoTime() + nanos; + q = new WaitNode(true, nanos, d == 0L ? 1L : d); // avoid 0 + } + else if (!queued) + queued = UNSAFE.compareAndSwapObject(this, WAITERS, + q.next = waiters, q); + else if (q.interruptControl < 0) { + removeWaiter(q); + throw new InterruptedException(); + } + else if (q.nanos <= 0L) { + if (result == null) { + removeWaiter(q); + throw new TimeoutException(); + } + } + else if (q.thread != null && result == null) { + try { + ForkJoinPool.managedBlock(q); + } catch (InterruptedException ex) { + q.interruptControl = -1; + } + } + } + } + + /** + * Tries to unlink a timed-out or interrupted wait node to avoid + * accumulating garbage. Internal nodes are simply unspliced + * without CAS since it is harmless if they are traversed anyway + * by releasers. To avoid effects of unsplicing from already + * removed nodes, the list is retraversed in case of an apparent + * race. This is slow when there are a lot of nodes, but we don't + * expect lists to be long enough to outweigh higher-overhead + * schemes. + */ + private void removeWaiter(WaitNode node) { + if (node != null) { + node.thread = null; + retry: + for (;;) { // restart on removeWaiter race + for (WaitNode pred = null, q = waiters, s; q != null; q = s) { + s = q.next; + if (q.thread != null) + pred = q; + else if (pred != null) { + pred.next = s; + if (pred.thread == null) // check for race + continue retry; + } + else if (!UNSAFE.compareAndSwapObject(this, WAITERS, q, s)) + continue retry; + } + break; + } + } + } + + /* ------------- Async tasks -------------- */ + + /** + * A marker interface identifying asynchronous tasks produced by + * {@code async} methods. This may be useful for monitoring, + * debugging, and tracking asynchronous activities. + * + * @since 1.8 + */ + public static interface AsynchronousCompletionTask { + } + + /** Base class can act as either FJ or plain Runnable */ + abstract static class Async extends ForkJoinTask + implements Runnable, AsynchronousCompletionTask { + public final Void getRawResult() { return null; } + public final void setRawResult(Void v) { } + public final void run() { exec(); } + } + + static final class AsyncRun extends Async { + final Runnable fn; + final CompletableFuture dst; + AsyncRun(Runnable fn, CompletableFuture dst) { + this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + fn.run(); + ex = null; + } catch (Throwable rex) { + ex = rex; + } + d.internalComplete(null, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AsyncSupply extends Async { + final Supplier fn; + final CompletableFuture dst; + AsyncSupply(Supplier fn, CompletableFuture dst) { + this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; U u; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + u = fn.get(); + ex = null; + } catch (Throwable rex) { + ex = rex; + u = null; + } + d.internalComplete(u, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AsyncApply extends Async { + final T arg; + final Function fn; + final CompletableFuture dst; + AsyncApply(T arg, Function fn, + CompletableFuture dst) { + this.arg = arg; this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; U u; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + u = fn.apply(arg); + ex = null; + } catch (Throwable rex) { + ex = rex; + u = null; + } + d.internalComplete(u, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AsyncCombine extends Async { + final T arg1; + final U arg2; + final BiFunction fn; + final CompletableFuture dst; + AsyncCombine(T arg1, U arg2, + BiFunction fn, + CompletableFuture dst) { + this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; V v; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + v = fn.apply(arg1, arg2); + ex = null; + } catch (Throwable rex) { + ex = rex; + v = null; + } + d.internalComplete(v, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AsyncAccept extends Async { + final T arg; + final Consumer fn; + final CompletableFuture dst; + AsyncAccept(T arg, Consumer fn, + CompletableFuture dst) { + this.arg = arg; this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + fn.accept(arg); + ex = null; + } catch (Throwable rex) { + ex = rex; + } + d.internalComplete(null, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AsyncAcceptBoth extends Async { + final T arg1; + final U arg2; + final BiConsumer fn; + final CompletableFuture dst; + AsyncAcceptBoth(T arg1, U arg2, + BiConsumer fn, + CompletableFuture dst) { + this.arg1 = arg1; this.arg2 = arg2; this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + fn.accept(arg1, arg2); + ex = null; + } catch (Throwable rex) { + ex = rex; + } + d.internalComplete(null, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AsyncCompose extends Async { + final T arg; + final Function> fn; + final CompletableFuture dst; + AsyncCompose(T arg, + Function> fn, + CompletableFuture dst) { + this.arg = arg; this.fn = fn; this.dst = dst; + } + public final boolean exec() { + CompletableFuture d, fr; U u; Throwable ex; + if ((d = this.dst) != null && d.result == null) { + try { + fr = fn.apply(arg); + ex = (fr == null) ? new NullPointerException() : null; + } catch (Throwable rex) { + ex = rex; + fr = null; + } + if (ex != null) + u = null; + else { + Object r = fr.result; + if (r == null) + r = fr.waitingGet(false); + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U ur = (U) r; + u = ur; + } + } + d.internalComplete(u, ex); + } + return true; + } + private static final long serialVersionUID = 5232453952276885070L; + } + + /* ------------- Completions -------------- */ + + /** + * Simple linked list nodes to record completions, used in + * basically the same way as WaitNodes. (We separate nodes from + * the Completions themselves mainly because for the And and Or + * methods, the same Completion object resides in two lists.) + */ + static final class CompletionNode { + final Completion completion; + volatile CompletionNode next; + CompletionNode(Completion completion) { this.completion = completion; } + } + + // Opportunistically subclass AtomicInteger to use compareAndSet to claim. + abstract static class Completion extends AtomicInteger implements Runnable { + } + + static final class ThenApply extends Completion { + final CompletableFuture src; + final Function fn; + final CompletableFuture dst; + final Executor executor; + ThenApply(CompletableFuture src, + Function fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final Function fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + Executor e = executor; + U u = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncApply(t, fn, dst)); + else + u = fn.apply(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(u, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ThenAccept extends Completion { + final CompletableFuture src; + final Consumer fn; + final CompletableFuture dst; + final Executor executor; + ThenAccept(CompletableFuture src, + Consumer fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final Consumer fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + Executor e = executor; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncAccept(t, fn, dst)); + else + fn.accept(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ThenRun extends Completion { + final CompletableFuture src; + final Runnable fn; + final CompletableFuture dst; + final Executor executor; + ThenRun(CompletableFuture src, + Runnable fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final Runnable fn; + final CompletableFuture dst; + Object r; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + Executor e = executor; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncRun(fn, dst)); + else + fn.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ThenCombine extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final BiFunction fn; + final CompletableFuture dst; + final Executor executor; + ThenCombine(CompletableFuture src, + CompletableFuture snd, + BiFunction fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.snd = snd; + this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final BiFunction fn; + final CompletableFuture dst; + Object r, s; T t; U u; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + (b = this.snd) != null && + (s = b.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex != null) + u = null; + else if (s instanceof AltResult) { + ex = ((AltResult)s).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + Executor e = executor; + V v = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncCombine(t, u, fn, dst)); + else + v = fn.apply(t, u); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(v, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ThenAcceptBoth extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final BiConsumer fn; + final CompletableFuture dst; + final Executor executor; + ThenAcceptBoth(CompletableFuture src, + CompletableFuture snd, + BiConsumer fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.snd = snd; + this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final BiConsumer fn; + final CompletableFuture dst; + Object r, s; T t; U u; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + (b = this.snd) != null && + (s = b.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex != null) + u = null; + else if (s instanceof AltResult) { + ex = ((AltResult)s).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + Executor e = executor; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncAcceptBoth(t, u, fn, dst)); + else + fn.accept(t, u); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class RunAfterBoth extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final Runnable fn; + final CompletableFuture dst; + final Executor executor; + RunAfterBoth(CompletableFuture src, + CompletableFuture snd, + Runnable fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.snd = snd; + this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final Runnable fn; + final CompletableFuture dst; + Object r, s; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + (b = this.snd) != null && + (s = b.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null && (s instanceof AltResult)) + ex = ((AltResult)s).ex; + Executor e = executor; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncRun(fn, dst)); + else + fn.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AndCompletion extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final CompletableFuture dst; + AndCompletion(CompletableFuture src, + CompletableFuture snd, + CompletableFuture dst) { + this.src = src; this.snd = snd; this.dst = dst; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final CompletableFuture dst; + Object r, s; Throwable ex; + if ((dst = this.dst) != null && + (a = this.src) != null && + (r = a.result) != null && + (b = this.snd) != null && + (s = b.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null && (s instanceof AltResult)) + ex = ((AltResult)s).ex; + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ApplyToEither extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final Function fn; + final CompletableFuture dst; + final Executor executor; + ApplyToEither(CompletableFuture src, + CompletableFuture snd, + Function fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.snd = snd; + this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final Function fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (((a = this.src) != null && (r = a.result) != null) || + ((b = this.snd) != null && (r = b.result) != null)) && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + Executor e = executor; + U u = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncApply(t, fn, dst)); + else + u = fn.apply(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(u, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class AcceptEither extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final Consumer fn; + final CompletableFuture dst; + final Executor executor; + AcceptEither(CompletableFuture src, + CompletableFuture snd, + Consumer fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.snd = snd; + this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final Consumer fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (((a = this.src) != null && (r = a.result) != null) || + ((b = this.snd) != null && (r = b.result) != null)) && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + Executor e = executor; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncAccept(t, fn, dst)); + else + fn.accept(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class RunAfterEither extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final Runnable fn; + final CompletableFuture dst; + final Executor executor; + RunAfterEither(CompletableFuture src, + CompletableFuture snd, + Runnable fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.snd = snd; + this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final Runnable fn; + final CompletableFuture dst; + Object r; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (((a = this.src) != null && (r = a.result) != null) || + ((b = this.snd) != null && (r = b.result) != null)) && + compareAndSet(0, 1)) { + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + Executor e = executor; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncRun(fn, dst)); + else + fn.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class OrCompletion extends Completion { + final CompletableFuture src; + final CompletableFuture snd; + final CompletableFuture dst; + OrCompletion(CompletableFuture src, + CompletableFuture snd, + CompletableFuture dst) { + this.src = src; this.snd = snd; this.dst = dst; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture b; + final CompletableFuture dst; + Object r, t; Throwable ex; + if ((dst = this.dst) != null && + (((a = this.src) != null && (r = a.result) != null) || + ((b = this.snd) != null && (r = b.result) != null)) && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + t = r; + } + dst.internalComplete(t, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ExceptionCompletion extends Completion { + final CompletableFuture src; + final Function fn; + final CompletableFuture dst; + ExceptionCompletion(CompletableFuture src, + Function fn, + CompletableFuture dst) { + this.src = src; this.fn = fn; this.dst = dst; + } + public final void run() { + final CompletableFuture a; + final Function fn; + final CompletableFuture dst; + Object r; T t = null; Throwable ex, dx = null; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if ((r instanceof AltResult) && + (ex = ((AltResult)r).ex) != null) { + try { + t = fn.apply(ex); + } catch (Throwable rex) { + dx = rex; + } + } + else { + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + dst.internalComplete(t, dx); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ThenCopy extends Completion { + final CompletableFuture src; + final CompletableFuture dst; + ThenCopy(CompletableFuture src, + CompletableFuture dst) { + this.src = src; this.dst = dst; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + dst.internalComplete(t, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + // version of ThenCopy for CompletableFuture dst + static final class ThenPropagate extends Completion { + final CompletableFuture src; + final CompletableFuture dst; + ThenPropagate(CompletableFuture src, + CompletableFuture dst) { + this.src = src; this.dst = dst; + } + public final void run() { + final CompletableFuture a; + final CompletableFuture dst; + Object r; Throwable ex; + if ((dst = this.dst) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + dst.internalComplete(null, ex); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class HandleCompletion extends Completion { + final CompletableFuture src; + final BiFunction fn; + final CompletableFuture dst; + HandleCompletion(CompletableFuture src, + BiFunction fn, + CompletableFuture dst) { + this.src = src; this.fn = fn; this.dst = dst; + } + public final void run() { + final CompletableFuture a; + final BiFunction fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u = null; Throwable dx = null; + try { + u = fn.apply(t, ex); + } catch (Throwable rex) { + dx = rex; + } + dst.internalComplete(u, dx); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + static final class ThenCompose extends Completion { + final CompletableFuture src; + final Function> fn; + final CompletableFuture dst; + final Executor executor; + ThenCompose(CompletableFuture src, + Function> fn, + CompletableFuture dst, + Executor executor) { + this.src = src; this.fn = fn; this.dst = dst; + this.executor = executor; + } + public final void run() { + final CompletableFuture a; + final Function> fn; + final CompletableFuture dst; + Object r; T t; Throwable ex; Executor e; + if ((dst = this.dst) != null && + (fn = this.fn) != null && + (a = this.src) != null && + (r = a.result) != null && + compareAndSet(0, 1)) { + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + CompletableFuture c = null; + U u = null; + boolean complete = false; + if (ex == null) { + if ((e = executor) != null) + e.execute(new AsyncCompose(t, fn, dst)); + else { + try { + if ((c = fn.apply(t)) == null) + ex = new NullPointerException(); + } catch (Throwable rex) { + ex = rex; + } + } + } + if (c != null) { + ThenCopy d = null; + Object s; + if ((s = c.result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenCopy(c, dst)); + while ((s = c.result) == null) { + if (UNSAFE.compareAndSwapObject + (c, COMPLETIONS, p.next = c.completions, p)) + break; + } + } + if (s != null && (d == null || d.compareAndSet(0, 1))) { + complete = true; + if (s instanceof AltResult) { + ex = ((AltResult)s).ex; // no rewrap + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + } + } + if (complete || ex != null) + dst.internalComplete(u, ex); + if (c != null) + c.helpPostComplete(); + } + } + private static final long serialVersionUID = 5232453952276885070L; + } + + // public methods + + /** + * Creates a new incomplete CompletableFuture. + */ + public CompletableFuture() { + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * by a task running in the {@link ForkJoinPool#commonPool()} with + * the value obtained by calling the given Supplier. + * + * @param supplier a function returning the value to be used + * to complete the returned CompletableFuture + * @return the new CompletableFuture + */ + public static CompletableFuture supplyAsync(Supplier supplier) { + if (supplier == null) throw new NullPointerException(); + CompletableFuture f = new CompletableFuture(); + ForkJoinPool.commonPool(). + execute((ForkJoinTask)new AsyncSupply(supplier, f)); + return f; + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * by a task running in the given executor with the value obtained + * by calling the given Supplier. + * + * @param supplier a function returning the value to be used + * to complete the returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public static CompletableFuture supplyAsync(Supplier supplier, + Executor executor) { + if (executor == null || supplier == null) + throw new NullPointerException(); + CompletableFuture f = new CompletableFuture(); + executor.execute(new AsyncSupply(supplier, f)); + return f; + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * by a task running in the {@link ForkJoinPool#commonPool()} after + * it runs the given action. + * + * @param runnable the action to run before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public static CompletableFuture runAsync(Runnable runnable) { + if (runnable == null) throw new NullPointerException(); + CompletableFuture f = new CompletableFuture(); + ForkJoinPool.commonPool(). + execute((ForkJoinTask)new AsyncRun(runnable, f)); + return f; + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * by a task running in the given executor after it runs the given + * action. + * + * @param runnable the action to run before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public static CompletableFuture runAsync(Runnable runnable, + Executor executor) { + if (executor == null || runnable == null) + throw new NullPointerException(); + CompletableFuture f = new CompletableFuture(); + executor.execute(new AsyncRun(runnable, f)); + return f; + } + + /** + * Returns a new CompletableFuture that is already completed with + * the given value. + * + * @param value the value + * @return the completed CompletableFuture + */ + public static CompletableFuture completedFuture(U value) { + CompletableFuture f = new CompletableFuture(); + f.result = (value == null) ? NIL : value; + return f; + } + + /** + * Returns {@code true} if completed in any fashion: normally, + * exceptionally, or via cancellation. + * + * @return {@code true} if completed + */ + public boolean isDone() { + return result != null; + } + + /** + * Waits if necessary for this future to complete, and then + * returns its result. + * + * @return the result value + * @throws CancellationException if this future was cancelled + * @throws ExecutionException if this future completed exceptionally + * @throws InterruptedException if the current thread was interrupted + * while waiting + */ + public T get() throws InterruptedException, ExecutionException { + Object r; Throwable ex, cause; + if ((r = result) == null && (r = waitingGet(true)) == null) + throw new InterruptedException(); + if (!(r instanceof AltResult)) { + @SuppressWarnings("unchecked") T tr = (T) r; + return tr; + } + if ((ex = ((AltResult)r).ex) == null) + return null; + if (ex instanceof CancellationException) + throw (CancellationException)ex; + if ((ex instanceof CompletionException) && + (cause = ex.getCause()) != null) + ex = cause; + throw new ExecutionException(ex); + } + + /** + * Waits if necessary for at most the given time for this future + * to complete, and then returns its result, if available. + * + * @param timeout the maximum time to wait + * @param unit the time unit of the timeout argument + * @return the result value + * @throws CancellationException if this future was cancelled + * @throws ExecutionException if this future completed exceptionally + * @throws InterruptedException if the current thread was interrupted + * while waiting + * @throws TimeoutException if the wait timed out + */ + public T get(long timeout, TimeUnit unit) + throws InterruptedException, ExecutionException, TimeoutException { + Object r; Throwable ex, cause; + long nanos = unit.toNanos(timeout); + if (Thread.interrupted()) + throw new InterruptedException(); + if ((r = result) == null) + r = timedAwaitDone(nanos); + if (!(r instanceof AltResult)) { + @SuppressWarnings("unchecked") T tr = (T) r; + return tr; + } + if ((ex = ((AltResult)r).ex) == null) + return null; + if (ex instanceof CancellationException) + throw (CancellationException)ex; + if ((ex instanceof CompletionException) && + (cause = ex.getCause()) != null) + ex = cause; + throw new ExecutionException(ex); + } + + /** + * Returns the result value when complete, or throws an + * (unchecked) exception if completed exceptionally. To better + * conform with the use of common functional forms, if a + * computation involved in the completion of this + * CompletableFuture threw an exception, this method throws an + * (unchecked) {@link CompletionException} with the underlying + * exception as its cause. + * + * @return the result value + * @throws CancellationException if the computation was cancelled + * @throws CompletionException if this future completed + * exceptionally or a completion computation threw an exception + */ + public T join() { + Object r; Throwable ex; + if ((r = result) == null) + r = waitingGet(false); + if (!(r instanceof AltResult)) { + @SuppressWarnings("unchecked") T tr = (T) r; + return tr; + } + if ((ex = ((AltResult)r).ex) == null) + return null; + if (ex instanceof CancellationException) + throw (CancellationException)ex; + if (ex instanceof CompletionException) + throw (CompletionException)ex; + throw new CompletionException(ex); + } + + /** + * Returns the result value (or throws any encountered exception) + * if completed, else returns the given valueIfAbsent. + * + * @param valueIfAbsent the value to return if not completed + * @return the result value, if completed, else the given valueIfAbsent + * @throws CancellationException if the computation was cancelled + * @throws CompletionException if this future completed + * exceptionally or a completion computation threw an exception + */ + public T getNow(T valueIfAbsent) { + Object r; Throwable ex; + if ((r = result) == null) + return valueIfAbsent; + if (!(r instanceof AltResult)) { + @SuppressWarnings("unchecked") T tr = (T) r; + return tr; + } + if ((ex = ((AltResult)r).ex) == null) + return null; + if (ex instanceof CancellationException) + throw (CancellationException)ex; + if (ex instanceof CompletionException) + throw (CompletionException)ex; + throw new CompletionException(ex); + } + + /** + * If not already completed, sets the value returned by {@link + * #get()} and related methods to the given value. + * + * @param value the result value + * @return {@code true} if this invocation caused this CompletableFuture + * to transition to a completed state, else {@code false} + */ + public boolean complete(T value) { + boolean triggered = result == null && + UNSAFE.compareAndSwapObject(this, RESULT, null, + value == null ? NIL : value); + postComplete(); + return triggered; + } + + /** + * If not already completed, causes invocations of {@link #get()} + * and related methods to throw the given exception. + * + * @param ex the exception + * @return {@code true} if this invocation caused this CompletableFuture + * to transition to a completed state, else {@code false} + */ + public boolean completeExceptionally(Throwable ex) { + if (ex == null) throw new NullPointerException(); + boolean triggered = result == null && + UNSAFE.compareAndSwapObject(this, RESULT, null, new AltResult(ex)); + postComplete(); + return triggered; + } + + /** + * Returns a new CompletableFuture that is completed + * when this CompletableFuture completes, with the result of the + * given function of this CompletableFuture's result. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied function throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenApply(Function fn) { + return doThenApply(fn, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when this CompletableFuture completes, with the result of the + * given function of this CompletableFuture's result from a + * task running in the {@link ForkJoinPool#commonPool()}. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied function throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenApplyAsync + (Function fn) { + return doThenApply(fn, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when this CompletableFuture completes, with the result of the + * given function of this CompletableFuture's result from a + * task running in the given executor. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied function throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture thenApplyAsync + (Function fn, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doThenApply(fn, executor); + } + + private CompletableFuture doThenApply + (Function fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenApply d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenApply(this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncApply(t, fn, dst)); + else + u = fn.apply(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(u, ex); + } + helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when this CompletableFuture completes, after performing the given + * action with this CompletableFuture's result. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied action throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param block the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenAccept(Consumer block) { + return doThenAccept(block, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when this CompletableFuture completes, after performing the given + * action with this CompletableFuture's result from a task running + * in the {@link ForkJoinPool#commonPool()}. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied action throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param block the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenAcceptAsync(Consumer block) { + return doThenAccept(block, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when this CompletableFuture completes, after performing the given + * action with this CompletableFuture's result from a task running + * in the given executor. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied action throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param block the action to perform before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture thenAcceptAsync(Consumer block, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doThenAccept(block, executor); + } + + private CompletableFuture doThenAccept(Consumer fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenAccept d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenAccept(this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncAccept(t, fn, dst)); + else + fn.accept(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when this CompletableFuture completes, after performing the given + * action. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied action throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param action the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenRun(Runnable action) { + return doThenRun(action, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when this CompletableFuture completes, after performing the given + * action from a task running in the {@link ForkJoinPool#commonPool()}. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied action throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param action the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenRunAsync(Runnable action) { + return doThenRun(action, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when this CompletableFuture completes, after performing the given + * action from a task running in the given executor. + * + *

    If this CompletableFuture completes exceptionally, or the + * supplied action throws an exception, then the returned + * CompletableFuture completes exceptionally with a + * CompletionException holding the exception as its cause. + * + * @param action the action to perform before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture thenRunAsync(Runnable action, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doThenRun(action, executor); + } + + private CompletableFuture doThenRun(Runnable action, + Executor e) { + if (action == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenRun d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = new CompletionNode + (d = new ThenRun(this, action, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncRun(action, dst)); + else + action.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when both this and the other given CompletableFuture complete, + * with the result of the given function of the results of the two + * CompletableFutures. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied function throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenCombine + (CompletableFuture other, + BiFunction fn) { + return doThenCombine(other, fn, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when both this and the other given CompletableFuture complete, + * with the result of the given function of the results of the two + * CompletableFutures from a task running in the + * {@link ForkJoinPool#commonPool()}. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied function throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenCombineAsync + (CompletableFuture other, + BiFunction fn) { + return doThenCombine(other, fn, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when both this and the other given CompletableFuture complete, + * with the result of the given function of the results of the two + * CompletableFutures from a task running in the given executor. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied function throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture thenCombineAsync + (CompletableFuture other, + BiFunction fn, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doThenCombine(other, fn, executor); + } + + private CompletableFuture doThenCombine + (CompletableFuture other, + BiFunction fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenCombine d = null; + Object r, s = null; + if ((r = result) == null || (s = other.result) == null) { + d = new ThenCombine(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r == null && (r = result) == null) || + (s == null && (s = other.result) == null)) { + if (q != null) { + if (s != null || + UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (r != null || + UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) { + if (s != null) + break; + q = new CompletionNode(d); + } + } + } + if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { + T t; U u; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex != null) + u = null; + else if (s instanceof AltResult) { + ex = ((AltResult)s).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + V v = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncCombine(t, u, fn, dst)); + else + v = fn.apply(t, u); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(v, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when both this and the other given CompletableFuture complete, + * after performing the given action with the results of the two + * CompletableFutures. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied action throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param block the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenAcceptBoth + (CompletableFuture other, + BiConsumer block) { + return doThenAcceptBoth(other, block, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when both this and the other given CompletableFuture complete, + * after performing the given action with the results of the two + * CompletableFutures from a task running in the {@link + * ForkJoinPool#commonPool()}. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied action throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param block the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture thenAcceptBothAsync + (CompletableFuture other, + BiConsumer block) { + return doThenAcceptBoth(other, block, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when both this and the other given CompletableFuture complete, + * after performing the given action with the results of the two + * CompletableFutures from a task running in the given executor. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied action throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param block the action to perform before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture thenAcceptBothAsync + (CompletableFuture other, + BiConsumer block, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doThenAcceptBoth(other, block, executor); + } + + private CompletableFuture doThenAcceptBoth + (CompletableFuture other, + BiConsumer fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ThenAcceptBoth d = null; + Object r, s = null; + if ((r = result) == null || (s = other.result) == null) { + d = new ThenAcceptBoth(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r == null && (r = result) == null) || + (s == null && (s = other.result) == null)) { + if (q != null) { + if (s != null || + UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (r != null || + UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) { + if (s != null) + break; + q = new CompletionNode(d); + } + } + } + if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { + T t; U u; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex != null) + u = null; + else if (s instanceof AltResult) { + ex = ((AltResult)s).ex; + u = null; + } + else { + @SuppressWarnings("unchecked") U us = (U) s; + u = us; + } + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncAcceptBoth(t, u, fn, dst)); + else + fn.accept(t, u); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when both this and the other given CompletableFuture complete, + * after performing the given action. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied action throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param action the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture runAfterBoth(CompletableFuture other, + Runnable action) { + return doRunAfterBoth(other, action, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when both this and the other given CompletableFuture complete, + * after performing the given action from a task running in the + * {@link ForkJoinPool#commonPool()}. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied action throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param action the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture runAfterBothAsync(CompletableFuture other, + Runnable action) { + return doRunAfterBoth(other, action, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when both this and the other given CompletableFuture complete, + * after performing the given action from a task running in the + * given executor. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, or the supplied action throws an exception, + * then the returned CompletableFuture completes exceptionally + * with a CompletionException holding the exception as its cause. + * + * @param other the other CompletableFuture + * @param action the action to perform before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture runAfterBothAsync(CompletableFuture other, + Runnable action, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doRunAfterBoth(other, action, executor); + } + + private CompletableFuture doRunAfterBoth(CompletableFuture other, + Runnable action, + Executor e) { + if (other == null || action == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + RunAfterBoth d = null; + Object r, s = null; + if ((r = result) == null || (s = other.result) == null) { + d = new RunAfterBoth(this, other, action, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r == null && (r = result) == null) || + (s == null && (s = other.result) == null)) { + if (q != null) { + if (s != null || + UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (r != null || + UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) { + if (s != null) + break; + q = new CompletionNode(d); + } + } + } + if (r != null && s != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null && (s instanceof AltResult)) + ex = ((AltResult)s).ex; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncRun(action, dst)); + else + action.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when either this or the other given CompletableFuture completes, + * with the result of the given function of either this or the other + * CompletableFuture's result. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied function + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture applyToEither + (CompletableFuture other, + Function fn) { + return doApplyToEither(other, fn, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when either this or the other given CompletableFuture completes, + * with the result of the given function of either this or the other + * CompletableFuture's result from a task running in the + * {@link ForkJoinPool#commonPool()}. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied function + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture applyToEitherAsync + (CompletableFuture other, + Function fn) { + return doApplyToEither(other, fn, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when either this or the other given CompletableFuture completes, + * with the result of the given function of either this or the other + * CompletableFuture's result from a task running in the + * given executor. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied function + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param fn the function to use to compute the value of + * the returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture applyToEitherAsync + (CompletableFuture other, + Function fn, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doApplyToEither(other, fn, executor); + } + + private CompletableFuture doApplyToEither + (CompletableFuture other, + Function fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ApplyToEither d = null; + Object r; + if ((r = result) == null && (r = other.result) == null) { + d = new ApplyToEither(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r = result) == null && (r = other.result) == null) { + if (q != null) { + if (UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + q = new CompletionNode(d); + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncApply(t, fn, dst)); + else + u = fn.apply(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(u, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when either this or the other given CompletableFuture completes, + * after performing the given action with the result of either this + * or the other CompletableFuture's result. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied action + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param block the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture acceptEither + (CompletableFuture other, + Consumer block) { + return doAcceptEither(other, block, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when either this or the other given CompletableFuture completes, + * after performing the given action with the result of either this + * or the other CompletableFuture's result from a task running in + * the {@link ForkJoinPool#commonPool()}. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied action + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param block the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture acceptEitherAsync + (CompletableFuture other, + Consumer block) { + return doAcceptEither(other, block, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when either this or the other given CompletableFuture completes, + * after performing the given action with the result of either this + * or the other CompletableFuture's result from a task running in + * the given executor. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied action + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param block the action to perform before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture acceptEitherAsync + (CompletableFuture other, + Consumer block, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doAcceptEither(other, block, executor); + } + + private CompletableFuture doAcceptEither + (CompletableFuture other, + Consumer fn, + Executor e) { + if (other == null || fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + AcceptEither d = null; + Object r; + if ((r = result) == null && (r = other.result) == null) { + d = new AcceptEither(this, other, fn, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r = result) == null && (r = other.result) == null) { + if (q != null) { + if (UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + q = new CompletionNode(d); + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncAccept(t, fn, dst)); + else + fn.accept(t); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed + * when either this or the other given CompletableFuture completes, + * after performing the given action. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied action + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param action the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture runAfterEither(CompletableFuture other, + Runnable action) { + return doRunAfterEither(other, action, null); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when either this or the other given CompletableFuture completes, + * after performing the given action from a task running in the + * {@link ForkJoinPool#commonPool()}. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied action + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param action the action to perform before completing the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture runAfterEitherAsync + (CompletableFuture other, + Runnable action) { + return doRunAfterEither(other, action, ForkJoinPool.commonPool()); + } + + /** + * Returns a new CompletableFuture that is asynchronously completed + * when either this or the other given CompletableFuture completes, + * after performing the given action from a task running in the + * given executor. + * + *

    If this and/or the other CompletableFuture complete + * exceptionally, then the returned CompletableFuture may also do so, + * with a CompletionException holding one of these exceptions as its + * cause. No guarantees are made about which result or exception is + * used in the returned CompletableFuture. If the supplied action + * throws an exception, then the returned CompletableFuture completes + * exceptionally with a CompletionException holding the exception as + * its cause. + * + * @param other the other CompletableFuture + * @param action the action to perform before completing the + * returned CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the new CompletableFuture + */ + public CompletableFuture runAfterEitherAsync + (CompletableFuture other, + Runnable action, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doRunAfterEither(other, action, executor); + } + + private CompletableFuture doRunAfterEither + (CompletableFuture other, + Runnable action, + Executor e) { + if (other == null || action == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + RunAfterEither d = null; + Object r; + if ((r = result) == null && (r = other.result) == null) { + d = new RunAfterEither(this, other, action, dst, e); + CompletionNode q = null, p = new CompletionNode(d); + while ((r = result) == null && (r = other.result) == null) { + if (q != null) { + if (UNSAFE.compareAndSwapObject + (other, COMPLETIONS, q.next = other.completions, q)) + break; + } + else if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + q = new CompletionNode(d); + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null) { + try { + if (e != null) + e.execute(new AsyncRun(action, dst)); + else + action.run(); + } catch (Throwable rex) { + ex = rex; + } + } + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + other.helpPostComplete(); + return dst; + } + + /** + * Returns a CompletableFuture that upon completion, has the same + * value as produced by the given function of the result of this + * CompletableFuture. + * + *

    If this CompletableFuture completes exceptionally, then the + * returned CompletableFuture also does so, with a + * CompletionException holding this exception as its cause. + * Similarly, if the computed CompletableFuture completes + * exceptionally, then so does the returned CompletableFuture. + * + * @param fn the function returning a new CompletableFuture + * @return the CompletableFuture + */ + public CompletableFuture thenCompose + (Function> fn) { + return doThenCompose(fn, null); + } + + /** + * Returns a CompletableFuture that upon completion, has the same + * value as that produced asynchronously using the {@link + * ForkJoinPool#commonPool()} by the given function of the result + * of this CompletableFuture. + * + *

    If this CompletableFuture completes exceptionally, then the + * returned CompletableFuture also does so, with a + * CompletionException holding this exception as its cause. + * Similarly, if the computed CompletableFuture completes + * exceptionally, then so does the returned CompletableFuture. + * + * @param fn the function returning a new CompletableFuture + * @return the CompletableFuture + */ + public CompletableFuture thenComposeAsync + (Function> fn) { + return doThenCompose(fn, ForkJoinPool.commonPool()); + } + + /** + * Returns a CompletableFuture that upon completion, has the same + * value as that produced asynchronously using the given executor + * by the given function of this CompletableFuture. + * + *

    If this CompletableFuture completes exceptionally, then the + * returned CompletableFuture also does so, with a + * CompletionException holding this exception as its cause. + * Similarly, if the computed CompletableFuture completes + * exceptionally, then so does the returned CompletableFuture. + * + * @param fn the function returning a new CompletableFuture + * @param executor the executor to use for asynchronous execution + * @return the CompletableFuture + */ + public CompletableFuture thenComposeAsync + (Function> fn, + Executor executor) { + if (executor == null) throw new NullPointerException(); + return doThenCompose(fn, executor); + } + + private CompletableFuture doThenCompose + (Function> fn, + Executor e) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = null; + ThenCompose d = null; + Object r; + if ((r = result) == null) { + dst = new CompletableFuture(); + CompletionNode p = new CompletionNode + (d = new ThenCompose(this, fn, dst, e)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject + (this, COMPLETIONS, p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + if (ex == null) { + if (e != null) { + if (dst == null) + dst = new CompletableFuture(); + e.execute(new AsyncCompose(t, fn, dst)); + } + else { + try { + if ((dst = fn.apply(t)) == null) + ex = new NullPointerException(); + } catch (Throwable rex) { + ex = rex; + } + } + } + if (dst == null) + dst = new CompletableFuture(); + if (e == null || ex != null) + dst.internalComplete(null, ex); + } + helpPostComplete(); + dst.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed when this + * CompletableFuture completes, with the result of the given + * function of the exception triggering this CompletableFuture's + * completion when it completes exceptionally; otherwise, if this + * CompletableFuture completes normally, then the returned + * CompletableFuture also completes normally with the same value. + * + * @param fn the function to use to compute the value of the + * returned CompletableFuture if this CompletableFuture completed + * exceptionally + * @return the new CompletableFuture + */ + public CompletableFuture exceptionally + (Function fn) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + ExceptionCompletion d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = + new CompletionNode(d = new ExceptionCompletion(this, fn, dst)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, + p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t = null; Throwable ex, dx = null; + if (r instanceof AltResult) { + if ((ex = ((AltResult)r).ex) != null) { + try { + t = fn.apply(ex); + } catch (Throwable rex) { + dx = rex; + } + } + } + else { + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + dst.internalComplete(t, dx); + } + helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed when this + * CompletableFuture completes, with the result of the given + * function of the result and exception of this CompletableFuture's + * completion. The given function is invoked with the result (or + * {@code null} if none) and the exception (or {@code null} if none) + * of this CompletableFuture when complete. + * + * @param fn the function to use to compute the value of the + * returned CompletableFuture + * @return the new CompletableFuture + */ + public CompletableFuture handle + (BiFunction fn) { + if (fn == null) throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + HandleCompletion d = null; + Object r; + if ((r = result) == null) { + CompletionNode p = + new CompletionNode(d = new HandleCompletion(this, fn, dst)); + while ((r = result) == null) { + if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, + p.next = completions, p)) + break; + } + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + T t; Throwable ex; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + @SuppressWarnings("unchecked") T tr = (T) r; + t = tr; + } + U u; Throwable dx; + try { + u = fn.apply(t, ex); + dx = null; + } catch (Throwable rex) { + dx = rex; + u = null; + } + dst.internalComplete(u, dx); + } + helpPostComplete(); + return dst; + } + + + /* ------------- Arbitrary-arity constructions -------------- */ + + /* + * The basic plan of attack is to recursively form binary + * completion trees of elements. This can be overkill for small + * sets, but scales nicely. The And/All vs Or/Any forms use the + * same idea, but details differ. + */ + + /** + * Returns a new CompletableFuture that is completed when all of + * the given CompletableFutures complete. If any of the given + * CompletableFutures complete exceptionally, then the returned + * CompletableFuture also does so, with a CompletionException + * holding this exception as its cause. Otherwise, the results, + * if any, of the given CompletableFutures are not reflected in + * the returned CompletableFuture, but may be obtained by + * inspecting them individually. If no CompletableFutures are + * provided, returns a CompletableFuture completed with the value + * {@code null}. + * + *

    Among the applications of this method is to await completion + * of a set of independent CompletableFutures before continuing a + * program, as in: {@code CompletableFuture.allOf(c1, c2, + * c3).join();}. + * + * @param cfs the CompletableFutures + * @return a new CompletableFuture that is completed when all of the + * given CompletableFutures complete + * @throws NullPointerException if the array or any of its elements are + * {@code null} + */ + public static CompletableFuture allOf(CompletableFuture... cfs) { + int len = cfs.length; // Directly handle empty and singleton cases + if (len > 1) + return allTree(cfs, 0, len - 1); + else { + CompletableFuture dst = new CompletableFuture(); + CompletableFuture f; + if (len == 0) + dst.result = NIL; + else if ((f = cfs[0]) == null) + throw new NullPointerException(); + else { + ThenPropagate d = null; + CompletionNode p = null; + Object r; + while ((r = f.result) == null) { + if (d == null) + d = new ThenPropagate(f, dst); + else if (p == null) + p = new CompletionNode(d); + else if (UNSAFE.compareAndSwapObject + (f, COMPLETIONS, p.next = f.completions, p)) + break; + } + if (r != null && (d == null || d.compareAndSet(0, 1))) + dst.internalComplete(null, (r instanceof AltResult) ? + ((AltResult)r).ex : null); + f.helpPostComplete(); + } + return dst; + } + } + + /** + * Recursively constructs an And'ed tree of CompletableFutures. + * Called only when array known to have at least two elements. + */ + private static CompletableFuture allTree(CompletableFuture[] cfs, + int lo, int hi) { + CompletableFuture fst, snd; + int mid = (lo + hi) >>> 1; + if ((fst = (lo == mid ? cfs[lo] : allTree(cfs, lo, mid))) == null || + (snd = (hi == mid+1 ? cfs[hi] : allTree(cfs, mid+1, hi))) == null) + throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + AndCompletion d = null; + CompletionNode p = null, q = null; + Object r = null, s = null; + while ((r = fst.result) == null || (s = snd.result) == null) { + if (d == null) + d = new AndCompletion(fst, snd, dst); + else if (p == null) + p = new CompletionNode(d); + else if (q == null) { + if (UNSAFE.compareAndSwapObject + (fst, COMPLETIONS, p.next = fst.completions, p)) + q = new CompletionNode(d); + } + else if (UNSAFE.compareAndSwapObject + (snd, COMPLETIONS, q.next = snd.completions, q)) + break; + } + if ((r != null || (r = fst.result) != null) && + (s != null || (s = snd.result) != null) && + (d == null || d.compareAndSet(0, 1))) { + Throwable ex; + if (r instanceof AltResult) + ex = ((AltResult)r).ex; + else + ex = null; + if (ex == null && (s instanceof AltResult)) + ex = ((AltResult)s).ex; + dst.internalComplete(null, ex); + } + fst.helpPostComplete(); + snd.helpPostComplete(); + return dst; + } + + /** + * Returns a new CompletableFuture that is completed when any of + * the given CompletableFutures complete, with the same result. + * Otherwise, if it completed exceptionally, the returned + * CompletableFuture also does so, with a CompletionException + * holding this exception as its cause. If no CompletableFutures + * are provided, returns an incomplete CompletableFuture. + * + * @param cfs the CompletableFutures + * @return a new CompletableFuture that is completed with the + * result or exception of any of the given CompletableFutures when + * one completes + * @throws NullPointerException if the array or any of its elements are + * {@code null} + */ + public static CompletableFuture anyOf(CompletableFuture... cfs) { + int len = cfs.length; // Same idea as allOf + if (len > 1) + return anyTree(cfs, 0, len - 1); + else { + CompletableFuture dst = new CompletableFuture(); + CompletableFuture f; + if (len == 0) + ; // skip + else if ((f = cfs[0]) == null) + throw new NullPointerException(); + else { + ThenCopy d = null; + CompletionNode p = null; + Object r; + while ((r = f.result) == null) { + if (d == null) + d = new ThenCopy(f, dst); + else if (p == null) + p = new CompletionNode(d); + else if (UNSAFE.compareAndSwapObject + (f, COMPLETIONS, p.next = f.completions, p)) + break; + } + if (r != null && (d == null || d.compareAndSet(0, 1))) { + Throwable ex; Object t; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + t = r; + } + dst.internalComplete(t, ex); + } + f.helpPostComplete(); + } + return dst; + } + } + + /** + * Recursively constructs an Or'ed tree of CompletableFutures. + */ + private static CompletableFuture anyTree(CompletableFuture[] cfs, + int lo, int hi) { + CompletableFuture fst, snd; + int mid = (lo + hi) >>> 1; + if ((fst = (lo == mid ? cfs[lo] : anyTree(cfs, lo, mid))) == null || + (snd = (hi == mid+1 ? cfs[hi] : anyTree(cfs, mid+1, hi))) == null) + throw new NullPointerException(); + CompletableFuture dst = new CompletableFuture(); + OrCompletion d = null; + CompletionNode p = null, q = null; + Object r; + while ((r = fst.result) == null && (r = snd.result) == null) { + if (d == null) + d = new OrCompletion(fst, snd, dst); + else if (p == null) + p = new CompletionNode(d); + else if (q == null) { + if (UNSAFE.compareAndSwapObject + (fst, COMPLETIONS, p.next = fst.completions, p)) + q = new CompletionNode(d); + } + else if (UNSAFE.compareAndSwapObject + (snd, COMPLETIONS, q.next = snd.completions, q)) + break; + } + if ((r != null || (r = fst.result) != null || + (r = snd.result) != null) && + (d == null || d.compareAndSet(0, 1))) { + Throwable ex; Object t; + if (r instanceof AltResult) { + ex = ((AltResult)r).ex; + t = null; + } + else { + ex = null; + t = r; + } + dst.internalComplete(t, ex); + } + fst.helpPostComplete(); + snd.helpPostComplete(); + return dst; + } + + /* ------------- Control and status methods -------------- */ + + /** + * If not already completed, completes this CompletableFuture with + * a {@link CancellationException}. Dependent CompletableFutures + * that have not already completed will also complete + * exceptionally, with a {@link CompletionException} caused by + * this {@code CancellationException}. + * + * @param mayInterruptIfRunning this value has no effect in this + * implementation because interrupts are not used to control + * processing. + * + * @return {@code true} if this task is now cancelled + */ + public boolean cancel(boolean mayInterruptIfRunning) { + boolean cancelled = (result == null) && + UNSAFE.compareAndSwapObject + (this, RESULT, null, new AltResult(new CancellationException())); + postComplete(); + return cancelled || isCancelled(); + } + + /** + * Returns {@code true} if this CompletableFuture was cancelled + * before it completed normally. + * + * @return {@code true} if this CompletableFuture was cancelled + * before it completed normally + */ + public boolean isCancelled() { + Object r; + return ((r = result) instanceof AltResult) && + (((AltResult)r).ex instanceof CancellationException); + } + + /** + * Forcibly sets or resets the value subsequently returned by + * method {@link #get()} and related methods, whether or not + * already completed. This method is designed for use only in + * error recovery actions, and even in such situations may result + * in ongoing dependent completions using established versus + * overwritten outcomes. + * + * @param value the completion value + */ + public void obtrudeValue(T value) { + result = (value == null) ? NIL : value; + postComplete(); + } + + /** + * Forcibly causes subsequent invocations of method {@link #get()} + * and related methods to throw the given exception, whether or + * not already completed. This method is designed for use only in + * recovery actions, and even in such situations may result in + * ongoing dependent completions using established versus + * overwritten outcomes. + * + * @param ex the exception + */ + public void obtrudeException(Throwable ex) { + if (ex == null) throw new NullPointerException(); + result = new AltResult(ex); + postComplete(); + } + + /** + * Returns the estimated number of CompletableFutures whose + * completions are awaiting completion of this CompletableFuture. + * This method is designed for use in monitoring system state, not + * for synchronization control. + * + * @return the number of dependent CompletableFutures + */ + public int getNumberOfDependents() { + int count = 0; + for (CompletionNode p = completions; p != null; p = p.next) + ++count; + return count; + } + + /** + * Returns a string identifying this CompletableFuture, as well as + * its completion state. The state, in brackets, contains the + * String {@code "Completed Normally"} or the String {@code + * "Completed Exceptionally"}, or the String {@code "Not + * completed"} followed by the number of CompletableFutures + * dependent upon its completion, if any. + * + * @return a string identifying this CompletableFuture, as well as its state + */ + public String toString() { + Object r = result; + int count; + return super.toString() + + ((r == null) ? + (((count = getNumberOfDependents()) == 0) ? + "[Not completed]" : + "[Not completed, " + count + " dependents]") : + (((r instanceof AltResult) && ((AltResult)r).ex != null) ? + "[Completed exceptionally]" : + "[Completed normally]")); + } + + // Unsafe mechanics + private static final sun.misc.Unsafe UNSAFE; + private static final long RESULT; + private static final long WAITERS; + private static final long COMPLETIONS; + static { + try { + UNSAFE = sun.misc.Unsafe.getUnsafe(); + Class k = CompletableFuture.class; + RESULT = UNSAFE.objectFieldOffset + (k.getDeclaredField("result")); + WAITERS = UNSAFE.objectFieldOffset + (k.getDeclaredField("waiters")); + COMPLETIONS = UNSAFE.objectFieldOffset + (k.getDeclaredField("completions")); + } catch (Exception e) { + throw new Error(e); + } + } +} diff --git a/jdk/src/share/classes/java/util/concurrent/CompletionException.java b/jdk/src/share/classes/java/util/concurrent/CompletionException.java new file mode 100644 index 00000000000..2a3cfc56adf --- /dev/null +++ b/jdk/src/share/classes/java/util/concurrent/CompletionException.java @@ -0,0 +1,90 @@ +/* + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +package java.util.concurrent; + +/** + * Exception thrown when an error or other exception is encountered + * in the course of completing a result or task. + * + * @since 1.8 + * @author Doug Lea + */ +public class CompletionException extends RuntimeException { + private static final long serialVersionUID = 7830266012832686185L; + + /** + * Constructs a {@code CompletionException} with no detail message. + * The cause is not initialized, and may subsequently be + * initialized by a call to {@link #initCause(Throwable) initCause}. + */ + protected CompletionException() { } + + /** + * Constructs a {@code CompletionException} with the specified detail + * message. The cause is not initialized, and may subsequently be + * initialized by a call to {@link #initCause(Throwable) initCause}. + * + * @param message the detail message + */ + protected CompletionException(String message) { + super(message); + } + + /** + * Constructs a {@code CompletionException} with the specified detail + * message and cause. + * + * @param message the detail message + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method) + */ + public CompletionException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a {@code CompletionException} with the specified cause. + * The detail message is set to {@code (cause == null ? null : + * cause.toString())} (which typically contains the class and + * detail message of {@code cause}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method) + */ + public CompletionException(Throwable cause) { + super(cause); + } +} diff --git a/jdk/test/java/util/concurrent/CompletableFuture/Basic.java b/jdk/test/java/util/concurrent/CompletableFuture/Basic.java new file mode 100644 index 00000000000..e8ed70658d9 --- /dev/null +++ b/jdk/test/java/util/concurrent/CompletableFuture/Basic.java @@ -0,0 +1,761 @@ +/* + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* + * @test + * @bug 8005696 + * @summary Basic tests for CompletableFuture + * @author Chris Hegarty + */ + +import java.lang.reflect.Array; +import java.util.concurrent.Phaser; +import static java.util.concurrent.TimeUnit.*; +import java.util.concurrent.CompletableFuture; +import static java.util.concurrent.CompletableFuture.*; +import java.util.concurrent.CompletionException; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import static java.util.concurrent.ForkJoinPool.*; +import java.util.concurrent.atomic.AtomicInteger; + + +public class Basic { + + static void checkCompletedNormally(CompletableFuture cf, Object value) { + checkCompletedNormally(cf, value == null ? null : new Object[] { value }); + } + + static void checkCompletedNormally(CompletableFuture cf, Object[] values) { + try { equalAnyOf(cf.join(), values); } catch (Throwable x) { unexpected(x); } + try { equalAnyOf(cf.getNow(null), values); } catch (Throwable x) { unexpected(x); } + try { equalAnyOf(cf.get(), values); } catch (Throwable x) { unexpected(x); } + try { equalAnyOf(cf.get(0L, SECONDS), values); } catch (Throwable x) { unexpected(x); } + check(cf.isDone(), "Expected isDone to be true, got:" + cf); + check(!cf.isCancelled(), "Expected isCancelled to be false"); + check(!cf.cancel(true), "Expected cancel to return false"); + check(cf.toString().contains("[Completed normally]")); + check(cf.complete(null) == false, "Expected complete() to fail"); + check(cf.completeExceptionally(new Throwable()) == false, + "Expected completeExceptionally() to fail"); + } + + static void checkCompletedExceptionally(CompletableFuture cf) + throws Exception + { + checkCompletedExceptionally(cf, false); + } + + @SuppressWarnings("unchecked") + static void checkCompletedExceptionally(CompletableFuture cf, boolean cancelled) + throws Exception + { + try { cf.join(); fail("Excepted exception to be thrown"); } + catch (CompletionException x) { if (cancelled) fail(); else pass(); } + catch (CancellationException x) { if (cancelled) pass(); else fail(); } + try { cf.getNow(null); fail("Excepted exception to be thrown"); } + catch (CompletionException x) { if (cancelled) fail(); else pass(); } + catch (CancellationException x) { if (cancelled) pass(); else fail(); } + try { cf.get(); fail("Excepted exception to be thrown");} + catch (CancellationException x) { if (cancelled) pass(); else fail(); } + catch (ExecutionException x) { if (cancelled) check(x.getCause() instanceof CancellationException); else pass(); } + try { cf.get(0L, SECONDS); fail("Excepted exception to be thrown");} + catch (CancellationException x) { if (cancelled) pass(); else fail(); } + catch (ExecutionException x) { if (cancelled) check(x.getCause() instanceof CancellationException); else pass(); } + check(cf.isDone(), "Expected isDone to be true, got:" + cf); + check(cf.isCancelled() == cancelled, "Expected isCancelled: " + cancelled + ", got:" + cf.isCancelled()); + check(cf.cancel(true) == cancelled, "Expected cancel: " + cancelled + ", got:" + cf.cancel(true)); + check(cf.toString().contains("[Completed exceptionally]")); // ## TODO: 'E'xceptionally + check(cf.complete((T)new Object()) == false, "Expected complete() to fail"); + check(cf.completeExceptionally(new Throwable()) == false, + "Expected completeExceptionally() to fail, already completed"); + } + + private static void realMain(String[] args) throws Throwable { + ExecutorService executor = Executors.newFixedThreadPool(2); + try { + test(executor); + } finally { + executor.shutdown(); + executor.awaitTermination(30, SECONDS); + } + } + + static AtomicInteger atomicInt = new AtomicInteger(0); + + private static void test(ExecutorService executor) throws Throwable { + + Thread.currentThread().setName("mainThread"); + + //---------------------------------------------------------------- + // supplyAsync tests + //---------------------------------------------------------------- + try { + CompletableFuture cf = supplyAsync(() -> "a test string"); + checkCompletedNormally(cf, cf.join()); + cf = supplyAsync(() -> "a test string", commonPool()); + checkCompletedNormally(cf, cf.join()); + cf = supplyAsync(() -> "a test string", executor); + checkCompletedNormally(cf, cf.join()); + cf = supplyAsync(() -> { throw new RuntimeException(); }); + checkCompletedExceptionally(cf); + cf = supplyAsync(() -> { throw new RuntimeException(); }, commonPool()); + checkCompletedExceptionally(cf); + cf = supplyAsync(() -> { throw new RuntimeException(); }, executor); + checkCompletedExceptionally(cf); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // runAsync tests + //---------------------------------------------------------------- + try { + CompletableFuture cf = runAsync(() -> { }); + checkCompletedNormally(cf, cf.join()); + cf = runAsync(() -> { }, commonPool()); + checkCompletedNormally(cf, cf.join()); + cf = runAsync(() -> { }, executor); + checkCompletedNormally(cf, cf.join()); + cf = runAsync(() -> { throw new RuntimeException(); }); + checkCompletedExceptionally(cf); + cf = runAsync(() -> { throw new RuntimeException(); }, commonPool()); + checkCompletedExceptionally(cf); + cf = runAsync(() -> { throw new RuntimeException(); }, executor); + checkCompletedExceptionally(cf); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // explicit completion + //---------------------------------------------------------------- + try { + final Phaser phaser = new Phaser(1); + final int phase = phaser.getPhase(); + CompletableFuture cf; + cf = supplyAsync(() -> { phaser.awaitAdvance(phase); return 1; }); + cf.complete(2); + phaser.arrive(); + checkCompletedNormally(cf, 2); + + cf = supplyAsync(() -> { phaser.awaitAdvance(phase+1); return 1; }); + cf.completeExceptionally(new Throwable()); + phaser.arrive(); + checkCompletedExceptionally(cf); + + cf = supplyAsync(() -> { phaser.awaitAdvance(phase+2); return 1; }); + cf.cancel(true); + phaser.arrive(); + checkCompletedExceptionally(cf, true); + + cf = supplyAsync(() -> { phaser.awaitAdvance(phase+3); return 1; }); + check(cf.getNow(2) == 2); + phaser.arrive(); + checkCompletedNormally(cf, 1); + check(cf.getNow(2) == 1); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // thenApplyXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf2; + CompletableFuture cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenApply((x) -> { if (x.equals("a test string")) return 1; else return 0; }); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, 1); + + cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; }); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, 1); + + cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; }, executor); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, 1); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenApply((x) -> { return 0; } ); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenApplyAsync((x) -> { return 0; } ); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenApplyAsync((x) -> { return 0; }, executor); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // thenAcceptXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf2; + int before = atomicInt.get(); + CompletableFuture cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenAccept((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }, executor); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenAccept((x) -> { atomicInt.incrementAndGet(); } ); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); } ); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); }, executor ); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // thenRunXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf2; + int before = atomicInt.get(); + CompletableFuture cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> "a test string"); + cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor); + checkCompletedNormally(cf1, "a test string"); + checkCompletedNormally(cf2, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); }); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // thenCombineXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + CompletableFuture cf1 = supplyAsync(() -> 1); + CompletableFuture cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenCombine(cf2, (x, y) -> { return x + y; }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, 2); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, 2); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; }, executor); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, 2); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenCombine(cf2, (x, y) -> { return 0; }); + checkCompletedExceptionally(cf1); + checkCompletedNormally(cf2, 1); + checkCompletedExceptionally(cf3); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; }); + checkCompletedNormally(cf1, 1); + checkCompletedExceptionally(cf2); + checkCompletedExceptionally(cf3); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; }, executor); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + checkCompletedExceptionally(cf3); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // thenAcceptBothXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + int before = atomicInt.get(); + CompletableFuture cf1 = supplyAsync(() -> 1); + CompletableFuture cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { check(x + y == 2); atomicInt.incrementAndGet(); }, executor); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> 1); + cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { atomicInt.incrementAndGet(); }); + checkCompletedExceptionally(cf1); + checkCompletedNormally(cf2, 1); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf1, 1); + checkCompletedExceptionally(cf2); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); }, executor); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // runAfterBothXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + int before = atomicInt.get(); + CompletableFuture cf1 = supplyAsync(() -> 1); + CompletableFuture cf2 = supplyAsync(() -> 1); + cf3 = cf1.runAfterBoth(cf2, () -> { check(cf1.isDone()); check(cf2.isDone()); atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + CompletableFuture cfa = supplyAsync(() -> 1); + CompletableFuture cfb = supplyAsync(() -> 1); + cf3 = cfa.runAfterBothAsync(cfb, () -> { check(cfa.isDone()); check(cfb.isDone()); atomicInt.incrementAndGet(); }); + checkCompletedNormally(cfa, 1); + checkCompletedNormally(cfb, 1); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + CompletableFuture cfx = supplyAsync(() -> 1); + CompletableFuture cfy = supplyAsync(() -> 1); + cf3 = cfy.runAfterBothAsync(cfx, () -> { check(cfx.isDone()); check(cfy.isDone()); atomicInt.incrementAndGet(); }, executor); + checkCompletedNormally(cfx, 1); + checkCompletedNormally(cfy, 1); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + CompletableFuture cf4 = supplyAsync(() -> { throw new RuntimeException(); }); + CompletableFuture cf5 = supplyAsync(() -> 1); + cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); }, executor); + checkCompletedExceptionally(cf4); + checkCompletedNormally(cf5, 1); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + + before = atomicInt.get(); + cf4 = supplyAsync(() -> 1); + cf5 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); }); + checkCompletedNormally(cf4, 1); + checkCompletedExceptionally(cf5); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + + before = atomicInt.get(); + cf4 = supplyAsync(() -> { throw new RuntimeException(); }); + cf5 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf5.runAfterBoth(cf4, () -> { atomicInt.incrementAndGet(); }); + checkCompletedExceptionally(cf4); + checkCompletedExceptionally(cf5); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // applyToEitherXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + CompletableFuture cf1 = supplyAsync(() -> 1); + CompletableFuture cf2 = supplyAsync(() -> 2); + cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 1 || x == 2); return x; }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, new Object[] {1, 2}); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 2); + cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, new Object[] {1, 2}); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 2); + cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; }, executor); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, new Object[] {1, 2}); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> 2); + cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; }); + check(cf1.isDone() || cf2.isDone()); + try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); } + check(cf3.isDone()); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; }); + check(cf1.isDone() || cf2.isDone()); + try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); } + check(cf3.isDone()); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.applyToEitherAsync(cf2, (x) -> { fail(); return x; }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedExceptionally(cf3); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // acceptEitherXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + int before = atomicInt.get(); + CompletableFuture cf1 = supplyAsync(() -> 1); + CompletableFuture cf2 = supplyAsync(() -> 2); + cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 2); + cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> 2); + cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }, executor); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> 2); + cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 2); }, executor); + check(cf1.isDone() || cf2.isDone()); + try { check(cf3.join() == null); } catch (CompletionException x) { pass(); } + check(cf3.isDone()); + + cf1 = supplyAsync(() -> 1); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1); }); + check(cf1.isDone() || cf2.isDone()); + try { check(cf3.join() == null); } catch (CompletionException x) { pass(); } + check(cf3.isDone()); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = supplyAsync(() -> { throw new RuntimeException(); }); + cf3 = cf2.acceptEitherAsync(cf1, (x) -> { fail(); }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedExceptionally(cf3); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // runAfterEitherXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + int before = atomicInt.get(); + CompletableFuture cf1 = runAsync(() -> { }); + CompletableFuture cf2 = runAsync(() -> { }); + cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = runAsync(() -> { }); + cf2 = runAsync(() -> { }); + cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); }); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = runAsync(() -> { }); + cf2 = runAsync(() -> { }); + cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor); + check(cf1.isDone() || cf2.isDone()); + checkCompletedNormally(cf3, null); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = runAsync(() -> { throw new RuntimeException(); }); + cf2 = runAsync(() -> { }); + cf3 = cf2.runAfterEither(cf1, () -> { atomicInt.incrementAndGet(); }); + check(cf1.isDone() || cf2.isDone()); + try { check(cf3.join() == null); } catch (CompletionException x) { pass(); } + check(cf3.isDone()); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = runAsync(() -> { }); + cf2 = runAsync(() -> { throw new RuntimeException(); }); + cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); }); + check(cf1.isDone() || cf2.isDone()); + try { check(cf3.join() == null); } catch (CompletionException x) { pass(); } + check(cf3.isDone()); + check(atomicInt.get() == (before + 1)); + + before = atomicInt.get(); + cf1 = runAsync(() -> { throw new RuntimeException(); }); + cf2 = runAsync(() -> { throw new RuntimeException(); }); + cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor); + check(cf1.isDone() || cf2.isDone()); + checkCompletedExceptionally(cf3); + check(atomicInt.get() == before); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // thenComposeXXX tests + //---------------------------------------------------------------- + try { + CompletableFuture cf2; + CompletableFuture cf1 = supplyAsync(() -> 1); + cf2 = cf1.thenCompose((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 2); + + cf1 = supplyAsync(() -> 1); + cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); }); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 2); + + cf1 = supplyAsync(() -> 1); + cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); }, executor); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 2); + + int before = atomicInt.get(); + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenCompose((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); }); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> { throw new RuntimeException(); }); + cf2 = cf1.thenComposeAsync((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); }); + checkCompletedExceptionally(cf1); + checkCompletedExceptionally(cf2); + check(atomicInt.get() == before); + + cf1 = supplyAsync(() -> 1); + cf2 = cf1.thenComposeAsync((x) -> { throw new RuntimeException(); }, executor); + checkCompletedNormally(cf1, 1); + checkCompletedExceptionally(cf2); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // anyOf tests + //---------------------------------------------------------------- + //try { + // CompletableFuture cf3; + // for (int k=0; k < 10; k++){ + // CompletableFuture cf1 = supplyAsync(() -> 1); + // CompletableFuture cf2 = supplyAsync(() -> 2); + // cf3 = CompletableFuture.anyOf(cf1, cf2); + // check(cf1.isDone() || cf2.isDone()); + // checkCompletedNormally(cf3, new Object[] {1, 2}); + // } + //} catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // allOf tests + //---------------------------------------------------------------- + try { + CompletableFuture cf3; + for (int k=0; k < 10; k++){ + CompletableFuture[] cfs = (CompletableFuture[]) + Array.newInstance(CompletableFuture.class, 10); + for (int j=0; j < 10; j++) { + final int v = j; + cfs[j] = supplyAsync(() -> v); + } + cf3 = CompletableFuture.allOf(cfs); + for (int j=0; j < 10; j++) + checkCompletedNormally(cfs[j], j); + checkCompletedNormally(cf3, null); + } + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // exceptionally tests + //---------------------------------------------------------------- + try { + CompletableFuture cf2; + CompletableFuture cf1 = supplyAsync(() -> 1); + cf2 = cf1.exceptionally((t) -> { fail("function should never be called"); return 2;}); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 1); + + final RuntimeException t = new RuntimeException(); + cf1 = supplyAsync(() -> { throw t; }); + cf2 = cf1.exceptionally((x) -> { check(x.getCause() == t); return 2;}); + checkCompletedExceptionally(cf1); + checkCompletedNormally(cf2, 2); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // handle tests + //---------------------------------------------------------------- + try { + CompletableFuture cf2; + CompletableFuture cf1 = supplyAsync(() -> 1); + cf2 = cf1.handle((x,t) -> x+1); + checkCompletedNormally(cf1, 1); + checkCompletedNormally(cf2, 2); + + final RuntimeException ex = new RuntimeException(); + cf1 = supplyAsync(() -> { throw ex; }); + cf2 = cf1.handle((x,t) -> { check(t.getCause() == ex); return 2;}); + checkCompletedExceptionally(cf1); + checkCompletedNormally(cf2, 2); + } catch (Throwable t) { unexpected(t); } + + } + + //--------------------- Infrastructure --------------------------- + static volatile int passed = 0, failed = 0; + static void pass() {passed++;} + static void fail() {failed++; Thread.dumpStack();} + static void fail(String msg) {System.out.println(msg); fail();} + static void unexpected(Throwable t) {failed++; t.printStackTrace();} + static void check(boolean cond) {if (cond) pass(); else fail();} + static void check(boolean cond, String msg) {if (cond) pass(); else fail(msg);} + static void equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) pass(); + else fail(x + " not equal to " + y);} + static void equalAnyOf(Object x, Object[] y) { + if (x == null && y == null) { pass(); return; } + for (Object z : y) { if (x.equals(z)) { pass(); return; } } + StringBuilder sb = new StringBuilder(); + for (Object o : y) + sb.append(o).append(" "); + fail(x + " not equal to one of [" + sb + "]");} + public static void main(String[] args) throws Throwable { + try {realMain(args);} catch (Throwable t) {unexpected(t);} + System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); + if (failed > 0) throw new AssertionError("Some tests failed");} +} From 0a6c65bc99ee750499d9c894d18ab325b452d8d9 Mon Sep 17 00:00:00 2001 From: Tim Bell Date: Tue, 9 Apr 2013 13:05:22 -0700 Subject: [PATCH 152/155] 8011348: use of which in common/autoconf/autogen.sh is not portable Reviewed-by: erikj, katleman, mduigou --- common/autoconf/autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/autoconf/autogen.sh b/common/autoconf/autogen.sh index 6df1f557552..35ed2a5813a 100644 --- a/common/autoconf/autogen.sh +++ b/common/autoconf/autogen.sh @@ -43,8 +43,8 @@ fi custom_hook=$custom_script_dir/custom-hook.m4 -AUTOCONF=$(which autoconf 2> /dev/null); -AUTOCONF_267=$(which autoconf-2.67 2> /dev/null); +AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" +AUTOCONF_267="`which autoconf-2.67 2> /dev/null | grep -v '^no autoconf-2.67 in'`" echo "Autoconf found: ${AUTOCONF}" echo "Autoconf-2.67 found: ${AUTOCONF_267}" From 916bf9b7c96766bfdb3aba67804e96d260709dc8 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:46:58 +0200 Subject: [PATCH 153/155] Added tag jdk8-b83 for changeset bcebd3fdefc9 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index aee5d6a2d78..95524f5c8df 100644 --- a/.hgtags +++ b/.hgtags @@ -204,3 +204,4 @@ a1313a8d90d17d363a3b2a645dc4030ec204b168 jdk8-b79 3fa21fbf9be7e6b482af43aacb6a09acfa30bdb6 jdk8-b80 e41d716405b209d3eddef8bd4240cec2bd34dcca jdk8-b81 5e8c55025644730385a6f8fa029ecdb2d2c98a07 jdk8-b82 +bcebd3fdefc91abb9d7fa0c5af6211b3f8720da6 jdk8-b83 From 8e31509df1443c2282cd08575266c5f142a6681a Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:48:17 +0200 Subject: [PATCH 154/155] Added tag jdk8-b84 for changeset d7ad0dfaa411 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 95524f5c8df..a689628fb73 100644 --- a/.hgtags +++ b/.hgtags @@ -205,3 +205,4 @@ a1313a8d90d17d363a3b2a645dc4030ec204b168 jdk8-b79 e41d716405b209d3eddef8bd4240cec2bd34dcca jdk8-b81 5e8c55025644730385a6f8fa029ecdb2d2c98a07 jdk8-b82 bcebd3fdefc91abb9d7fa0c5af6211b3f8720da6 jdk8-b83 +d7ad0dfaa41151bd3a9ae46725b0aec3730a9cd0 jdk8-b84 From 488df135583efd941bbe34f8faf564fda70228fc Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 11 Apr 2013 09:40:13 -0700 Subject: [PATCH 155/155] Added tag jdk8-b85 for changeset c62699ce4007 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 5548c0a383e..ef6e16f2fe3 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -206,3 +206,4 @@ c0f8022eba536dcdc8aae659005b33f3982b9368 jdk8-b81 624bcb4800065c6656171948e31ebb2925f25c7a jdk8-b82 ac519af51769e92c51b597a730974e8607357709 jdk8-b83 7b4721e4edb4e1c65e9c839a70d7cc67f81c7632 jdk8-b84 +296676d534c52888c36e305a2bf7f345c4ca70f8 jdk8-b85