This commit is contained in:
Lana Steuck 2012-06-27 12:54:48 -07:00
commit db40815a4c
154 changed files with 4094 additions and 1313 deletions

View File

@ -165,3 +165,4 @@ b3a91113026c99b0da010d41055719ab0d8938f0 jdk8-b37
c029c972396cea042a0dc67c0f7ccf2fe68007d4 jdk8-b41
5c5a64ec0839df5affe9394b99ff338c363acbca jdk8-b42
69d8a827cdf9236be9694a46d75c710d71dac7d7 jdk8-b43
7e981cb0ad6a194f1fa859f9ad47586db461f269 jdk8-b44

View File

@ -165,3 +165,4 @@ a2b2d435f1d275fa8010774c653197c64e326d3a jdk8-b40
1a8c7c530f8a9b7f5bdb9b0693b2f5435ca5205e jdk8-b41
1ce5dc16416611c58b7480ca67a2eee5153498a6 jdk8-b42
661c9aae602bbd9766d12590800c90f1edd1d8dd jdk8-b43
e4f81a817447c3a4f6868f083c81c2fb1b15d44c jdk8-b44

View File

@ -165,3 +165,4 @@ b8cbfb31139f820e5e094ba71449e58159fbe22e jdk8-b38
113f0d5f0a08aa0947b3edf783b603e7f042748a jdk8-b41
79cc42c9c71bbd6630ede681642e98f5e4a841fa jdk8-b42
cd879aff5d3cc1f58829aab3116880aa19525b78 jdk8-b43
439d9bf8e4ff204cc89c9974c1515a508b2cc6ff jdk8-b44

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -217,7 +217,7 @@ public final class ClientRequestInfoImpl
// ClientRequestInfo validity table (see ptc/00-08-06 table 21-1).
// Note: These must be in the same order as specified in contants.
protected static final boolean validCall[][] = {
private static final boolean validCall[][] = {
// LEGEND:
// s_req = send_request r_rep = receive_reply
// s_pol = send_poll r_exc = receive_exception

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -195,7 +195,7 @@ public final class ServerRequestInfoImpl
// ServerRequestInfo validity table (see ptc/00-08-06 table 21-2).
// Note: These must be in the same order as specified in contants.
protected static final boolean validCall[][] = {
private static final boolean validCall[][] = {
// LEGEND:
// r_rsc = receive_request_service_contexts
// r_req = receive_request

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -130,10 +130,23 @@ public class Util implements javax.rmi.CORBA.UtilDelegate
private UtilSystemException utilWrapper = UtilSystemException.get(
CORBALogDomains.RPC_ENCODING);
public static Util instance = null;
private static Util instance = null;
public Util() {
instance = this;
setInstance(this);
}
private static void setInstance( Util util ) {
assert instance == null : "Instance already defined";
instance = util;
}
public static Util getInstance() {
return instance;
}
public static boolean isInstanceDefined() {
return instance != null;
}
// Used by TOAFactory.shutdown to unexport all targets for this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -93,7 +93,7 @@ public abstract class POAPolicyMediatorBase_R extends POAPolicyMediatorBase {
activeObjectMap.putServant( servant, entry ) ;
if (Util.instance != null) {
if (Util.isInstanceDefined()) {
POAManagerImpl pm = (POAManagerImpl)poa.the_POAManager() ;
POAFactory factory = pm.getFactory() ;
factory.registerPOAForServant(poa, servant);
@ -129,7 +129,7 @@ public abstract class POAPolicyMediatorBase_R extends POAPolicyMediatorBase {
activeObjectMap.remove(key);
if (Util.instance != null) {
if (Util.isInstanceDefined()) {
POAManagerImpl pm = (POAManagerImpl)poa.the_POAManager() ;
POAFactory factory = pm.getFactory() ;
factory.unregisterPOAForServant(poa, s);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -78,8 +78,8 @@ public class TOAFactory implements ObjectAdapterFactory
public void shutdown( boolean waitForCompletion )
{
if (Util.instance != null) {
Util.instance.unregisterTargetsForORB(orb);
if (Util.isInstanceDefined()) {
Util.getInstance().unregisterTargetsForORB(orb);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -106,7 +106,9 @@ public class ParserTable {
public ParserData[] getParserData()
{
return parserData ;
ParserData[] parserArray = new ParserData[parserData.length];
System.arraycopy(parserData, 0, parserArray, 0, parserData.length);
return parserArray;
}
private ParserTable() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,7 +62,7 @@ public class RepositoryId_1_3 {
// legal use of '.' in a Java name.
public static final RepositoryIdCache_1_3 cache = new RepositoryIdCache_1_3();
public static final byte[] IDL_IDENTIFIER_CHARS = {
private static final byte[] IDL_IDENTIFIER_CHARS = {
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
@ -180,7 +180,7 @@ public class RepositoryId_1_3 {
public static final String kRemoteTypeStr = "";
public static final String kRemoteValueRepID = "";
public static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
static {
kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
@ -189,7 +189,7 @@ public class RepositoryId_1_3 {
}
public static final Hashtable kSpecialCasesRepIDs = new Hashtable();
private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
static {
kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
@ -197,7 +197,7 @@ public class RepositoryId_1_3 {
kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
}
public static final Hashtable kSpecialCasesStubValues = new Hashtable();
private static final Hashtable kSpecialCasesStubValues = new Hashtable();
static {
kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
@ -209,7 +209,7 @@ public class RepositoryId_1_3 {
}
public static final Hashtable kSpecialCasesVersions = new Hashtable();
private static final Hashtable kSpecialCasesVersions = new Hashtable();
static {
kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
@ -220,7 +220,7 @@ public class RepositoryId_1_3 {
kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
}
public static final Hashtable kSpecialCasesClasses = new Hashtable();
private static final Hashtable kSpecialCasesClasses = new Hashtable();
static {
kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
@ -232,7 +232,7 @@ public class RepositoryId_1_3 {
//kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
}
public static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
static {
kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
@ -243,7 +243,7 @@ public class RepositoryId_1_3 {
kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
}
public static final Hashtable kSpecialPrimitives = new Hashtable();
private static final Hashtable kSpecialPrimitives = new Hashtable();
static {
kSpecialPrimitives.put("int","long");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
@ -63,7 +63,7 @@ public class RepositoryId_1_3_1 {
// uniformly, and is safe because that is the only
// legal use of '.' in a Java name.
public static final byte[] IDL_IDENTIFIER_CHARS = {
private static final byte[] IDL_IDENTIFIER_CHARS = {
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
@ -198,7 +198,7 @@ public class RepositoryId_1_3_1 {
public static final String kRemoteTypeStr = "";
public static final String kRemoteValueRepID = "";
public static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
static {
kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
@ -207,7 +207,7 @@ public class RepositoryId_1_3_1 {
}
public static final Hashtable kSpecialCasesRepIDs = new Hashtable();
private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
static {
kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
@ -215,7 +215,7 @@ public class RepositoryId_1_3_1 {
kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
}
public static final Hashtable kSpecialCasesStubValues = new Hashtable();
private static final Hashtable kSpecialCasesStubValues = new Hashtable();
static {
kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
@ -227,7 +227,7 @@ public class RepositoryId_1_3_1 {
}
public static final Hashtable kSpecialCasesVersions = new Hashtable();
private static final Hashtable kSpecialCasesVersions = new Hashtable();
static {
kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
@ -238,7 +238,7 @@ public class RepositoryId_1_3_1 {
kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
}
public static final Hashtable kSpecialCasesClasses = new Hashtable();
private static final Hashtable kSpecialCasesClasses = new Hashtable();
static {
kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
@ -250,7 +250,7 @@ public class RepositoryId_1_3_1 {
//kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
}
public static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
static {
kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
@ -261,7 +261,7 @@ public class RepositoryId_1_3_1 {
kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
}
public static final Hashtable kSpecialPrimitives = new Hashtable();
private static final Hashtable kSpecialPrimitives = new Hashtable();
static {
kSpecialPrimitives.put("int","long");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -52,7 +52,7 @@ public abstract class LocalClientRequestDispatcherBase implements LocalClientReq
// If isNextIsLocalValid.get() == Boolean.TRUE,
// the next call to isLocal should be valid
protected static ThreadLocal isNextCallValid = new ThreadLocal() {
private static final ThreadLocal isNextCallValid = new ThreadLocal() {
protected synchronized Object initialValue() {
return Boolean.TRUE;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -57,7 +57,7 @@ public class RepositoryId {
// uniformly, and is safe because that is the only
// legal use of '.' in a Java name.
public static final byte[] IDL_IDENTIFIER_CHARS = {
private static final byte[] IDL_IDENTIFIER_CHARS = {
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
@ -95,7 +95,7 @@ public class RepositoryId {
private static IdentityHashtable classIDLToRepStr = new IdentityHashtable();
private static IdentityHashtable classSeqToRepStr = new IdentityHashtable();
private static IdentityHashtable repStrToByteArray = new IdentityHashtable();
private static final IdentityHashtable repStrToByteArray = new IdentityHashtable();
private static Hashtable repStrToClass = new Hashtable();
private String repId = null;
@ -192,7 +192,7 @@ public class RepositoryId {
public static final String kRemoteTypeStr = "";
public static final String kRemoteValueRepID = "";
public static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
static {
kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
@ -201,7 +201,7 @@ public class RepositoryId {
}
public static final Hashtable kSpecialCasesRepIDs = new Hashtable();
private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
static {
kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
@ -209,7 +209,7 @@ public class RepositoryId {
kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
}
public static final Hashtable kSpecialCasesStubValues = new Hashtable();
private static final Hashtable kSpecialCasesStubValues = new Hashtable();
static {
kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
@ -221,7 +221,7 @@ public class RepositoryId {
}
public static final Hashtable kSpecialCasesVersions = new Hashtable();
private static final Hashtable kSpecialCasesVersions = new Hashtable();
static {
kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
@ -232,7 +232,7 @@ public class RepositoryId {
kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
}
public static final Hashtable kSpecialCasesClasses = new Hashtable();
private static final Hashtable kSpecialCasesClasses = new Hashtable();
static {
kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
@ -244,7 +244,7 @@ public class RepositoryId {
//kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
}
public static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
static {
kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
@ -255,7 +255,7 @@ public class RepositoryId {
kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
}
public static final Hashtable kSpecialPrimitives = new Hashtable();
private static final Hashtable kSpecialPrimitives = new Hashtable();
static {
kSpecialPrimitives.put("int","long");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* 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
@ -58,7 +58,7 @@ public abstract class CORBALogDomains {
private CORBALogDomains() {}
// Top level log domain for CORBA
public static String TOP_LEVEL_DOMAIN = "javax.enterprise.resource.corba";
public static final String TOP_LEVEL_DOMAIN = "javax.enterprise.resource.corba";
public static final String RPC = "rpc" ;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -71,6 +71,34 @@ public class IDLNames implements sun.rmi.rmic.iiop.Constants {
(byte)'F',
};
// Legal IDL Identifier characters (1 = legal). Note
// that '.' (2E) is marked as legal even though it is
// not legal in IDL. This allows us to treat a fully
// qualified Java name with '.' package separators
// uniformly, and is safe because that is the only
// legal use of '.' in a Java name.
private static final byte[] IDL_IDENTIFIER_CHARS = {
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 10-1f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0, // 20-2f
1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0, // 30-3f
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 40-4f
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, // 50-5f
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 60-6f
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0, // 70-7f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 80-8f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 90-9f
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // a0-af
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // b0-bf
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // c0-cf
0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // d0-df
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // e0-ef
0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // f0-ff
};
//_____________________________________________________________________
// Public Interfaces
//_____________________________________________________________________
@ -139,7 +167,7 @@ public class IDLNames implements sun.rmi.rmic.iiop.Constants {
result = replace(result,"x\\U","U");
// Now see if we have any remaining illegal characters (see
// RepositoryId.IDL_IDENTIFIER_CHARS array)...
// IDL_IDENTIFIER_CHARS array)...
int length = result.length();
StringBuffer buffer = null;
@ -148,7 +176,7 @@ public class IDLNames implements sun.rmi.rmic.iiop.Constants {
char c = result.charAt(i);
if (c > 255 || RepositoryId.IDL_IDENTIFIER_CHARS[c] == 0) {
if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
// We gotta convert. Have we already started?

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -425,7 +425,7 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
// Write the _ids() method...
p.plnI("public String[] _ids() { ");
p.pln("return _type_ids;");
p.pln("return (String[]) _type_ids.clone();");
p.pOln("}");
// Get all the methods and write each stub method...
@ -1860,11 +1860,11 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
{
if(POATie){
p.plnI("public String[] _all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId){");
p.pln("return _type_ids;");
p.pln("return (String[]) _type_ids.clone();");
p.pOln("}");
} else {
p.plnI("public String[] _ids() { ");
p.pln("return _type_ids;");
p.pln("return (String[]) _type_ids.clone();");
p.pOln("}");
}
}

View File

@ -255,3 +255,4 @@ bd568544be7fcd12a9327e6c448592198d57b043 hs24-b13
55954061c6e8750ea39a63523fd65d580db6eeb1 jdk8-b42
e77b8e0ed1f84e3e268239e276c7ab64fa573baa jdk8-b43
5ba29a1db46ecb80a321ca873adb56a3fe6ad320 hs24-b14
831e5c76a20af18f3c08c5a95ed31be0e128a010 jdk8-b44

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -67,7 +67,7 @@
// ------------------------------------------------------------------
// ciField::ciField
ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with(NULL) {
ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) {
ASSERT_IN_VM;
CompilerThread *thread = CompilerThread::current();
@ -143,7 +143,7 @@ ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with(NULL) {
initialize_from(&field_desc);
}
ciField::ciField(fieldDescriptor *fd): _known_to_link_with(NULL) {
ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) {
ASSERT_IN_VM;
_cp_index = -1;
@ -315,6 +315,10 @@ ciType* ciField::compute_type_impl() {
bool ciField::will_link(ciInstanceKlass* accessing_klass,
Bytecodes::Code bc) {
VM_ENTRY_MARK;
assert(bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic ||
bc == Bytecodes::_getfield || bc == Bytecodes::_putfield,
"unexpected bytecode");
if (_offset == -1) {
// at creation we couldn't link to our holder so we need to
// maintain that stance, otherwise there's no safe way to use this
@ -322,8 +326,22 @@ bool ciField::will_link(ciInstanceKlass* accessing_klass,
return false;
}
if (_known_to_link_with == accessing_klass) {
return true;
// Check for static/nonstatic mismatch
bool is_static = (bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic);
if (is_static != this->is_static()) {
return false;
}
// Get and put can have different accessibility rules
bool is_put = (bc == Bytecodes::_putfield || bc == Bytecodes::_putstatic);
if (is_put) {
if (_known_to_link_with_put == accessing_klass) {
return true;
}
} else {
if (_known_to_link_with_get == accessing_klass) {
return true;
}
}
FieldAccessInfo result;
@ -334,8 +352,13 @@ bool ciField::will_link(ciInstanceKlass* accessing_klass,
true, false, KILL_COMPILE_ON_FATAL_(false));
// update the hit-cache, unless there is a problem with memory scoping:
if (accessing_klass->is_shared() || !is_shared())
_known_to_link_with = accessing_klass;
if (accessing_klass->is_shared() || !is_shared()) {
if (is_put) {
_known_to_link_with_put = accessing_klass;
} else {
_known_to_link_with_get = accessing_klass;
}
}
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -49,7 +49,8 @@ private:
ciType* _type;
int _offset;
bool _is_constant;
ciInstanceKlass* _known_to_link_with;
ciInstanceKlass* _known_to_link_with_put;
ciInstanceKlass* _known_to_link_with_get;
ciConstant _constant_value;
// Used for will_link

View File

@ -1884,10 +1884,10 @@ void ClassVerifier::verify_invoke_init(
VerificationType type = current_frame->pop_stack(
VerificationType::reference_check(), CHECK_VERIFY(this));
if (type == VerificationType::uninitialized_this_type()) {
// The method must be an <init> method of either this class, or one of its
// superclasses
// The method must be an <init> method of this class or its superclass
klassOop superk = current_class()->super();
if (ref_class_type.name() != current_class()->name() &&
!name_in_supers(ref_class_type.name(), current_class())) {
ref_class_type.name() != superk->klass_part()->name()) {
verify_error(bci, "Bad <init> method call");
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -551,13 +551,21 @@ void CompilerOracle::parse_from_line(char* line) {
}
static const char* cc_file() {
#ifdef ASSERT
if (CompileCommandFile == NULL)
return ".hotspot_compiler";
#endif
return CompileCommandFile;
}
bool CompilerOracle::has_command_file() {
return cc_file() != NULL;
}
bool CompilerOracle::_quiet = false;
void CompilerOracle::parse_from_file() {
assert(has_command_file(), "command file must be specified");
FILE* stream = fopen(cc_file(), "rt");
if (stream == NULL) return;
@ -600,6 +608,7 @@ void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*
}
void CompilerOracle::append_comment_to_file(const char* message) {
assert(has_command_file(), "command file must be specified");
fileStream stream(fopen(cc_file(), "at"));
stream.print("# ");
for (int index = 0; message[index] != '\0'; index++) {
@ -610,6 +619,7 @@ void CompilerOracle::append_comment_to_file(const char* message) {
}
void CompilerOracle::append_exclude_to_file(methodHandle method) {
assert(has_command_file(), "command file must be specified");
fileStream stream(fopen(cc_file(), "at"));
stream.print("exclude ");
Klass::cast(method->method_holder())->name()->print_symbol_on(&stream);
@ -624,7 +634,9 @@ void CompilerOracle::append_exclude_to_file(methodHandle method) {
void compilerOracle_init() {
CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only);
CompilerOracle::parse_from_file();
if (CompilerOracle::has_command_file()) {
CompilerOracle::parse_from_file();
}
if (lists[PrintCommand] != NULL) {
if (PrintAssembly) {
warning("CompileCommand and/or .hotspot_compiler file contains 'print' commands, but PrintAssembly is also enabled");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,6 +36,10 @@ class CompilerOracle : AllStatic {
static bool _quiet;
public:
// True if the command file has been specified or is implicit
static bool has_command_file();
// Reads from file and adds to lists
static void parse_from_file();

View File

@ -896,7 +896,8 @@ static void report_null_exception_in_code_cache(address exception_pc) {
methodOop method = ((nmethod*)n)->method();
tty->print_cr("# Method where it happened %s.%s ", Klass::cast(method->method_holder())->name()->as_C_string(), method->name()->as_C_string());
tty->print_cr("#");
if (ShowMessageBoxOnError && UpdateHotSpotCompilerFileOnError) {
if (ShowMessageBoxOnError && UpdateHotSpotCompilerFileOnError &&
CompilerOracle::has_command_file()) {
const char* title = "HotSpot Runtime Error";
const char* question = "Do you want to exclude compilation of this method in future runs?";
if (os::message_box(title, question)) {

View File

@ -3017,12 +3017,14 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
}
}
#ifdef ASSERT
// Parse default .hotspotrc settings file
if (!settings_file_specified) {
if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) {
return JNI_EINVAL;
}
}
#endif
if (PrintVMOptions) {
for (index = 0; index < args->nOptions; index++) {

View File

@ -0,0 +1,122 @@
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# @test Test7110720.sh
# @bug 7110720
# @summary improve VM configuration file loading
# @run shell Test7110720.sh
#
if [ "${TESTSRC}" = "" ]
then TESTSRC=.
fi
if [ "${TESTJAVA}" = "" ]
then
PARENT=`dirname \`which java\``
TESTJAVA=`dirname ${PARENT}`
echo "TESTJAVA not set, selecting " ${TESTJAVA}
echo "If this is incorrect, try setting the variable manually."
fi
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
# Jtreg sets TESTVMOPTS which may include -d64 which is
# required to test a 64-bit JVM on some platforms.
# If another test harness still creates HOME/JDK64BIT,
# we can recognise that.
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux )
FS="/"
RM=/bin/rm
CP=/bin/cp
MV=/bin/mv
## for solaris, linux it's HOME
FILE_LOCATION=$HOME
if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
then
TESTVMOPTS=`cat ${FILE_LOCATION}${FS}JDK64BIT`
fi
;;
Windows_* )
FS="\\"
RM=rm
CP=cp
MV=mv
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
JAVA=${TESTJAVA}${FS}bin${FS}java
# Don't test debug builds, they do read the config files:
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "debug" >/dev/null
if [ "$?" = "0" ]; then
echo Skipping test for debug build.
exit 0
fi
ok=yes
$RM -f .hotspot_compiler .hotspotrc
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "garbage in" >/dev/null
if [ "$?" = "0" ]; then
echo "FAILED: base case failure"
exit 1
fi
echo "garbage in, garbage out" > .hotspot_compiler
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "garbage in" >/dev/null
if [ "$?" = "0" ]; then
echo "FAILED: .hotspot_compiler was read"
ok=no
fi
$MV .hotspot_compiler hs_comp.txt
${JAVA} ${TESTVMOPTS} -XX:CompileCommandFile=hs_comp.txt -version 2>&1 | grep "garbage in" >/dev/null
if [ "$?" = "1" ]; then
echo "FAILED: explicit compiler command file not read"
ok=no
fi
$RM -f .hotspot_compiler hs_comp.txt
echo "garbage" > .hotspotrc
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "garbage" >/dev/null
if [ "$?" = "0" ]; then
echo "FAILED: .hotspotrc was read"
ok=no
fi
$MV .hotspotrc hs_flags.txt
${JAVA} ${TESTVMOPTS} -XX:Flags=hs_flags.txt -version 2>&1 | grep "garbage" >/dev/null
if [ "$?" = "1" ]; then
echo "FAILED: explicit flags file not read"
ok=no
fi
if [ "${ok}" = "no" ]; then
echo "Some tests failed."
exit 1
else
echo "Passed"
exit 0
fi

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test Test7160757.java
* @bug 7160757
* @summary Tests that superclass initialization is not skipped
*/
public class Test7160757 {
public static void main(String args[]) throws Exception {
ClassLoader loader = new SLoader();
try {
Class.forName("S", true, loader);
System.out.println("FAILED");
throw new Exception("Should have thrown a VerifyError.");
} catch (VerifyError e) {
System.out.println(e);
System.out.println("PASSED");
}
}
static class SLoader extends ClassLoader {
/**
* public class S extends Throwable {
* public S() {
* aload_0
* invokespecial Object.<init>()
* return
* }
* }
*/
static byte b(int i) { return (byte)i; }
static byte S_class[] = {
b(0xca), b(0xfe), b(0xba), b(0xbe), 0x00, 0x00, 0x00, 0x32,
0x00, 0x0c, 0x0a, 0x00, 0x0b, 0x00, 0x07, 0x07,
0x00, 0x08, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06,
0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00,
0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43,
0x6f, 0x64, 0x65, 0x0c, 0x00, 0x04, 0x00, 0x05,
0x01, 0x00, 0x01, 0x53, 0x01, 0x00, 0x13, 0x6a,
0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67,
0x2f, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x61, 0x62,
0x6c, 0x65, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76,
0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f,
0x62, 0x6a, 0x65, 0x63, 0x74, 0x07, 0x00, 0x0a,
0x00, 0x21, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04,
0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00,
0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
0x00, 0x05, 0x2a, b(0xb7), 0x00, 0x01, b(0xb1), 0x00,
0x00, 0x00, 0x00, 0x00, 0x00
};
public Class findClass(String name) throws ClassNotFoundException {
return defineClass(name, S_class, 0, S_class.length);
}
}
}

View File

@ -165,3 +165,4 @@ f95fdbe525c88ef0d57dc1390be6582a8af5e07c jdk8-b39
6f5c0e17415de7a9c74900ef4ba12f47accdf88b jdk8-b41
39ee03c1602155ff02e5feb6cd44869452f24cf7 jdk8-b42
eff4ece9c8bc43b3ce2b3758574c4c20147f0689 jdk8-b43
0b3f3a4ce13930430b32b616a717dfc7fe385b28 jdk8-b44

View File

@ -286,12 +286,13 @@ public class XMLDocumentFragmentScannerImpl
//STAX related properties
//defaultValues.
protected boolean fSupportDTD = true;
protected boolean fReplaceEntityReferences = true;
protected boolean fSupportExternalEntities = false;
protected boolean fReportCdataEvent = false ;
protected boolean fIsCoalesce = false ;
protected String fDeclaredEncoding = null;
/** Disallow doctype declaration. */
/** Xerces Feature: Disallow doctype declaration. */
protected boolean fDisallowDoctype = false;
// drivers
@ -1847,7 +1848,7 @@ public class XMLDocumentFragmentScannerImpl
// start general entity
if (!fEntityStore.isDeclaredEntity(name)) {
//SUPPORT_DTD=false && ReplaceEntityReferences should throw exception
if (fDisallowDoctype && fReplaceEntityReferences) {
if (!fSupportDTD && fReplaceEntityReferences) {
reportFatalError("EntityNotDeclared", new Object[]{name});
return;
}

View File

@ -278,7 +278,7 @@ public class XMLDocumentScannerImpl
fDoctypeSystemId = null;
fSeenDoctypeDecl = false;
fNamespaceContext.reset();
fDisallowDoctype = !((Boolean)propertyManager.getProperty(XMLInputFactory.SUPPORT_DTD)).booleanValue();
fSupportDTD = ((Boolean)propertyManager.getProperty(XMLInputFactory.SUPPORT_DTD)).booleanValue();
// xerces features
fLoadExternalDTD = !((Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD)).booleanValue();
@ -628,7 +628,7 @@ public class XMLDocumentScannerImpl
// scanning methods
/** Scans a doctype declaration. */
protected boolean scanDoctypeDecl(boolean ignore) throws IOException, XNIException {
protected boolean scanDoctypeDecl(boolean supportDTD) throws IOException, XNIException {
// spaces
if (!fEntityScanner.skipSpaces()) {
@ -653,7 +653,7 @@ public class XMLDocumentScannerImpl
fHasExternalDTD = fDoctypeSystemId != null;
// Attempt to locate an external subset with an external subset resolver.
if (!ignore && !fHasExternalDTD && fExternalSubsetResolver != null) {
if (supportDTD && !fHasExternalDTD && fExternalSubsetResolver != null) {
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
fDTDDescription.setRootName(fDoctypeName);
fExternalSubsetSource = fExternalSubsetResolver.getExternalSubset(fDTDDescription);
@ -661,7 +661,7 @@ public class XMLDocumentScannerImpl
}
// call handler
if (!ignore && fDocumentHandler != null) {
if (supportDTD && fDocumentHandler != null) {
// NOTE: I don't like calling the doctypeDecl callback until
// end of the *full* doctype line (including internal
// subset) is parsed correctly but SAX2 requires that
@ -916,6 +916,10 @@ public class XMLDocumentScannerImpl
}
case SCANNER_STATE_DOCTYPE: {
if (fDisallowDoctype) {
reportFatalError("DoctypeNotAllowed", null);
}
if (fSeenDoctypeDecl) {
reportFatalError("AlreadySeenDoctype", null);
@ -924,7 +928,7 @@ public class XMLDocumentScannerImpl
// scanDoctypeDecl() sends XNI doctypeDecl event that
// in SAX is converted to startDTD() event.
if (scanDoctypeDecl(fDisallowDoctype)) {
if (scanDoctypeDecl(fSupportDTD)) {
//allow parsing of entity decls to continue in order to stay well-formed
setScannerState(SCANNER_STATE_DTD_INTERNAL_DECLS);
fSeenInternalSubset = true;
@ -934,8 +938,6 @@ public class XMLDocumentScannerImpl
setDriver(fContentDriver);
//always return DTD event, the event however, will not contain any entities
return fDTDDriver.next();
// If no DTD support, ignore and continue parsing
//return fDisallowDoctype ? next() : dtdEvent;
}
if(fSeenDoctypeDecl){
@ -950,7 +952,7 @@ public class XMLDocumentScannerImpl
if (fDoctypeSystemId != null) {
if (((fValidation || fLoadExternalDTD)
&& (fValidationManager == null || !fValidationManager.isCachedDTD()))) {
if (!fDisallowDoctype)
if (fSupportDTD)
setScannerState(SCANNER_STATE_DTD_EXTERNAL);
else
setScannerState(SCANNER_STATE_PROLOG);
@ -967,7 +969,7 @@ public class XMLDocumentScannerImpl
// This handles the case of a DOCTYPE that had neither an internal subset or an external subset.
fDTDScanner.setInputSource(fExternalSubsetSource);
fExternalSubsetSource = null;
if (!fDisallowDoctype)
if (fSupportDTD)
setScannerState(SCANNER_STATE_DTD_EXTERNAL_DECLS);
else
setScannerState(SCANNER_STATE_PROLOG);
@ -1113,7 +1115,7 @@ public class XMLDocumentScannerImpl
}
fMarkupDepth--;
if (fDisallowDoctype) {
if (!fSupportDTD) {
//simply reset the entity store without having to mess around
//with the DTD Scanner code
fEntityStore = fEntityManager.getEntityStore();

View File

@ -402,6 +402,16 @@ public abstract class XMLScanner
boolean dataFoundForTarget = false;
boolean sawSpace = fEntityScanner.skipSpaces();
// since pseudoattributes are *not* attributes,
// their quotes don't need to be preserved in external parameter entities.
// the XMLEntityScanner#scanLiteral method will continue to
// emit -1 in such cases when it finds a quote; this is
// fine for other methods that parse scanned entities,
// but not for the scanning of pseudoattributes. So,
// temporarily, we must mark the current entity as not being "literal"
Entity.ScannedEntity currEnt = fEntityManager.getCurrentEntity();
boolean currLiteral = currEnt.literal;
currEnt.literal = false;
while (fEntityScanner.peekChar() != '?') {
dataFoundForTarget = true;
String name = scanPseudoAttribute(scanningTextDecl, fString);
@ -499,6 +509,9 @@ public abstract class XMLScanner
}
sawSpace = fEntityScanner.skipSpaces();
}
// restore original literal value
if(currLiteral)
currEnt.literal = true;
// REVISIT: should we remove this error reporting?
if (scanningTextDecl && state != STATE_DONE) {
reportFatalError("MorePseudoAttributes", null);

View File

@ -248,8 +248,11 @@ public class XMLEventReaderImpl implements javax.xml.stream.XMLEventReader{
object = nextEvent();
}catch(XMLStreamException streamException){
fLastEvent = null ;
//xxx: what should be done in this case ?
throw new NoSuchElementException();
//don't swallow the cause
NoSuchElementException e = new NoSuchElementException(streamException.getMessage());
e.initCause(streamException.getCause());
throw e;
}
return object;
}

View File

@ -165,3 +165,4 @@ ac1ba3b56775e3cdcd91b7a48793b59f6a3c18b5 jdk8-b38
f2072b164b0519227833a2994f78e3988ee67827 jdk8-b41
1f20f37818a91b66eaeba268d0b785718598ee0e jdk8-b42
f00c12994562c2f68d348a7c3e829374a89294e2 jdk8-b43
f6a417540ef124c9b4123d07da5e26f2ab909949 jdk8-b44

View File

@ -165,3 +165,4 @@ b88fc3359dc7edabfa8a228855d8cebf8843c055 jdk8-b40
4eac56f073ea8179b1a35fcd2af9b48b0088be9f jdk8-b41
cf5c1f6fbc5ba14163fe0ef8eb8601b33f951372 jdk8-b42
b3246687c3695dff6f461bb407f9db88f7d072e7 jdk8-b43
db471a7af03168e4441c245b1d9976f720a7cb77 jdk8-b44

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
# 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
@ -100,6 +100,23 @@ FILES_ties = $(subst javax/management/remote/rmi/,javax/management/remote/rmi/
# so that *_tie classes are generated in package without the prefix
# org.omg.stub (6375696)
#
# To ensure the latest stub generator files are picked up from corba repo
# when available, we need to run with latest rmic version available. rmic
# launch tool not built at this stage but we can invoke via rmi class.
RMIC_JAVA = $(OUTPUTDIR)/bin/java
# need to treat 64bit solaris differently
ifeq ($(PLATFORM)-$(LIBARCH), solaris-amd64)
RMIC_JAVA = $(OUTPUTDIR)/bin/amd64/java
endif
ifeq ($(PLATFORM)-$(LIBARCH), solaris-sparcv9)
RMIC_JAVA = $(OUTPUTDIR)/bin/sparcv9/java
endif
ifeq ($(CROSS_COMPILE_ARCH),)
RMIC = $(RMIC_JAVA) $(JAVA_TOOLS_FLAGS) -cp $(OUTPUTDIR)/classes sun.rmi.rmic.Main
endif
$(CLASSDESTDIR)/%_Stub.class: $(CLASSDESTDIR)/%.class
$(prep-target)
$(RMIC) -classpath "$(CLASSDESTDIR)" \

View File

@ -42,7 +42,7 @@ REQUIRED_ALSA_VERSION =
OTHER_CPPFLAGS += -DJAVASE_EMBEDDED
# Product naming
PRODUCT_SUFFIX = SE Runtime Environment for Embedded
PRODUCT_SUFFIX = SE Embedded Runtime Environment
RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX)
# Reduced JRE locations

View File

@ -372,6 +372,7 @@ JAVA_JAVA_java = \
java/util/spi/CurrencyNameProvider.java \
java/util/spi/LocaleNameProvider.java \
java/util/spi/LocaleServiceProvider.java \
java/util/spi/ResourceBundleControlProvider.java \
java/util/spi/TimeZoneNameProvider.java \
java/io/Closeable.java \
java/io/Flushable.java \

View File

@ -88,6 +88,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_IOUtil_fdVal;
Java_sun_nio_ch_IOUtil_fdLimit;
Java_sun_nio_ch_IOUtil_initIDs;
Java_sun_nio_ch_IOUtil_iovMax;
Java_sun_nio_ch_IOUtil_makePipe;
Java_sun_nio_ch_IOUtil_randomBytes;
Java_sun_nio_ch_IOUtil_setfdVal;

View File

@ -76,6 +76,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_IOUtil_fdLimit;
Java_sun_nio_ch_IOUtil_fdVal;
Java_sun_nio_ch_IOUtil_initIDs;
Java_sun_nio_ch_IOUtil_iovMax;
Java_sun_nio_ch_IOUtil_makePipe;
Java_sun_nio_ch_IOUtil_randomBytes;
Java_sun_nio_ch_IOUtil_setfdVal;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package apple.applescript;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.Map.Entry;
@ -297,7 +298,7 @@ public class AppleScriptEngine implements ScriptEngine {
File tmpfile;
FileWriter tmpwrite;
try {
tmpfile = File.createTempFile("AppleScriptEngine.", ".scpt");
tmpfile = Files.createTempFile("AppleScriptEngine.", ".scpt").toFile();
tmpwrite = new FileWriter(tmpfile);
// read in our input and write directly to tmpfile

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* 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
@ -35,6 +35,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.MessageFormat;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -385,9 +386,7 @@ class Driver {
if ( base.getParentFile() == null && suffix.equals(".bak"))
where = new File(".").getAbsoluteFile();
File f = File.createTempFile(prefix, suffix, where);
return f;
return Files.createTempFile(where.toPath(), prefix, suffix).toFile();
}
static private

View File

@ -659,7 +659,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
* us work with drivers that do not support
* getObject with a map in fairly sensible way
*/
if (map == null) {
if (map == null || map.isEmpty()) {
obj = data.getObject(i);
} else {
obj = data.getObject(i, map);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* 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
@ -812,101 +812,119 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
}
}
/**
* Inserts a row that has been inserted into the given
* <code>CachedRowSet</code> object into the data source from which
* the rowset is derived, returning <code>false</code> if the insertion
* was successful.
*
* @param crs the <code>CachedRowSet</code> object that has had a row inserted
* and to whose underlying data source the row will be inserted
* @param pstmt the <code>PreparedStatement</code> object that will be used
* to execute the insertion
* @return <code>false</code> to indicate that the insertion was successful;
* <code>true</code> otherwise
* @throws SQLException if a database access error occurs
*/
private boolean insertNewRow(CachedRowSet crs,
PreparedStatement pstmt, CachedRowSetImpl crsRes) throws SQLException {
int i = 0;
int icolCount = crs.getMetaData().getColumnCount();
/**
* Inserts a row that has been inserted into the given
* <code>CachedRowSet</code> object into the data source from which
* the rowset is derived, returning <code>false</code> if the insertion
* was successful.
*
* @param crs the <code>CachedRowSet</code> object that has had a row inserted
* and to whose underlying data source the row will be inserted
* @param pstmt the <code>PreparedStatement</code> object that will be used
* to execute the insertion
* @return <code>false</code> to indicate that the insertion was successful;
* <code>true</code> otherwise
* @throws SQLException if a database access error occurs
*/
private boolean insertNewRow(CachedRowSet crs,
PreparedStatement pstmt, CachedRowSetImpl crsRes) throws SQLException {
boolean returnVal = false;
PreparedStatement pstmtSel = con.prepareStatement(selectCmd,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs, rs2 = null;
DatabaseMetaData dbmd = con.getMetaData();
rs = pstmtSel.executeQuery();
String table = crs.getTableName();
rs2 = dbmd.getPrimaryKeys(null, null, table);
String [] primaryKeys = new String[icolCount];
int k = 0;
while(rs2.next()) {
String pkcolname = rs2.getString("COLUMN_NAME");
primaryKeys[k] = pkcolname;
k++;
}
boolean returnVal = false;
if(rs.next()) {
for(int j=0;j<primaryKeys.length;j++) {
if(primaryKeys[j] != null) {
if(crs.getObject(primaryKeys[j]) == null){
break;
}
String crsPK = (crs.getObject(primaryKeys[j])).toString();
String rsPK = (rs.getObject(primaryKeys[j])).toString();
if(crsPK.equals(rsPK)) {
returnVal = true;
this.crsResolve.moveToInsertRow();
for(i = 1; i <= icolCount; i++) {
String colname = (rs.getMetaData()).getColumnName(i);
if(colname.equals(primaryKeys[j]))
this.crsResolve.updateObject(i,rsPK);
else
this.crsResolve.updateNull(i);
}
this.crsResolve.insertRow();
this.crsResolve.moveToCurrentRow();
}
}
}
}
if(returnVal)
return returnVal;
try (PreparedStatement pstmtSel = con.prepareStatement(selectCmd,
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = pstmtSel.executeQuery();
ResultSet rs2 = con.getMetaData().getPrimaryKeys(null, null,
crs.getTableName())
) {
try {
for (i = 1; i <= icolCount; i++) {
Object obj = crs.getObject(i);
if (obj != null) {
pstmt.setObject(i, obj);
} else {
pstmt.setNull(i,crs.getMetaData().getColumnType(i));
}
}
ResultSetMetaData rsmd = crs.getMetaData();
int icolCount = rsmd.getColumnCount();
String[] primaryKeys = new String[icolCount];
int k = 0;
while (rs2.next()) {
primaryKeys[k] = rs2.getString("COLUMN_NAME");
k++;
}
i = pstmt.executeUpdate();
return false;
if (rs.next()) {
for (String pkName : primaryKeys) {
if (!isPKNameValid(pkName, rsmd)) {
} catch (SQLException ex) {
/**
* Cursor will come here if executeUpdate fails.
* There can be many reasons why the insertion failed,
* one can be violation of primary key.
* Hence we cannot exactly identify why the insertion failed
* Present the current row as a null row to the user.
**/
this.crsResolve.moveToInsertRow();
/* We came here as one of the the primary keys
* of the table is not present in the cached
* rowset object, it should be an autoincrement column
* and not included while creating CachedRowSet
* Object, proceed to check for other primary keys
*/
continue;
}
for(i = 1; i <= icolCount; i++) {
this.crsResolve.updateNull(i);
}
Object crsPK = crs.getObject(pkName);
if (crsPK == null) {
/*
* It is possible that the PK is null on some databases
* and will be filled in at insert time (MySQL for example)
*/
break;
}
this.crsResolve.insertRow();
this.crsResolve.moveToCurrentRow();
String rsPK = rs.getObject(pkName).toString();
if (crsPK.toString().equals(rsPK)) {
returnVal = true;
this.crsResolve.moveToInsertRow();
for (int i = 1; i <= icolCount; i++) {
String colname = (rs.getMetaData()).getColumnName(i);
if (colname.equals(pkName))
this.crsResolve.updateObject(i,rsPK);
else
this.crsResolve.updateNull(i);
}
this.crsResolve.insertRow();
this.crsResolve.moveToCurrentRow();
}
}
}
return true;
}
}
if (returnVal) {
return returnVal;
}
try {
for (int i = 1; i <= icolCount; i++) {
Object obj = crs.getObject(i);
if (obj != null) {
pstmt.setObject(i, obj);
} else {
pstmt.setNull(i,crs.getMetaData().getColumnType(i));
}
}
pstmt.executeUpdate();
return false;
} catch (SQLException ex) {
/*
* Cursor will come here if executeUpdate fails.
* There can be many reasons why the insertion failed,
* one can be violation of primary key.
* Hence we cannot exactly identify why the insertion failed,
* present the current row as a null row to the caller.
*/
this.crsResolve.moveToInsertRow();
for (int i = 1; i <= icolCount; i++) {
this.crsResolve.updateNull(i);
}
this.crsResolve.insertRow();
this.crsResolve.moveToCurrentRow();
return true;
}
}
}
/**
* Deletes the row in the underlying data source that corresponds to
@ -1437,4 +1455,25 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
}
static final long serialVersionUID =-8506030970299413976L;
/**
* Validate whether the Primary Key is known to the CachedRowSet. If it is
* not, it is an auto-generated key
* @param pk - Primary Key to validate
* @param rsmd - ResultSetMetadata for the RowSet
* @return true if found, false otherwise (auto generated key)
*/
private boolean isPKNameValid(String pk, ResultSetMetaData rsmd) throws SQLException {
boolean isValid = false;
int cols = rsmd.getColumnCount();
for(int i = 1; i<= cols; i++) {
String colName = rsmd.getColumnClassName(i);
if(colName.equalsIgnoreCase(pk)) {
isValid = true;
break;
}
}
return isValid;
}
}

View File

@ -764,6 +764,7 @@ public class XmlReaderContentHandler extends DefaultHandler {
rs.next();
rs.setOriginalRow();
applyUpdates();
rs.deleteRow();
} catch (SQLException ex) {
throw new SAXException(MessageFormat.format(resBundle.handleGetObject("xmlrch.errdel").toString() , ex.getMessage()));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,6 +36,7 @@ import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
import java.io.*;
import java.lang.ref.SoftReference;
import java.nio.file.Files;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.text.AttributedCharacterIterator.Attribute;
@ -831,7 +832,7 @@ public class Font implements java.io.Serializable
File f = null;
boolean hasPerm = false;
try {
f = File.createTempFile("+~JT", ".tmp", null);
f = Files.createTempFile("+~JT", ".tmp").toFile();
f.delete();
f = null;
hasPerm = true;
@ -881,7 +882,7 @@ public class Font implements java.io.Serializable
final File tFile = AccessController.doPrivileged(
new PrivilegedExceptionAction<File>() {
public File run() throws IOException {
return File.createTempFile("+~JF", ".tmp", null);
return Files.createTempFile("+~JF", ".tmp").toFile();
}
}
);

View File

@ -1,54 +1,74 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.io;
package java.io;
/**
* Context during upcalls from object stream to class-defined
* readObject/writeObject methods.
* Holds object currently being deserialized and descriptor for current class.
*
* This context keeps track of the thread it was constructed on, and allows
* only a single call of defaultReadObject, readFields, defaultWriteObject
* or writeFields which must be invoked on the same thread before the class's
* readObject/writeObject method has returned.
* If not set to the current thread, the getObj method throws NotActiveException.
*/
final class SerialCallbackContext {
private final Object obj;
private final ObjectStreamClass desc;
/**
* Thread this context is in use by.
* As this only works in one thread, we do not need to worry about thread-safety.
*/
private Thread thread;
/**
* Context during upcalls from object stream to class-defined
* readObject/writeObject methods.
* Holds object currently being deserialized and descriptor for current class.
*
* This context keeps track of the thread it was constructed on, and allows
* only a single call of defaultReadObject, readFields, defaultWriteObject
* or writeFields which must be invoked on the same thread before the class's
* readObject/writeObject method has returned.
* If not set to the current thread, the getObj method throws NotActiveException.
*/
final class SerialCallbackContext {
private final Object obj;
private final ObjectStreamClass desc;
/**
* Thread this context is in use by.
* As this only works in one thread, we do not need to worry about thread-safety.
*/
private Thread thread;
public SerialCallbackContext(Object obj, ObjectStreamClass desc) {
this.obj = obj;
this.desc = desc;
this.thread = Thread.currentThread();
}
public SerialCallbackContext(Object obj, ObjectStreamClass desc) {
this.obj = obj;
this.desc = desc;
this.thread = Thread.currentThread();
}
public Object getObj() throws NotActiveException {
checkAndSetUsed();
return obj;
}
public Object getObj() throws NotActiveException {
checkAndSetUsed();
return obj;
}
public ObjectStreamClass getDesc() {
return desc;
}
public ObjectStreamClass getDesc() {
return desc;
}
private void checkAndSetUsed() throws NotActiveException {
if (thread != Thread.currentThread()) {
throw new NotActiveException(
"not in readObject invocation or fields already read");
}
thread = null;
}
private void checkAndSetUsed() throws NotActiveException {
if (thread != Thread.currentThread()) {
throw new NotActiveException(
"not in readObject invocation or fields already read");
}
thread = null;
}
public void setUsed() {
thread = null;
}
}
public void setUsed() {
thread = null;
}
}

View File

@ -407,7 +407,7 @@ public class MethodHandles {
* an access$N method.
*/
Lookup() {
this(getCallerClassAtEntryPoint(), ALL_MODES);
this(getCallerClassAtEntryPoint(false), ALL_MODES);
// make sure we haven't accidentally picked up a privileged class:
checkUnprivilegedlookupClass(lookupClass);
}
@ -461,8 +461,8 @@ public class MethodHandles {
&& !VerifyAccess.isSamePackageMember(this.lookupClass, requestedLookupClass)) {
newModes &= ~PRIVATE;
}
if (newModes == PUBLIC
&& !VerifyAccess.isClassAccessible(requestedLookupClass, this.lookupClass)) {
if ((newModes & PUBLIC) != 0
&& !VerifyAccess.isClassAccessible(requestedLookupClass, this.lookupClass, allowedModes)) {
// The requested class it not accessible from the lookup class.
// No permissions.
newModes = 0;
@ -540,13 +540,17 @@ public class MethodHandles {
}
}
// call this from an entry point method in Lookup with extraFrames=0.
private static Class<?> getCallerClassAtEntryPoint() {
/* Obtain the external caller class, when called from Lookup.<init> or a first-level subroutine. */
private static Class<?> getCallerClassAtEntryPoint(boolean inSubroutine) {
final int CALLER_DEPTH = 4;
// Stack for the constructor entry point (inSubroutine=false):
// 0: Reflection.getCC, 1: getCallerClassAtEntryPoint,
// 2: Lookup.<init>, 3: MethodHandles.*, 4: caller
// The stack is slightly different for a subroutine of a Lookup.find* method:
// 2: Lookup.*, 3: Lookup.find*.*, 4: caller
// Note: This should be the only use of getCallerClass in this file.
assert(Reflection.getCallerClass(CALLER_DEPTH-1) == MethodHandles.class);
assert(Reflection.getCallerClass(CALLER_DEPTH-2) == Lookup.class);
assert(Reflection.getCallerClass(CALLER_DEPTH-1) == (inSubroutine ? Lookup.class : MethodHandles.class));
return Reflection.getCallerClass(CALLER_DEPTH);
}
@ -1087,7 +1091,7 @@ return mh1;
void checkSymbolicClass(Class<?> refc) throws IllegalAccessException {
Class<?> caller = lookupClassOrNull();
if (caller != null && !VerifyAccess.isClassAccessible(refc, caller))
if (caller != null && !VerifyAccess.isClassAccessible(refc, caller, allowedModes))
throw new MemberName(refc).makeAccessException("symbolic reference class is not public", this);
}
@ -1102,7 +1106,13 @@ return mh1;
// Step 1:
smgr.checkMemberAccess(refc, Member.PUBLIC);
// Step 2:
if (!VerifyAccess.classLoaderIsAncestor(lookupClass, refc))
Class<?> callerClass = ((allowedModes & PRIVATE) != 0
? lookupClass // for strong access modes, no extra check
// next line does stack walk magic; do not refactor:
: getCallerClassAtEntryPoint(true));
if (!VerifyAccess.classLoaderIsAncestor(lookupClass, refc) ||
(callerClass != lookupClass &&
!VerifyAccess.classLoaderIsAncestor(callerClass, refc)))
smgr.checkPackageAccess(VerifyAccess.getPackageName(refc));
// Step 3:
if (m.isPublic()) return;
@ -1153,9 +1163,10 @@ return mh1;
int requestedModes = fixmods(mods); // adjust 0 => PACKAGE
if ((requestedModes & allowedModes) != 0
&& VerifyAccess.isMemberAccessible(refc, m.getDeclaringClass(),
mods, lookupClass()))
mods, lookupClass(), allowedModes))
return;
if (((requestedModes & ~allowedModes) & PROTECTED) != 0
&& (allowedModes & PACKAGE) != 0
&& VerifyAccess.isSamePackage(m.getDeclaringClass(), lookupClass()))
// Protected members can also be checked as if they were package-private.
return;
@ -1170,9 +1181,9 @@ return mh1;
(defc == refc ||
Modifier.isPublic(refc.getModifiers())));
if (!classOK && (allowedModes & PACKAGE) != 0) {
classOK = (VerifyAccess.isClassAccessible(defc, lookupClass()) &&
classOK = (VerifyAccess.isClassAccessible(defc, lookupClass(), ALL_MODES) &&
(defc == refc ||
VerifyAccess.isClassAccessible(refc, lookupClass())));
VerifyAccess.isClassAccessible(refc, lookupClass(), ALL_MODES)));
}
if (!classOK)
return "class is not public";

View File

@ -288,12 +288,11 @@ public class HashMap<K,V>
* in lower bits.
*/
final int hash(Object k) {
int h = hashSeed;
if (k instanceof String) {
return ((String)k).hash32();
return ((String) k).hash32();
}
h ^= k.hashCode();
int h = hashSeed ^ k.hashCode();
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded

View File

@ -194,19 +194,17 @@ public class Hashtable<K,V>
transient final int hashSeed = sun.misc.Hashing.randomHashSeed(this);
private int hash(Object k) {
int h = hashSeed;
if (k instanceof String) {
return ((String)k).hash32();
} else {
h ^= k.hashCode();
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded
// number of collisions (approximately 8 at default load factor).
h ^= (h >>> 20) ^ (h >>> 12);
return h ^ (h >>> 7) ^ (h >>> 4);
}
int h = hashSeed ^ k.hashCode();
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded
// number of collisions (approximately 8 at default load factor).
h ^= (h >>> 20) ^ (h >>> 12);
return h ^ (h >>> 7) ^ (h >>> 4);
}
/**
@ -1015,7 +1013,7 @@ public class Hashtable<K,V>
*/
private static class Entry<K,V> implements Map.Entry<K,V> {
final int hash;
K key;
final K key;
V value;
Entry<K,V> next;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,6 +55,7 @@ import java.security.PrivilegedExceptionAction;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.jar.JarEntry;
import java.util.spi.ResourceBundleControlProvider;
import sun.util.locale.BaseLocale;
import sun.util.locale.LocaleObjectCache;
@ -192,6 +193,17 @@ import sun.util.locale.LocaleObjectCache;
* {@link #getBundle(String, Locale, ClassLoader, Control) getBundle}
* factory method for details.
*
* <p><a name="modify_default_behavior">For the {@code getBundle} factory
* methods that take no {@link Control} instance, their <a
* href="#default_behavior"> default behavior</a> of resource bundle loading
* can be modified with <em>installed</em> {@link
* ResourceBundleControlProvider} implementations. Any installed providers are
* detected at the {@code ResourceBundle} class loading time. If any of the
* providers provides a {@link Control} for the given base name, that {@link
* Control} will be used instead of the default {@link Control}. If there is
* more than one service provider installed for supporting the same base name,
* the first one returned from {@link ServiceLoader} will be used.
*
* <h4>Cache Management</h4>
*
* Resource bundle instances created by the <code>getBundle</code> factory
@ -294,8 +306,7 @@ public abstract class ResourceBundle {
/**
* Queue for reference objects referring to class loaders or bundles.
*/
private static final ReferenceQueue<Object> referenceQueue =
new ReferenceQueue<>();
private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
/**
* The parent bundle of this bundle.
@ -330,6 +341,21 @@ public abstract class ResourceBundle {
*/
private volatile Set<String> keySet;
private static final List<ResourceBundleControlProvider> providers;
static {
List<ResourceBundleControlProvider> list = null;
ServiceLoader<ResourceBundleControlProvider> serviceLoaders
= ServiceLoader.loadInstalled(ResourceBundleControlProvider.class);
for (ResourceBundleControlProvider provider : serviceLoaders) {
if (list == null) {
list = new ArrayList<>();
}
list.add(provider);
}
providers = list;
}
/**
* Sole constructor. (For invocation by subclass constructors, typically
* implicit.)
@ -725,7 +751,7 @@ public abstract class ResourceBundle {
return getBundleImpl(baseName, Locale.getDefault(),
/* must determine loader here, else we break stack invariant */
getLoader(),
Control.INSTANCE);
getDefaultControl(baseName));
}
/**
@ -797,7 +823,7 @@ public abstract class ResourceBundle {
return getBundleImpl(baseName, locale,
/* must determine loader here, else we break stack invariant */
getLoader(),
Control.INSTANCE);
getDefaultControl(baseName));
}
/**
@ -849,9 +875,15 @@ public abstract class ResourceBundle {
* Gets a resource bundle using the specified base name, locale, and class
* loader.
*
* <p><a name="default_behavior"/>This method behaves the same as calling
* <p>This method behaves the same as calling
* {@link #getBundle(String, Locale, ClassLoader, Control)} passing a
* default instance of {@link Control}. The following describes this behavior.
* default instance of {@link Control} unless another {@link Control} is
* provided with the {@link ResourceBundleControlProvider} SPI. Refer to the
* description of <a href="#modify_default_behavior">modifying the default
* behavior</a>.
*
* <p><a name="default_behavior"/>The following describes the default
* behavior.
*
* <p><code>getBundle</code> uses the base name, the specified locale, and
* the default locale (obtained from {@link java.util.Locale#getDefault()
@ -1026,7 +1058,7 @@ public abstract class ResourceBundle {
if (loader == null) {
throw new NullPointerException();
}
return getBundleImpl(baseName, locale, loader, Control.INSTANCE);
return getBundleImpl(baseName, locale, loader, getDefaultControl(baseName));
}
/**
@ -1247,6 +1279,18 @@ public abstract class ResourceBundle {
return getBundleImpl(baseName, targetLocale, loader, control);
}
private static Control getDefaultControl(String baseName) {
if (providers != null) {
for (ResourceBundleControlProvider provider : providers) {
Control control = provider.getControl(baseName);
if (control != null) {
return control;
}
}
}
return Control.INSTANCE;
}
private static ResourceBundle getBundleImpl(String baseName, Locale locale,
ClassLoader loader, Control control) {
if (locale == null || control == null) {

View File

@ -295,13 +295,11 @@ public class WeakHashMap<K,V>
* otherwise encounter collisions for hashCodes that do not differ
* in lower bits.
*/
int hash(Object k) {
int h = hashSeed;
final int hash(Object k) {
if (k instanceof String) {
return ((String) k).hash32();
} else {
h ^= k.hashCode();
}
int h = hashSeed ^ k.hashCode();
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded

View File

@ -269,13 +269,11 @@ public class ConcurrentHashMap<K, V> extends AbstractMap<K, V>
* differ in lower or upper bits.
*/
private int hash(Object k) {
int h = hashSeed;
if (k instanceof String) {
return ((String) k).hash32();
}
h ^= k.hashCode();
int h = hashSeed ^ k.hashCode();
// Spread bits to regularize both segment and index locations,
// using variant of single-word Wang/Jenkins hash.

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.util.spi;
import java.util.ResourceBundle;
/**
* An interface for service providers that provide implementations of {@link
* java.util.ResourceBundle.Control}. The <a
* href="../ResourceBundle.html#default_behavior">default resource bundle loading
* behavior</a> of the {@code ResourceBundle.getBundle} factory methods that take
* no {@link java.util.ResourceBundle.Control} instance can be modified with {@code
* ResourceBundleControlProvider} implementations.
*
* <p>Provider implementations must be packaged using the <a
* href="../../../../technotes/guides/extensions/index.html">Java Extension
* Mechanism</a> as installed extensions. Refer to {@link java.util.ServiceLoader}
* for the extension packaging. Any installed {@code
* ResourceBundleControlProvider} implementations are loaded using {@link
* java.util.ServiceLoader} at the {@code ResourceBundle} class loading time.
*
* @author Masayoshi Okutsu
* @since 1.8
* @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, ResourceBundle.Control)
* ResourceBundle.getBundle
* @see java.util.ServiceLoader#loadInstalled(Class)
*/
public interface ResourceBundleControlProvider {
/**
* Returns a {@code ResourceBundle.Control} instance that is used
* to handle resource bundle loading for the given {@code
* baseName}. This method must return {@code null} if the given
* {@code baseName} isn't handled by this provider.
*
* @param baseName the base name of the resource bundle
* @return a {@code ResourceBundle.Control} instance,
* or {@code null} if the given {@code baseName} is not
* applicable to this provider.
* @throws NullPointerException if {@code baseName} is {@code null}
*/
public ResourceBundle.Control getControl(String baseName);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@ import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import com.sun.imageio.stream.StreamCloser;
import com.sun.imageio.stream.StreamFinalizer;
import sun.java2d.Disposer;
@ -97,8 +98,11 @@ public class FileCacheImageInputStream extends ImageInputStreamImpl {
throw new IllegalArgumentException("Not a directory!");
}
this.stream = stream;
this.cacheFile =
File.createTempFile("imageio", ".tmp", cacheDir);
if (cacheDir == null)
this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
else
this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
.toFile();
this.cache = new RandomAccessFile(cacheFile, "rw");
this.closeAction = StreamCloser.createCloseAction(this);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import com.sun.imageio.stream.StreamCloser;
/**
@ -83,8 +84,11 @@ public class FileCacheImageOutputStream extends ImageOutputStreamImpl {
throw new IllegalArgumentException("Not a directory!");
}
this.stream = stream;
this.cacheFile =
File.createTempFile("imageio", ".tmp", cacheDir);
if (cacheDir == null)
this.cacheFile = Files.createTempFile("imageio", ".tmp").toFile();
else
this.cacheFile = Files.createTempFile(cacheDir.toPath(), "imageio", ".tmp")
.toFile();
this.cache = new RandomAccessFile(cacheFile, "rw");
this.closeAction = StreamCloser.createCloseAction(this);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,6 +44,7 @@ import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLStreamHandlerFactory;
import java.nio.file.Files;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@ -1160,8 +1161,9 @@ public class MLet extends java.net.URLClassLoader
try {
File directory = new File(libraryDirectory);
directory.mkdirs();
File file = File.createTempFile(libname + ".", null,
directory);
File file = Files.createTempFile(directory.toPath(),
libname + ".", null)
.toFile();
file.deleteOnExit();
FileOutputStream fileOutput = new FileOutputStream(file);
try {

View File

@ -152,8 +152,8 @@ public class SynthButtonUI extends BasicButtonUI implements
if (!c.isEnabled()) {
state = DISABLED;
}
if (SynthLookAndFeel.selectedUI == this) {
return SynthLookAndFeel.selectedUIState | SynthConstants.ENABLED;
if (SynthLookAndFeel.getSelectedUI() == this) {
return SynthLookAndFeel.getSelectedUIState() | SynthConstants.ENABLED;
}
AbstractButton button = (AbstractButton) c;
ButtonModel model = button.getModel();

View File

@ -97,9 +97,9 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
private int getComponentState(JComponent c) {
int state = SynthLookAndFeel.getComponentState(c);
if (SynthLookAndFeel.selectedUI == this &&
if (SynthLookAndFeel.getSelectedUI() == this &&
state == SynthConstants.ENABLED) {
state = SynthLookAndFeel.selectedUIState | SynthConstants.ENABLED;
state = SynthLookAndFeel.getSelectedUIState() | SynthConstants.ENABLED;
}
return state;
}

View File

@ -76,28 +76,26 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
private static final Object STYLE_FACTORY_KEY =
new StringBuffer("com.sun.java.swing.plaf.gtk.StyleCache");
/**
* AppContext key to get selectedUI.
*/
private static final Object SELECTED_UI_KEY = new StringBuilder("selectedUI");
/**
* AppContext key to get selectedUIState.
*/
private static final Object SELECTED_UI_STATE_KEY = new StringBuilder("selectedUIState");
/**
* The last SynthStyleFactory that was asked for from AppContext
* <code>lastContext</code>.
*/
private static SynthStyleFactory lastFactory;
/**
* If this is true it indicates there is more than one AppContext active
* and that we need to make sure in getStyleCache the requesting
* AppContext matches that of <code>lastContext</code> before returning
* it.
*/
private static boolean multipleApps;
/**
* AppContext lastLAF came from.
*/
private static AppContext lastContext;
// Refer to setSelectedUI
static ComponentUI selectedUI;
// Refer to setSelectedUI
static int selectedUIState;
/**
* SynthStyleFactory for the this SynthLookAndFeel.
*/
@ -111,6 +109,10 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
private Handler _handler;
static ComponentUI getSelectedUI() {
return (ComponentUI) AppContext.getAppContext().get(SELECTED_UI_KEY);
}
/**
* Used by the renderers. For the most part the renderers are implemented
* as Labels, which is problematic in so far as they are never selected.
@ -122,8 +124,8 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
static void setSelectedUI(ComponentUI uix, boolean selected,
boolean focused, boolean enabled,
boolean rollover) {
selectedUI = uix;
selectedUIState = 0;
int selectedUIState = 0;
if (selected) {
selectedUIState = SynthConstants.SELECTED;
if (focused) {
@ -140,19 +142,32 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
else {
if (enabled) {
selectedUIState |= SynthConstants.ENABLED;
selectedUIState = SynthConstants.FOCUSED;
if (focused) {
selectedUIState |= SynthConstants.FOCUSED;
}
}
else {
selectedUIState |= SynthConstants.DISABLED;
}
}
AppContext context = AppContext.getAppContext();
context.put(SELECTED_UI_KEY, uix);
context.put(SELECTED_UI_STATE_KEY, Integer.valueOf(selectedUIState));
}
static int getSelectedUIState() {
Integer result = (Integer) AppContext.getAppContext().get(SELECTED_UI_STATE_KEY);
return result == null ? 0 : result.intValue();
}
/**
* Clears out the selected UI that was last set in setSelectedUI.
*/
static void resetSelectedUI() {
selectedUI = null;
AppContext.getAppContext().remove(SELECTED_UI_KEY);
}
@ -167,10 +182,6 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
// for a particular AppContext.
synchronized(SynthLookAndFeel.class) {
AppContext context = AppContext.getAppContext();
if (!multipleApps && context != lastContext &&
lastContext != null) {
multipleApps = true;
}
lastFactory = cache;
lastContext = context;
context.put(STYLE_FACTORY_KEY, cache);
@ -184,17 +195,13 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
*/
public static SynthStyleFactory getStyleFactory() {
synchronized(SynthLookAndFeel.class) {
if (!multipleApps) {
return lastFactory;
}
AppContext context = AppContext.getAppContext();
if (lastContext == context) {
return lastFactory;
}
lastContext = context;
lastFactory = (SynthStyleFactory)AppContext.getAppContext().get
(STYLE_FACTORY_KEY);
lastFactory = (SynthStyleFactory) context.get(STYLE_FACTORY_KEY);
return lastFactory;
}
}

View File

@ -33,7 +33,7 @@ package sun.font;
import sun.font.GlyphLayout.*;
import java.awt.geom.Point2D;
import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Locale;
/*
@ -129,9 +129,9 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory
// !!! don't need this unless we have more than one sun layout engine...
public LayoutEngine getEngine(LayoutEngineKey key) {
HashMap cache = (HashMap)cacheref.get();
ConcurrentHashMap cache = (ConcurrentHashMap)cacheref.get();
if (cache == null) {
cache = new HashMap();
cache = new ConcurrentHashMap();
cacheref = new SoftReference(cache);
}

View File

@ -37,6 +37,8 @@ public class VerifyAccess {
private VerifyAccess() { } // cannot instantiate
private static final int PACKAGE_ONLY = 0;
private static final int PACKAGE_ALLOWED = java.lang.invoke.MethodHandles.Lookup.PACKAGE;
private static final int PROTECTED_OR_PACKAGE_ALLOWED = (PACKAGE_ALLOWED|PROTECTED);
private static final int ALL_ACCESS_MODES = (PUBLIC|PRIVATE|PROTECTED|PACKAGE_ONLY);
private static final boolean ALLOW_NESTMATE_ACCESS = false;
@ -82,14 +84,19 @@ public class VerifyAccess {
public static boolean isMemberAccessible(Class<?> refc, // symbolic ref class
Class<?> defc, // actual def class
int mods, // actual member mods
Class<?> lookupClass) {
Class<?> lookupClass,
int allowedModes) {
if (allowedModes == 0) return false;
assert((allowedModes & PUBLIC) != 0 &&
(allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED)) == 0);
// Usually refc and defc are the same, but if they differ, verify them both.
if (refc != defc) {
if (!isClassAccessible(refc, lookupClass)) {
if (!isClassAccessible(refc, lookupClass, allowedModes)) {
// Note that defc is verified in the switch below.
return false;
}
if ((mods & (ALL_ACCESS_MODES|STATIC)) == (PROTECTED|STATIC)) {
if ((mods & (ALL_ACCESS_MODES|STATIC)) == (PROTECTED|STATIC) &&
(allowedModes & PROTECTED_OR_PACKAGE_ALLOWED) != 0) {
// Apply the special rules for refc here.
if (!isRelatedClass(refc, lookupClass))
return isSamePackage(defc, lookupClass);
@ -98,19 +105,28 @@ public class VerifyAccess {
// a superclass of the lookup class.
}
}
if (defc == lookupClass)
if (defc == lookupClass &&
(allowedModes & PRIVATE) != 0)
return true; // easy check; all self-access is OK
switch (mods & ALL_ACCESS_MODES) {
case PUBLIC:
if (refc != defc) return true; // already checked above
return isClassAccessible(refc, lookupClass);
return isClassAccessible(refc, lookupClass, allowedModes);
case PROTECTED:
return isSamePackage(defc, lookupClass) || isPublicSuperClass(defc, lookupClass);
case PACKAGE_ONLY:
return isSamePackage(defc, lookupClass);
if ((allowedModes & PROTECTED_OR_PACKAGE_ALLOWED) != 0 &&
isSamePackage(defc, lookupClass))
return true;
if ((allowedModes & PROTECTED) != 0 &&
isPublicSuperClass(defc, lookupClass))
return true;
return false;
case PACKAGE_ONLY: // That is, zero. Unmarked member is package-only access.
return ((allowedModes & PACKAGE_ALLOWED) != 0 &&
isSamePackage(defc, lookupClass));
case PRIVATE:
// Loosened rules for privates follows access rules for inner classes.
return (ALLOW_NESTMATE_ACCESS &&
(allowedModes & PRIVATE) != 0 &&
isSamePackageMember(defc, lookupClass));
default:
throw new IllegalArgumentException("bad modifiers: "+Modifier.toString(mods));
@ -138,11 +154,16 @@ public class VerifyAccess {
* @param refc the symbolic reference class to which access is being checked (C)
* @param lookupClass the class performing the lookup (D)
*/
public static boolean isClassAccessible(Class<?> refc, Class<?> lookupClass) {
public static boolean isClassAccessible(Class<?> refc, Class<?> lookupClass,
int allowedModes) {
if (allowedModes == 0) return false;
assert((allowedModes & PUBLIC) != 0 &&
(allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED)) == 0);
int mods = refc.getModifiers();
if (isPublic(mods))
return true;
if (isSamePackage(lookupClass, refc))
if ((allowedModes & PACKAGE_ALLOWED) != 0 &&
isSamePackage(lookupClass, refc))
return true;
return false;
}
@ -157,7 +178,7 @@ public class VerifyAccess {
assert(!class1.isArray() && !class2.isArray());
if (class1 == class2)
return true;
if (!loadersAreRelated(class1.getClassLoader(), class2.getClassLoader(), false))
if (class1.getClassLoader() != class2.getClassLoader())
return false;
String name1 = class1.getName(), name2 = class2.getName();
int dot = name1.lastIndexOf('.');

View File

@ -201,23 +201,20 @@ public class JarIndex {
packageName = fileName;
}
// add the mapping to indexMap
addToList(packageName, jarName, indexMap);
// add the mapping to jarMap
addToList(jarName, packageName, jarMap);
addMapping(packageName, jarName);
}
/**
* Same as add(String,String) except that it doesn't strip off from the
* last index of '/'. It just adds the filename.
* last index of '/'. It just adds the jarItem (filename or package)
* as it is received.
*/
private void addExplicit(String fileName, String jarName) {
private void addMapping(String jarItem, String jarName) {
// add the mapping to indexMap
addToList(fileName, jarName, indexMap);
addToList(jarItem, jarName, indexMap);
// add the mapping to jarMap
addToList(jarName, fileName, jarMap);
addToList(jarName, jarItem, jarMap);
}
/**
@ -248,18 +245,14 @@ public class JarIndex {
fileName.equals(JarFile.MANIFEST_NAME))
continue;
if (!metaInfFilenames) {
if (!metaInfFilenames || !fileName.startsWith("META-INF/")) {
add(fileName, currentJar);
} else {
if (!fileName.startsWith("META-INF/")) {
add(fileName, currentJar);
} else if (!entry.isDirectory()) {
} else if (!entry.isDirectory()) {
// Add files under META-INF explicitly so that certain
// services, like ServiceLoader, etc, can be located
// with greater accuracy. Directories can be skipped
// since each file will be added explicitly.
addExplicit(fileName, currentJar);
}
addMapping(fileName, currentJar);
}
}
@ -324,8 +317,7 @@ public class JarIndex {
jars.add(currentJar);
} else {
String name = line;
addToList(name, currentJar, indexMap);
addToList(currentJar, name, jarMap);
addMapping(name, currentJar);
}
}
@ -354,7 +346,7 @@ public class JarIndex {
if (path != null) {
jarName = path.concat(jarName);
}
toIndex.add(packageName, jarName);
toIndex.addMapping(packageName, jarName);
}
}
}

View File

@ -36,6 +36,11 @@ import java.nio.ByteBuffer;
public class IOUtil {
/**
* Max number of iovec structures that readv/writev supports
*/
static final int IOV_MAX;
private IOUtil() { } // No instantiation
static int write(FileDescriptor fd, ByteBuffer src, long position,
@ -111,7 +116,8 @@ public class IOUtil {
// Iterate over buffers to populate native iovec array.
int count = offset + length;
for (int i=offset; i<count; i++) {
int i = offset;
while (i < count && iov_len < IOV_MAX) {
ByteBuffer buf = bufs[i];
int pos = buf.position();
int lim = buf.limit();
@ -135,6 +141,7 @@ public class IOUtil {
vec.putLen(iov_len, rem);
iov_len++;
}
i++;
}
if (iov_len == 0)
return 0L;
@ -240,7 +247,8 @@ public class IOUtil {
// Iterate over buffers to populate native iovec array.
int count = offset + length;
for (int i=offset; i<count; i++) {
int i = offset;
while (i < count && iov_len < IOV_MAX) {
ByteBuffer buf = bufs[i];
if (buf.isReadOnly())
throw new IllegalArgumentException("Read-only buffer");
@ -264,6 +272,7 @@ public class IOUtil {
vec.putLen(iov_len, rem);
iov_len++;
}
i++;
}
if (iov_len == 0)
return 0L;
@ -336,11 +345,14 @@ public class IOUtil {
static native int fdLimit();
static native int iovMax();
static native void initIDs();
static {
// Note that IOUtil.initIDs is called from within Util.load.
Util.load();
IOV_MAX = iovMax();
}
}

View File

@ -45,7 +45,7 @@ public class Util {
// -- Caches --
// The number of temp buffers in our pool
private static final int TEMP_BUF_POOL_SIZE = 8;
private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
// Per-thread cache of temporary direct buffers
private static ThreadLocal<BufferCache> bufferCache =

View File

@ -97,6 +97,7 @@ import sun.font.FontUtilities;
import java.nio.charset.*;
import java.nio.CharBuffer;
import java.nio.ByteBuffer;
import java.nio.file.Files;
//REMIND: Remove use of this class when IPPPrintService is moved to share directory.
import java.lang.reflect.Method;
@ -659,7 +660,7 @@ public class PSPrinterJob extends RasterPrinterJob {
* is not removed for some reason, request that it is
* removed when the VM exits.
*/
spoolFile = File.createTempFile("javaprint", ".ps", null);
spoolFile = Files.createTempFile("javaprint", ".ps").toFile();
spoolFile.deleteOnExit();
result = new FileOutputStream(spoolFile);

View File

@ -429,6 +429,7 @@ public class ServiceDialog extends JDialog implements ActionListener {
ValidatingFileChooser jfc = new ValidatingFileChooser();
jfc.setApproveButtonText(getMsg("button.ok"));
jfc.setDialogTitle(getMsg("dialog.printtofile"));
jfc.setDialogType(JFileChooser.SAVE_DIALOG);
jfc.setSelectedFile(fileDest);
int returnVal = jfc.showDialog(this, null);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -43,6 +43,7 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.nio.file.Files;
import java.nio.channels.Channel;
import java.nio.channels.ServerSocketChannel;
import java.rmi.AccessException;
@ -1940,7 +1941,7 @@ public class Activation implements Serializable {
new PrivilegedExceptionAction<Void>() {
public Void run() throws IOException {
File file =
File.createTempFile("rmid-err", null, null);
Files.createTempFile("rmid-err", null).toFile();
PrintStream errStream =
new PrintStream(new FileOutputStream(file));
System.setErr(errStream);

View File

@ -90,6 +90,7 @@ class BasicChecker extends PKIXCertPathChecker {
this.date = date;
this.sigProvider = sigProvider;
this.sigOnly = sigOnly;
this.prevPubKey = trustedPubKey;
}
/**

View File

@ -1119,6 +1119,7 @@ final public class SSLEngineImpl extends SSLEngine {
* handle a few more records, so the sequence number
* of the last record cannot be wrapped.
*/
hsStatus = getHSStatus(hsStatus);
if (connectionState < cs_ERROR && !isInboundDone() &&
(hsStatus == HandshakeStatus.NOT_HANDSHAKING)) {
if (checkSequenceNumber(readMAC,
@ -1287,6 +1288,7 @@ final public class SSLEngineImpl extends SSLEngine {
* handle a few more records, so the sequence number
* of the last record cannot be wrapped.
*/
hsStatus = getHSStatus(hsStatus);
if (connectionState < cs_ERROR && !isOutboundDone() &&
(hsStatus == HandshakeStatus.NOT_HANDSHAKING)) {
if (checkSequenceNumber(writeMAC, eor.contentType())) {

View File

@ -32,8 +32,10 @@ import java.lang.reflect.InvocationTargetException;
import java.security.cert.CRLException;
import java.security.cert.CertificateException;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Map;
import java.util.TreeMap;
import sun.security.util.*;
@ -61,7 +63,8 @@ import sun.security.util.*;
*/
public class CRLExtensions {
private Hashtable<String,Extension> map = new Hashtable<String,Extension>();
private Map<String,Extension> map = Collections.synchronizedMap(
new TreeMap<String,Extension>());
private boolean unsupportedCritExt = false;
/**
@ -214,7 +217,7 @@ public class CRLExtensions {
* @return an enumeration of the extensions in this CRL.
*/
public Enumeration<Extension> getElements() {
return map.elements();
return Collections.enumeration(map.values());
}
/**

View File

@ -57,7 +57,8 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
private static final Debug debug = Debug.getInstance("x509");
private Hashtable<String,Extension> map = new Hashtable<String,Extension>();
private Map<String,Extension> map = Collections.synchronizedMap(
new TreeMap<String,Extension>());
private boolean unsupportedCritExt = false;
private Map<String,Extension> unparseableExtensions;
@ -118,7 +119,7 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
if (ext.isCritical() == false) {
// ignore errors parsing non-critical extensions
if (unparseableExtensions == null) {
unparseableExtensions = new HashMap<String,Extension>();
unparseableExtensions = new TreeMap<String,Extension>();
}
unparseableExtensions.put(ext.getExtensionId().toString(),
new UnparseableExtension(ext, e));
@ -219,6 +220,12 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
return (obj);
}
// Similar to get(String), but throw no exception, might return null.
// Used in X509CertImpl::getExtension(OID).
Extension getExtension(String name) {
return map.get(name);
}
/**
* Delete the attribute value.
* @param name the extension name used in the lookup.
@ -246,7 +253,7 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
* attribute.
*/
public Enumeration<Extension> getElements() {
return map.elements();
return Collections.enumeration(map.values());
}
/**

View File

@ -30,14 +30,7 @@ import java.security.cert.CRLException;
import java.security.cert.CRLReason;
import java.security.cert.X509CRLEntry;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.*;
import javax.security.auth.x500.X500Principal;
@ -74,7 +67,8 @@ import sun.misc.HexDumpEncoder;
* @author Hemma Prafullchandra
*/
public class X509CRLEntryImpl extends X509CRLEntry {
public class X509CRLEntryImpl extends X509CRLEntry
implements Comparable<X509CRLEntryImpl> {
private SerialNumber serialNumber = null;
private Date revocationDate = null;
@ -195,9 +189,14 @@ public class X509CRLEntryImpl extends X509CRLEntry {
* @exception CRLException if an encoding error occurs.
*/
public byte[] getEncoded() throws CRLException {
return getEncoded0().clone();
}
// Called internally to avoid clone
private byte[] getEncoded0() throws CRLException {
if (revokedCert == null)
this.encode(new DerOutputStream());
return revokedCert.clone();
return revokedCert;
}
@Override
@ -351,7 +350,7 @@ public class X509CRLEntryImpl extends X509CRLEntry {
if (extensions == null) {
return null;
}
Set<String> extSet = new HashSet<String>();
Set<String> extSet = new TreeSet<>();
for (Extension ex : extensions.getAllExtensions()) {
if (ex.isCritical()) {
extSet.add(ex.getExtensionId().toString());
@ -372,7 +371,7 @@ public class X509CRLEntryImpl extends X509CRLEntry {
if (extensions == null) {
return null;
}
Set<String> extSet = new HashSet<String>();
Set<String> extSet = new TreeSet<>();
for (Extension ex : extensions.getAllExtensions()) {
if (!ex.isCritical()) {
extSet.add(ex.getExtensionId().toString());
@ -500,16 +499,39 @@ public class X509CRLEntryImpl extends X509CRLEntry {
getExtension(PKIXExtensions.CertificateIssuer_Id);
}
/**
* Returns all extensions for this entry in a map
* @return the extension map, can be empty, but not null
*/
public Map<String, java.security.cert.Extension> getExtensions() {
if (extensions == null) {
return Collections.emptyMap();
}
Collection<Extension> exts = extensions.getAllExtensions();
HashMap<String, java.security.cert.Extension> map =
new HashMap<String, java.security.cert.Extension>(exts.size());
Map<String, java.security.cert.Extension> map = new TreeMap<>();
for (Extension ext : exts) {
map.put(ext.getId(), ext);
}
return map;
}
@Override
public int compareTo(X509CRLEntryImpl that) {
int compSerial = getSerialNumber().compareTo(that.getSerialNumber());
if (compSerial != 0) {
return compSerial;
}
try {
byte[] thisEncoded = this.getEncoded0();
byte[] thatEncoded = that.getEncoded0();
for (int i=0; i<thisEncoded.length && i<thatEncoded.length; i++) {
int a = thisEncoded[i] & 0xff;
int b = thatEncoded[i] & 0xff;
if (a != b) return a-b;
}
return thisEncoded.length -thatEncoded.length;
} catch (CRLException ce) {
return -1;
}
}
}

View File

@ -52,7 +52,7 @@ import sun.misc.HexDumpEncoder;
/**
* <p>
* An implmentation for X509 CRL (Certificate Revocation List).
* An implementation for X509 CRL (Certificate Revocation List).
* <p>
* The X.509 v2 CRL format is described below in ASN.1:
* <pre>
@ -103,7 +103,8 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
private X500Principal issuerPrincipal = null;
private Date thisUpdate = null;
private Date nextUpdate = null;
private Map<X509IssuerSerial,X509CRLEntry> revokedCerts = new LinkedHashMap<X509IssuerSerial,X509CRLEntry>();
private Map<X509IssuerSerial,X509CRLEntry> revokedMap = new TreeMap<>();
private List<X509CRLEntry> revokedList = new LinkedList<>();
private CRLExtensions extensions = null;
private final static boolean isExplicit = true;
private static final long YR_2050 = 2524636800000L;
@ -222,7 +223,8 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
badCert.setCertificateIssuer(crlIssuer, badCertIssuer);
X509IssuerSerial issuerSerial = new X509IssuerSerial
(badCertIssuer, badCert.getSerialNumber());
this.revokedCerts.put(issuerSerial, badCert);
this.revokedMap.put(issuerSerial, badCert);
this.revokedList.add(badCert);
if (badCert.hasExtensions()) {
this.version = 1;
}
@ -304,8 +306,8 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
tmp.putGeneralizedTime(nextUpdate);
}
if (!revokedCerts.isEmpty()) {
for (X509CRLEntry entry : revokedCerts.values()) {
if (!revokedList.isEmpty()) {
for (X509CRLEntry entry : revokedList) {
((X509CRLEntryImpl)entry).encode(rCerts);
}
tmp.write(DerValue.tag_Sequence, rCerts);
@ -489,14 +491,14 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
sb.append("\nThis Update: " + thisUpdate.toString() + "\n");
if (nextUpdate != null)
sb.append("Next Update: " + nextUpdate.toString() + "\n");
if (revokedCerts.isEmpty())
if (revokedList.isEmpty())
sb.append("\nNO certificates have been revoked\n");
else {
sb.append("\nRevoked Certificates: " + revokedCerts.size());
sb.append("\nRevoked Certificates: " + revokedList.size());
int i = 1;
for (Iterator<X509CRLEntry> iter = revokedCerts.values().iterator();
iter.hasNext(); i++)
sb.append("\n[" + i + "] " + iter.next().toString());
for (X509CRLEntry entry: revokedList) {
sb.append("\n[" + i++ + "] " + entry.toString());
}
}
if (extensions != null) {
Collection<Extension> allExts = extensions.getAllExtensions();
@ -542,12 +544,12 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
* false otherwise.
*/
public boolean isRevoked(Certificate cert) {
if (revokedCerts.isEmpty() || (!(cert instanceof X509Certificate))) {
if (revokedMap.isEmpty() || (!(cert instanceof X509Certificate))) {
return false;
}
X509Certificate xcert = (X509Certificate) cert;
X509IssuerSerial issuerSerial = new X509IssuerSerial(xcert);
return revokedCerts.containsKey(issuerSerial);
return revokedMap.containsKey(issuerSerial);
}
/**
@ -637,24 +639,24 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
* @see X509CRLEntry
*/
public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
if (revokedCerts.isEmpty()) {
if (revokedMap.isEmpty()) {
return null;
}
// assume this is a direct CRL entry (cert and CRL issuer are the same)
X509IssuerSerial issuerSerial = new X509IssuerSerial
(getIssuerX500Principal(), serialNumber);
return revokedCerts.get(issuerSerial);
return revokedMap.get(issuerSerial);
}
/**
* Gets the CRL entry for the given certificate.
*/
public X509CRLEntry getRevokedCertificate(X509Certificate cert) {
if (revokedCerts.isEmpty()) {
if (revokedMap.isEmpty()) {
return null;
}
X509IssuerSerial issuerSerial = new X509IssuerSerial(cert);
return revokedCerts.get(issuerSerial);
return revokedMap.get(issuerSerial);
}
/**
@ -666,10 +668,10 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
* @see X509CRLEntry
*/
public Set<X509CRLEntry> getRevokedCertificates() {
if (revokedCerts.isEmpty()) {
if (revokedList.isEmpty()) {
return null;
} else {
return new HashSet<X509CRLEntry>(revokedCerts.values());
return new TreeSet<X509CRLEntry>(revokedList);
}
}
@ -905,7 +907,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
if (extensions == null) {
return null;
}
Set<String> extSet = new HashSet<String>();
Set<String> extSet = new TreeSet<>();
for (Extension ex : extensions.getAllExtensions()) {
if (ex.isCritical()) {
extSet.add(ex.getExtensionId().toString());
@ -926,7 +928,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
if (extensions == null) {
return null;
}
Set<String> extSet = new HashSet<String>();
Set<String> extSet = new TreeSet<>();
for (Extension ex : extensions.getAllExtensions()) {
if (!ex.isCritical()) {
extSet.add(ex.getExtensionId().toString());
@ -1103,7 +1105,8 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
entry.setCertificateIssuer(crlIssuer, badCertIssuer);
X509IssuerSerial issuerSerial = new X509IssuerSerial
(badCertIssuer, entry.getSerialNumber());
revokedCerts.put(issuerSerial, entry);
revokedMap.put(issuerSerial, entry);
revokedList.add(entry);
}
}
@ -1207,7 +1210,8 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
/**
* Immutable X.509 Certificate Issuer DN and serial number pair
*/
private final static class X509IssuerSerial {
private final static class X509IssuerSerial
implements Comparable<X509IssuerSerial> {
final X500Principal issuer;
final BigInteger serial;
volatile int hashcode = 0;
@ -1286,5 +1290,13 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
}
return hashcode;
}
@Override
public int compareTo(X509IssuerSerial another) {
int cissuer = issuer.toString()
.compareTo(another.issuer.toString());
if (cissuer != 0) return cissuer;
return this.serial.compareTo(another.serial);
}
}
}

View File

@ -1202,7 +1202,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
if (exts == null) {
return null;
}
Set<String> extSet = new HashSet<String>();
Set<String> extSet = new TreeSet<>();
for (Extension ex : exts.getAllExtensions()) {
if (ex.isCritical()) {
extSet.add(ex.getExtensionId().toString());
@ -1232,7 +1232,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
if (exts == null) {
return null;
}
Set<String> extSet = new HashSet<String>();
Set<String> extSet = new TreeSet<>();
for (Extension ex : exts.getAllExtensions()) {
if (!ex.isCritical()) {
extSet.add(ex.getExtensionId().toString());
@ -1266,10 +1266,14 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
if (extensions == null) {
return null;
} else {
for (Extension ex : extensions.getAllExtensions()) {
if (ex.getExtensionId().equals((Object)oid)) {
Extension ex = extensions.getExtension(oid.toString());
if (ex != null) {
return ex;
}
for (Extension ex2: extensions.getAllExtensions()) {
if (ex2.getExtensionId().equals((Object)oid)) {
//XXXX May want to consider cloning this
return ex;
return ex2;
}
}
/* no such extension in this certificate */
@ -1465,10 +1469,10 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
if (names.isEmpty()) {
return Collections.<List<?>>emptySet();
}
Set<List<?>> newNames = new HashSet<List<?>>();
List<List<?>> newNames = new ArrayList<>();
for (GeneralName gname : names.names()) {
GeneralNameInterface name = gname.getName();
List<Object> nameEntry = new ArrayList<Object>(2);
List<Object> nameEntry = new ArrayList<>(2);
nameEntry.add(Integer.valueOf(name.getType()));
switch (name.getType()) {
case GeneralNameInterface.NAME_RFC822:
@ -1526,12 +1530,12 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
}
}
if (mustClone) {
Set<List<?>> namesCopy = new HashSet<List<?>>();
List<List<?>> namesCopy = new ArrayList<>();
for (List<?> nameEntry : altNames) {
Object nameObject = nameEntry.get(1);
if (nameObject instanceof byte[]) {
List<Object> nameEntryCopy =
new ArrayList<Object>(nameEntry);
new ArrayList<>(nameEntry);
nameEntryCopy.set(1, ((byte[])nameObject).clone());
namesCopy.add(Collections.unmodifiableList(nameEntryCopy));
} else {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -137,7 +137,7 @@ class Main {
File dir = file.getParentFile();
if (dir == null)
dir = new File(".");
return File.createTempFile("jartmp", null, dir);
return Files.createTempFile(dir.toPath(), "jartmp", null).toFile();
}
private boolean ok;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -71,6 +71,7 @@ import java.text.MessageFormat;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.file.Files;
import java.io.UnsupportedEncodingException;
import java.nio.charset.UnsupportedCharsetException;
import sun.tools.native2ascii.A2NFilter;
@ -240,9 +241,7 @@ public class Main {
if (tempDir == null)
tempDir = new File(System.getProperty("user.dir"));
tempFile = File.createTempFile("_N2A",
".TMP",
tempDir);
tempFile = Files.createTempFile(tempDir.toPath(), "_N2A", ".TMP").toFile();
tempFile.deleteOnExit();
try {
@ -292,9 +291,7 @@ public class Main {
File tempDir = f.getParentFile();
if (tempDir == null)
tempDir = new File(System.getProperty("user.dir"));
tempFile = File.createTempFile("_N2A",
".TMP",
tempDir);
tempFile = Files.createTempFile(tempDir.toPath(), "_N2A", ".TMP").toFile();
tempFile.deleteOnExit();
try {

View File

@ -120,7 +120,7 @@ typedef struct LookupTable {
TableIndex table_incr; /* Suggested increment size. */
TableIndex hash_bucket_count; /* Number of hash buckets. */
int elem_size; /* Size of element. */
int info_size; /* Size of info structure. */
int info_size; /* Size of info structure (can be 0). */
void *freed_bv; /* Freed element bit vector */
int freed_count; /* Count of freed'd elements */
TableIndex freed_start; /* First freed in table */
@ -208,9 +208,6 @@ get_info(LookupTable *ltable, TableIndex index)
{
TableElement *element;
if ( ltable->info_size == 0 ) {
return NULL;
}
element = (TableElement*)ELEMENT_PTR(ltable,index);
return element->info;
}
@ -760,7 +757,11 @@ table_walk_items(LookupTable *ltable, LookupTableIterator func, void* arg)
void *info;
get_key(ltable, index, &key_ptr, &key_len);
info = get_info(ltable, index);
if ( ltable->info_size == 0 ) {
info = NULL;
} else {
info = get_info(ltable, index);
}
(*func)(SANITY_ADD_HARE(index, ltable->hare), key_ptr, key_len, info, arg);
if ( is_freed_entry(ltable, index) ) {
fcount++;

View File

@ -132,10 +132,10 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# corresponding RuntimePermission ("defineClassInPackage."+package) has
# been granted.
#
# by default, no packages are restricted for definition, and none of
# the class loaders supplied with the JDK call checkPackageDefinition.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
#package.definition=
package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# Determines whether this properties file can be appended to

View File

@ -133,10 +133,10 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# corresponding RuntimePermission ("defineClassInPackage."+package) has
# been granted.
#
# by default, no packages are restricted for definition, and none of
# the class loaders supplied with the JDK call checkPackageDefinition.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
#package.definition=
package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# Determines whether this properties file can be appended to

View File

@ -134,10 +134,10 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# corresponding RuntimePermission ("defineClassInPackage."+package) has
# been granted.
#
# by default, no packages are restricted for definition, and none of
# the class loaders supplied with the JDK call checkPackageDefinition.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
#package.definition=
package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# Determines whether this properties file can be appended to

View File

@ -133,10 +133,10 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# corresponding RuntimePermission ("defineClassInPackage."+package) has
# been granted.
#
# by default, no packages are restricted for definition, and none of
# the class loaders supplied with the JDK call checkPackageDefinition.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
#package.definition=
package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# Determines whether this properties file can be appended to

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -68,6 +68,8 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
*/
IPv6_available = IPv6_supported() & (!preferIPv4Stack);
initLocalAddrTable ();
parseExclusiveBindProperty(env);
return JNI_VERSION_1_2;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -120,6 +120,7 @@ JNIEXPORT jobject JNICALL
NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port);
void initLocalAddrTable ();
void parseExclusiveBindProperty(JNIEnv *env);
void
NET_SetTrafficClass(struct sockaddr *him, int trafficClass);

View File

@ -337,7 +337,7 @@ sun_jpeg_fill_suspended_buffer(j_decompress_ptr cinfo)
/* Save the data currently in the buffer */
offset = src->pub.bytes_in_buffer;
if (src->pub.next_input_byte > src->inbuf) {
memcpy(src->inbuf, src->pub.next_input_byte, offset);
memmove(src->inbuf, src->pub.next_input_byte, offset);
}
RELEASE_ARRAYS(env, src);
buflen = (*env)->GetArrayLength(env, src->hInputBuffer) - offset;

View File

@ -95,6 +95,10 @@ le_int32 LookupProcessor::process(LEGlyphStorage &glyphStorage, GlyphPositionAdj
if (selectMask != 0) {
const LookupTable *lookupTable = lookupListTable->getLookupTable(lookup);
if (!lookupTable)
continue;
le_uint16 lookupFlags = SWAPW(lookupTable->lookupFlags);
glyphIterator.reset(lookupFlags, selectMask);
@ -136,6 +140,9 @@ le_int32 LookupProcessor::selectLookups(const FeatureTable *featureTable, Featur
for (le_uint16 lookup = 0; lookup < lookupCount; lookup += 1) {
le_uint16 lookupListIndex = SWAPW(featureTable->lookupListIndexArray[lookup]);
if (lookupListIndex >= lookupSelectCount)
continue;
lookupSelectArray[lookupListIndex] |= featureMask;
lookupOrderArray[store++] = lookupListIndex;
}
@ -147,7 +154,7 @@ LookupProcessor::LookupProcessor(const char *baseAddress,
Offset scriptListOffset, Offset featureListOffset, Offset lookupListOffset,
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool orderFeatures,
LEErrorCode& success)
: lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL),
: lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL), lookupSelectCount(0),
lookupOrderArray(NULL), lookupOrderCount(0)
{
const ScriptListTable *scriptListTable = NULL;
@ -195,6 +202,8 @@ LookupProcessor::LookupProcessor(const char *baseAddress,
lookupSelectArray[i] = 0;
}
lookupSelectCount = lookupListCount;
le_int32 count, order = 0;
le_int32 featureReferences = 0;
const FeatureTable *featureTable = NULL;
@ -211,6 +220,10 @@ LookupProcessor::LookupProcessor(const char *baseAddress,
le_uint16 featureIndex = SWAPW(langSysTable->featureIndexArray[feature]);
featureTable = featureListTable->getFeatureTable(featureIndex, &featureTag);
if (!featureTable)
continue;
featureReferences += SWAPW(featureTable->lookupCount);
}

View File

@ -90,6 +90,7 @@ protected:
const FeatureListTable *featureListTable;
FeatureMask *lookupSelectArray;
le_uint32 lookupSelectCount;
le_uint16 *lookupOrderArray;
le_uint32 lookupOrderCount;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,7 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Properties;
@ -387,7 +388,7 @@ public class FcFontConfiguration extends FontConfiguration {
File fcInfoFile = getFcInfoFile();
File dir = fcInfoFile.getParentFile();
dir.mkdirs();
File tempFile = File.createTempFile("fcinfo", null, dir);
File tempFile = Files.createTempFile(dir.toPath(), "fcinfo", null).toFile();
FileOutputStream fos = new FileOutputStream(tempFile);
props.store(fos,
"JDK Font Configuration Generated File: *Do Not Edit*");

View File

@ -278,14 +278,26 @@ public class CUPSPrinter {
is);
is.close();
if (responseMap.length > 0) {
if (responseMap != null && responseMap.length > 0) {
defaultMap = responseMap[0];
}
if (defaultMap == null) {
os.close();
urlConnection.disconnect();
return null;
/* CUPS on OS X, as initially configured, considers the
* default printer to be the last one used that's
* presently available. So if no default was
* reported, exec lpstat -d which has all the Apple
* special behaviour for this built in.
*/
if (UnixPrintServiceLookup.isMac()) {
return UnixPrintServiceLookup.
getDefaultPrinterNameSysV();
} else {
return null;
}
}
AttributeClass attribClass = (AttributeClass)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -42,6 +42,7 @@ import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.util.Vector;
import javax.print.CancelablePrintJob;
@ -938,7 +939,7 @@ public class UnixPrintJob implements CancelablePrintJob {
* is not removed for some reason, request that it is
* removed when the VM exits.
*/
spoolFile = File.createTempFile("javaprint", ".ps", null);
spoolFile = Files.createTempFile("javaprint", ".ps").toFile();
spoolFile.deleteOnExit();
}
result = new FileOutputStream(spoolFile);

View File

@ -51,6 +51,7 @@ import javax.print.attribute.standard.PrinterName;
import java.io.File;
import java.io.FileReader;
import java.net.URL;
import java.nio.file.Files;
/*
* Remind: This class uses solaris commands. We also need a linux
@ -114,6 +115,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
new sun.security.action.GetPropertyAction("os.name"));
}
static boolean isMac() {
return osname.startsWith("Mac");
}
static boolean isSysV() {
return osname.equals("SunOS");
}
@ -212,7 +217,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
}
}
} else {
if (isSysV()) {
if (isMac() || isSysV()) {
printers = getAllPrinterNamesSysV();
} else { //BSD
printers = getAllPrinterNamesBSD();
@ -361,7 +366,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
if (name == null || name.equals("") || !checkPrinterName(name)) {
return null;
}
if (isSysV()) {
if (isMac() || isSysV()) {
printer = getNamedPrinterNameSysV(name);
} else {
printer = getNamedPrinterNameBSD(name);
@ -523,7 +528,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
if (CUPSPrinter.isCupsRunning()) {
defaultPrinter = CUPSPrinter.getDefaultPrinter();
} else {
if (isSysV()) {
if (isMac() || isSysV()) {
defaultPrinter = getDefaultPrinterNameSysV();
} else {
defaultPrinter = getDefaultPrinterNameBSD();
@ -644,7 +649,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
return names;
}
private String getDefaultPrinterNameSysV() {
static String getDefaultPrinterNameSysV() {
String defaultPrinter = "lp";
String command = "/usr/bin/lpstat -d";
@ -714,7 +719,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
Process proc;
BufferedReader bufferedReader = null;
File f = File.createTempFile("prn","xc");
File f = Files.createTempFile("prn","xc").toFile();
cmd[2] = cmd[2]+">"+f.getAbsolutePath();
proc = Runtime.getRuntime().exec(cmd);

View File

@ -119,9 +119,13 @@ md_connect(char *hostname, unsigned short port)
/* create a socket */
fd = socket(AF_INET, SOCK_STREAM, 0);
if ( fd < 0 ) {
return -1;
}
/* find remote host's addr from name */
if ((hentry = gethostbyname(hostname)) == NULL) {
(void)close(fd);
return -1;
}
(void)memset((char *)&s, 0, sizeof(s));
@ -134,6 +138,7 @@ md_connect(char *hostname, unsigned short port)
/* now try connecting */
if (-1 == connect(fd, (struct sockaddr*)&s, sizeof(s))) {
(void)close(fd);
return 0;
}
return fd;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -76,7 +76,7 @@ gai_strerror_f gai_strerror_ptr = NULL;
getnameinfo_f getnameinfo_ptr = NULL;
/*
* EXCLBIND socket options only on Solaris 8 & 9.
* EXCLBIND socket options only on Solaris
*/
#if defined(__solaris__) && !defined(TCP_EXCLBIND)
#define TCP_EXCLBIND 0x21
@ -131,6 +131,7 @@ int getDefaultScopeID(JNIEnv *env) {
static int init_tcp_max_buf, init_udp_max_buf;
static int tcp_max_buf;
static int udp_max_buf;
static int useExclBind = 0;
/*
* Get the specified parameter from the specified driver. The value
@ -765,6 +766,26 @@ void initLocalAddrTable () {}
#endif
void parseExclusiveBindProperty(JNIEnv *env) {
#ifdef __solaris__
jstring s, flagSet;
jclass iCls;
jmethodID mid;
s = (*env)->NewStringUTF(env, "sun.net.useExclusiveBind");
CHECK_NULL(s);
iCls = (*env)->FindClass(env, "java/lang/System");
CHECK_NULL(iCls);
mid = (*env)->GetStaticMethodID(env, iCls, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;");
CHECK_NULL(mid);
flagSet = (*env)->CallStaticObjectMethod(env, iCls, mid, s);
if (flagSet != NULL) {
useExclBind = 1;
}
#endif
}
/* In the case of an IPv4 Inetaddress this method will return an
* IPv4 mapped address where IPv6 is available and v4MappedAddress is TRUE.
* Otherwise it will return a sockaddr_in structure for an IPv4 InetAddress.
@ -1478,8 +1499,8 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
* Linux allows a socket to bind to 127.0.0.255 which must be
* caught.
*
* On Solaris 8/9 with IPv6 enabled we must use an exclusive
* bind to guaranteed a unique port number across the IPv4 and
* On Solaris with IPv6 enabled we must use an exclusive
* bind to guarantee a unique port number across the IPv4 and
* IPv6 port spaces.
*
*/
@ -1509,10 +1530,10 @@ NET_Bind(int fd, struct sockaddr *him, int len)
#if defined(__solaris__) && defined(AF_INET6)
/*
* Solaris 8/9 have seperate IPv4 and IPv6 port spaces so we
* Solaris has separate IPv4 and IPv6 port spaces so we
* use an exclusive bind when SO_REUSEADDR is not used to
* give the illusion of a unified port space.
* This also avoid problems with IPv6 sockets connecting
* This also avoids problems with IPv6 sockets connecting
* to IPv4 mapped addresses whereby the socket conversion
* results in a late bind that fails because the
* corresponding IPv4 port is in use.
@ -1521,11 +1542,12 @@ NET_Bind(int fd, struct sockaddr *him, int len)
int arg, len;
len = sizeof(arg);
if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg,
&len) == 0) {
if (arg == 0) {
if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
(char *)&arg, &len) == 0) {
if (useExclBind || arg == 0) {
/*
* SO_REUSEADDR is disabled so enable TCP_EXCLBIND or
* SO_REUSEADDR is disabled or sun.net.useExclusiveBind
* property is true so enable TCP_EXCLBIND or
* UDP_EXCLBIND
*/
len = sizeof(arg);

View File

@ -94,9 +94,6 @@ Java_sun_nio_ch_FileDispatcherImpl_readv0(JNIEnv *env, jclass clazz,
{
jint fd = fdval(env, fdo);
struct iovec *iov = (struct iovec *)jlong_to_ptr(address);
if (len > 16) {
len = 16;
}
return convertLongReturnVal(env, readv(fd, iov, len), JNI_TRUE);
}
@ -126,9 +123,6 @@ Java_sun_nio_ch_FileDispatcherImpl_writev0(JNIEnv *env, jclass clazz,
{
jint fd = fdval(env, fdo);
struct iovec *iov = (struct iovec *)jlong_to_ptr(address);
if (len > 16) {
len = 16;
}
return convertLongReturnVal(env, writev(fd, iov, len), JNI_FALSE);
}

View File

@ -136,6 +136,16 @@ Java_sun_nio_ch_IOUtil_fdLimit(JNIEnv *env, jclass this)
}
}
JNIEXPORT jint JNICALL
Java_sun_nio_ch_IOUtil_iovMax(JNIEnv *env, jclass this)
{
jlong iov_max = sysconf(_SC_IOV_MAX);
if (iov_max == -1)
iov_max = 16;
return (jint)iov_max;
}
/* Declared in nio_util.h for use elsewhere in NIO */
jint

View File

@ -126,6 +126,7 @@ DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
}
void initLocalAddrTable () {}
void parseExclusiveBindProperty (JNIEnv *env) {}
/*
* Since winsock doesn't have the equivalent of strerror(errno)

View File

@ -151,7 +151,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
VOID *pInput = 0;
DWORD inputLen;
CHAR buffOut[512];
CHAR buffOut[1024];
jboolean isCopy;
SECURITY_STATUS ss;
SecBufferDesc OutBuffDesc;
@ -178,7 +178,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
OutBuffDesc.cBuffers = 1;
OutBuffDesc.pBuffers = &OutSecBuff;
OutSecBuff.cbBuffer = 512;
OutSecBuff.cbBuffer = 1024;
OutSecBuff.BufferType = SECBUFFER_TOKEN;
OutSecBuff.pvBuffer = buffOut;

View File

@ -41,9 +41,6 @@ static jfieldID handle_fdID;
/* field id for jint 'fd' in java.io.FileDescriptor used for socket fds */
static jfieldID fd_fdID;
/* false for 95/98/ME, true for NT/W2K */
static jboolean onNT = JNI_FALSE;
JNIEXPORT jboolean JNICALL
Java_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed
(JNIEnv *env, jclass clazz, jbyteArray randArray);
@ -55,13 +52,6 @@ Java_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed
JNIEXPORT void JNICALL
Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz)
{
OSVERSIONINFO ver;
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
onNT = JNI_TRUE;
}
clazz = (*env)->FindClass(env, "java/io/FileDescriptor");
fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I");
handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J");
@ -80,6 +70,13 @@ Java_sun_nio_ch_IOUtil_randomBytes(JNIEnv *env, jclass clazz,
randArray);
}
JNIEXPORT jint JNICALL
Java_sun_nio_ch_IOUtil_iovMax(JNIEnv *env, jclass this)
{
return 16;
}
jint
convertReturnVal(JNIEnv *env, jint n, jboolean reading)
{
@ -205,9 +202,3 @@ handleval(JNIEnv *env, jobject fdo)
{
return (*env)->GetLongField(env, fdo, handle_fdID);
}
jboolean
isNT()
{
return onNT;
}

View File

@ -97,10 +97,6 @@ Java_sun_nio_ch_SocketDispatcher_readv0(JNIEnv *env, jclass clazz, jobject fdo,
return IOS_THROWN;
}
if ((isNT() == JNI_FALSE) && (len > 16)) {
len = 16;
}
/* copy iovec into WSABUF */
for(i=0; i<len; i++) {
jint iov_len = iovp[i].iov_len;
@ -141,41 +137,54 @@ Java_sun_nio_ch_SocketDispatcher_readv0(JNIEnv *env, jclass clazz, jobject fdo,
JNIEXPORT jint JNICALL
Java_sun_nio_ch_SocketDispatcher_write0(JNIEnv *env, jclass clazz, jobject fdo,
jlong address, jint len)
jlong address, jint total)
{
/* set up */
int i = 0;
DWORD written = 0;
jint count = 0;
jint fd = fdval(env, fdo);
WSABUF buf;
/* limit size */
if (len > MAX_BUFFER_SIZE)
len = MAX_BUFFER_SIZE;
do {
/* limit size */
jint len = total - count;
if (len > MAX_BUFFER_SIZE)
len = MAX_BUFFER_SIZE;
/* copy iovec into WSABUF */
buf.buf = (char *)address;
buf.len = (u_long)len;
/* copy iovec into WSABUF */
buf.buf = (char *)address;
buf.len = (u_long)len;
/* read into the buffers */
i = WSASend((SOCKET)fd, /* Socket */
&buf, /* pointers to the buffers */
(DWORD)1, /* number of buffers to process */
&written, /* receives number of bytes written */
0, /* no flags */
0, /* no overlapped sockets */
0); /* no completion routine */
/* write from the buffer */
i = WSASend((SOCKET)fd, /* Socket */
&buf, /* pointers to the buffers */
(DWORD)1, /* number of buffers to process */
&written, /* receives number of bytes written */
0, /* no flags */
0, /* no overlapped sockets */
0); /* no completion routine */
if (i == SOCKET_ERROR) {
int theErr = (jint)WSAGetLastError();
if (theErr == WSAEWOULDBLOCK) {
return IOS_UNAVAILABLE;
if (i == SOCKET_ERROR) {
if (count > 0) {
/* can't throw exception when some bytes have been written */
break;
} else {
int theErr = (jint)WSAGetLastError();
if (theErr == WSAEWOULDBLOCK) {
return IOS_UNAVAILABLE;
}
JNU_ThrowIOExceptionWithLastError(env, "Write failed");
return IOS_THROWN;
}
}
JNU_ThrowIOExceptionWithLastError(env, "Write failed");
return IOS_THROWN;
}
return convertReturnVal(env, (jint)written, JNI_FALSE);
count += written;
address += written;
} while ((count < total) && (written == MAX_BUFFER_SIZE));
return count;
}
JNIEXPORT jlong JNICALL
@ -195,10 +204,6 @@ Java_sun_nio_ch_SocketDispatcher_writev0(JNIEnv *env, jclass clazz,
return IOS_THROWN;
}
if ((isNT() == JNI_FALSE) && (len > 16)) {
len = 16;
}
/* copy iovec into WSABUF */
for(i=0; i<len; i++) {
jint iov_len = iovp[i].iov_len;

View File

@ -35,7 +35,6 @@
jint fdval(JNIEnv *env, jobject fdo);
jlong handleval(JNIEnv *env, jobject fdo);
jboolean isNT();
jint convertReturnVal(JNIEnv *env, jint n, jboolean r);
jlong convertLongReturnVal(JNIEnv *env, jlong n, jboolean r);
jboolean purgeOutstandingICMP(JNIEnv *env, jclass clazz, jint fd);

View File

@ -287,6 +287,9 @@ java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java generic-al
# jdk_security
# 7177556
com/sun/crypto/provider/KeyFactory/TestProviderLeak.java generic-all
# 7147060
com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all

View File

@ -0,0 +1,495 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @summary test access checking by java.lang.invoke.MethodHandles.Lookup
* @library ../../../..
* @build test.java.lang.invoke.AccessControlTest
* @build test.java.lang.invoke.AccessControlTest_subpkg.Acquaintance_remote
* @run junit/othervm test.java.lang.invoke.AccessControlTest
*/
package test.java.lang.invoke;
import java.lang.invoke.*;
import java.lang.reflect.*;
import java.util.*;
import org.junit.*;
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodHandles.Lookup.*;
import static java.lang.invoke.MethodType.*;
import static org.junit.Assert.*;
import test.java.lang.invoke.AccessControlTest_subpkg.Acquaintance_remote;
/**
* Test many combinations of Lookup access and cross-class lookupStatic.
* @author jrose
*/
public class AccessControlTest {
static final Class<?> THIS_CLASS = AccessControlTest.class;
// How much output?
static int verbosity = 0;
static {
String vstr = System.getProperty(THIS_CLASS.getSimpleName()+".verbosity");
if (vstr == null)
vstr = System.getProperty(THIS_CLASS.getName()+".verbosity");
if (vstr != null) verbosity = Integer.parseInt(vstr);
}
private class LookupCase implements Comparable<LookupCase> {
final Lookup lookup;
final Class<?> lookupClass;
final int lookupModes;
public LookupCase(Lookup lookup) {
this.lookup = lookup;
this.lookupClass = lookup.lookupClass();
this.lookupModes = lookup.lookupModes();
assert(lookupString().equals(lookup.toString()));
numberOf(lookupClass().getClassLoader()); // assign CL#
}
public LookupCase(Class<?> lookupClass, int lookupModes) {
this.lookup = null;
this.lookupClass = lookupClass;
this.lookupModes = lookupModes;
numberOf(lookupClass().getClassLoader()); // assign CL#
}
public final Class<?> lookupClass() { return lookupClass; }
public final int lookupModes() { return lookupModes; }
public Lookup lookup() { lookup.getClass(); return lookup; }
@Override
public int compareTo(LookupCase that) {
Class<?> c1 = this.lookupClass();
Class<?> c2 = that.lookupClass();
if (c1 != c2) {
int cmp = c1.getName().compareTo(c2.getName());
if (cmp != 0) return cmp;
cmp = numberOf(c1.getClassLoader()) - numberOf(c2.getClassLoader());
assert(cmp != 0);
return cmp;
}
return -(this.lookupModes() - that.lookupModes());
}
@Override
public boolean equals(Object that) {
return (that instanceof LookupCase && equals((LookupCase)that));
}
public boolean equals(LookupCase that) {
return (this.lookupClass() == that.lookupClass() &&
this.lookupModes() == that.lookupModes());
}
@Override
public int hashCode() {
return lookupClass().hashCode() + (lookupModes() * 31);
}
/** Simulate all assertions in the spec. for Lookup.toString. */
private String lookupString() {
String name = lookupClass.getName();
String suffix = "";
if (lookupModes == 0)
suffix = "/noaccess";
else if (lookupModes == PUBLIC)
suffix = "/public";
else if (lookupModes == (PUBLIC|PACKAGE))
suffix = "/package";
else if (lookupModes == (PUBLIC|PACKAGE|PRIVATE))
suffix = "/private";
else if (lookupModes == (PUBLIC|PACKAGE|PRIVATE|PROTECTED))
suffix = "";
else
suffix = "/#"+Integer.toHexString(lookupModes);
return name+suffix;
}
/** Simulate all assertions from the spec. for Lookup.in:
* <hr/>
* Creates a lookup on the specified new lookup class.
* [A1] The resulting object will report the specified
* class as its own {@link #lookupClass lookupClass}.
* <p>
* [A2] However, the resulting {@code Lookup} object is guaranteed
* to have no more access capabilities than the original.
* In particular, access capabilities can be lost as follows:<ul>
* <li>[A3] If the new lookup class differs from the old one,
* protected members will not be accessible by virtue of inheritance.
* (Protected members may continue to be accessible because of package sharing.)
* <li>[A4] If the new lookup class is in a different package
* than the old one, protected and default (package) members will not be accessible.
* <li>[A5] If the new lookup class is not within the same package member
* as the old one, private members will not be accessible.
* <li>[A6] If the new lookup class is not accessible to the old lookup class,
* using the original access modes,
* then no members, not even public members, will be accessible.
* [A7] (In all other cases, public members will continue to be accessible.)
* </ul>
* Other than the above cases, the new lookup will have the same
* access capabilities as the original. [A8]
* <hr/>
*/
public LookupCase in(Class<?> c2) {
Class<?> c1 = lookupClass();
int m1 = lookupModes();
int changed = 0;
boolean samePackage = (c1.getClassLoader() == c2.getClassLoader() &&
packagePrefix(c1).equals(packagePrefix(c2)));
boolean sameTopLevel = (topLevelClass(c1) == topLevelClass(c2));
boolean sameClass = (c1 == c2);
assert(samePackage || !sameTopLevel);
assert(sameTopLevel || !sameClass);
boolean accessible = sameClass; // [A6]
if ((m1 & PACKAGE) != 0) accessible |= samePackage;
if ((m1 & PUBLIC ) != 0) accessible |= (c2.getModifiers() & PUBLIC) != 0;
if (!accessible) {
// Different package and no access to c2; lose all access.
changed |= (PUBLIC|PACKAGE|PRIVATE|PROTECTED); // [A6]
}
if (!samePackage) {
// Different package; lose PACKAGE and lower access.
changed |= (PACKAGE|PRIVATE|PROTECTED); // [A4]
}
if (!sameTopLevel) {
// Different top-level class. Lose PRIVATE and lower access.
changed |= (PRIVATE|PROTECTED); // [A5]
}
if (!sameClass) {
changed |= (PROTECTED); // [A3]
} else {
assert(changed == 0); // [A8] (no deprivation if same class)
}
if (accessible) assert((changed & PUBLIC) == 0); // [A7]
int m2 = m1 & ~changed;
LookupCase l2 = new LookupCase(c2, m2);
assert(l2.lookupClass() == c2); // [A1]
assert((m1 | m2) == m1); // [A2] (no elevation of access)
return l2;
}
@Override
public String toString() {
String s = lookupClass().getSimpleName();
String lstr = lookupString();
int sl = lstr.indexOf('/');
if (sl >= 0) s += lstr.substring(sl);
ClassLoader cld = lookupClass().getClassLoader();
if (cld != THIS_LOADER) s += "/loader#"+numberOf(cld);
return s;
}
/** Predict the success or failure of accessing this method. */
public boolean willAccess(Method m) {
Class<?> c1 = lookupClass();
Class<?> c2 = m.getDeclaringClass();
LookupCase lc = this.in(c2);
int m1 = lc.lookupModes();
int m2 = fixMods(m.getModifiers());
// privacy is strictly enforced on lookups
if (c1 != c2) m1 &= ~PRIVATE;
// protected access is sometimes allowed
if ((m2 & PROTECTED) != 0) {
int prev = m2;
m2 |= PACKAGE; // it acts like a package method also
if ((lookupModes() & PROTECTED) != 0 &&
c2.isAssignableFrom(c1))
m2 |= PUBLIC; // from a subclass, it acts like a public method also
}
if (verbosity >= 2)
System.out.println(this+" willAccess "+lc+" m1="+m1+" m2="+m2+" => "+((m2 & m1) != 0));
return (m2 & m1) != 0;
}
}
private static Class<?> topLevelClass(Class<?> cls) {
Class<?> c = cls;
for (Class<?> ec; (ec = c.getEnclosingClass()) != null; )
c = ec;
assert(c.getEnclosingClass() == null);
assert(c == cls || cls.getEnclosingClass() != null);
return c;
}
private static String packagePrefix(Class<?> c) {
while (c.isArray()) c = c.getComponentType();
String s = c.getName();
assert(s.indexOf('/') < 0);
return s.substring(0, s.lastIndexOf('.')+1);
}
private final TreeSet<LookupCase> CASES = new TreeSet<>();
private final TreeMap<LookupCase,TreeSet<LookupCase>> CASE_EDGES = new TreeMap<>();
private final ArrayList<ClassLoader> LOADERS = new ArrayList<>();
private final ClassLoader THIS_LOADER = this.getClass().getClassLoader();
{ if (THIS_LOADER != null) LOADERS.add(THIS_LOADER); } // #1
private LookupCase lookupCase(String name) {
for (LookupCase lc : CASES) {
if (lc.toString().equals(name))
return lc;
}
throw new AssertionError(name);
}
private int numberOf(ClassLoader cl) {
if (cl == null) return 0;
int i = LOADERS.indexOf(cl);
if (i < 0) {
i = LOADERS.size();
LOADERS.add(cl);
}
return i+1;
}
private void addLookupEdge(LookupCase l1, Class<?> c2, LookupCase l2) {
TreeSet<LookupCase> edges = CASE_EDGES.get(l2);
if (edges == null) CASE_EDGES.put(l2, edges = new TreeSet<>());
if (edges.add(l1)) {
Class<?> c1 = l1.lookupClass();
assert(l2.lookupClass() == c2); // [A1]
int m1 = l1.lookupModes();
int m2 = l2.lookupModes();
assert((m1 | m2) == m1); // [A2] (no elevation of access)
LookupCase expect = l1.in(c2);
if (!expect.equals(l2))
System.out.println("*** expect "+l1+" => "+expect+" but got "+l2);
assertEquals(expect, l2);
}
}
private void makeCases(Lookup[] originalLookups) {
// make initial set of lookup test cases
CASES.clear(); LOADERS.clear(); CASE_EDGES.clear();
ArrayList<Class<?>> classes = new ArrayList<>();
for (Lookup l : originalLookups) {
CASES.add(new LookupCase(l));
classes.remove(l.lookupClass()); // no dups please
classes.add(l.lookupClass());
}
System.out.println("loaders = "+LOADERS);
int rounds = 0;
for (int lastCount = -1; lastCount != CASES.size(); ) {
lastCount = CASES.size(); // if CASES grow in the loop we go round again
for (LookupCase lc1 : CASES.toArray(new LookupCase[0])) {
for (Class<?> c2 : classes) {
LookupCase lc2 = new LookupCase(lc1.lookup().in(c2));
addLookupEdge(lc1, c2, lc2);
CASES.add(lc2);
}
}
rounds++;
}
System.out.println("filled in "+CASES.size()+" cases from "+originalLookups.length+" original cases in "+rounds+" rounds");
if (false) {
System.out.println("CASES: {");
for (LookupCase lc : CASES) {
System.out.println(lc);
Set<LookupCase> edges = CASE_EDGES.get(lc);
if (edges != null)
for (LookupCase prev : edges) {
System.out.println("\t"+prev);
}
}
System.out.println("}");
}
}
@Test public void test() {
makeCases(lookups());
if (verbosity > 0) {
verbosity += 9;
Method pro_in_self = targetMethod(THIS_CLASS, PROTECTED, methodType(void.class));
testOneAccess(lookupCase("AccessControlTest/public"), pro_in_self, "find");
testOneAccess(lookupCase("Remote_subclass/public"), pro_in_self, "find");
testOneAccess(lookupCase("Remote_subclass"), pro_in_self, "find");
verbosity -= 9;
}
Set<Class<?>> targetClassesDone = new HashSet<>();
for (LookupCase targetCase : CASES) {
Class<?> targetClass = targetCase.lookupClass();
if (!targetClassesDone.add(targetClass)) continue; // already saw this one
String targetPlace = placeName(targetClass);
if (targetPlace == null) continue; // Object, String, not a target
for (int targetAccess : ACCESS_CASES) {
MethodType methodType = methodType(void.class);
Method method = targetMethod(targetClass, targetAccess, methodType);
// Try to access target method from various contexts.
for (LookupCase sourceCase : CASES) {
testOneAccess(sourceCase, method, "find");
testOneAccess(sourceCase, method, "unreflect");
}
}
}
System.out.println("tested "+testCount+" access scenarios; "+testCountFails+" accesses were denied");
}
private int testCount, testCountFails;
private void testOneAccess(LookupCase sourceCase, Method method, String kind) {
Class<?> targetClass = method.getDeclaringClass();
String methodName = method.getName();
MethodType methodType = methodType(method.getReturnType(), method.getParameterTypes());
boolean willAccess = sourceCase.willAccess(method);
boolean didAccess = false;
ReflectiveOperationException accessError = null;
try {
switch (kind) {
case "find":
if ((method.getModifiers() & Modifier.STATIC) != 0)
sourceCase.lookup().findStatic(targetClass, methodName, methodType);
else
sourceCase.lookup().findVirtual(targetClass, methodName, methodType);
break;
case "unreflect":
sourceCase.lookup().unreflect(method);
break;
default:
throw new AssertionError(kind);
}
didAccess = true;
} catch (ReflectiveOperationException ex) {
accessError = ex;
}
if (willAccess != didAccess) {
System.out.println(sourceCase+" => "+targetClass.getSimpleName()+"."+methodName+methodType);
System.out.println("fail on "+method+" ex="+accessError);
assertEquals(willAccess, didAccess);
}
testCount++;
if (!didAccess) testCountFails++;
}
static Method targetMethod(Class<?> targetClass, int targetAccess, MethodType methodType) {
String methodName = accessName(targetAccess)+placeName(targetClass);
if (verbosity >= 2)
System.out.println(targetClass.getSimpleName()+"."+methodName+methodType);
try {
Method method = targetClass.getDeclaredMethod(methodName, methodType.parameterArray());
assertEquals(method.getReturnType(), methodType.returnType());
int haveMods = method.getModifiers();
assert(Modifier.isStatic(haveMods));
assert(targetAccess == fixMods(haveMods));
return method;
} catch (NoSuchMethodException ex) {
throw new AssertionError(methodName, ex);
}
}
static String placeName(Class<?> cls) {
// return "self", "sibling", "nestmate", etc.
if (cls == AccessControlTest.class) return "self";
String cln = cls.getSimpleName();
int under = cln.lastIndexOf('_');
if (under < 0) return null;
return cln.substring(under+1);
}
static String accessName(int acc) {
switch (acc) {
case PUBLIC: return "pub_in_";
case PROTECTED: return "pro_in_";
case PACKAGE: return "pkg_in_";
case PRIVATE: return "pri_in_";
}
assert(false);
return "?";
}
private static final int[] ACCESS_CASES = {
PUBLIC, PACKAGE, PRIVATE, PROTECTED
};
/** Return one of the ACCESS_CASES. */
static int fixMods(int mods) {
mods &= (PUBLIC|PRIVATE|PROTECTED);
switch (mods) {
case PUBLIC: case PRIVATE: case PROTECTED: return mods;
case 0: return PACKAGE;
}
throw new AssertionError(mods);
}
static Lookup[] lookups() {
ArrayList<Lookup> tem = new ArrayList<>();
Collections.addAll(tem,
AccessControlTest.lookup_in_self(),
Inner_nestmate.lookup_in_nestmate(),
AccessControlTest_sibling.lookup_in_sibling());
if (true) {
Collections.addAll(tem,Acquaintance_remote.lookups());
} else {
try {
Class<?> remc = Class.forName("test.java.lang.invoke.AccessControlTest_subpkg.Acquaintance_remote");
Lookup[] remls = (Lookup[]) remc.getMethod("lookups").invoke(null);
Collections.addAll(tem, remls);
} catch (ReflectiveOperationException ex) {
throw new LinkageError("reflection failed", ex);
}
}
tem.add(publicLookup());
tem.add(publicLookup().in(String.class));
tem.add(publicLookup().in(List.class));
return tem.toArray(new Lookup[0]);
}
static Lookup lookup_in_self() {
return MethodHandles.lookup();
}
static public void pub_in_self() { }
static protected void pro_in_self() { }
static /*package*/ void pkg_in_self() { }
static private void pri_in_self() { }
static class Inner_nestmate {
static Lookup lookup_in_nestmate() {
return MethodHandles.lookup();
}
static public void pub_in_nestmate() { }
static protected void pro_in_nestmate() { }
static /*package*/ void pkg_in_nestmate() { }
static private void pri_in_nestmate() { }
}
}
class AccessControlTest_sibling {
static Lookup lookup_in_sibling() {
return MethodHandles.lookup();
}
static public void pub_in_sibling() { }
static protected void pro_in_sibling() { }
static /*package*/ void pkg_in_sibling() { }
static private void pri_in_sibling() { }
}
// This guy tests access from outside the package:
/*
package test.java.lang.invoke.AccessControlTest_subpkg;
public class Acquaintance_remote {
public static Lookup[] lookups() { ...
}
...
}
*/

Some files were not shown because too many files have changed in this diff Show More