This commit is contained in:
David Dehaven 2016-02-02 11:50:55 -08:00
commit 5feab91d1b
16 changed files with 117 additions and 108 deletions

View File

@ -30,7 +30,7 @@ import java.lang.reflect.Field;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
/**
* The JVM interface for the method handles package is all here.

View File

@ -26,10 +26,10 @@
package java.lang.ref;
import jdk.internal.vm.annotation.DontInline;
import sun.misc.Cleaner;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaLangRefAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.ref.Cleaner;
/**
* Abstract base class for reference objects. This class defines the

View File

@ -28,9 +28,9 @@
package java.nio;
import java.io.FileDescriptor;
import sun.misc.Cleaner;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.ref.Cleaner;
import sun.nio.ch.DirectBuffer;

View File

@ -23,7 +23,7 @@
* questions.
*/
package sun.misc;
package jdk.internal.ref;
import java.lang.ref.*;
import java.security.AccessController;
@ -58,6 +58,7 @@ import java.security.PrivilegedAction;
public class Cleaner
extends PhantomReference<Object>
implements Runnable
{
// Dummy reference queue, needed because the PhantomReference constructor
@ -153,4 +154,11 @@ public class Cleaner
}
}
@Override public void run() {
SecurityManager security = System.getSecurityManager();
if (security != null)
security.checkPackageAccess("jdk.internal.ref");
this.clean();
}
}

View File

@ -25,7 +25,7 @@
package sun.nio.ch;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
public interface DirectBuffer {

View File

@ -47,7 +47,7 @@ import java.util.List;
import jdk.internal.misc.JavaIOFileDescriptorAccess;
import jdk.internal.misc.JavaNioAccess;
import jdk.internal.misc.SharedSecrets;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
import sun.security.action.GetPropertyAction;
public class FileChannelImpl

View File

@ -26,7 +26,7 @@
package sun.nio.ch;
import java.nio.ByteBuffer;
import sun.misc.*;
import jdk.internal.ref.Cleaner;
/**

View File

@ -33,7 +33,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import jdk.internal.misc.Unsafe;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
import sun.security.action.GetPropertyAction;

View File

@ -26,7 +26,7 @@
package sun.nio.fs;
import jdk.internal.misc.Unsafe;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
/**
* A light-weight buffer in native memory.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -653,6 +653,7 @@ public final class ProviderList {
String type = null;
String algorithm;
String provider;
String alternateName = null;
PreferredEntry(String t, String p) {
int i = t.indexOf('.');
@ -664,6 +665,11 @@ public final class ProviderList {
}
provider = p;
if (algorithm.compareToIgnoreCase("SHA1") == 0) {
alternateName = "SHA-1";
} else if (algorithm.compareToIgnoreCase("SHA-1") == 0) {
alternateName = "SHA1";
}
}
boolean match(String t, String a) {
@ -685,6 +691,15 @@ public final class ProviderList {
return true;
}
if (alternateName != null &&
a.compareToIgnoreCase(alternateName) == 0) {
if (debug != null) {
debug.println("Config entry found (alternateName): " +
toString());
}
return true;
}
// No match
return false;
}

View File

@ -109,7 +109,8 @@ security.provider.tbd=sun.security.pkcs11.SunPKCS11
# jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \
# MessageDigest.SHA-256:SUN
#ifdef solaris-sparc
jdk.security.provider.preferred=AES:SunJCE, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, SHA-224:SUN, \
SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
#endif
#ifdef solaris-x86
jdk.security.provider.preferred=AES:SunJCE, RSA:SunRsaSign

View File

@ -78,6 +78,7 @@ jdk_lang = \
sun/reflect \
jdk/lambda \
jdk/internal/misc \
jdk/internal/ref \
vm
# All of the java.util package

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 4954921 8009259
* @library /test/lib/share/classes
* @build jdk.test.lib.*
* @build jdk.test.lib.process.*
* @run main ExitOnThrow
* @summary Ensure that if a cleaner throws an exception then the VM exits
*/
import java.util.Arrays;
import jdk.internal.ref.Cleaner;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class ExitOnThrow {
static final String cp = System.getProperty("test.classes", ".");
public static void main(String[] args) throws Exception {
if (args.length == 0) {
String[] cmd = JDKToolLauncher.createUsingTestJDK("java")
.addToolArg("-cp")
.addToolArg(cp)
.addToolArg("ExitOnThrow")
.addToolArg("-executeCleaner")
.getCommand();
ProcessBuilder pb = new ProcessBuilder(cmd);
OutputAnalyzer out = ProcessTools.executeProcess(pb);
System.out.println("======================");
System.out.println(Arrays.toString(cmd));
String msg = " stdout: [" + out.getStdout() + "]\n" +
" stderr: [" + out.getStderr() + "]\n" +
" exitValue = " + out.getExitValue() + "\n";
System.out.println(msg);
if (out.getExitValue() != 1)
throw new RuntimeException("Unexpected exit code: " +
out.getExitValue());
} else {
Cleaner.create(new Object(),
() -> { throw new RuntimeException("Foo!"); } );
while (true) {
System.gc();
Thread.sleep(100);
}
}
}
}

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 sun.misc.*;
public class ExitOnThrow {
public static void main(String[] args) throws Exception {
Cleaner.create(new Object(),
new Runnable() {
public void run() {
throw new RuntimeException("Foo!");
}
});
while (true) {
System.gc();
Thread.sleep(100);
}
}
}

View File

@ -1,48 +0,0 @@
#! /bin/sh
#
# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# @test
# @bug 4954921 8009259
# @summary Ensure that if a cleaner throws an exception then the VM exits
#
# @build ExitOnThrow
# @run shell exitOnThrow.sh
# Command-line usage: sh exitOnThrow.sh /path/to/build
if [ -z "$TESTJAVA" ]; then
if [ $# -lt 1 ]; then exit 1; fi
TESTJAVA=$1; shift
TESTCLASSES=`pwd`
fi
if $TESTJAVA/bin/java ${TESTVMOPTS} -cp $TESTCLASSES ExitOnThrow; then
echo Failed: VM exited normally
exit 1
else
echo Passed: VM exited with code $?
exit 0
fi

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/**
* @test
* @bug 8076359 8133151
* @bug 8076359 8133151 8145344
* @summary Test the value for new jdk.security.provider.preferred security property
* @requires os.name == "SunOS"
*/
@ -40,8 +40,9 @@ import javax.crypto.NoSuchPaddingException;
public class PreferredProviderTest {
private static final List<DataTuple> SPARC_DATA = Arrays.asList(
new DataTuple("SHA-256", "SUN"), new DataTuple("SHA-384", "SUN"),
new DataTuple("SHA-512", "SUN"));
new DataTuple("SHA1", "SUN"), new DataTuple("SHA-1", "SUN"),
new DataTuple("SHA-224", "SUN"), new DataTuple("SHA-256", "SUN"),
new DataTuple("SHA-384", "SUN"), new DataTuple("SHA-512", "SUN"));
private static final List<DataTuple> X86_DATA = Arrays
.asList(new DataTuple("RSA", "SunRsaSign"));
@ -52,7 +53,7 @@ public class PreferredProviderTest {
String actualProvider = null;
if (type.equals("sparcv9")) {
if (!preferredProvider.equals(
"AES:SunJCE, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN")) {
"AES:SunJCE, SHA1:SUN, SHA-224:SUN, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN")) {
throw new RuntimeException(
"Test Failed: wrong jdk.security.provider.preferred "
+ "value on solaris-sparcv9");