extends Type, Annota
* for any reason
* @return an array of {@code Type}s representing the upper
* bound(s) of this type variable
- */
+ */
Type[] getBounds();
/**
diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/WildcardType.java b/jdk/src/java.base/share/classes/java/lang/reflect/WildcardType.java
index aa8e824d88a..7b8f3962514 100644
--- a/jdk/src/java.base/share/classes/java/lang/reflect/WildcardType.java
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/WildcardType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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 @@ package java.lang.reflect;
public interface WildcardType extends Type {
/**
* Returns an array of {@code Type} objects representing the upper
- * bound(s) of this type variable. Note that if no upper bound is
+ * bound(s) of this type variable. If no upper bound is
* explicitly declared, the upper bound is {@code Object}.
*
* For each upper bound B :
@@ -57,7 +57,7 @@ public interface WildcardType extends Type {
/**
* Returns an array of {@code Type} objects representing the
- * lower bound(s) of this type variable. Note that if no lower bound is
+ * lower bound(s) of this type variable. If no lower bound is
* explicitly declared, the lower bound is the type of {@code null}.
* In this case, a zero length array is returned.
*
diff --git a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java
index dbcffe36136..56d98363dd9 100644
--- a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java
+++ b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java
@@ -25,9 +25,11 @@
package java.security;
-import java.util.HashMap;
+import java.util.Map;
import java.util.ArrayList;
import java.net.URL;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
import sun.security.util.Debug;
@@ -48,7 +50,7 @@ public class SecureClassLoader extends ClassLoader {
private final boolean initialized;
/*
- * HashMap that maps the CodeSource URL (as a String) to ProtectionDomain.
+ * Map that maps the CodeSource URL (as a String) to ProtectionDomain.
* We use a String instead of a CodeSource/URL as the key to avoid
* potential expensive name service lookups. This does mean that URLs that
* are equivalent after nameservice lookup will be placed in separate
@@ -56,7 +58,8 @@ public class SecureClassLoader extends ClassLoader {
* canonicalized and resolved resulting in a consistent set of granted
* permissions.
*/
- private final HashMap pdcache = new HashMap<>(11);
+ private final Map pdcache
+ = new ConcurrentHashMap<>(11);
private static final Debug debug = Debug.getInstance("scl");
@@ -206,25 +209,28 @@ public class SecureClassLoader extends ClassLoader {
return null;
}
- ProtectionDomain pd = null;
- synchronized (pdcache) {
- // Use a String form of the URL as the key. It should behave in the
- // same manner as the URL when compared for equality except that no
- // nameservice lookup is done on the hostname (String comparison
- // only), and the fragment is not considered.
- String key = cs.getLocationNoFragString();
- pd = pdcache.get(key);
- if (pd == null) {
- PermissionCollection perms = getPermissions(cs);
- pd = new ProtectionDomain(cs, perms, this, null);
- pdcache.put(key, pd);
+ // Use a String form of the URL as the key. It should behave in the
+ // same manner as the URL when compared for equality except that no
+ // nameservice lookup is done on the hostname (String comparison
+ // only), and the fragment is not considered.
+ String key = cs.getLocationNoFragString();
+ if (key == null) {
+ key = "";
+ }
+ return pdcache.computeIfAbsent(key, new Function<>() {
+ @Override
+ public ProtectionDomain apply(String key /* not used */) {
+ PermissionCollection perms
+ = SecureClassLoader.this.getPermissions(cs);
+ ProtectionDomain pd = new ProtectionDomain(
+ cs, perms, SecureClassLoader.this, null);
if (debug != null) {
- debug.println(" getPermissions "+ pd);
+ debug.println(" getPermissions " + pd);
debug.println("");
}
+ return pd;
}
- }
- return pd;
+ });
}
/*
diff --git a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java
index 625a0bed15a..c2c85a69f04 100644
--- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java
+++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java
@@ -542,7 +542,22 @@ final class ProcessImpl extends Process {
@Override
public CompletableFuture onExit() {
return ProcessHandleImpl.completion(pid, false)
- .handleAsync((exitStatus, unusedThrowable) -> this);
+ .handleAsync((exitStatus, unusedThrowable) -> {
+ boolean interrupted = false;
+ while (true) {
+ // Ensure that the concurrent task setting the exit status has completed
+ try {
+ waitFor();
+ break;
+ } catch (InterruptedException ie) {
+ interrupted = true;
+ }
+ }
+ if (interrupted) {
+ Thread.currentThread().interrupt();
+ }
+ return this;
+ });
}
@Override
diff --git a/jdk/src/java.base/windows/native/launcher/java.manifest b/jdk/src/java.base/windows/native/launcher/java.manifest
index 906624bd6fa..eee6045f3f8 100644
--- a/jdk/src/java.base/windows/native/launcher/java.manifest
+++ b/jdk/src/java.base/windows/native/launcher/java.manifest
@@ -52,6 +52,8 @@
+
+
diff --git a/jdk/src/java.base/windows/native/libjava/java_props_md.c b/jdk/src/java.base/windows/native/libjava/java_props_md.c
index 270d0e350ce..0385638575d 100644
--- a/jdk/src/java.base/windows/native/libjava/java_props_md.c
+++ b/jdk/src/java.base/windows/native/libjava/java_props_md.c
@@ -351,8 +351,8 @@ java_props_t *
GetJavaProperties(JNIEnv* env)
{
static java_props_t sprops = {0};
-
- OSVERSIONINFOEX ver;
+ int majorVersion;
+ int minorVersion;
if (sprops.line_separator) {
return &sprops;
@@ -383,21 +383,65 @@ GetJavaProperties(JNIEnv* env)
/* OS properties */
{
char buf[100];
- SYSTEM_INFO si;
- PGNSI pGNSI;
+ boolean is_workstation;
+ boolean is_64bit;
+ DWORD platformId;
+ {
+ OSVERSIONINFOEX ver;
+ ver.dwOSVersionInfoSize = sizeof(ver);
+ GetVersionEx((OSVERSIONINFO *) &ver);
+ majorVersion = ver.dwMajorVersion;
+ minorVersion = ver.dwMinorVersion;
+ is_workstation = (ver.wProductType == VER_NT_WORKSTATION);
+ platformId = ver.dwPlatformId;
+ sprops.patch_level = _strdup(ver.szCSDVersion);
+ }
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx((OSVERSIONINFO *) &ver);
+ {
+ SYSTEM_INFO si;
+ ZeroMemory(&si, sizeof(SYSTEM_INFO));
+ GetNativeSystemInfo(&si);
- ZeroMemory(&si, sizeof(SYSTEM_INFO));
- // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
- pGNSI = (PGNSI) GetProcAddress(
- GetModuleHandle(TEXT("kernel32.dll")),
- "GetNativeSystemInfo");
- if(NULL != pGNSI)
- pGNSI(&si);
- else
- GetSystemInfo(&si);
+ is_64bit = (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64);
+ }
+ do {
+ // Read the major and minor version number from kernel32.dll
+ VS_FIXEDFILEINFO *file_info;
+ WCHAR kernel32_path[MAX_PATH];
+ UINT len, ret;
+
+ // Get the full path to \Windows\System32\kernel32.dll and use that for
+ // determining what version of Windows we're running on.
+ len = MAX_PATH - (UINT)strlen("\\kernel32.dll") - 1;
+ ret = GetSystemDirectoryW(kernel32_path, len);
+ if (ret == 0 || ret > len) {
+ break;
+ }
+ wcsncat(kernel32_path, L"\\kernel32.dll", MAX_PATH - ret);
+
+ DWORD version_size = GetFileVersionInfoSizeW(kernel32_path, NULL);
+ if (version_size == 0) {
+ break;
+ }
+
+ LPTSTR version_info = (LPTSTR)malloc(version_size);
+ if (version_info == NULL) {
+ break;
+ }
+
+ if (!GetFileVersionInfoW(kernel32_path, 0, version_size, version_info)) {
+ free(version_info);
+ break;
+ }
+
+ if (!VerQueryValueW(version_info, L"\\", (LPVOID*)&file_info, &len)) {
+ free(version_info);
+ break;
+ }
+ majorVersion = HIWORD(file_info->dwProductVersionMS);
+ minorVersion = LOWORD(file_info->dwProductVersionMS);
+ free(version_info);
+ } while (0);
/*
* From msdn page on OSVERSIONINFOEX, current as of this
@@ -423,17 +467,15 @@ GetJavaProperties(JNIEnv* env)
* Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION)
* Windows 8 6 2 (VER_NT_WORKSTATION)
* Windows Server 2012 6 2 (!VER_NT_WORKSTATION)
+ * Windows 10 10 0 (VER_NT_WORKSTATION)
*
* This mapping will presumably be augmented as new Windows
* versions are released.
*/
- switch (ver.dwPlatformId) {
- case VER_PLATFORM_WIN32s:
- sprops.os_name = "Windows 3.1";
- break;
+ switch (platformId) {
case VER_PLATFORM_WIN32_WINDOWS:
- if (ver.dwMajorVersion == 4) {
- switch (ver.dwMinorVersion) {
+ if (majorVersion == 4) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows 95"; break;
case 10: sprops.os_name = "Windows 98"; break;
case 90: sprops.os_name = "Windows Me"; break;
@@ -444,10 +486,10 @@ GetJavaProperties(JNIEnv* env)
}
break;
case VER_PLATFORM_WIN32_NT:
- if (ver.dwMajorVersion <= 4) {
+ if (majorVersion <= 4) {
sprops.os_name = "Windows NT";
- } else if (ver.dwMajorVersion == 5) {
- switch (ver.dwMinorVersion) {
+ } else if (majorVersion == 5) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows 2000"; break;
case 1: sprops.os_name = "Windows XP"; break;
case 2:
@@ -462,8 +504,7 @@ GetJavaProperties(JNIEnv* env)
* If it is, the operating system is Windows XP 64 bit;
* otherwise, it is Windows Server 2003."
*/
- if(ver.wProductType == VER_NT_WORKSTATION &&
- si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
+ if (is_workstation && is_64bit) {
sprops.os_name = "Windows XP"; /* 64 bit */
} else {
sprops.os_name = "Windows 2003";
@@ -471,12 +512,12 @@ GetJavaProperties(JNIEnv* env)
break;
default: sprops.os_name = "Windows NT (unknown)"; break;
}
- } else if (ver.dwMajorVersion == 6) {
+ } else if (majorVersion == 6) {
/*
* See table in MSDN OSVERSIONINFOEX documentation.
*/
- if (ver.wProductType == VER_NT_WORKSTATION) {
- switch (ver.dwMinorVersion) {
+ if (is_workstation) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows Vista"; break;
case 1: sprops.os_name = "Windows 7"; break;
case 2: sprops.os_name = "Windows 8"; break;
@@ -484,7 +525,7 @@ GetJavaProperties(JNIEnv* env)
default: sprops.os_name = "Windows NT (unknown)";
}
} else {
- switch (ver.dwMinorVersion) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows Server 2008"; break;
case 1: sprops.os_name = "Windows Server 2008 R2"; break;
case 2: sprops.os_name = "Windows Server 2012"; break;
@@ -492,6 +533,17 @@ GetJavaProperties(JNIEnv* env)
default: sprops.os_name = "Windows NT (unknown)";
}
}
+ } else if (majorVersion == 10) {
+ if (is_workstation) {
+ switch (minorVersion) {
+ case 0: sprops.os_name = "Windows 10"; break;
+ default: sprops.os_name = "Windows NT (unknown)";
+ }
+ } else {
+ switch (minorVersion) {
+ default: sprops.os_name = "Windows NT (unknown)";
+ }
+ }
} else {
sprops.os_name = "Windows NT (unknown)";
}
@@ -500,7 +552,7 @@ GetJavaProperties(JNIEnv* env)
sprops.os_name = "Windows (unknown)";
break;
}
- sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion);
+ sprintf(buf, "%d.%d", majorVersion, minorVersion);
sprops.os_version = _strdup(buf);
#if _M_IA64
sprops.os_arch = "ia64";
@@ -511,9 +563,6 @@ GetJavaProperties(JNIEnv* env)
#else
sprops.os_arch = "unknown";
#endif
-
- sprops.patch_level = _strdup(ver.szCSDVersion);
-
sprops.desktop = "windows";
}
@@ -624,7 +673,7 @@ GetJavaProperties(JNIEnv* env)
&display_encoding);
sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
- if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && ver.dwMajorVersion == 6) {
+ if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) {
// MS claims "Vista has built-in support for HKSCS-2004.
// All of the HKSCS-2004 characters have Unicode 4.1.
// PUA code point assignments". But what it really means
diff --git a/jdk/test/java/lang/ProcessHandle/OnExitTest.java b/jdk/test/java/lang/ProcessHandle/OnExitTest.java
index 98e6b9c3b39..1043c55bba2 100644
--- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java
+++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java
@@ -26,21 +26,17 @@ import java.lang.InterruptedException;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
-import java.util.stream.Collectors;
-import jdk.testlibrary.Platform;
import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.TestNG;
/*
* @test
- * @library /lib/testlibrary
* @summary Functions of Process.onExit and ProcessHandle.onExit
* @author Roger Riggs
*/
diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
index 618522ff8e7..a01e016ef90 100644
--- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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,12 +29,9 @@
* @run main/othervm CheckPackageAccess
*/
-import java.security.Security;
import java.util.Collections;
-import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
/*
* The main benefit of this test is to catch merge errors or other types
@@ -44,60 +41,12 @@ import java.util.StringTokenizer;
*/
public class CheckPackageAccess {
- /*
- * This array should be updated whenever new packages are added to the
- * package.access property in the java.security file
- * NOTE: it should be in the same order as the java.security file
- */
- private static final String[] packages = {
- "sun.",
- "com.sun.xml.internal.",
- "com.sun.imageio.",
- "com.sun.istack.internal.",
- "com.sun.jmx.",
- "com.sun.media.sound.",
- "com.sun.naming.internal.",
- "com.sun.proxy.",
- "com.sun.corba.se.",
- "com.sun.org.apache.bcel.internal.",
- "com.sun.org.apache.regexp.internal.",
- "com.sun.org.apache.xerces.internal.",
- "com.sun.org.apache.xpath.internal.",
- "com.sun.org.apache.xalan.internal.extensions.",
- "com.sun.org.apache.xalan.internal.lib.",
- "com.sun.org.apache.xalan.internal.res.",
- "com.sun.org.apache.xalan.internal.templates.",
- "com.sun.org.apache.xalan.internal.utils.",
- "com.sun.org.apache.xalan.internal.xslt.",
- "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
- "com.sun.org.apache.xalan.internal.xsltc.compiler.",
- "com.sun.org.apache.xalan.internal.xsltc.trax.",
- "com.sun.org.apache.xalan.internal.xsltc.util.",
- "com.sun.org.apache.xml.internal.res.",
- "com.sun.org.apache.xml.internal.security.",
- "com.sun.org.apache.xml.internal.serializer.utils.",
- "com.sun.org.apache.xml.internal.utils.",
- "com.sun.org.glassfish.",
- "com.sun.tools.script.",
- "com.oracle.xmlns.internal.",
- "com.oracle.webservices.internal.",
- "org.jcp.xml.dsig.internal.",
- "jdk.internal.",
- "jdk.nashorn.internal.",
- "jdk.nashorn.tools.",
- "jdk.tools.jimage.",
- "com.sun.activation.registries."
- };
-
public static void main(String[] args) throws Exception {
- List pkgs = new ArrayList<>(Arrays.asList(packages));
- String osName = System.getProperty("os.name");
- if (osName.contains("OS X")) {
- pkgs.add("apple."); // add apple package for OS X
- }
+ // get expected list of restricted packages
+ List pkgs = RestrictedPackages.expected();
- List jspkgs =
- getPackages(Security.getProperty("package.access"));
+ // get actual list of restricted packages
+ List jspkgs = RestrictedPackages.actual();
if (!isOpenJDKOnly()) {
String lastPkg = pkgs.get(pkgs.size() - 1);
@@ -127,7 +76,7 @@ public class CheckPackageAccess {
}
System.setSecurityManager(new SecurityManager());
SecurityManager sm = System.getSecurityManager();
- for (String pkg : packages) {
+ for (String pkg : pkgs) {
String subpkg = pkg + "foo";
try {
sm.checkPackageAccess(pkg);
@@ -153,18 +102,6 @@ public class CheckPackageAccess {
System.out.println("Test passed");
}
- private static List getPackages(String p) {
- List packages = new ArrayList<>();
- if (p != null && !p.equals("")) {
- StringTokenizer tok = new StringTokenizer(p, ",");
- while (tok.hasMoreElements()) {
- String s = tok.nextToken().trim();
- packages.add(s);
- }
- }
- return packages;
- }
-
private static boolean isOpenJDKOnly() {
String prop = System.getProperty("java.runtime.name");
return prop != null && prop.startsWith("OpenJDK");
diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java b/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java
new file mode 100644
index 00000000000..32a5e77d54f
--- /dev/null
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2015, 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 8072692
+ * @summary Check the matching implemented by SecurityManager.checkPackageAccess
+ * @run main/othervm CheckPackageMatching
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/*
+ * The purpose of this test is not to verify the content of the package
+ * access list - but to ensure that the matching implemented by the
+ * SecurityManager is correct. This is why we have our own pattern matching
+ * algorithm here.
+ */
+public class CheckPackageMatching {
+
+ /**
+ * The restricted packages listed in the package.access property of the
+ * java.security file.
+ */
+ private static final String[] packages =
+ RestrictedPackages.actual().toArray(new String[0]);
+
+ private static final boolean OPEN_JDK = isOpenJDKOnly();
+
+ /**
+ * PackageMatcher implements a state machine that matches package
+ * names against packages parsed from the package access list.
+ */
+ private static abstract class PackageMatcher {
+ // For each state, chars[state] contains the chars that matches.
+ private final char[][] chars;
+ // For each state, states[state][i] contains the next state to go
+ // to when chars[state][i] matches the current character.
+ private final int[][] states;
+
+ // Some markers. We're making the assumption that 0
+ // cannot be a valid character for a package name.
+ //
+ // We use 0 for marking that we expect an end of string in
+ // char[state][i].
+ private static final char END_OF_STRING = 0;
+ // This special state value indicates that we expect the string to end
+ // there.
+ private static final int END_STATE = -1;
+ // This special state value indicates that we can accept any character
+ // from now on.
+ private static final int WILDCARD_STATE = Integer.MIN_VALUE;
+
+ // Create the data for a new state machine to match package names from
+ // the array of package names passed as argument.
+ // Each package name in the array is expected to end with '.'
+ // For each package in packages we're going to compile state data
+ // that will match the regexp:
+ // ^packages[i].substring(0, packages[i].length()-1).replace(".","\\.")$|^packages[i].replace(".","\\.").*
+ //
+ // Let's say the package array is:
+ //
+ // String[] packages = { "sun.", "com.sun.jmx.", "com.sun.proxy.",
+ // "apple." };
+ //
+ // then the state machine will need data that looks like:
+ //
+ // char[][] chars = {
+ // { 'a', 'c', 's' }, { 'p' }, { 'p' }, { 'l' }, { 'e' }, { 0, '.' },
+ // { 'o' }, { 'm' }, { '.' }, { 's' }, { 'u' }, { 'n' }, { '.' },
+ // { 'j', 'p'},
+ // { 'm' }, { 'x' }, { 0, '.' },
+ // { 'r' }, { 'o' }, { 'x' }, { 'y' }, { 0, '.' },
+ // { 'u' }, { 'n' }, { 0, '.' }
+ // }
+ // int[][] states = {
+ // { 1, 6, 22 }, { 2 }, { 3 }, { 4 }, { 5 },
+ // { END_STATE, WILDCARD_STATE },
+ // { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14, 17 },
+ // { 15 }, { 16 }, { END_STATE, WILDCARD_STATE },
+ // { 18 }, { 19 }, { 20 }, { 21 }, { END_STATE, WILDCARD_STATE },
+ // { 23 }, { 24 }, { END_STATE, WILDCARD_STATE }
+ // }
+ //
+ // The machine will start by loading the chars and states for state 0
+ // chars[0] => { 'a', 'c', 's' } states[0] => { 1, 6, 22 }
+ // then it examines the char at index 0 in the candidate name.
+ // if the char matches one of the characters in chars[0], then it goes
+ // to the corresponding state in states[0]. For instance - if the first
+ // char in the candidate name is 's', which corresponds to chars[0][2] -
+ // then it will proceed with the next char in the candidate name and go
+ // to state 22 (as indicated by states[0][2]) - where it will load the
+ // chars and states for states 22: chars[22] = { 'u' },
+ // states[22] = { 23 } etc... until the candidate char at the current
+ // index matches no char in chars[states] => the candidate name doesn't
+ // match - or until it finds a success termination condition: the
+ // candidate chars are exhausted and states[state][0] is END_STATE, or
+ // the candidate chars are not exhausted - and
+ // states[state][chars[state]] is WILDCARD_STATE indicating a '.*' like
+ // regexp.
+ //
+ // [Note that the chars in chars[i] are sorted]
+ //
+ // The compile(...) method is reponsible for building the state machine
+ // data and is called only once in the constructor.
+ //
+ // The matches(String candidate) method will tell whether the candidate
+ // matches by implementing the algorithm described above.
+ //
+ PackageMatcher(String[] packages) {
+ final boolean[] selected = new boolean[packages.length];
+ Arrays.fill(selected, true);
+ final ArrayList charList = new ArrayList<>();
+ final ArrayList stateList = new ArrayList<>();
+ compile(0, 0, packages, selected, charList, stateList);
+ chars = charList.toArray(new char[0][0]);
+ states = stateList.toArray(new int[0][0]);
+ }
+
+ /**
+ * Compiles the state machine data (recursive).
+ *
+ * @param step The index of the character which we're looking at in
+ * this step.
+ * @param state The current state (starts at 0).
+ * @param pkgs The list of packages from which the automaton is built.
+ * @param selected Indicates which packages we're looking at in this
+ step.
+ * @param charList The list from which we will build
+ {@code char[][] chars;}
+ * @param stateList The list from which we will build
+ {@code int[][] states;}
+ * @return the next available state.
+ */
+ private int compile(int step, int state, String[] pkgs,
+ boolean[] selected, ArrayList charList,
+ ArrayList stateList) {
+ final char[] next = new char[pkgs.length];
+ final int[] nexti = new int[pkgs.length];
+ int j = 0;
+ char min = Character.MAX_VALUE; char max = 0;
+ for (int i = 0; i < pkgs.length; i++) {
+ if (!selected[i]) continue;
+ final String p = pkgs[i];
+ final int len = p.length();
+ if (step > len) {
+ selected[i] = false;
+ continue;
+ }
+ if (len - 1 == step) {
+ boolean unknown = true;
+ for (int k = 0; k < j ; k++) {
+ if (next[k] == END_OF_STRING) {
+ unknown = false;
+ break;
+ }
+ }
+ if (unknown) {
+ next[j] = END_OF_STRING;
+ j++;
+ }
+ nexti[i] = END_STATE;
+ }
+ final char c = p.charAt(step);
+ nexti[i] = len - 1 == step ? END_STATE : c;
+ boolean unknown = j == 0 || c < min || c > max;
+ if (!unknown) {
+ if (c != min || c != max) {
+ unknown = true;
+ for (int k = 0; k < j ; k++) {
+ if (next[k] == c) {
+ unknown = false;
+ break;
+ }
+ }
+ }
+ }
+ if (unknown) {
+ min = min > c ? c : min;
+ max = max < c ? c : max;
+ next[j] = c;
+ j++;
+ }
+ }
+ final char[] nc = new char[j];
+ final int[] nst = new int[j];
+ System.arraycopy(next, 0, nc, 0, nc.length);
+ Arrays.sort(nc);
+ final boolean ns[] = new boolean[pkgs.length];
+
+ charList.ensureCapacity(state + 1);
+ stateList.ensureCapacity(state + 1);
+ charList.add(state, nc);
+ stateList.add(state, nst);
+ state = state + 1;
+ for (int k = 0; k < nc.length; k++) {
+ int selectedCount = 0;
+ boolean endStateFound = false;
+ boolean wildcardFound = false;
+ for (int l = 0; l < nexti.length; l++) {
+ if (!(ns[l] = selected[l])) {
+ continue;
+ }
+ ns[l] = nexti[l] == nc[k] || nexti[l] == END_STATE
+ && nc[k] == '.';
+ endStateFound = endStateFound || nc[k] == END_OF_STRING
+ && nexti[l] == END_STATE;
+ wildcardFound = wildcardFound || nc[k] == '.'
+ && nexti[l] == END_STATE;
+ if (ns[l]) {
+ selectedCount++;
+ }
+ }
+ nst[k] = (endStateFound ? END_STATE
+ : wildcardFound ? WILDCARD_STATE : state);
+ if (selectedCount == 0 || wildcardFound) {
+ continue;
+ }
+ state = compile(step + 1, state, pkgs, ns, charList, stateList);
+ }
+ return state;
+ }
+
+ /**
+ * Matches 'pkg' against the list of package names compiled in the
+ * state machine data.
+ *
+ * @param pkg The package name to match. Must not end with '.'.
+ * @return true if the package name matches, false otherwise.
+ */
+ public boolean matches(String pkg) {
+ int state = 0;
+ int i;
+ final int len = pkg.length();
+ next: for (i = 0; i <= len; i++) {
+ if (state == WILDCARD_STATE) {
+ return true; // all characters will match.
+ }
+ if (state == END_STATE) {
+ return i == len;
+ }
+ final char[] ch = chars[state];
+ final int[] st = states[state];
+ if (i == len) {
+ // matches only if we have exhausted the string.
+ return st[0] == END_STATE;
+ }
+ if (st[0] == END_STATE && st.length == 1) {
+ // matches only if we have exhausted the string.
+ return i == len;
+ }
+ final char c = pkg.charAt(i); // look at next char...
+ for (int j = st[0] == END_STATE ? 1 : 0; j < ch.length; j++) {
+ final char n = ch[j];
+ if (c == n) { // found a match
+ state = st[j]; // get the next state.
+ continue next; // go to next state
+ } else if (c < n) {
+ break; // chars are sorted. we won't find it. no match.
+ }
+ }
+ break; // no match
+ }
+ return false;
+ }
+ }
+
+ private static final class TestPackageMatcher extends PackageMatcher {
+ private final List list;
+
+ TestPackageMatcher(String[] packages) {
+ super(packages);
+ this.list = Collections.unmodifiableList(Arrays.asList(packages));
+ }
+
+ @Override
+ public boolean matches(String pkg) {
+ final boolean match1 = super.matches(pkg);
+ boolean match2 = false;
+ String p2 = pkg + ".";
+ for (String p : list) {
+ if (pkg.startsWith(p) || p2.equals(p)) {
+ match2 = true;
+ break;
+ }
+ }
+ if (match1 != match2) {
+ System.err.println("Test Bug: PackageMatcher.matches(\"" +
+ pkg + "\") returned " + match1);
+ System.err.println("Package Access List is: " + list);
+ throw new Error("Test Bug: PackageMatcher.matches(\"" +
+ pkg + "\") returned " + match1);
+ }
+ return match1;
+ }
+ }
+
+ private static void smokeTest() {
+ // these checks should pass.
+ System.getSecurityManager().checkPackageAccess("com.sun.blah");
+ System.getSecurityManager().checkPackageAccess("com.sun.jm");
+ System.getSecurityManager().checkPackageAccess("com.sun.jmxa");
+ System.getSecurityManager().checkPackageAccess("jmx");
+ List actual = Arrays.asList(packages);
+ for (String p : actual) {
+ if (!actual.contains(p)) {
+ System.err.println("Warning: '" + p + " not in package.access");
+ }
+ }
+ if (!actual.contains("sun.")) {
+ throw new Error("package.access does not contain 'sun.'");
+ }
+ }
+
+ // This is a sanity test for our own test code.
+ private static void testTheTest(String[] pkgs, char[][] chars,
+ int[][] states) {
+
+ PackageMatcher m = new TestPackageMatcher(pkgs);
+ String unexpected = "";
+ if (!Arrays.deepEquals(chars, m.chars)) {
+ System.err.println("Char arrays differ");
+ if (chars.length != m.chars.length) {
+ System.err.println("Char array lengths differ: expected="
+ + chars.length + " actual=" + m.chars.length);
+ }
+ System.err.println(Arrays.deepToString(m.chars).replace((char)0,
+ '0'));
+ unexpected = "chars[]";
+ }
+ if (!Arrays.deepEquals(states, m.states)) {
+ System.err.println("State arrays differ");
+ if (states.length != m.states.length) {
+ System.err.println("Char array lengths differ: expected="
+ + states.length + " actual=" + m.states.length);
+ }
+ System.err.println(Arrays.deepToString(m.states));
+ if (unexpected.length() > 0) {
+ unexpected = unexpected + " and ";
+ }
+ unexpected = unexpected + "states[]";
+ }
+
+ if (unexpected.length() > 0) {
+ throw new Error("Unexpected "+unexpected+" in PackageMatcher");
+ }
+
+ testMatches(m, pkgs);
+ }
+
+ // This is a sanity test for our own test code.
+ private static void testTheTest() {
+ final String[] packages2 = { "sun.", "com.sun.jmx.",
+ "com.sun.proxy.", "apple." };
+
+ final int END_STATE = PackageMatcher.END_STATE;
+ final int WILDCARD_STATE = PackageMatcher.WILDCARD_STATE;
+
+ final char[][] chars2 = {
+ { 'a', 'c', 's' }, { 'p' }, { 'p' }, { 'l' }, { 'e' }, { 0, '.' },
+ { 'o' }, { 'm' }, { '.' }, { 's' }, { 'u' }, { 'n' }, { '.' },
+ { 'j', 'p'},
+ { 'm' }, { 'x' }, { 0, '.' },
+ { 'r' }, { 'o' }, { 'x' }, { 'y' }, { 0, '.' },
+ { 'u' }, { 'n' }, { 0, '.' }
+ };
+
+ final int[][] states2 = {
+ { 1, 6, 22 }, { 2 }, { 3 }, { 4 }, { 5 },
+ { END_STATE, WILDCARD_STATE },
+ { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14, 17 },
+ { 15 }, { 16 }, { END_STATE, WILDCARD_STATE },
+ { 18 }, { 19 }, { 20 }, { 21 }, { END_STATE, WILDCARD_STATE },
+ { 23 }, { 24 }, { END_STATE, WILDCARD_STATE }
+ };
+
+ testTheTest(packages2, chars2, states2);
+
+ final String[] packages3 = { "sun.", "com.sun.pro.",
+ "com.sun.proxy.", "apple." };
+
+ final char[][] chars3 = {
+ { 'a', 'c', 's' }, { 'p' }, { 'p' }, { 'l' }, { 'e' }, { 0, '.' },
+ { 'o' }, { 'm' }, { '.' }, { 's' }, { 'u' }, { 'n' }, { '.' },
+ { 'p' }, { 'r' }, { 'o' }, { 0, '.', 'x' },
+ { 'y' }, { 0, '.' },
+ { 'u' }, { 'n' }, { 0, '.' }
+ };
+
+ final int[][] states3 = {
+ { 1, 6, 19 }, { 2 }, { 3 }, { 4 }, { 5 },
+ { END_STATE, WILDCARD_STATE },
+ { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14 },
+ { 15 }, { 16 }, { END_STATE, WILDCARD_STATE, 17 },
+ { 18 }, { END_STATE, WILDCARD_STATE },
+ { 20 }, { 21 }, { END_STATE, WILDCARD_STATE }
+ };
+
+ testTheTest(packages3, chars3, states3);
+ }
+
+ private static volatile boolean sanityTesting = false;
+
+ public static void main(String[] args) {
+ System.setSecurityManager(new SecurityManager());
+
+ // Some smoke tests.
+ smokeTest();
+ System.out.println("Smoke tests passed.");
+
+ // Test our own pattern matching algorithm. Here we actually test
+ // the PackageMatcher class from our own test code.
+ sanityTesting = true;
+ try {
+ testTheTest();
+ System.out.println("Sanity tests passed.");
+ } finally {
+ sanityTesting = false;
+ }
+
+ // Now test the package matching in the security manager.
+ PackageMatcher matcher = new TestPackageMatcher(packages);
+
+ // These should not match.
+ for (String pkg : new String[] {"gloups.machin", "su",
+ "org.jcp.xml.dsig.interna",
+ "com.sun.jm", "com.sun.jmxa"}) {
+ testMatch(matcher, pkg, false, true);
+ }
+
+ // These should match.
+ for (String pkg : Arrays.asList(
+ new String[] {"sun.gloups.machin", "sun", "sun.com",
+ "com.sun.jmx", "com.sun.jmx.a",
+ "org.jcp.xml.dsig.internal",
+ "org.jcp.xml.dsig.internal.foo"})) {
+ testMatch(matcher, pkg, true, true);
+ }
+
+ // Derive a list of packages that should match or not match from
+ // the list in 'packages' - and check that the security manager
+ // throws the appropriate exception.
+ testMatches(matcher, packages);
+ }
+
+ private static void testMatches(PackageMatcher matcher, String[] pkgs) {
+ Collection pkglist = Arrays.asList(pkgs);
+ PackageMatcher ref = new TestPackageMatcher(packages);
+
+ for (String pkg : pkgs) {
+ String candidate = pkg + "toto";
+ boolean expected = true;
+ testMatch(matcher, candidate, expected,
+ ref.matches(candidate) == expected);
+ }
+
+ for (String pkg : pkgs) {
+ String candidate = pkg.substring(0, pkg.length() - 1);
+ boolean expected = pkglist.contains(candidate + ".");
+ testMatch(matcher, candidate, expected,
+ ref.matches(candidate) == expected);
+ }
+
+ for (String pkg : pkgs) {
+ if (!OPEN_JDK && pkg.equals("com.sun.media.sound.")) {
+ // don't test com.sun.media.sound since there is an entry
+ // for com.sun.media in non OpenJDK builds. Otherwise,
+ // the test for this package will fail unexpectedly.
+ continue;
+ }
+ String candidate = pkg.substring(0, pkg.length() - 2);
+ boolean expected = pkglist.contains(candidate + ".");
+ testMatch(matcher, candidate, expected,
+ ref.matches(candidate) == expected);
+ }
+ }
+
+ private static void testMatch(PackageMatcher matcher, String candidate,
+ boolean expected, boolean testSecurityManager)
+ {
+ final boolean m = matcher.matches(candidate);
+ if (m != expected) {
+ final String msg = "\"" + candidate + "\": " +
+ (m ? "matches" : "does not match");
+ throw new Error("PackageMatcher does not give expected results: "
+ + msg);
+ }
+
+ if (sanityTesting) {
+ testSecurityManager = false;
+ }
+
+ if (testSecurityManager) {
+ System.out.println("Access to " + candidate + " should be " +
+ (expected ? "rejected" : "granted"));
+ final String errormsg = "\"" + candidate + "\" : " +
+ (expected ? "granted" : "not granted");
+ try {
+ System.getSecurityManager().checkPackageAccess(candidate);
+ if (expected) {
+ System.err.println(errormsg);
+ throw new Error("Expected exception not thrown: " +
+ errormsg);
+ }
+ } catch (SecurityException x) {
+ if (!expected) {
+ System.err.println(errormsg);
+ throw new Error(errormsg + " - unexpected exception: " +
+ x, x);
+ } else {
+ System.out.println("Got expected exception: " + x);
+ }
+ }
+ }
+ }
+
+ private static boolean isOpenJDKOnly() {
+ String prop = System.getProperty("java.runtime.name");
+ return prop != null && prop.startsWith("OpenJDK");
+ }
+}
diff --git a/jdk/test/java/lang/SecurityManager/RestrictedPackages.java b/jdk/test/java/lang/SecurityManager/RestrictedPackages.java
new file mode 100644
index 00000000000..729432707bd
--- /dev/null
+++ b/jdk/test/java/lang/SecurityManager/RestrictedPackages.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2015, 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.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * A collection of utility methods and constants for testing the package
+ * access and package definition security checks.
+ */
+final class RestrictedPackages {
+
+ /*
+ * The expected list of restricted packages.
+ *
+ * This array should be updated whenever new packages are added to the
+ * package.access property in the java.security file
+ * NOTE: it should be in the same order as the java.security file
+ */
+ static final String[] EXPECTED = {
+ "sun.",
+ "com.sun.xml.internal.",
+ "com.sun.imageio.",
+ "com.sun.istack.internal.",
+ "com.sun.jmx.",
+ "com.sun.media.sound.",
+ "com.sun.naming.internal.",
+ "com.sun.proxy.",
+ "com.sun.corba.se.",
+ "com.sun.org.apache.bcel.internal.",
+ "com.sun.org.apache.regexp.internal.",
+ "com.sun.org.apache.xerces.internal.",
+ "com.sun.org.apache.xpath.internal.",
+ "com.sun.org.apache.xalan.internal.extensions.",
+ "com.sun.org.apache.xalan.internal.lib.",
+ "com.sun.org.apache.xalan.internal.res.",
+ "com.sun.org.apache.xalan.internal.templates.",
+ "com.sun.org.apache.xalan.internal.utils.",
+ "com.sun.org.apache.xalan.internal.xslt.",
+ "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
+ "com.sun.org.apache.xalan.internal.xsltc.compiler.",
+ "com.sun.org.apache.xalan.internal.xsltc.trax.",
+ "com.sun.org.apache.xalan.internal.xsltc.util.",
+ "com.sun.org.apache.xml.internal.res.",
+ "com.sun.org.apache.xml.internal.security.",
+ "com.sun.org.apache.xml.internal.serializer.utils.",
+ "com.sun.org.apache.xml.internal.utils.",
+ "com.sun.org.glassfish.",
+ "com.sun.tools.script.",
+ "com.oracle.xmlns.internal.",
+ "com.oracle.webservices.internal.",
+ "org.jcp.xml.dsig.internal.",
+ "jdk.internal.",
+ "jdk.nashorn.internal.",
+ "jdk.nashorn.tools.",
+ "jdk.tools.jimage.",
+ "com.sun.activation.registries."
+ };
+
+ /*
+ * A non-exhaustive list of restricted packages.
+ *
+ * Contrary to what is in the EXPECTED list, this list does not need
+ * to be exhaustive.
+ */
+ static final String[] EXPECTED_NONEXHAUSTIVE = {
+ "sun.",
+ "com.sun.xml.internal.",
+ "com.sun.imageio.",
+ "com.sun.istack.internal.",
+ "com.sun.jmx.",
+ "com.sun.proxy.",
+ "com.sun.org.apache.bcel.internal.",
+ "com.sun.org.apache.regexp.internal.",
+ "com.sun.org.apache.xerces.internal.",
+ "com.sun.org.apache.xpath.internal.",
+ "com.sun.org.apache.xalan.internal.extensions.",
+ "com.sun.org.apache.xalan.internal.lib.",
+ "com.sun.org.apache.xalan.internal.res.",
+ "com.sun.org.apache.xalan.internal.templates.",
+ "com.sun.org.apache.xalan.internal.utils.",
+ "com.sun.org.apache.xalan.internal.xslt.",
+ "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
+ "com.sun.org.apache.xalan.internal.xsltc.compiler.",
+ "com.sun.org.apache.xalan.internal.xsltc.trax.",
+ "com.sun.org.apache.xalan.internal.xsltc.util.",
+ "com.sun.org.apache.xml.internal.res.",
+ "com.sun.org.apache.xml.internal.serializer.utils.",
+ "com.sun.org.apache.xml.internal.utils.",
+ "com.sun.org.apache.xml.internal.security.",
+ "com.sun.org.glassfish.",
+ "org.jcp.xml.dsig.internal."
+ };
+
+ private static final String OS_NAME = System.getProperty("os.name");
+
+ /**
+ * Returns a list of expected restricted packages, including any
+ * OS specific packages. The returned list is mutable.
+ */
+ static List expected() {
+ List pkgs = new ArrayList<>(Arrays.asList(EXPECTED));
+ if (OS_NAME.contains("OS X")) {
+ pkgs.add("apple."); // add apple package for OS X
+ }
+ return pkgs;
+ }
+
+ /**
+ * Returns a list of actual restricted packages. The returned list
+ * is mutable.
+ */
+ static List actual() {
+ String prop = Security.getProperty("package.access");
+ List packages = new ArrayList<>();
+ if (prop != null && !prop.equals("")) {
+ StringTokenizer tok = new StringTokenizer(prop, ",");
+ while (tok.hasMoreElements()) {
+ String s = tok.nextToken().trim();
+ packages.add(s);
+ }
+ }
+ return packages;
+ }
+
+ private RestrictedPackages() { }
+}
diff --git a/jdk/test/java/lang/invoke/LFCaching/LFCachingTestCase.java b/jdk/test/java/lang/invoke/LFCaching/LFCachingTestCase.java
index 50a57e40c67..b5f99bd0018 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LFCachingTestCase.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LFCachingTestCase.java
@@ -77,7 +77,7 @@ public abstract class LFCachingTestCase extends LambdaFormTestCase {
}
} catch (IllegalAccessException | IllegalArgumentException |
SecurityException | InvocationTargetException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
}
}
diff --git a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
index ea5342f7f12..b6964c392a7 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
@@ -24,6 +24,7 @@
/*
* @test LFGarbageCollectedTest
* @bug 8046703
+ * @key randomness
* @ignore 8078602
* @summary Test verifies that lambda forms are garbage collected
* @author kshefov
@@ -73,7 +74,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase {
try {
adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE);
} catch (NoSuchMethodException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
mtype = adapter.type();
Object lambdaForm = INTERNAL_FORM.invoke(adapter);
@@ -94,7 +95,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase {
collectLambdaForm();
} catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
}
diff --git a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
index 35c2f97d191..55e79f24a1f 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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,6 +24,7 @@
/*
* @test LFMultiThreadCachingTest
* @bug 8046703
+ * @key randomness
* @summary Test verifies that lambda forms are cached when run with multiple threads
* @author kshefov
* @library /lib/testlibrary/jsr292 /lib/testlibrary
@@ -35,18 +36,23 @@
*/
import java.lang.invoke.MethodHandle;
+import java.util.Collections;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/**
* Multiple threaded lambda forms caching test class.
*/
public final class LFMultiThreadCachingTest extends LFCachingTestCase {
+
private static final TestMethods.Kind[] KINDS;
+
static {
EnumSet set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
KINDS = set.toArray(new TestMethods.Kind[set.size()]);
@@ -72,21 +78,55 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase {
ConcurrentLinkedQueue adapters = new ConcurrentLinkedQueue<>();
CyclicBarrier begin = new CyclicBarrier(CORES);
CountDownLatch end = new CountDownLatch(CORES);
+ final Map threadUncaughtExceptions
+ = Collections.synchronizedMap(new HashMap(CORES));
+ Thread.UncaughtExceptionHandler exHandler = (t, e) -> {
+ threadUncaughtExceptions.put(t, e);
+ };
for (int i = 0; i < CORES; ++i) {
TestMethods.Kind kind = KINDS[i % KINDS.length];
- new Thread(() -> {
+ Thread t = new Thread(() -> {
try {
begin.await();
adapters.add(getTestMethod().getTestCaseMH(data, kind));
- } catch (InterruptedException | BrokenBarrierException | IllegalAccessException | NoSuchMethodException ex) {
- throw new Error("Unexpected exception: ", ex);
+ } catch (InterruptedException | BrokenBarrierException
+ | IllegalAccessException | NoSuchMethodException ex) {
+ throw new Error("Unexpected exception", ex);
} finally {
end.countDown();
}
- }).start();
+ });
+ t.setUncaughtExceptionHandler(exHandler);
+ t.start();
}
try {
end.await();
+ boolean vmeThrown = false;
+ boolean nonVmeThrown = false;
+ Throwable vme = null;
+ for (Map.Entry entry : threadUncaughtExceptions.entrySet()) {
+ Thread t = entry.getKey();
+ Throwable e = entry.getValue();
+ System.err.printf("%nA thread with name \"%s\" of %d threads"
+ + " has thrown exception:%n", t.getName(), CORES);
+ e.printStackTrace();
+ if (CodeCacheOverflowProcessor.isThrowableCausedByVME(e)) {
+ vmeThrown = true;
+ vme = e;
+ } else {
+ nonVmeThrown = true;
+ }
+ if (nonVmeThrown) {
+ throw new Error("One ore more threads have"
+ + " thrown unexpected exceptions. See log.");
+ }
+ if (vmeThrown) {
+ throw new Error("One ore more threads have"
+ + " thrown VirtualMachineError caused by"
+ + " code cache overflow. See log.", vme);
+ }
+ }
} catch (InterruptedException ex) {
throw new Error("Unexpected exception: ", ex);
}
diff --git a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
index 6a44e44d8b6..3a97456e1a4 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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,6 +24,7 @@
/*
* @test LFSingleThreadCachingTest
* @bug 8046703
+ * @key randomness
* @summary Test verifies that lambda forms are cached when run with single thread
* @author kshefov
* @library /lib/testlibrary/jsr292 /lib/testlibrary
@@ -62,7 +63,7 @@ public final class LFSingleThreadCachingTest extends LFCachingTestCase {
adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);
} catch (NoSuchMethodException | IllegalAccessException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
checkLFCaching(adapter1, adapter2);
}
diff --git a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
index f3fb33bd9f3..f945883807a 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -22,7 +22,7 @@
*/
import com.oracle.testlibrary.jsr292.Helper;
-import com.sun.management.HotSpotDiagnosticMXBean;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import java.lang.invoke.MethodHandle;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
@@ -44,8 +44,6 @@ import jdk.testlibrary.TimeLimitedRunner;
*/
public abstract class LambdaFormTestCase {
- private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
- = 45 / (128.0 * 1024 * 1024);
private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
/**
@@ -72,7 +70,7 @@ public abstract class LambdaFormTestCase {
REF_FIELD = Reference.class.getDeclaredField("referent");
REF_FIELD.setAccessible(true);
} catch (Exception ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
gcInfo = ManagementFactory.getGarbageCollectorMXBeans();
@@ -101,28 +99,6 @@ public abstract class LambdaFormTestCase {
long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
iterations, iterations * testCaseNum);
- HotSpotDiagnosticMXBean hsDiagBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
- long codeCacheSize = Long.parseLong(
- hsDiagBean.getVMOption("ReservedCodeCacheSize").getValue());
- System.out.printf("Code cache size is %d bytes%n", codeCacheSize);
- long iterationsByCodeCacheSize = (long) (codeCacheSize
- * ITERATIONS_TO_CODE_CACHE_SIZE_RATIO);
- long nonProfiledCodeCacheSize = Long.parseLong(
- hsDiagBean.getVMOption("NonProfiledCodeHeapSize").getValue());
- System.out.printf("Non-profiled code cache size is %d bytes%n", nonProfiledCodeCacheSize);
- long iterationsByNonProfiledCodeCacheSize = (long) (nonProfiledCodeCacheSize
- * ITERATIONS_TO_CODE_CACHE_SIZE_RATIO);
- System.out.printf("Number of iterations limited by code cache size is %d (%d cases)%n",
- iterationsByCodeCacheSize, iterationsByCodeCacheSize * testCaseNum);
- System.out.printf("Number of iterations limited by non-profiled code cache size is %d (%d cases)%n",
- iterationsByNonProfiledCodeCacheSize, iterationsByNonProfiledCodeCacheSize * testCaseNum);
- iterations = Math.min(iterationsByCodeCacheSize,
- Math.min(iterations, iterationsByNonProfiledCodeCacheSize));
- if (iterations == 0) {
- System.out.println("Warning: code cache size is too small to provide at"
- + " least one iteration! Test will try to do one iteration.");
- iterations = 1;
- }
System.out.printf("Number of iterations is set to %d (%d cases)%n",
iterations, iterations * testCaseNum);
System.out.flush();
@@ -141,22 +117,27 @@ public abstract class LambdaFormTestCase {
for (TestMethods testMethod : testMethods) {
LambdaFormTestCase testCase = ctor.apply(testMethod);
try {
- System.err.printf("Tested LF caching feature with MethodHandles.%s method.%n",
+ System.err.printf("Tested LF caching feature"
+ + " with MethodHandles.%s method.%n",
testCase.getTestMethod().name);
- testCase.doTest();
+ Throwable t = CodeCacheOverflowProcessor
+ .runMHTest(testCase::doTest);
+ if (t != null) {
+ return false;
+ }
System.err.println("PASSED");
- } catch (OutOfMemoryError e) {
+ } catch (OutOfMemoryError oome) {
// Don't swallow OOME so a heap dump can be created.
System.err.println("FAILED");
- throw e;
+ throw oome;
} catch (Throwable t) {
t.printStackTrace();
System.err.printf("FAILED. Caused by %s%n", t.getMessage());
passed = false;
failCounter++;
}
- testCounter++;
- }
+ testCounter++;
+ }
doneIterations++;
return true;
}
@@ -205,8 +186,8 @@ public abstract class LambdaFormTestCase {
* @param testMethods list of test methods
*/
public static void runTests(Function ctor, Collection testMethods) {
- LambdaFormTestCase.TestRun run =
- new LambdaFormTestCase.TestRun(ctor, testMethods);
+ LambdaFormTestCase.TestRun run
+ = new LambdaFormTestCase.TestRun(ctor, testMethods);
TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
try {
runner.call();
diff --git a/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java b/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
index 45284277fcb..dab58a40d94 100644
--- a/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
+++ b/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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,7 @@
package test.java.lang.invoke.MethodHandles;
import com.oracle.testlibrary.jsr292.Helper;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import jdk.testlibrary.Asserts;
import jdk.testlibrary.TimeLimitedRunner;
import jdk.testlibrary.Utils;
@@ -35,7 +36,6 @@ import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
-import java.util.concurrent.TimeUnit;
/* @test
* @library /lib/testlibrary/jsr292 /lib/testlibrary/
@@ -91,6 +91,10 @@ public class CatchExceptionTest {
}
public static void main(String[] args) throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(CatchExceptionTest::test);
+ }
+
+ public static void test() throws Throwable {
System.out.println("classes = " + ARGS_CLASSES);
TestFactory factory = new TestFactory();
@@ -116,7 +120,6 @@ public class CatchExceptionTest {
return Helper.getParams(ARGS_CLASSES, isVararg, argsCount);
}
-
private List> getCatcherParams() {
int catchArgc = 1 + this.argsCount - dropped;
List> result = new ArrayList<>(
diff --git a/jdk/test/java/lang/invoke/MethodHandlesTest.java b/jdk/test/java/lang/invoke/MethodHandlesTest.java
index 993eaefef0f..48aad9112eb 100644
--- a/jdk/test/java/lang/invoke/MethodHandlesTest.java
+++ b/jdk/test/java/lang/invoke/MethodHandlesTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, 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,7 @@
/* @test
* @summary unit tests for java.lang.invoke.MethodHandles
+ * @library /lib/testlibrary /lib/testlibrary/jsr292
* @compile MethodHandlesTest.java remote/RemoteExample.java
* @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest
*/
@@ -36,6 +37,7 @@ import java.lang.reflect.*;
import java.util.*;
import org.junit.*;
import static org.junit.Assert.*;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/**
@@ -499,6 +501,10 @@ public class MethodHandlesTest {
@Test
public void testFindStatic() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindStatic0);
+ }
+
+ public void testFindStatic0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findStatic");
testFindStatic(PubExample.class, void.class, "s0");
@@ -586,6 +592,10 @@ public class MethodHandlesTest {
@Test
public void testFindVirtual() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindVirtual0);
+ }
+
+ public void testFindVirtual0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findVirtual");
testFindVirtual(Example.class, void.class, "v0");
@@ -616,6 +626,10 @@ public class MethodHandlesTest {
@Test
public void testFindVirtualClone() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindVirtualClone0);
+ }
+
+ public void testFindVirtualClone0() throws Throwable {
// test some ad hoc system methods
testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone");
testFindVirtual(true, PUBLIC, Object[].class, Object.class, "clone");
@@ -699,6 +713,10 @@ public class MethodHandlesTest {
@Test
public void testFindSpecial() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindSpecial0);
+ }
+
+ public void testFindSpecial0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findSpecial");
testFindSpecial(SubExample.class, Example.class, void.class, "v0");
@@ -775,6 +793,10 @@ public class MethodHandlesTest {
@Test
public void testFindConstructor() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindConstructor0);
+ }
+
+ public void testFindConstructor0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findConstructor");
testFindConstructor(true, EXAMPLE, Example.class);
@@ -818,6 +840,10 @@ public class MethodHandlesTest {
@Test
public void testBind() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testBind0);
+ }
+
+ public void testBind0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("bind");
testBind(Example.class, void.class, "v0");
@@ -879,6 +905,10 @@ public class MethodHandlesTest {
@Test
public void testUnreflect() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflect0);
+ }
+
+ public void testUnreflect0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflect");
testUnreflect(Example.class, true, void.class, "s0");
@@ -985,6 +1015,10 @@ public class MethodHandlesTest {
@Test
public void testUnreflectSpecial() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSpecial0);
+ }
+
+ public void testUnreflectSpecial0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflectSpecial");
testUnreflectSpecial(Example.class, Example.class, void.class, "v0");
@@ -1077,23 +1111,38 @@ public class MethodHandlesTest {
@Test
public void testUnreflectGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflectGetter0);
+ }
+
+ public void testUnreflectGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflectGetter");
testGetter(TEST_UNREFLECT);
}
+
@Test
public void testFindGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindGetter0);
+ }
+
+ public void testFindGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findGetter");
testGetter(TEST_FIND_FIELD);
testGetter(TEST_FIND_FIELD | TEST_BOUND);
}
+
@Test
public void testFindStaticGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindStaticGetter0);
+ }
+
+ public void testFindStaticGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findStaticGetter");
testGetter(TEST_FIND_STATIC);
}
+
public void testGetter(int testMode) throws Throwable {
Lookup lookup = PRIVATE; // FIXME: test more lookups than this one
for (Object[] c : HasFields.CASES) {
@@ -1287,26 +1336,40 @@ public class MethodHandlesTest {
}
}
-
@Test
public void testUnreflectSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSetter0);
+ }
+
+ public void testUnreflectSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflectSetter");
testSetter(TEST_UNREFLECT);
}
+
@Test
public void testFindSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindSetter0);
+ }
+
+ public void testFindSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findSetter");
testSetter(TEST_FIND_FIELD);
testSetter(TEST_FIND_FIELD | TEST_BOUND);
}
+
@Test
public void testFindStaticSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindStaticSetter0);
+ }
+
+ public void testFindStaticSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findStaticSetter");
testSetter(TEST_FIND_STATIC);
}
+
public void testSetter(int testMode) throws Throwable {
Lookup lookup = PRIVATE; // FIXME: test more lookups than this one
startTest("unreflectSetter");
@@ -1329,6 +1392,10 @@ public class MethodHandlesTest {
@Test
public void testArrayElementGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testArrayElementGetter0);
+ }
+
+ public void testArrayElementGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("arrayElementGetter");
testArrayElementGetterSetter(false);
@@ -1336,6 +1403,10 @@ public class MethodHandlesTest {
@Test
public void testArrayElementSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testArrayElementSetter0);
+ }
+
+ public void testArrayElementSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("arrayElementSetter");
testArrayElementGetterSetter(true);
@@ -1349,6 +1420,10 @@ public class MethodHandlesTest {
@Test
public void testArrayElementErrors() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testArrayElementErrors0);
+ }
+
+ public void testArrayElementErrors0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("arrayElementErrors");
testArrayElementGetterSetter(false, TEST_ARRAY_NPE);
@@ -1528,6 +1603,10 @@ public class MethodHandlesTest {
@Test
public void testConvertArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testConvertArguments0);
+ }
+
+ public void testConvertArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("convertArguments");
testConvert(Callee.ofType(1), null, "id", int.class);
@@ -1591,6 +1670,10 @@ public class MethodHandlesTest {
@Test
public void testVarargsCollector() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testVarargsCollector0);
+ }
+
+ public void testVarargsCollector0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("varargsCollector");
MethodHandle vac0 = PRIVATE.findStatic(MethodHandlesTest.class, "called",
@@ -1605,8 +1688,12 @@ public class MethodHandlesTest {
}
}
- @Test // SLOW
+ @Test // SLOW
public void testPermuteArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testPermuteArguments0);
+ }
+
+ public void testPermuteArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("permuteArguments");
testPermuteArguments(4, Integer.class, 2, long.class, 6);
@@ -1744,8 +1831,12 @@ public class MethodHandlesTest {
}
- @Test // SLOW
+ @Test // SLOW
public void testSpreadArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testSpreadArguments0);
+ }
+
+ public void testSpreadArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("spreadArguments");
for (Class> argType : new Class>[]{Object.class, Integer.class, int.class}) {
@@ -1838,8 +1929,12 @@ public class MethodHandlesTest {
}
}
- @Test // SLOW
+ @Test // SLOW
public void testAsCollector() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testAsCollector0);
+ }
+
+ public void testAsCollector0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("asCollector");
for (Class> argType : new Class>[]{Object.class, Integer.class, int.class}) {
@@ -1880,8 +1975,12 @@ public class MethodHandlesTest {
assertArrayEquals(collectedArgs, returnValue);
}
- @Test // SLOW
+ @Test // SLOW
public void testInsertArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testInsertArguments0);
+ }
+
+ public void testInsertArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("insertArguments");
for (int nargs = 0; nargs < 50; nargs++) {
@@ -1923,6 +2022,10 @@ public class MethodHandlesTest {
@Test
public void testFilterReturnValue() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFilterReturnValue0);
+ }
+
+ public void testFilterReturnValue0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("filterReturnValue");
Class> classOfVCList = varargsList(1).invokeWithArguments(0).getClass();
@@ -1972,6 +2075,10 @@ public class MethodHandlesTest {
@Test
public void testFilterArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFilterArguments0);
+ }
+
+ public void testFilterArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("filterArguments");
for (int nargs = 1; nargs <= 6; nargs++) {
@@ -2004,6 +2111,10 @@ public class MethodHandlesTest {
@Test
public void testCollectArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testCollectArguments0);
+ }
+
+ public void testCollectArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("collectArguments");
testFoldOrCollectArguments(true);
@@ -2011,6 +2122,10 @@ public class MethodHandlesTest {
@Test
public void testFoldArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFoldArguments0);
+ }
+
+ public void testFoldArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("foldArguments");
testFoldOrCollectArguments(false);
@@ -2112,6 +2227,10 @@ public class MethodHandlesTest {
@Test
public void testDropArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testDropArguments0);
+ }
+
+ public void testDropArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("dropArguments");
for (int nargs = 0; nargs <= 4; nargs++) {
@@ -2143,6 +2262,10 @@ public class MethodHandlesTest {
@Test // SLOW
public void testInvokers() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testInvokers0);
+ }
+
+ public void testInvokers0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker");
// exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker
@@ -2344,6 +2467,10 @@ public class MethodHandlesTest {
@Test
public void testGuardWithTest() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testGuardWithTest0);
+ }
+
+ public void testGuardWithTest0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("guardWithTest");
for (int nargs = 0; nargs <= 50; nargs++) {
@@ -2415,6 +2542,10 @@ public class MethodHandlesTest {
@Test
public void testThrowException() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testThrowException0);
+ }
+
+ public void testThrowException0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("throwException");
testThrowException(int.class, new ClassCastException("testing"));
@@ -2446,6 +2577,10 @@ public class MethodHandlesTest {
@Test
public void testInterfaceCast() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testInterfaceCast0);
+ }
+
+ public void testInterfaceCast0() throws Throwable {
//if (CAN_SKIP_WORKING) return;
startTest("interfaceCast");
assert( (((Object)"foo") instanceof CharSequence));
@@ -2543,6 +2678,10 @@ public class MethodHandlesTest {
@Test // SLOW
public void testCastFailure() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testCastFailure0);
+ }
+
+ public void testCastFailure0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("testCastFailure");
testCastFailure("cast/argument", 11000);
@@ -2655,6 +2794,10 @@ public class MethodHandlesTest {
@Test
public void testUserClassInSignature() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUserClassInSignature0);
+ }
+
+ public void testUserClassInSignature0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("testUserClassInSignature");
Lookup lookup = MethodHandles.lookup();
@@ -2706,6 +2849,10 @@ public class MethodHandlesTest {
@Test
public void testAsInterfaceInstance() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testAsInterfaceInstance0);
+ }
+
+ public void testAsInterfaceInstance0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("asInterfaceInstance");
Lookup lookup = MethodHandles.lookup();
@@ -2869,6 +3016,10 @@ public class MethodHandlesTest {
@Test
public void testRunnableProxy() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testRunnableProxy0);
+ }
+
+ public void testRunnableProxy0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("testRunnableProxy");
MethodHandles.Lookup lookup = MethodHandles.lookup();
diff --git a/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java b/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java
index d5d6c102b42..160c04a65d2 100644
--- a/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java
+++ b/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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,9 +24,12 @@
/*
* @test
* @bug 8019184
+ * @library /lib/testlibrary /lib/testlibrary/jsr292
* @summary MethodHandles.catchException() fails when methods have 8 args + varargs
+ * @run main TestCatchExceptionWithVarargs
*/
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import java.util.*;
import java.lang.invoke.*;
@@ -68,6 +71,11 @@ public class TestCatchExceptionWithVarargs {
}
public static void main(String[] args) throws Throwable {
+ CodeCacheOverflowProcessor
+ .runMHTest(TestCatchExceptionWithVarargs::test);
+ }
+
+ public static void test() throws Throwable {
List> ptypes = new LinkedList<>();
ptypes.add(Object[].class);
diff --git a/jdk/test/java/lang/invoke/VarargsArrayTest.java b/jdk/test/java/lang/invoke/VarargsArrayTest.java
index 91bf36485f2..a247fa5b434 100644
--- a/jdk/test/java/lang/invoke/VarargsArrayTest.java
+++ b/jdk/test/java/lang/invoke/VarargsArrayTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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,14 +24,14 @@
package java.lang.invoke;
import sun.invoke.util.Wrapper;
-
import java.util.Arrays;
import java.util.Collections;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/* @test
* @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int),
* MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int)
- *
+ * @library /lib/testlibrary /lib/testlibrary/jsr292
* @run main/bootclasspath java.lang.invoke.VarargsArrayTest
* @run main/bootclasspath -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250
* java.lang.invoke.VarargsArrayTest
@@ -47,6 +47,10 @@ public class VarargsArrayTest {
private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE");
public static void main(String[] args) throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test);
+ }
+
+ public static void test() throws Throwable {
testVarargsArray();
testVarargsReferenceArray();
testVarargsPrimitiveArray();
diff --git a/jdk/test/java/nio/channels/DatagramChannel/EmptyBuffer.java b/jdk/test/java/nio/channels/DatagramChannel/EmptyBuffer.java
index ea47112303a..36cbd4160bc 100644
--- a/jdk/test/java/nio/channels/DatagramChannel/EmptyBuffer.java
+++ b/jdk/test/java/nio/channels/DatagramChannel/EmptyBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, 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,39 +27,50 @@
* @author Mike McCloskey
*/
-import java.io.*;
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.nio.charset.*;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.ClosedByInterruptException;
+import java.nio.channels.DatagramChannel;
public class EmptyBuffer {
- static PrintStream log = System.err;
+ private static final PrintStream log = System.err;
public static void main(String[] args) throws Exception {
test();
}
- static void test() throws Exception {
- Server server = new Server();
+ private static void test() throws Exception {
+ DatagramChannel dc = DatagramChannel.open();
+ InetAddress localHost = InetAddress.getLocalHost();
+ dc.bind(new InetSocketAddress(localHost, 0));
+
+ Server server = new Server(dc.getLocalAddress());
Thread serverThread = new Thread(server);
serverThread.start();
- DatagramChannel dc = DatagramChannel.open();
+
try {
+ InetSocketAddress isa = new InetSocketAddress(localHost, server.port());
+ dc.connect(isa);
+
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.order(ByteOrder.BIG_ENDIAN);
bb.putInt(1).putLong(1);
bb.flip();
- InetAddress address = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(address, server.port());
- dc.connect(isa);
+
dc.write(bb);
bb.rewind();
dc.write(bb);
bb.rewind();
dc.write(bb);
+
Thread.sleep(2000);
+
serverThread.interrupt();
server.throwException();
} finally {
@@ -67,12 +78,14 @@ public class EmptyBuffer {
}
}
- public static class Server implements Runnable {
- final DatagramChannel dc;
- Exception e = null;
+ private static class Server implements Runnable {
+ private final DatagramChannel dc;
+ private final SocketAddress clientAddress;
+ private Exception e = null;
- Server() throws IOException {
+ Server(SocketAddress clientAddress) throws IOException {
this.dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ this.clientAddress = clientAddress;
}
int port() {
@@ -94,30 +107,37 @@ public class EmptyBuffer {
log.println();
}
+ @Override
public void run() {
- SocketAddress sa = null;
- int numberReceived = 0;
try {
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.clear();
// Only one clear. The buffer will be full after
// the first receive, but it should still block
// and receive and discard the next two
+ int numberReceived = 0;
while (!Thread.interrupted()) {
+ SocketAddress sa;
try {
sa = dc.receive(bb);
} catch (ClosedByInterruptException cbie) {
// Expected
log.println("Took expected exit");
+ // Verify that enough packets were received
+ if (numberReceived != 3)
+ throw new RuntimeException("Failed: Too few datagrams");
break;
}
if (sa != null) {
log.println("Client: " + sa);
- showBuffer("RECV", bb);
- sa = null;
- numberReceived++;
+ // Check client address so as not to count stray packets
+ if (sa.equals(clientAddress)) {
+ showBuffer("RECV", bb);
+ numberReceived++;
+ }
if (numberReceived > 3)
- throw new RuntimeException("Test failed");
+ throw new RuntimeException("Failed: Too many datagrams");
+ sa = null;
}
}
} catch (Exception ex) {
@@ -127,5 +147,4 @@ public class EmptyBuffer {
}
}
}
-
}
diff --git a/jdk/test/java/nio/file/Files/CopyAndMove.java b/jdk/test/java/nio/file/Files/CopyAndMove.java
index 38470cc810b..80f35b88960 100644
--- a/jdk/test/java/nio/file/Files/CopyAndMove.java
+++ b/jdk/test/java/nio/file/Files/CopyAndMove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, 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 @@
/* @test
* @bug 4313887 6838333 6917021 7006126 6950237 8006645
- * @summary Unit test for java.nio.file.Files copy and move methods
- * @library ..
- * @build CopyAndMove PassThroughFileSystem
+ * @summary Unit test for java.nio.file.Files copy and move methods (use -Dseed=X to set PRNG seed)
+ * @library .. /lib/testlibrary/
+ * @build jdk.testlibrary.* CopyAndMove PassThroughFileSystem
* @run main/othervm CopyAndMove
* @key randomness
*/
@@ -39,9 +39,10 @@ import java.nio.file.attribute.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
+import jdk.testlibrary.RandomFactory;
public class CopyAndMove {
- static final Random rand = new Random();
+ static final Random rand = RandomFactory.getRandom();
static boolean heads() { return rand.nextBoolean(); }
private static boolean testPosixAttributes = false;
diff --git a/jdk/test/java/util/prefs/CodePointZeroPrefsTest.java b/jdk/test/java/util/prefs/CodePointZeroPrefsTest.java
index 79fe3f3fb87..661039092c5 100644
--- a/jdk/test/java/util/prefs/CodePointZeroPrefsTest.java
+++ b/jdk/test/java/util/prefs/CodePointZeroPrefsTest.java
@@ -28,6 +28,7 @@ import java.util.prefs.PreferencesFactory;
* @test
* @bug 8068373 8075110 8075156
* @summary Ensure a code point U+0000 null control character is detected.
+ * @run main/othervm -Djava.util.prefs.userRoot=. CodePointZeroPrefsTest
*/
public class CodePointZeroPrefsTest
{
diff --git a/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java
new file mode 100644
index 00000000000..09f7f010b96
--- /dev/null
+++ b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, 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 com.sun.security.auth.NTUserPrincipal;
+import com.sun.security.auth.UnixPrincipal;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import javax.security.auth.Subject;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8050409
+ * @summary Tests with Subject.getPrivateCredentials to check permission checks with one or more principals.
+ * @run testng/othervm/policy=MoreThenOnePrincipals.policy MoreThenOnePrincipals
+ */
+public class MoreThenOnePrincipals {
+ private static final String[] CRED_VALUES =
+ new String[]{"testPrivateCredential-1", "testPrivateCredentials-2"};
+ private static final HashSet CREDS = new HashSet<>(Arrays.asList(CRED_VALUES));
+
+ /**
+ * Policy file grants access to the private Credential,belonging to a
+ * Subject with at least two associated Principals:"com.sun.security.auth
+ * .NTUserPrincipal", with the name,"NTUserPrincipal-1", and
+ * "com.sun.security.auth.UnixPrincipal", with the name, "UnixPrincipals-1".
+ *
+ * For test1 and test2, subjects are associated with none or only one of
+ * principals mentioned above, SecurityException is expected.
+ * For test 3 and test 4, subjects are associated with two or more
+ * Principals (above principals are included), no exception is expected.
+ *
+ */
+
+ @Test(dataProvider = "Provider1", expectedExceptions = SecurityException.class)
+ public void test1(Subject s) {
+ s.getPrivateCredentials(String.class);
+ }
+
+ @Test(dataProvider = "Provider1", expectedExceptions = SecurityException.class)
+ public void test2(Subject s) {
+ s.getPrivateCredentials().iterator().next();
+ }
+
+ @Test(dataProvider = "Provider2")
+ public void test3(Subject s) {
+ s.getPrivateCredentials(String.class);
+ }
+
+ @Test(dataProvider = "Provider2")
+ public void test4(Subject s) {
+ s.getPrivateCredentials().iterator().next();
+ }
+
+ @DataProvider
+ public Object[][] Provider1() {
+ Subject s1 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s1.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-2"));
+ Subject s2 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s2.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
+ return new Object[][]{{s1}, {s2}};
+ }
+
+ @DataProvider
+ public Object[][] Provider2() {
+ Subject s3 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s3.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
+ s3.getPrincipals().add(new UnixPrincipal("UnixPrincipals-1"));
+ Subject s4 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s4.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
+ s4.getPrincipals().add(new UnixPrincipal("UnixPrincipals-1"));
+ s4.getPrincipals().add(new UnixPrincipal("UnixPrincipals-2"));
+ return new Object[][]{{s3}, {s4}};
+ }
+
+}
diff --git a/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.policy b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.policy
new file mode 100644
index 00000000000..875690041e9
--- /dev/null
+++ b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.policy
@@ -0,0 +1,10 @@
+grant{
+// permissions for TestNG execution
+permission java.io.FilePermission "*","read,write";
+permission java.lang.RuntimePermission "accessDeclaredMembers";
+permission java.util.PropertyPermission "*","read";
+permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+// permissions for test itself
+permission javax.security.auth.AuthPermission "modifyPrincipals";
+permission javax.security.auth.PrivateCredentialPermission "* com.sun.security.auth.NTUserPrincipal \"NTUserPrincipal-1\" com.sun.security.auth.UnixPrincipal \"UnixPrincipals-1\"", "read";
+};
diff --git a/jdk/test/lib/security/CheckBlacklistedCerts.java b/jdk/test/lib/security/CheckBlacklistedCerts.java
index a281a0460d8..bd1cf890275 100644
--- a/jdk/test/lib/security/CheckBlacklistedCerts.java
+++ b/jdk/test/lib/security/CheckBlacklistedCerts.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -69,7 +69,9 @@ public class CheckBlacklistedCerts {
};
// Is this an OPENJDK build?
- if (!new File(home, "lib/security/local_policy.jar").exists()) {
+ String prop = System.getProperty("java.runtime.name");
+ if (prop != null && prop.startsWith("OpenJDK")) {
+ System.out.println("This is a OpenJDK build.");
blacklists = Arrays.copyOf(blacklists, 1);
}
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java
index 85081f42719..ab570fea544 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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,9 +25,6 @@ package jdk.testlibrary;
import static jdk.testlibrary.Asserts.assertTrue;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
@@ -40,6 +37,7 @@ import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;
+import java.util.function.Function;
/**
* Common library for various test helper functions.
@@ -326,4 +324,38 @@ public final class Utils {
}
return condition.getAsBoolean();
}
+
+ /**
+ * Interface same as java.lang.Runnable but with
+ * method {@code run()} able to throw any Throwable.
+ */
+ public static interface ThrowingRunnable {
+ void run() throws Throwable;
+ }
+
+ /**
+ * Filters out an exception that may be thrown by the given
+ * test according to the given filter.
+ *
+ * @param test - method that is invoked and checked for exception.
+ * @param filter - function that checks if the thrown exception matches
+ * criteria given in the filter's implementation.
+ * @return - exception that matches the filter if it has been thrown or
+ * {@code null} otherwise.
+ * @throws Throwable - if test has thrown an exception that does not
+ * match the filter.
+ */
+ public static Throwable filterException(ThrowingRunnable test,
+ Function filter) throws Throwable {
+ try {
+ test.run();
+ } catch (Throwable t) {
+ if (filter.apply(t)) {
+ return t;
+ } else {
+ throw t;
+ }
+ }
+ return null;
+ }
}
diff --git a/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java b/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java
new file mode 100644
index 00000000000..d5d6b1c34f3
--- /dev/null
+++ b/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, 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.testlibrary.jsr292;
+
+import jdk.testlibrary.Utils;
+
+/**
+ * Helper class used to catch and process VirtualMachineError with message "Out
+ * of space in CodeCache". Some JSR292 tests run out of code cache size, so code
+ * cache overflows and VME is thrown. This VME is considered as non-critical in
+ * some JSR292 tests, so it should be processed to prevent test failure.
+ */
+public class CodeCacheOverflowProcessor {
+
+ /**
+ * Checks if an instance of Throwable is caused by VirtualMachineError with
+ * message "Out of space in CodeCache". May be used as filter in method
+ * {@code jdk.testlibrary.Utils.filterException}.
+ *
+ * @param t - Throwable to check.
+ * @return true if Throwable is caused by VME, false otherwise.
+ */
+ public static Boolean isThrowableCausedByVME(Throwable t) {
+ Throwable causeOfT = t;
+ do {
+ if (causeOfT instanceof VirtualMachineError
+ && causeOfT.getMessage().matches(".*[Oo]ut of space"
+ + " in CodeCache.*")) {
+ return true;
+ }
+ causeOfT = causeOfT != null ? causeOfT.getCause() : null;
+ } while (causeOfT != null && causeOfT != t);
+ return false;
+ }
+
+ /**
+ * Checks if the given test throws an exception caused by
+ * VirtualMachineError with message "Out of space in CodeCache", and, if VME
+ * takes place, processes it so that no exception is thrown, and prints its
+ * stack trace. If test throws exception not caused by VME, this method just
+ * re-throws this exception.
+ *
+ * @param test - test to check for and process VirtualMachineError.
+ * @return - an exception caused by VME or null
+ * if test has thrown no exception.
+ * @throws Throwable - if test has thrown an exception
+ * that is not caused by VME.
+ */
+ public static Throwable runMHTest(Utils.ThrowingRunnable test) throws Throwable {
+ Throwable t = Utils.filterException(test::run,
+ CodeCacheOverflowProcessor::isThrowableCausedByVME);
+ if (t != null) {
+ System.err.printf("%nNon-critical exception caught becuse of"
+ + " code cache size is not enough to run all test cases.%n%n");
+ t.printStackTrace();
+ }
+ return t;
+ }
+}
diff --git a/langtools/.hgtags b/langtools/.hgtags
index c88b1a7021f..9f6f06f41c9 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -311,3 +311,4 @@ a28b7f42dae9bd59513beaa5a2d6eb563dc09e08 jdk9-b63
fd6bda430d96fc5ab421161de016412f2ddd9082 jdk9-b66
fd782cd69b0497299269952d30a6b88cad960fcf jdk9-b67
c71857c93f57c63be44258d3d67e656c2bacdb45 jdk9-b68
+931ec7dd6cd9e4a92bde7b2cd26e9a9fb0ecdb56 jdk9-b69
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
index 892410f9986..64ddd24e72c 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -4140,7 +4140,12 @@ public class Attr extends JCTree.Visitor {
public void visitAnnotatedType(JCAnnotatedType tree) {
attribAnnotationTypes(tree.annotations, env);
- Type underlyingType = attribType(tree.underlyingType, env);
+ JCExpression underlyingTypeTree = tree.getUnderlyingType();
+ Type underlyingType = attribTree(underlyingTypeTree, env,
+ new ResultInfo(KindSelector.TYP_PCK, Type.noType));
+ if (!chk.checkAnnotableType(underlyingType, tree.annotations, underlyingTypeTree.pos())) {
+ underlyingType = underlyingTypeTree.type = syms.errType;
+ }
Type annotatedType = underlyingType.annotatedType(Annotations.TO_BE_SET);
if (!env.info.isNewClass)
@@ -4631,16 +4636,7 @@ public class Attr extends JCTree.Visitor {
}
} else if (enclTr.hasTag(ANNOTATED_TYPE)) {
JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr;
- if (enclTy == null || enclTy.hasTag(NONE)) {
- if (at.getAnnotations().size() == 1) {
- log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
- } else {
- ListBuffer comps = new ListBuffer<>();
- for (JCAnnotation an : at.getAnnotations()) {
- comps.add(an.attribute);
- }
- log.error(at.underlyingType.pos(), "cant.type.annotate.scoping", comps.toList());
- }
+ if (!chk.checkAnnotableType(enclTy, at.getAnnotations(), at.underlyingType.pos())) {
repeat = false;
}
enclTr = at.underlyingType;
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
index afefb5b3c94..dcc55b4aa6b 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
@@ -62,6 +62,8 @@ import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
import static com.sun.tools.javac.code.TypeTag.*;
import static com.sun.tools.javac.code.TypeTag.WILDCARD;
+import static com.sun.tools.javac.resources.CompilerProperties.Errors.CantTypeAnnotateScoping;
+import static com.sun.tools.javac.resources.CompilerProperties.Errors.CantTypeAnnotateScoping1;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
/** Type checking helper class for the attribution phase.
@@ -2691,6 +2693,29 @@ public class Check {
* Check annotations
**************************************************************************/
+ /** Verify that a component of a qualified type name being type annotated
+ * can indeed be legally be annotated. For example, package names and type
+ * names used to access static members cannot be annotated.
+ *
+ * @param typeComponent the component of the qualified name being annotated
+ * @param annotations the annotations
+ * @param pos diagnostic position
+ * @return true if all is swell, false otherwise.
+ */
+ boolean checkAnnotableType(Type typeComponent, List annotations, DiagnosticPosition pos) {
+ if (typeComponent == null || typeComponent.hasTag(PACKAGE) || typeComponent.hasTag(NONE)) {
+ ListBuffer lb = new ListBuffer<>();
+ for (JCAnnotation annotation : annotations) {
+ lb.append(annotation.annotationType.type.tsym);
+ }
+ List symbols = lb.toList();
+ log.error(pos,
+ symbols.size() > 1 ? CantTypeAnnotateScoping(symbols)
+ : CantTypeAnnotateScoping1(symbols.get(0)));
+ return false;
+ }
+ return true;
+ }
/**
* Recursively validate annotations values
*/
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java
index 011a20d2eb6..e394d5ee277 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java
@@ -1,12 +1,12 @@
/*
* @test /nodynamiccopyright/
- * @bug 8026564
+ * @bug 8026564 8074346
* @summary The parts of a fully-qualified type can't be annotated.
* @author Werner Dietl
- * @ignore 8057679 clarify error messages trying to annotate scoping
* @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java
*/
+
import java.lang.annotation.*;
import java.util.List;
@@ -21,6 +21,8 @@ class CantAnnotatePackages {
java. @TA lang.Object of3;
List of4;
+ List<@CantAnnotatePackages_TB java.lang.Object> of5; // test that we do reasonable things for missing types.
+
// TODO: also note the order of error messages.
}
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out
index 600d699ebd4..6585a948dd3 100644
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out
@@ -1,5 +1,7 @@
-CantAnnotatePackages.java:14:13: compiler.err.cant.type.annotate.scoping.1: @TA
-CantAnnotatePackages.java:19:18: compiler.err.cant.type.annotate.scoping.1: @TA
-CantAnnotatePackages.java:20:19: compiler.err.cant.type.annotate.scoping.1: @TA
-CantAnnotatePackages.java:21:24: compiler.err.cant.type.annotate.scoping.1: @TA
-4 errors
+CantAnnotatePackages.java:20:14: compiler.err.cant.type.annotate.scoping.1: TA
+CantAnnotatePackages.java:21:9: compiler.err.cant.type.annotate.scoping.1: TA
+CantAnnotatePackages.java:22:14: compiler.err.cant.type.annotate.scoping.1: TA
+CantAnnotatePackages.java:24:11: compiler.err.cant.resolve.location: kindname.class, CantAnnotatePackages_TB, , , (compiler.misc.location: kindname.class, CantAnnotatePackages, null)
+CantAnnotatePackages.java:24:35: compiler.err.cant.type.annotate.scoping.1: CantAnnotatePackages_TB
+CantAnnotatePackages.java:15:18: compiler.err.cant.type.annotate.scoping.1: @TA
+6 errors
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.java b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.java
new file mode 100644
index 00000000000..347d84b4829
--- /dev/null
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8074346
+ * @author sadayapalam
+ * @summary Test that type annotation on a qualified type doesn't cause spurious 'cannot find symbol' errors
+ * @compile/fail/ref=T8074346.out -XDrawDiagnostics T8074346.java
+*/
+
+abstract class T8074346 implements
+ @T8074346_TA @T8074346_TB java.util.Map<@T8074346_TA java.lang.String, java.lang.@T8074346_TA String>,
+ java.util.@T8074346_TA List {
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
+@interface T8074346_TA { }
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
+@interface T8074346_TB { }
\ No newline at end of file
diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.out b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.out
new file mode 100644
index 00000000000..c32d75101c8
--- /dev/null
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.out
@@ -0,0 +1,3 @@
+T8074346.java:10:35: compiler.err.cant.type.annotate.scoping: T8074346_TA,T8074346_TB
+T8074346.java:10:62: compiler.err.cant.type.annotate.scoping.1: T8074346_TA
+2 errors
\ No newline at end of file
diff --git a/langtools/test/tools/javac/generics/typeargs/Metharg1.java b/langtools/test/tools/javac/generics/typeargs/Metharg1.java
index 1b09197132a..d3264126727 100644
--- a/langtools/test/tools/javac/generics/typeargs/Metharg1.java
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg1.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Metharg1.java
+ * @compile/fail/ref=Metharg1.out -XDrawDiagnostics Metharg1.java
*/
// Test type mismatch on type argument for method call
diff --git a/langtools/test/tools/javac/generics/typeargs/Metharg1.out b/langtools/test/tools/javac/generics/typeargs/Metharg1.out
new file mode 100644
index 00000000000..1bbc7b2d7cf
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg1.out
@@ -0,0 +1,2 @@
+Metharg1.java:33:13: compiler.err.cant.apply.symbol: kindname.method, f, K, java.lang.String, kindname.class, T, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
diff --git a/langtools/test/tools/javac/generics/typeargs/Metharg2.java b/langtools/test/tools/javac/generics/typeargs/Metharg2.java
index 2153f19202e..2f0d2c3f0e3 100644
--- a/langtools/test/tools/javac/generics/typeargs/Metharg2.java
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg2.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Metharg2.java
+ * @compile/fail/ref=Metharg2.out -XDrawDiagnostics Metharg2.java
*/
// Test type mismatch on type argument for qualified method call
diff --git a/langtools/test/tools/javac/generics/typeargs/Metharg2.out b/langtools/test/tools/javac/generics/typeargs/Metharg2.out
new file mode 100644
index 00000000000..0db888d8a4e
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg2.out
@@ -0,0 +1,2 @@
+Metharg2.java:39:10: compiler.err.cant.apply.symbol: kindname.method, f, K, java.lang.String, kindname.class, T, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
diff --git a/langtools/test/tools/javac/generics/typeargs/Newarg1.java b/langtools/test/tools/javac/generics/typeargs/Newarg1.java
index 82d531b70bd..42f84164965 100644
--- a/langtools/test/tools/javac/generics/typeargs/Newarg1.java
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg1.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Newarg1.java
+ * @compile/fail/ref=Newarg1.out -XDrawDiagnostics Newarg1.java
*/
// Test type mismatch on type argument for constructor
diff --git a/langtools/test/tools/javac/generics/typeargs/Newarg1.out b/langtools/test/tools/javac/generics/typeargs/Newarg1.out
new file mode 100644
index 00000000000..d099a74b5ba
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg1.out
@@ -0,0 +1,2 @@
+Newarg1.java:18:9: compiler.err.cant.apply.symbol: kindname.constructor, T, K, java.lang.String, kindname.class, T, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
diff --git a/langtools/test/tools/javac/generics/typeargs/Newarg2.java b/langtools/test/tools/javac/generics/typeargs/Newarg2.java
index 41d42ae719a..d23a794c8f6 100644
--- a/langtools/test/tools/javac/generics/typeargs/Newarg2.java
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg2.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Newarg2.java
+ * @compile/fail/ref=Newarg2.out -XDrawDiagnostics Newarg2.java
*/
// Test type mismatch on type argument for inner constructor
diff --git a/langtools/test/tools/javac/generics/typeargs/Newarg2.out b/langtools/test/tools/javac/generics/typeargs/Newarg2.out
new file mode 100644
index 00000000000..50dced2bdb4
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg2.out
@@ -0,0 +1,2 @@
+Newarg2.java:19:17: compiler.err.cant.apply.symbol: kindname.constructor, U, B, java.lang.String, kindname.class, T.U, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
diff --git a/langtools/test/tools/javac/generics/typeargs/Superarg1.java b/langtools/test/tools/javac/generics/typeargs/Superarg1.java
index 2b2e73b9c77..e1dae6a45df 100644
--- a/langtools/test/tools/javac/generics/typeargs/Superarg1.java
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg1.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Superarg1.java
+ * @compile/fail/ref=Superarg1.out -XDrawDiagnostics Superarg1.java
*/
// Test type mismatch on type argument for super constructor
diff --git a/langtools/test/tools/javac/generics/typeargs/Superarg1.out b/langtools/test/tools/javac/generics/typeargs/Superarg1.out
new file mode 100644
index 00000000000..0783d5e19ed
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg1.out
@@ -0,0 +1,2 @@
+Superarg1.java:16:13: compiler.err.cant.apply.symbol: kindname.constructor, T, A, java.lang.String, kindname.class, T, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
diff --git a/langtools/test/tools/javac/generics/typeargs/Superarg2.java b/langtools/test/tools/javac/generics/typeargs/Superarg2.java
index c24f783ef67..62476951031 100644
--- a/langtools/test/tools/javac/generics/typeargs/Superarg2.java
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg2.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Superarg2.java
+ * @compile/fail/ref=Superarg2.out -XDrawDiagnostics Superarg2.java
*/
// Test type mismatch on type argument for inner super constructor
diff --git a/langtools/test/tools/javac/generics/typeargs/Superarg2.out b/langtools/test/tools/javac/generics/typeargs/Superarg2.out
new file mode 100644
index 00000000000..8a89698c076
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg2.out
@@ -0,0 +1,2 @@
+Superarg2.java:25:14: compiler.err.cant.apply.symbols: kindname.constructor, U, java.lang.String,{(compiler.misc.inapplicable.method: kindname.constructor, T.U, T.U(B), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.constructor, T.U, T.U(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int)))}
+1 error
diff --git a/langtools/test/tools/javac/generics/typeargs/ThisArg.java b/langtools/test/tools/javac/generics/typeargs/ThisArg.java
index c1cf1266e56..c2cf7f43b22 100644
--- a/langtools/test/tools/javac/generics/typeargs/ThisArg.java
+++ b/langtools/test/tools/javac/generics/typeargs/ThisArg.java
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail ThisArg.java
+ * @compile/fail/ref=ThisArg.out -XDrawDiagnostics ThisArg.java
*/
// Test type mismatch on type argument for this constructor
diff --git a/langtools/test/tools/javac/generics/typeargs/ThisArg.out b/langtools/test/tools/javac/generics/typeargs/ThisArg.out
new file mode 100644
index 00000000000..6bcf9d8add1
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typeargs/ThisArg.out
@@ -0,0 +1,2 @@
+ThisArg.java:19:13: compiler.err.cant.apply.symbols: kindname.constructor, U, java.lang.String,{(compiler.misc.inapplicable.method: kindname.constructor, T.U, T.U(B), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.constructor, T.U, T.U(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int)))}
+1 error
diff --git a/langtools/test/tools/javac/generics/typevars/4856983/T4856983.java b/langtools/test/tools/javac/generics/typevars/4856983/T4856983.java
index 222dd9340c0..c90a2aacf5a 100644
--- a/langtools/test/tools/javac/generics/typevars/4856983/T4856983.java
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2015, 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/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.java b/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.java
index d0a1aefffe9..ff722efe5c7 100644
--- a/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.java
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.java
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 2004, 2006, 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
+ * @test /nodynamiccopyright/
* @bug 4856983
* @summary (crash) mutually f-bounded type vars with multiple bounds may crash javac
* @author Peter von der Ah\u00e9
- * @compile/fail T4856983a.java
+ * @compile/fail/ref=T4856983a.out -XDrawDiagnostics T4856983a.java
*/
interface I1 { Number m(); }
diff --git a/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.out b/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.out
new file mode 100644
index 00000000000..f359892417f
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.out
@@ -0,0 +1,2 @@
+T4856983a.java:13:6: compiler.err.types.incompatible.diff.ret: I2, I1, m()
+1 error
diff --git a/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.java b/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.java
index a9040006699..ba013aeaf6d 100644
--- a/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.java
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.java
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 2004, 2006, 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
+ * @test /nodynamiccopyright/
* @bug 4856983
* @summary (crash) mutually f-bounded type vars with multiple bounds may crash javac
* @author Peter von der Ah\u00e9
- * @compile/fail T4856983b.java
+ * @compile/fail/ref=T4856983b.out -XDrawDiagnostics T4856983b.java
*/
interface I1 { Number m(); }
diff --git a/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.out b/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.out
new file mode 100644
index 00000000000..256af27c696
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.out
@@ -0,0 +1,2 @@
+T4856983b.java:12:24: compiler.err.types.incompatible.diff.ret: I2, I1, m()
+1 error
diff --git a/langtools/test/tools/javac/generics/typevars/6182630/T6182630.java b/langtools/test/tools/javac/generics/typevars/6182630/T6182630.java
index fadecfc0bd0..a7a9720467c 100644
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630.java
+++ b/langtools/test/tools/javac/generics/typevars/6182630/T6182630.java
@@ -1,39 +1,9 @@
/*
- * Copyright (c) 2004, 2006, 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
+ * @test /nodynamiccopyright/
* @bug 6182630
* @summary Method with parameter bound to raw type avoids unchecked warning
* @author Peter von der Ah\u00e9
- * @compile -Xlint:unchecked T6182630.java
- * @compile/fail -Werror -Xlint:unchecked T6182630.java
- * @compile/fail -Werror -Xlint:unchecked T6182630a.java
- * @compile/fail -Werror -Xlint:unchecked T6182630b.java
- * @compile/fail -Werror -Xlint:unchecked T6182630c.java
- * @compile/fail -Werror -Xlint:unchecked T6182630d.java
- * @compile/fail -Werror -Xlint:unchecked T6182630e.java
- * @compile/fail -Werror -Xlint:unchecked T6182630f.java
+ * @compile/ref=T6182630.out -XDrawDiagnostics -Xlint:unchecked T6182630.java
*/
public class T6182630 {
diff --git a/langtools/test/tools/javac/generics/typevars/6182630/T6182630.out b/langtools/test/tools/javac/generics/typevars/6182630/T6182630.out
new file mode 100644
index 00000000000..ba22d996eab
--- /dev/null
+++ b/langtools/test/tools/javac/generics/typevars/6182630/T6182630.out
@@ -0,0 +1,7 @@
+T6182630.java:16:10: compiler.warn.unchecked.assign.to.var: x, T6182630.Foo
+T6182630.java:17:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+T6182630.java:18:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+T6182630.java:19:10: compiler.warn.unchecked.assign.to.var: x, T6182630.Foo
+T6182630.java:20:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+T6182630.java:21:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+6 warnings
diff --git a/langtools/test/tools/javac/generics/typevars/6182630/T6182630e.java b/langtools/test/tools/javac/generics/typevars/6182630/T6182630e.java
deleted file mode 100644
index 72fa881b519..00000000000
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630e.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-public class T6182630e {
- static class Foo {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- void test1(T t, S s) {
- s.m("BAD");
- }
-}
diff --git a/langtools/test/tools/javac/generics/typevars/6182630/T6182630f.java b/langtools/test/tools/javac/generics/typevars/6182630/T6182630f.java
deleted file mode 100644
index ab39406d881..00000000000
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630f.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.
- */
-
-public class T6182630f {
- static class Foo {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- void test1(T t, S s) {
- s.m(s.x);
- }
-}
diff --git a/make/MacBundles.gmk b/make/MacBundles.gmk
index af017d05107..3593facd345 100644
--- a/make/MacBundles.gmk
+++ b/make/MacBundles.gmk
@@ -25,6 +25,7 @@
include $(SPEC)
include MakeBase.gmk
+include TextFileProcessing.gmk
default: bundles
diff --git a/make/common/CORE_PKGS.gmk b/make/common/CORE_PKGS.gmk
index fa1237b916d..581f10a4ba2 100644
--- a/make/common/CORE_PKGS.gmk
+++ b/make/common/CORE_PKGS.gmk
@@ -222,7 +222,6 @@ CORE_PKGS = \
javax.swing.plaf.nimbus \
javax.swing.plaf.synth \
javax.tools \
- javax.tools.annotation \
javax.transaction \
javax.transaction.xa \
javax.xml.parsers \
diff --git a/make/devkit/createMacosxDevkit.sh b/make/devkit/createMacosxDevkit.sh
new file mode 100644
index 00000000000..f9c0aedc4da
--- /dev/null
+++ b/make/devkit/createMacosxDevkit.sh
@@ -0,0 +1,147 @@
+#!/bin/bash
+#
+# Copyright (c) 2015, 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.
+#
+
+# This script copies part of an Xcode installer into a devkit suitable
+# for building OpenJDK and OracleJDK. The installation .dmg files for Xcode
+# and the aux tools need to be available.
+# erik.joelsson@oracle.com
+
+USAGE="$0 []"
+
+if [ "$1" = "" ] || [ "$2" = "" ]; then
+ echo $USAGE
+ exit 1
+fi
+
+XCODE_DMG="$1"
+XQUARTZ_DMG="$2"
+AUXTOOLS_DMG="$3"
+
+SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
+BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
+
+# Mount XCODE_DMG
+if [ -e "/Volumes/Xcode" ]; then
+ hdiutil detach /Volumes/Xcode
+fi
+hdiutil attach $XCODE_DMG
+
+# Find the version of Xcode
+XCODE_VERSION="$(/Volumes/Xcode/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version \
+ | awk '/Xcode/ { print $2 }' )"
+
+DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-devkit"
+DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
+
+echo "Xcode version: $XCODE_VERSION"
+echo "Creating devkit in $DEVKIT_ROOT"
+
+################################################################################
+# Copy files to root
+mkdir -p $DEVKIT_ROOT
+if [ ! -d $DEVKIT_ROOT/Xcode.app ]; then
+ echo "Copying Xcode.app..."
+ cp -RH "/Volumes/Xcode/Xcode.app" $DEVKIT_ROOT/
+fi
+# Trim out some seemingly unneeded parts to save space.
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Applications
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/iPhone*
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Documentation
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/share/man
+if [ -e $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk ]; then
+ rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
+ rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man
+fi
+
+hdiutil detach /Volumes/Xcode
+
+################################################################################
+# Copy Freetype into sysroot
+if [ -e "/Volumes/XQuartz-*" ]; then
+ hdiutil detach /Volumes/XQuartz-*
+fi
+hdiutil attach $XQUARTZ_DMG
+
+echo "Copying freetype..."
+rm -rf /tmp/XQuartz
+pkgutil --expand /Volumes/XQuartz-*/XQuartz.pkg /tmp/XQuartz/
+rm -rf /tmp/x11
+mkdir /tmp/x11
+cd /tmp/x11
+cat /tmp/XQuartz-*/x11.pkg/Payload | gunzip -dc |cpio -i
+
+cp -RH opt/X11/include/freetype2 \
+ $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
+cp -RH opt/X11/include/ft2build.h \
+ $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
+cp -RH opt/X11/lib/libfreetype.* \
+ $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/
+
+cd -
+
+hdiutil detach /Volumes/XQuartz-*
+
+################################################################################
+# Optionally copy PackageMaker
+
+if [ -e "$AUXTOOLS_DMG" ]; then
+ if [ -e "/Volumes/Auxiliary Tools" ]; then
+ hdiutil detach "/Volumes/Auxiliary Tools"
+ fi
+ hdiutil attach $AUXTOOLS_DMG
+
+ echo "Copying PackageMaker.app..."
+ cp -RH "/Volumes/Auxiliary Tools/PackageMaker.app" $DEVKIT_ROOT/
+
+ hdiutil detach "/Volumes/Auxiliary Tools"
+fi
+
+################################################################################
+# Generate devkit.info
+
+echo-info() {
+ echo "$1" >> $DEVKIT_ROOT/devkit.info
+}
+
+echo "Generating devkit.info..."
+rm -f $DEVKIT_ROOT/devkit.info
+echo-info "# This file describes to configure how to interpret the contents of this devkit"
+echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
+echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
+echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk\""
+echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/PackageMaker.app/Contents/MacOS:\$DEVKIT_TOOLCHAIN_PATH\""
+
+################################################################################
+# Copy this script
+
+echo "Copying this script..."
+cp $0 $DEVKIT_ROOT/
+
+################################################################################
+# Create bundle
+
+echo "Creating bundle..."
+(cd $DEVKIT_ROOT && tar c - . | gzip - > "$DEVKIT_BUNDLE")
diff --git a/make/devkit/createWindowsDevkit.sh b/make/devkit/createWindowsDevkit.sh
new file mode 100644
index 00000000000..ed8e5022a31
--- /dev/null
+++ b/make/devkit/createWindowsDevkit.sh
@@ -0,0 +1,131 @@
+#!/bin/bash
+#
+# Copyright (c) 2015, 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.
+#
+
+# This script copies parts of a Visual Studio 2013 installation into a devkit
+# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin.
+# erik.joelsson@oracle.com
+
+VS_VERSION="2013"
+VS_VERSION_NUM="12.0"
+VS_VERSION_NUM_NODOT="120"
+SDK_VERSION="8.1"
+
+SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
+BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
+DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}-devkit"
+DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
+
+echo "Creating devkit in $DEVKIT_ROOT"
+
+MSVCR_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcr${VS_VERSION_NUM_NODOT}.dll
+MSVCP_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcp${VS_VERSION_NUM_NODOT}.dll
+
+################################################################################
+# Copy Visual Studio files
+
+eval VSNNNCOMNTOOLS="\"\${VS${VS_VERSION_NUM_NODOT}COMNTOOLS}\""
+VS_INSTALL_DIR="$(cygpath "$VSNNNCOMNTOOLS/../..")"
+echo "VS_INSTALL_DIR: $VS_INSTALL_DIR"
+
+if [ ! -d $DEVKIT_ROOT/VC ]; then
+ echo "Copying VC..."
+ mkdir -p $DEVKIT_ROOT/VC/bin
+ cp -r "$VS_INSTALL_DIR/VC/bin/amd64" $DEVKIT_ROOT/VC/bin/
+ cp "$VS_INSTALL_DIR/VC/bin/"*.* $DEVKIT_ROOT/VC/bin/
+ cp -r "$VS_INSTALL_DIR/VC/bin/1033/" $DEVKIT_ROOT/VC/bin/
+ mkdir -p $DEVKIT_ROOT/VC/lib
+ cp -r "$VS_INSTALL_DIR/VC/lib/amd64" $DEVKIT_ROOT/VC/lib/
+ cp "$VS_INSTALL_DIR/VC/lib/"*.* $DEVKIT_ROOT/VC/lib/
+ cp -r "$VS_INSTALL_DIR/VC/include" $DEVKIT_ROOT/VC/
+ mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib
+ cp -r "$VS_INSTALL_DIR/VC/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/
+ cp -r "$VS_INSTALL_DIR/VC/atlmfc/lib/amd64" $DEVKIT_ROOT/VC/atlmfc/lib/
+ cp "$VS_INSTALL_DIR/VC/atlmfc/lib/"*.* $DEVKIT_ROOT/VC/atlmfc/lib/
+ mkdir -p $DEVKIT_ROOT/VC/redist
+ cp -r "$VS_INSTALL_DIR/VC/redist/x64" $DEVKIT_ROOT/VC/redist/
+ cp -r "$VS_INSTALL_DIR/VC/redist/x86" $DEVKIT_ROOT/VC/redist/
+ # The redist runtime libs are needed to run the compiler but may not be
+ # installed on the machine where the devkit will be used.
+ cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/
+ cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/
+ cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/amd64/
+ cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/amd64/
+fi
+
+################################################################################
+# Copy SDK files
+
+PROGRAMFILES_X86="`env | sed -n 's/^ProgramFiles(x86)=//p'`"
+SDK_INSTALL_DIR="$(cygpath "$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION")"
+echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR"
+
+if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then
+ echo "Copying SDK..."
+ mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin
+ cp -r "$SDK_INSTALL_DIR/bin/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/
+ cp -r "$SDK_INSTALL_DIR/bin/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/
+ mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib
+ cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x64 $DEVKIT_ROOT/$SDK_VERSION/lib/
+ cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x86 $DEVKIT_ROOT/$SDK_VERSION/lib/
+ cp -r "$SDK_INSTALL_DIR/include" $DEVKIT_ROOT/$SDK_VERSION/
+fi
+
+################################################################################
+# Generate devkit.info
+
+echo-info() {
+ echo "$1" >> $DEVKIT_ROOT/devkit.info
+}
+
+echo "Generating devkit.info..."
+rm -f $DEVKIT_ROOT/devkit.info
+echo-info "# This file describes to configure how to interpret the contents of this devkit"
+echo-info "DEVKIT_NAME=\"Microsoft Visual Studio $VS_VERSION (devkit)\""
+echo-info "DEVKIT_VS_VERSION=\"$VS_VERSION\""
+echo-info ""
+echo-info "DEVKIT_TOOLCHAIN_PATH_x86=\"\$DEVKIT_ROOT/VC/bin:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\""
+echo-info "DEVKIT_VS_INCLUDE_x86=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\""
+echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib;\$DEVKIT_ROOT/VC/atlmfc/lib;\$DEVKIT_ROOT/$SDK_VERSION/lib/x86\""
+echo-info "DEVKIT_MSVCR_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL\""
+echo-info "DEVKIT_MSVCP_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL\""
+echo-info ""
+echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/amd64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\""
+echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\""
+echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/amd64;\$DEVKIT_ROOT/VC/atlmfc/lib/amd64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64\""
+echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\""
+echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\""
+
+################################################################################
+# Copy this script
+
+echo "Copying this script..."
+cp $0 $DEVKIT_ROOT/
+
+################################################################################
+# Create bundle
+
+echo "Creating bundle: $DEVKIT_BUNDLE"
+(cd "$DEVKIT_ROOT" && tar zcf "$DEVKIT_BUNDLE" .)
diff --git a/nashorn/.hgtags b/nashorn/.hgtags
index e115ad742ac..851d7e66d4a 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -302,3 +302,4 @@ bc8e67bec2f92772c4a67e20e66a4f216207f0af jdk9-b63
9dd95cff9dae897e8dee712f1f0303c460262288 jdk9-b66
f822b749821e364cae0b7bd7c8f667d9437e6d83 jdk9-b67
dd6dd848b854dbd3f3cc422668276b1ae0834179 jdk9-b68
+194b74467afcab3ca0096f04570def424977215d jdk9-b69
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java
index 2661e096a48..97a4e0d8abf 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java
@@ -152,6 +152,7 @@ public class ConstructorGenerator extends ClassGenerator {
}
if (constructor != null) {
+ initPrototype(mi);
final int arity = constructor.getArity();
if (arity != MemberInfo.DEFAULT_ARITY) {
mi.loadThis();
@@ -193,6 +194,7 @@ public class ConstructorGenerator extends ClassGenerator {
}
private void initFunctionFields(final MethodGenerator mi) {
+ assert memberCount > 0;
for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
if (!memInfo.isConstructorFunction()) {
continue;
@@ -204,37 +206,39 @@ public class ConstructorGenerator extends ClassGenerator {
}
private void initDataFields(final MethodGenerator mi) {
- for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
- if (!memInfo.isConstructorProperty() || memInfo.isFinal()) {
- continue;
- }
- final Object value = memInfo.getValue();
- if (value != null) {
- mi.loadThis();
- mi.loadLiteral(value);
- mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
- } else if (!memInfo.getInitClass().isEmpty()) {
- final String clazz = memInfo.getInitClass();
- mi.loadThis();
- mi.newObject(clazz);
- mi.dup();
- mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC);
- mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
- }
+ assert memberCount > 0;
+ for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
+ if (!memInfo.isConstructorProperty() || memInfo.isFinal()) {
+ continue;
+ }
+ final Object value = memInfo.getValue();
+ if (value != null) {
+ mi.loadThis();
+ mi.loadLiteral(value);
+ mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
+ } else if (!memInfo.getInitClass().isEmpty()) {
+ final String clazz = memInfo.getInitClass();
+ mi.loadThis();
+ mi.newObject(clazz);
+ mi.dup();
+ mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC);
+ mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
+ }
}
+ }
- if (constructor != null) {
- mi.loadThis();
- final String protoName = scriptClassInfo.getPrototypeClassName();
- mi.newObject(protoName);
- mi.dup();
- mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
- mi.dup();
- mi.loadThis();
- mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR,
- PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC);
- mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC);
- }
+ private void initPrototype(final MethodGenerator mi) {
+ assert constructor != null;
+ mi.loadThis();
+ final String protoName = scriptClassInfo.getPrototypeClassName();
+ mi.newObject(protoName);
+ mi.dup();
+ mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
+ mi.dup();
+ mi.loadThis();
+ mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR,
+ PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC);
+ mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC);
}
/**
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java
index a855dfdc1da..d701e2a079c 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java
@@ -140,7 +140,7 @@ public class Main {
String simpleName = inFile.getName();
simpleName = simpleName.substring(0, simpleName.indexOf(".class"));
- if (sci.getPrototypeMemberCount() > 0) {
+ if (sci.isPrototypeNeeded()) {
// generate prototype class
final PrototypeGenerator protGen = new PrototypeGenerator(sci);
buf = protGen.getClassBytes();
@@ -152,7 +152,7 @@ public class Main {
}
}
- if (sci.getConstructorMemberCount() > 0 || sci.getConstructor() != null) {
+ if (sci.isConstructorNeeded()) {
// generate constructor class
final ConstructorGenerator consGen = new ConstructorGenerator(sci);
buf = consGen.getClassBytes();
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java
index 9e3dfc174ab..c91d75859f3 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java
@@ -126,10 +126,42 @@ public final class ScriptClassInfo {
return Collections.unmodifiableList(res);
}
+ boolean isConstructorNeeded() {
+ // Constructor class generation is needed if we one or
+ // more constructor properties are defined or @Constructor
+ // is defined in the class.
+ for (final MemberInfo memInfo : members) {
+ if (memInfo.getKind() == Kind.CONSTRUCTOR ||
+ memInfo.getWhere() == Where.CONSTRUCTOR) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean isPrototypeNeeded() {
+ // Prototype class generation is needed if we have atleast one
+ // prototype property or @Constructor defined in the class.
+ for (final MemberInfo memInfo : members) {
+ if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
int getPrototypeMemberCount() {
int count = 0;
for (final MemberInfo memInfo : members) {
- if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) {
+ switch (memInfo.getKind()) {
+ case SETTER:
+ case SPECIALIZED_FUNCTION:
+ // SETTER was counted when GETTER was encountered.
+ // SPECIALIZED_FUNCTION was counted as FUNCTION already.
+ continue;
+ }
+
+ if (memInfo.getWhere() == Where.PROTOTYPE) {
count++;
}
}
@@ -139,6 +171,16 @@ public final class ScriptClassInfo {
int getConstructorMemberCount() {
int count = 0;
for (final MemberInfo memInfo : members) {
+ switch (memInfo.getKind()) {
+ case CONSTRUCTOR:
+ case SETTER:
+ case SPECIALIZED_FUNCTION:
+ // SETTER was counted when GETTER was encountered.
+ // Constructor and constructor SpecializedFunctions
+ // are not added as members and so not counted.
+ continue;
+ }
+
if (memInfo.getWhere() == Where.CONSTRUCTOR) {
count++;
}
@@ -149,6 +191,14 @@ public final class ScriptClassInfo {
int getInstancePropertyCount() {
int count = 0;
for (final MemberInfo memInfo : members) {
+ switch (memInfo.getKind()) {
+ case SETTER:
+ case SPECIALIZED_FUNCTION:
+ // SETTER was counted when GETTER was encountered.
+ // SPECIALIZED_FUNCTION was counted as FUNCTION already.
+ continue;
+ }
+
if (memInfo.getWhere() == Where.INSTANCE) {
count++;
}
diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java
index ffe8bd3bbc7..285e8647165 100644
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java
@@ -288,9 +288,7 @@ public class ScriptClassInfoCollector extends ClassVisitor {
where = Where.PROTOTYPE;
break;
case SPECIALIZED_FUNCTION:
- if (isSpecializedConstructor) {
- where = Where.CONSTRUCTOR;
- }
+ where = isSpecializedConstructor? Where.CONSTRUCTOR : Where.PROTOTYPE;
//fallthru
default:
break;
diff --git a/nashorn/samples/javahelp.js b/nashorn/samples/javahelp.js
index b29be01e5a3..bc1bb7331bb 100644
--- a/nashorn/samples/javahelp.js
+++ b/nashorn/samples/javahelp.js
@@ -63,5 +63,3 @@ function fields(jobj) {
}
}
}
-
-undefined;
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java
index b2b11dd5e03..e3bd9c28031 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java
@@ -172,7 +172,7 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin
return Context.getContext();
}
}, GET_CONTEXT_ACC_CTXT);
- return wrapLikeMe(context.eval(global, s, sobj, null, false));
+ return wrapLikeMe(context.eval(global, s, sobj, null));
}
});
}
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java
index 7cdd9be378f..b9f6b10ed33 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java
@@ -103,7 +103,7 @@ public final class Compiler implements Loggable {
private final CodeInstaller installer;
- /** logger for compiler, trampolines, splits and related code generation events
+ /** logger for compiler, trampolines and related code generation events
* that affect classes */
private final DebugLogger log;
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java
index cd87f0f675a..a7e6653945a 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java
@@ -30,6 +30,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+
import jdk.nashorn.internal.runtime.PropertyMap;
/**
@@ -120,7 +122,7 @@ final class ConstantData {
private final int hashCode;
public PropertyMapWrapper(final PropertyMap map) {
- this.hashCode = Arrays.hashCode(map.getProperties());
+ this.hashCode = Arrays.hashCode(map.getProperties()) + 31 * Objects.hashCode(map.getClassName());
this.propertyMap = map;
}
@@ -131,8 +133,13 @@ final class ConstantData {
@Override
public boolean equals(final Object other) {
- return other instanceof PropertyMapWrapper &&
- Arrays.equals(propertyMap.getProperties(), ((PropertyMapWrapper) other).propertyMap.getProperties());
+ if (!(other instanceof PropertyMapWrapper)) {
+ return false;
+ }
+ final PropertyMap otherMap = ((PropertyMapWrapper) other).propertyMap;
+ return propertyMap == otherMap
+ || (Arrays.equals(propertyMap.getProperties(), otherMap.getProperties())
+ && Objects.equals(propertyMap.getClassName(), otherMap.getClassName()));
}
}
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java
index 5a5ec4bc4b7..294eee39b4e 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java
@@ -584,7 +584,9 @@ final class Lower extends NodeOperatorVisitor implements Lo
@Override
public Node leaveVarNode(final VarNode varNode) {
addStatement(varNode);
- if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && lc.getCurrentFunction().isProgram()) {
+ if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION)
+ && lc.getCurrentFunction().isProgram()
+ && ((FunctionNode) varNode.getInit()).isAnonymous()) {
new ExpressionStatement(varNode.getLineNumber(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
}
return varNode;
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java
index 9405d062faa..929e954d5a6 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java
@@ -42,13 +42,17 @@ import jdk.nashorn.internal.ir.Node;
import jdk.nashorn.internal.ir.SplitNode;
import jdk.nashorn.internal.ir.Statement;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.logging.DebugLogger;
+import jdk.nashorn.internal.runtime.logging.Loggable;
+import jdk.nashorn.internal.runtime.logging.Logger;
import jdk.nashorn.internal.runtime.options.Options;
/**
* Split the IR into smaller compile units.
*/
-final class Splitter extends NodeVisitor {
+@Logger(name="splitter")
+final class Splitter extends NodeVisitor implements Loggable {
/** Current compiler. */
private final Compiler compiler;
@@ -78,7 +82,17 @@ final class Splitter extends NodeVisitor {
this.compiler = compiler;
this.outermost = functionNode;
this.outermostCompileUnit = outermostCompileUnit;
- this.log = compiler.getLogger();
+ this.log = initLogger(compiler.getContext());
+ }
+
+ @Override
+ public DebugLogger initLogger(final Context context) {
+ return context.getLogger(this.getClass());
+ }
+
+ @Override
+ public DebugLogger getLogger() {
+ return log;
}
/**
@@ -89,7 +103,7 @@ final class Splitter extends NodeVisitor {
FunctionNode split(final FunctionNode fn, final boolean top) {
FunctionNode functionNode = fn;
- log.finest("Initiating split of '", functionNode.getName(), "'");
+ log.fine("Initiating split of '", functionNode.getName(), "'");
long weight = WeighNodes.weigh(functionNode);
@@ -98,7 +112,7 @@ final class Splitter extends NodeVisitor {
assert lc.isEmpty() : "LexicalContext not empty";
if (weight >= SPLIT_THRESHOLD) {
- log.finest("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD);
+ log.info("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD);
functionNode = (FunctionNode)functionNode.accept(this);
if (functionNode.isSplit()) {
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java
index 234dbdbaca6..9cc239a8436 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java
@@ -23,31 +23,6 @@
* questions.
*/
-/*
- * 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.codegen.types;
import static jdk.internal.org.objectweb.asm.Opcodes.I2D;
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
index 0a576bbf864..8a8c62e22d1 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
@@ -87,7 +87,7 @@ import jdk.nashorn.tools.ShellFunctions;
* Representation of global scope.
*/
@ScriptClass("Global")
-public final class Global extends ScriptObject implements Scope {
+public final class Global extends Scope {
// Placeholder value used in place of a location property (__FILE__, __DIR__, __LINE__)
private static final Object LOCATION_PROPERTY_PLACEHOLDER = new Object();
private final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
@@ -906,9 +906,6 @@ public final class Global extends ScriptObject implements Scope {
*/
private ScriptFunction typeErrorThrower;
- // Flag to indicate that a split method issued a return statement
- private int splitState = -1;
-
// Used to store the last RegExp result to support deprecated RegExp constructor properties
private RegExpResult lastRegExpResult;
@@ -995,7 +992,6 @@ public final class Global extends ScriptObject implements Scope {
public Global(final Context context) {
super(checkAndGetMap(context));
this.context = context;
- this.setIsScope();
this.lexicalScope = context.getEnv()._es6 ? new LexicalScope(this) : null;
}
@@ -1451,7 +1447,7 @@ public final class Global extends ScriptObject implements Scope {
* @return the result of eval
*/
public static Object eval(final Object self, final Object str) {
- return directEval(self, str, UNDEFINED, UNDEFINED, false);
+ return directEval(self, str, Global.instanceFrom(self), UNDEFINED, false);
}
/**
@@ -1461,7 +1457,7 @@ public final class Global extends ScriptObject implements Scope {
* @param str Evaluated code
* @param callThis "this" to be passed to the evaluated code
* @param location location of the eval call
- * @param strict is eval called a strict mode code?
+ * @param strict is eval called from a strict mode code?
*
* @return the return value of the eval
*
@@ -1502,26 +1498,53 @@ public final class Global extends ScriptObject implements Scope {
}
/**
- * Global load implementation - Nashorn extension
+ * Global load implementation - Nashorn extension.
*
- * @param self scope
- * @param source source to load
+ *
+ * load builtin loads the given script. Script source can be a URL or a File
+ * or a script object with name and script properties. Evaluated code gets
+ * global object "this" and uses global object as scope for evaluation.
+ *
+ *
+ * If self is undefined or null or global, then global object is used
+ * as scope as well as "this" for the evaluated code. If self is any other
+ * object, then it is indirect load call. With indirect load call, the
+ * properties of scope are available to evaluated script as variables. Also,
+ * global scope properties are accessible. Any var, function definition in
+ * evaluated script goes into an object that is not accessible to user scripts.
+ *
+ * Thus the indirect load call is equivalent to the following:
+ *
+ *
+ * (function (scope, source) {
+ * with(scope) {
+ * eval(<script_from_source>);
+ * }
+ * })(self, source);
+ *
+ *
*
- * @return result of load (undefined)
+ * @param self scope to use for the script evaluation
+ * @param source script source
+ *
+ * @return result of load (may be undefined)
*
* @throws IOException if source could not be read
*/
public static Object load(final Object self, final Object source) throws IOException {
final Global global = Global.instanceFrom(self);
- final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global;
- return global.getContext().load(scope, source);
+ return global.getContext().load(self, source);
}
/**
- * Global loadWithNewGlobal implementation - Nashorn extension
+ * Global loadWithNewGlobal implementation - Nashorn extension.
*
- * @param self scope
- * @param args from plus (optional) arguments to be passed to the loaded script
+ * loadWithNewGlobal builtin loads the given script from a URL or a File
+ * or a script object with name and script properties. Evaluated code gets
+ * new global object "this" and uses that new global object as scope for evaluation.
+ *
+ * @param self self This value is ignored by this function
+ * @param args optional arguments to be passed to the loaded script
*
* @return result of load (may be undefined)
*
@@ -2327,26 +2350,6 @@ public final class Global extends ScriptObject implements Scope {
}
}
- /**
- * Get the current split state.
- *
- * @return current split state
- */
- @Override
- public int getSplitState() {
- return splitState;
- }
-
- /**
- * Set the current split state.
- *
- * @param state current split state
- */
- @Override
- public void setSplitState(final int state) {
- splitState = state;
- }
-
/**
* Return the ES6 global scope for lexically declared bindings.
* @return the ES6 lexical global scope.
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java
index c42e78436ec..9f0c14d71f6 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java
@@ -37,6 +37,7 @@ import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyListeners;
import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.Scope;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -245,7 +246,7 @@ public final class NativeDebug extends ScriptObject {
final PrintWriter out = Context.getCurrentErr();
out.println("ScriptObject count " + ScriptObject.getCount());
- out.println("Scope count " + ScriptObject.getScopeCount());
+ out.println("Scope count " + Scope.getCount());
out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java
index bd2f2dd913b..d336ca1e38d 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java
@@ -279,8 +279,8 @@ public final class NativeFunction {
sb.append("})");
final Global global = Global.instance();
-
- return (ScriptFunction)Global.directEval(global, sb.toString(), global, "", global.isStrictContext());
+ final Context context = global.getContext();
+ return (ScriptFunction)context.eval(global, sb.toString(), global, "");
}
private static void checkFunctionParameters(final String params) {
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/AbstractParser.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/AbstractParser.java
index 3eb45cfb853..a7c7fb9e984 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/AbstractParser.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/AbstractParser.java
@@ -459,6 +459,19 @@ public abstract class AbstractParser {
if (kind == TokenKind.KEYWORD || kind == TokenKind.FUTURE || kind == TokenKind.FUTURESTRICT) {
return true;
}
+
+ // only literals allowed are null, false and true
+ if (kind == TokenKind.LITERAL) {
+ switch (type) {
+ case FALSE:
+ case NULL:
+ case TRUE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
// Fake out identifier.
final long identToken = Token.recast(token, IDENT);
// Get IDENT.
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java
index 4deaec87fd7..711a8cd8016 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java
@@ -668,12 +668,11 @@ public final class Context {
* @param string Evaluated code as a String
* @param callThis "this" to be passed to the evaluated code
* @param location location of the eval call
- * @param strict is this {@code eval} call from a strict mode code?
* @return the return value of the {@code eval}
*/
public Object eval(final ScriptObject initialScope, final String string,
- final Object callThis, final Object location, final boolean strict) {
- return eval(initialScope, string, callThis, location, strict, false);
+ final Object callThis, final Object location) {
+ return eval(initialScope, string, callThis, location, false, false);
}
/**
@@ -692,14 +691,16 @@ public final class Context {
final Object callThis, final Object location, final boolean strict, final boolean evalCall) {
final String file = location == UNDEFINED || location == null ? "" : location.toString();
final Source source = sourceFor(file, string, evalCall);
- final boolean directEval = location != UNDEFINED; // is this direct 'eval' call or indirectly invoked eval?
+ // is this direct 'eval' builtin call?
+ final boolean directEval = evalCall && (location != UNDEFINED);
final Global global = Context.getGlobal();
ScriptObject scope = initialScope;
// ECMA section 10.1.1 point 2 says eval code is strict if it begins
// with "use strict" directive or eval direct call itself is made
// from from strict mode code. We are passed with caller's strict mode.
- boolean strictFlag = directEval && strict;
+ // Nashorn extension: any 'eval' is unconditionally strict when -strict is specified.
+ boolean strictFlag = strict || this._strict;
Class> clazz = null;
try {
@@ -723,16 +724,8 @@ public final class Context {
// In strict mode, eval does not instantiate variables and functions
// in the caller's environment. A new environment is created!
if (strictFlag) {
- // Create a new scope object
- final ScriptObject strictEvalScope = global.newObject();
-
- // bless it as a "scope"
- strictEvalScope.setIsScope();
-
- // set given scope to be it's proto so that eval can still
- // access caller environment vars in the new environment.
- strictEvalScope.setProto(scope);
- scope = strictEvalScope;
+ // Create a new scope object with given scope as its prototype
+ scope = newScope(scope);
}
final ScriptFunction func = getProgramFunction(clazz, scope);
@@ -740,12 +733,17 @@ public final class Context {
if (directEval) {
evalThis = (callThis != UNDEFINED && callThis != null) || strictFlag ? callThis : global;
} else {
- evalThis = global;
+ // either indirect evalCall or non-eval (Function, engine.eval, ScriptObjectMirror.eval..)
+ evalThis = callThis;
}
return ScriptRuntime.apply(func, evalThis);
}
+ private static ScriptObject newScope(final ScriptObject callerScope) {
+ return new Scope(callerScope, PropertyMap.newMap(Scope.class));
+ }
+
private static Source loadInternal(final String srcStr, final String prefix, final String resourcePath) {
if (srcStr.startsWith(prefix)) {
final String resource = resourcePath + srcStr.substring(prefix.length());
@@ -779,7 +777,7 @@ public final class Context {
*
* @throws IOException if source cannot be found or loaded
*/
- public Object load(final ScriptObject scope, final Object from) throws IOException {
+ public Object load(final Object scope, final Object from) throws IOException {
final Object src = from instanceof ConsString ? from.toString() : from;
Source source = null;
@@ -831,7 +829,42 @@ public final class Context {
}
if (source != null) {
- return evaluateSource(source, scope, scope);
+ if (scope instanceof ScriptObject && ((ScriptObject)scope).isScope()) {
+ final ScriptObject sobj = (ScriptObject)scope;
+ // passed object is a script object
+ // Global is the only user accessible scope ScriptObject
+ assert sobj.isGlobal() : "non-Global scope object!!";
+ return evaluateSource(source, sobj, sobj);
+ } else if (scope == null || scope == UNDEFINED) {
+ // undefined or null scope. Use current global instance.
+ final Global global = getGlobal();
+ return evaluateSource(source, global, global);
+ } else {
+ /*
+ * Arbitrary object passed for scope.
+ * Indirect load that is equivalent to:
+ *
+ * (function(scope, source) {
+ * with (scope) {
+ * eval();
+ * }
+ * })(scope, source);
+ */
+ final Global global = getGlobal();
+ // Create a new object. This is where all declarations
+ // (var, function) from the evaluated code go.
+ // make global to be its __proto__ so that global
+ // definitions are accessible to the evaluated code.
+ final ScriptObject evalScope = newScope(global);
+
+ // finally, make a WithObject around user supplied scope object
+ // so that it's properties are accessible as variables.
+ final ScriptObject withObj = ScriptRuntime.openWith(evalScope, scope);
+
+ // evaluate given source with 'withObj' as scope
+ // but use global object as "this".
+ return evaluateSource(source, withObj, global);
+ }
}
throw typeError("cant.load.script", ScriptRuntime.safeToString(from));
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/DebuggerSupport.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/DebuggerSupport.java
index d5dc560f937..2556ad0659a 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/DebuggerSupport.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/DebuggerSupport.java
@@ -156,7 +156,7 @@ final class DebuggerSupport {
final Context context = global.getContext();
try {
- return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED, false);
+ return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED);
} catch (final Throwable ex) {
return returnException ? ex : null;
}
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionScope.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionScope.java
index 133c64f0331..30d06ff85fc 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionScope.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionScope.java
@@ -35,17 +35,12 @@ package jdk.nashorn.internal.runtime;
*
* The constructor of this class is responsible for any function prologue
* involving the scope.
- *
- * TODO see NASHORN-715.
*/
-public class FunctionScope extends ScriptObject implements Scope {
+public class FunctionScope extends Scope {
/** Area to store scope arguments. (public for access from scripts.) */
public final ScriptObject arguments;
- /** Flag to indicate that a split method issued a return statement */
- private int splitState = -1;
-
/**
* Constructor
*
@@ -56,7 +51,6 @@ public class FunctionScope extends ScriptObject implements Scope {
public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final ScriptObject arguments) {
super(callerScope, map);
this.arguments = arguments;
- setIsScope();
}
/**
@@ -68,7 +62,6 @@ public class FunctionScope extends ScriptObject implements Scope {
public FunctionScope(final PropertyMap map, final ScriptObject callerScope) {
super(callerScope, map);
this.arguments = null;
- setIsScope();
}
/**
@@ -82,23 +75,4 @@ public class FunctionScope extends ScriptObject implements Scope {
super(map, primitiveSpill, objectSpill);
this.arguments = null;
}
-
-
- /**
- * Get the current split state.
- * @return current split state
- */
- @Override
- public int getSplitState() {
- return splitState;
- }
-
- /**
- * Set the current split state.
- * @param state current split state
- */
- @Override
- public void setSplitState(final int state) {
- splitState = state;
- }
}
diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
index fbc0dbbf47d..9618a69e754 100644
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java
@@ -596,6 +596,15 @@ public final class PropertyMap implements Iterable