# HG changeset patch # User michaelm # Date 1294916548 0 # Node ID 2c27ff4c062e6a33c597df8517be9c476ba0bf41 # Parent 3af394bb6f5974108b68891c8601e35e4d30be43# Parent 0ae19fac0c55a73e2d754573c9b8622555cb903c Merge diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/back/debugInit.c --- a/jdk/src/share/back/debugInit.c Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/back/debugInit.c Thu Jan 13 11:02:28 2011 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,27 +133,60 @@ return error; } +typedef struct { + int major; + int minor; +} version_type; + +typedef struct { + version_type runtime; + version_type compiletime; +} compatible_versions_type; + +/* + * List of explicitly compatible JVMTI versions, specified as + * { runtime version, compile-time version } pairs. -1 is a wildcard. + */ +static int nof_compatible_versions = 3; +static compatible_versions_type compatible_versions_list[] = { + /* + * FIXUP: Allow version 0 to be compatible with anything + * Special check for FCS of 1.0. + */ + { { 0, -1 }, { -1, -1 } }, + { { -1, -1 }, { 0, -1 } }, + /* + * 1.2 is runtime compatible with 1.1 -- just make sure to check the + * version before using any new 1.2 features + */ + { { 1, 1 }, { 1, 2 } } +}; + + /* Logic to determine JVMTI version compatibility */ static jboolean compatible_versions(jint major_runtime, jint minor_runtime, jint major_compiletime, jint minor_compiletime) { -#if 1 /* FIXUP: We allow version 0 to be compatible with anything */ - /* Special check for FCS of 1.0. */ - if ( major_runtime == 0 || major_compiletime == 0 ) { - return JNI_TRUE; + /* + * First check to see if versions are explicitly compatible via the + * list specified above. + */ + int i; + for (i = 0; i < nof_compatible_versions; ++i) { + version_type runtime = compatible_versions_list[i].runtime; + version_type comptime = compatible_versions_list[i].compiletime; + + if ((major_runtime == runtime.major || runtime.major == -1) && + (minor_runtime == runtime.minor || runtime.minor == -1) && + (major_compiletime == comptime.major || comptime.major == -1) && + (minor_compiletime == comptime.minor || comptime.minor == -1)) { + return JNI_TRUE; + } } -#endif - /* Runtime major version must match. */ - if ( major_runtime != major_compiletime ) { - return JNI_FALSE; - } - /* Runtime minor version must be >= the version compiled with. */ - if ( minor_runtime < minor_compiletime ) { - return JNI_FALSE; - } - /* Assumed compatible */ - return JNI_TRUE; + + return major_runtime == major_compiletime && + minor_runtime >= minor_compiletime; } /* OnLoad startup: diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/back/eventFilter.c --- a/jdk/src/share/back/eventFilter.c Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/back/eventFilter.c Thu Jan 13 11:02:28 2011 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ #include "stepControl.h" #include "threadControl.h" #include "SDE.h" +#include "jvmti.h" typedef struct ClassFilter { jclass clazz; @@ -275,6 +276,24 @@ } } +static jboolean isVersionGte12x() { + jint version; + jvmtiError err = + JVMTI_FUNC_PTR(gdata->jvmti,GetVersionNumber)(gdata->jvmti, &version); + + if (err == JVMTI_ERROR_NONE) { + jint major, minor; + + major = (version & JVMTI_VERSION_MASK_MAJOR) + >> JVMTI_VERSION_SHIFT_MAJOR; + minor = (version & JVMTI_VERSION_MASK_MINOR) + >> JVMTI_VERSION_SHIFT_MINOR; + return (major > 1 || major == 1 && minor >= 2); + } else { + return JNI_FALSE; + } +} + /* Return the object instance in which the event occurred */ /* Return NULL if static or if an error occurs */ static jobject @@ -286,6 +305,14 @@ jint modifiers = 0; jvmtiError error; + static jboolean got_version = JNI_FALSE; + static jboolean is_version_gte_12x = JNI_FALSE; + + if (!got_version) { + is_version_gte_12x = isVersionGte12x(); + got_version = JNI_TRUE; + } + switch (evinfo->ei) { case EI_SINGLE_STEP: case EI_BREAKPOINT: @@ -314,11 +341,18 @@ /* fail if error or static (0x8) */ if (error == JVMTI_ERROR_NONE && thread!=NULL && (modifiers & 0x8) == 0) { FrameNumber fnum = 0; - /* get slot zero object "this" */ - error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalObject) - (gdata->jvmti, thread, fnum, 0, &object); - if (error != JVMTI_ERROR_NONE) + if (is_version_gte_12x) { + /* Use new 1.2.x function, GetLocalInstance */ + error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalInstance) + (gdata->jvmti, thread, fnum, &object); + } else { + /* get slot zero object "this" */ + error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalObject) + (gdata->jvmti, thread, fnum, 0, &object); + } + if (error != JVMTI_ERROR_NONE) { object = NULL; + } } return object; diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/Config.java --- a/jdk/src/share/classes/sun/security/krb5/Config.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/Config.java Thu Jan 13 11:02:28 2011 +0000 @@ -528,7 +528,7 @@ } }))); String Line; - Vector v = new Vector (); + Vector v = new Vector<>(); String previous = null; while ((Line = br.readLine()) != null) { // ignore comments and blank line in the configuration file. @@ -589,7 +589,7 @@ throw new KrbException("I/O error while reading" + " configuration file."); } - Hashtable table = new Hashtable (); + Hashtable table = new Hashtable<>(); for (int i = 0; i < v.size(); i++) { String line = v.elementAt(i).trim(); if (line.equalsIgnoreCase("[realms]")) { @@ -598,7 +598,7 @@ if ((count == v.size()) || (v.elementAt(count).startsWith("["))) { Hashtable>> temp = - new Hashtable>>(); + new Hashtable<>(); temp = parseRealmField(v, i + 1, count); table.put("realms", temp); i = count - 1; @@ -611,7 +611,7 @@ if ((count == v.size()) || (v.elementAt(count).startsWith("["))) { Hashtable>> temp = - new Hashtable>>(); + new Hashtable<>(); temp = parseRealmField(v, i + 1, count); table.put("capaths", temp); i = count - 1; @@ -729,7 +729,7 @@ * Parses key-value pairs under a stanza name. */ private Hashtable parseField(Vector v, int start, int end) { - Hashtable table = new Hashtable (); + Hashtable table = new Hashtable<>(); String line; for (int i = start; i < end; i++) { line = v.elementAt(i); @@ -751,7 +751,7 @@ * information for the realm given within a pair of braces. */ private Hashtable>> parseRealmField(Vector v, int start, int end) { - Hashtable>> table = new Hashtable>> (); + Hashtable>> table = new Hashtable<>(); String line; for (int i = start; i < end; i++) { line = v.elementAt(i).trim(); @@ -791,10 +791,9 @@ * Parses key-value pairs within each braces under [realms]. */ private Hashtable> parseRealmFieldEx(Vector v, int start, int end) { - Hashtable> table = - new Hashtable> (); - Vector keyVector = new Vector (); - Vector nameVector = new Vector (); + Hashtable> table = new Hashtable<>(); + Vector keyVector = new Vector<>(); + Vector nameVector = new Vector<>(); String line = ""; String key; for (int i = start; i < end; i++) { @@ -899,7 +898,7 @@ } st = new StringTokenizer(default_enctypes, delim); int len = st.countTokens(); - ArrayList ls = new ArrayList (len); + ArrayList ls = new ArrayList<>(len); int type; for (int i = 0; i < len; i++) { type = getType(st.nextToken()); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/KdcComm.java --- a/jdk/src/share/classes/sun/security/krb5/KdcComm.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/KdcComm.java Thu Jan 13 11:02:28 2011 +0000 @@ -462,7 +462,7 @@ */ static class KdcAccessibility { // Known bad KDCs - private static Set bads = new HashSet(); + private static Set bads = new HashSet<>(); private static synchronized void addBad(String kdc) { if (DEBUG) { @@ -492,9 +492,9 @@ // Returns a preferred KDC list by putting the bad ones at the end private static synchronized String[] list(String kdcList) { StringTokenizer st = new StringTokenizer(kdcList); - List list = new ArrayList(); + List list = new ArrayList<>(); if (badPolicy == BpType.TRY_LAST) { - List badkdcs = new ArrayList(); + List badkdcs = new ArrayList<>(); while (st.hasMoreTokens()) { String t = st.nextToken(); if (bads.contains(t)) badkdcs.add(t); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/PrincipalName.java --- a/jdk/src/share/classes/sun/security/krb5/PrincipalName.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/PrincipalName.java Thu Jan 13 11:02:28 2011 +0000 @@ -244,7 +244,7 @@ if (subDer.getTag() != DerValue.tag_SequenceOf) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } - Vector v = new Vector (); + Vector v = new Vector<>(); DerValue subSubDer; while(subDer.getData().available() > 0) { subSubDer = subDer.getData().getDerValue(); @@ -299,7 +299,7 @@ // Code repetition, realm parsed again by class Realm protected static String[] parseName(String name) { - Vector tempStrings = new Vector (); + Vector tempStrings = new Vector<>(); String temp = name; int i = 0; int componentStart = 0; diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/Realm.java --- a/jdk/src/share/classes/sun/security/krb5/Realm.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/Realm.java Thu Jan 13 11:02:28 2011 +0000 @@ -359,12 +359,12 @@ } String tempTarget = null, tempRealm = null; - Stack iStack = new Stack (); + Stack iStack = new Stack<>(); /* * I don't expect any more than a handful of intermediaries. */ - Vector tempList = new Vector (8, 8); + Vector tempList = new Vector<>(8, 8); /* * The initiator at first location. diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/Authenticator.java --- a/jdk/src/share/classes/sun/security/krb5/internal/Authenticator.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/Authenticator.java Thu Jan 13 11:02:28 2011 +0000 @@ -176,7 +176,7 @@ * @exception IOException if an I/O error occurs while reading encoded data. */ public byte[] asn1Encode() throws Asn1Exception, IOException { - Vector v = new Vector(); + Vector v = new Vector<>(); DerOutputStream temp = new DerOutputStream(); temp.putInteger(BigInteger.valueOf(authenticator_vno)); v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp.toByteArray())); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/AuthorizationData.java --- a/jdk/src/share/classes/sun/security/krb5/internal/AuthorizationData.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/AuthorizationData.java Thu Jan 13 11:02:28 2011 +0000 @@ -99,8 +99,7 @@ * @exception IOException if an I/O error occurs while reading encoded data. */ public AuthorizationData(DerValue der) throws Asn1Exception, IOException { - Vector v = - new Vector(); + Vector v = new Vector<>(); if (der.getTag() != DerValue.tag_Sequence) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java --- a/jdk/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java Thu Jan 13 11:02:28 2011 +0000 @@ -133,7 +133,7 @@ * @exception IOException if an I/O error occurs while reading encoded data. */ public byte[] asn1Encode() throws Asn1Exception, IOException { - Vector v = new Vector(); + Vector v = new Vector<>(); DerOutputStream temp = new DerOutputStream(); v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), ctime.asn1Encode())); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/HostAddresses.java --- a/jdk/src/share/classes/sun/security/krb5/internal/HostAddresses.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/HostAddresses.java Thu Jan 13 11:02:28 2011 +0000 @@ -179,7 +179,7 @@ */ public HostAddresses(DerValue encoding) throws Asn1Exception, IOException { - Vector tempAddresses = new Vector (); + Vector tempAddresses = new Vector<>(); DerValue der = null; while (encoding.getData().available() > 0) { der = encoding.getData().getDerValue(); @@ -265,8 +265,7 @@ if (addresses == null || addresses.length == 0) return null; - ArrayList ipAddrs = - new ArrayList (addresses.length); + ArrayList ipAddrs = new ArrayList<>(addresses.length); for (int i = 0; i < addresses.length; i++) { try { diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/KDCReq.java --- a/jdk/src/share/classes/sun/security/krb5/internal/KDCReq.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/KDCReq.java Thu Jan 13 11:02:28 2011 +0000 @@ -150,7 +150,7 @@ if (subsubDer.getTag() != DerValue.tag_SequenceOf) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } - Vector v = new Vector(); + Vector v = new Vector<>(); while (subsubDer.getData().available() > 0) { v.addElement(new PAData(subsubDer.getData().getDerValue())); } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/KDCReqBody.java --- a/jdk/src/share/classes/sun/security/krb5/internal/KDCReqBody.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/KDCReqBody.java Thu Jan 13 11:02:28 2011 +0000 @@ -158,7 +158,7 @@ throw new Asn1Exception(Krb5.ASN1_BAD_ID); } der = encoding.getData().getDerValue(); - Vector v = new Vector (); + Vector v = new Vector<>(); if ((der.getTag() & (byte)0x1F) == (byte)0x08) { subDer = der.getData().getDerValue(); @@ -183,7 +183,7 @@ encAuthorizationData = EncryptedData.parse(encoding.getData(), (byte)0x0A, true); } if (encoding.getData().available() > 0) { - Vector tempTickets = new Vector (); + Vector tempTickets = new Vector<>(); der = encoding.getData().getDerValue(); if ((der.getTag() & (byte)0x1F) == (byte)0x0B) { subDer = der.getData().getDerValue(); @@ -216,7 +216,7 @@ * */ public byte[] asn1Encode(int msgType) throws Asn1Exception, IOException { - Vector v = new Vector (); + Vector v = new Vector<>(); v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), kdcOptions.asn1Encode())); if (msgType == Krb5.KRB_AS_REQ) { if (cname != null) { diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/KRBCred.java --- a/jdk/src/share/classes/sun/security/krb5/internal/KRBCred.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/KRBCred.java Thu Jan 13 11:02:28 2011 +0000 @@ -134,7 +134,7 @@ if (subsubDer.getTag() != DerValue.tag_SequenceOf) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } - Vector v = new Vector(); + Vector v = new Vector<>(); while (subsubDer.getData().available() > 0) { v.addElement(new Ticket(subsubDer.getData().getDerValue())); } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/KRBError.java --- a/jdk/src/share/classes/sun/security/krb5/internal/KRBError.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/KRBError.java Thu Jan 13 11:02:28 2011 +0000 @@ -260,7 +260,7 @@ private void parsePAData(byte[] data) throws IOException, Asn1Exception { DerValue derPA = new DerValue(data); - List paList = new ArrayList(); + List paList = new ArrayList<>(); while (derPA.data.available() > 0) { // read the PA-DATA DerValue tmp = derPA.data.getDerValue(); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java --- a/jdk/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java Thu Jan 13 11:02:28 2011 +0000 @@ -157,7 +157,7 @@ * @exception IOException if an I/O error occurs while reading encoded data. */ public byte[] asn1Encode() throws Asn1Exception, IOException { - Vector v = new Vector (); + Vector v = new Vector<>(); v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), key.asn1Encode())); if (prealm != null) v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), prealm.asn1Encode())); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/LastReq.java --- a/jdk/src/share/classes/sun/security/krb5/internal/LastReq.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/LastReq.java Thu Jan 13 11:02:28 2011 +0000 @@ -77,7 +77,7 @@ */ public LastReq(DerValue encoding) throws Asn1Exception, IOException { - Vector v= new Vector (); + Vector v= new Vector<>(); if (encoding.getTag() != DerValue.tag_Sequence) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java --- a/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Thu Jan 13 11:02:28 2011 +0000 @@ -490,7 +490,7 @@ private static String exec(String c) { StringTokenizer st = new StringTokenizer(c); - Vector v = new Vector (); + Vector v = new Vector<>(); while (st.hasMoreTokens()) { v.addElement(st.nextToken()); } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java --- a/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/crypto/EType.java Thu Jan 13 11:02:28 2011 +0000 @@ -257,7 +257,7 @@ + configName); } - List list = new ArrayList (answer.length); + List list = new ArrayList<>(answer.length); for (int i = 0; i < answer.length; i++) { if (EncryptionKey.findKey(answer[i], keys) != null) { list.add(answer[i]); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java --- a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java Thu Jan 13 11:02:28 2011 +0000 @@ -57,7 +57,7 @@ private static KeyTab singleton = null; private static final boolean DEBUG = Krb5.DEBUG; private static String name; - private Vector entries = new Vector (); + private Vector entries = new Vector<>(); private KeyTab(String filename) throws IOException, RealmException { init(filename); @@ -240,7 +240,7 @@ KeyTabEntry entry; EncryptionKey key; int size = entries.size(); - ArrayList keys = new ArrayList (size); + ArrayList keys = new ArrayList<>(size); for (int i = size-1; i >= 0; i--) { entry = entries.elementAt(i); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/tools/JarSigner.java --- a/jdk/src/share/classes/sun/security/tools/JarSigner.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/tools/JarSigner.java Thu Jan 13 11:02:28 2011 +0000 @@ -123,19 +123,19 @@ // or the default keystore, never null String keystore; // key store file - List crlfiles = new ArrayList(); // CRL files to add + List crlfiles = new ArrayList<>(); // CRL files to add boolean nullStream = false; // null keystore input stream (NONE) boolean token = false; // token-based keystore String jarfile; // jar files to sign or verify String alias; // alias to sign jar with - List ckaliases = new ArrayList(); // aliases in -verify + List ckaliases = new ArrayList<>(); // aliases in -verify char[] storepass; // keystore password boolean protectedPath; // protected authentication path String storetype; // keystore type String providerName; // provider name Vector providers = null; // list of providers // arguments for provider constructors - HashMap providerArgs = new HashMap(); + HashMap providerArgs = new HashMap<>(); char[] keypass; // private key password String sigfile; // name of .SF file String sigalg; // name of signature algorithm @@ -236,7 +236,7 @@ if (crlfiles.size() > 0 || autoCRL) { CertificateFactory fac = CertificateFactory.getInstance("X509"); - List list = new ArrayList(); + List list = new ArrayList<>(); for (String file: crlfiles) { Collection tmp = KeyTool.loadCRLs(file); for (CRL crl: tmp) { @@ -606,7 +606,7 @@ try { jf = new JarFile(jarName, true); - Vector entriesVec = new Vector(); + Vector entriesVec = new Vector<>(); byte[] buffer = new byte[8192]; Enumeration entries = jf.entries(); @@ -633,8 +633,7 @@ // The map to record display info, only used when -verbose provided // key: signer info string // value: the list of files with common key - Map> output = - new LinkedHashMap>(); + Map> output = new LinkedHashMap<>(); if (man != null) { if (verbose != null) System.out.println(); @@ -1000,8 +999,7 @@ .append(signTimeForm.format(source)).append("]").toString(); } - private Map cacheForInKS = - new IdentityHashMap(); + private Map cacheForInKS = new IdentityHashMap<>(); private int inKeyStoreForOneSigner(CodeSigner signer) { if (cacheForInKS.containsKey(signer)) { @@ -1044,8 +1042,7 @@ return result; } - Hashtable storeHash = - new Hashtable(); + Hashtable storeHash = new Hashtable<>(); int inKeyStore(CodeSigner[] signers) { @@ -1175,7 +1172,7 @@ * generated one. (This may invalidate existing signatures!) */ BASE64Encoder encoder = new JarBASE64Encoder(); - Vector mfFiles = new Vector(); + Vector mfFiles = new Vector<>(); boolean wasSigned = false; @@ -1531,7 +1528,7 @@ return false; } - Map cacheForSignerInfo = new IdentityHashMap(); + Map cacheForSignerInfo = new IdentityHashMap<>(); /** * Returns a string of singer info, with a newline at the end @@ -1655,7 +1652,7 @@ } } } - Set tas = new HashSet(); + Set tas = new HashSet<>(); try { KeyStore caks = KeyTool.getCacertsKeyStore(); if (caks != null) { diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/tools/KeyTool.java --- a/jdk/src/share/classes/sun/security/tools/KeyTool.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java Thu Jan 13 11:02:28 2011 +0000 @@ -153,11 +153,11 @@ private KeyStore caks = null; // "cacerts" keystore private char[] srcstorePass = null; private String srcstoretype = null; - private Set passwords = new HashSet (); + private Set passwords = new HashSet<>(); private String startDate = null; - private List ids = new ArrayList (); // used in GENCRL - private List v3ext = new ArrayList (); + private List ids = new ArrayList<>(); // used in GENCRL + private List v3ext = new ArrayList<>(); enum Command { CERTREQ("Generates.a.certificate.request", @@ -2091,7 +2091,7 @@ */ public static List readCRLsFromCert(X509Certificate cert) throws Exception { - List crls = new ArrayList(); + List crls = new ArrayList<>(); CRLDistributionPointsExtension ext = X509CertImpl.toImpl(cert).getCRLDistributionPointsExtension(); if (ext == null) return crls; @@ -2258,7 +2258,7 @@ if (jarfile != null) { JarFile jf = new JarFile(jarfile, true); Enumeration entries = jf.entries(); - Set ss = new HashSet(); + Set ss = new HashSet<>(); byte[] buffer = new byte[8192]; int pos = 0; while (entries.hasMoreElements()) { @@ -3347,7 +3347,7 @@ } // start building chain - Vector chain = new Vector(2); + Vector chain = new Vector<>(2); if (buildChain((X509Certificate)certToVerify, chain, certs)) { Certificate[] newChain = new Certificate[chain.size()]; // buildChain() returns chain with self-signed root-cert first and @@ -3873,8 +3873,7 @@ break; case 2: // EKU if(value != null) { - Vector v = - new Vector (); + Vector v = new Vector<>(); for (String s: value.split(",")) { int p = oneOf(s, "anyExtendedKeyUsage", @@ -3944,7 +3943,7 @@ } if(value != null) { List accessDescriptions = - new ArrayList(); + new ArrayList<>(); String[] ps = value.split(","); for(String item: ps) { colonpos = item.indexOf(':'); @@ -4228,7 +4227,7 @@ } public static Pair of(A a, B b) { - return new Pair(a,b); + return new Pair<>(a,b); } } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/classes/sun/security/tools/policytool/PolicyTool.java --- a/jdk/src/share/classes/sun/security/tools/policytool/PolicyTool.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/classes/sun/security/tools/policytool/PolicyTool.java Thu Jan 13 11:02:28 2011 +0000 @@ -643,7 +643,7 @@ Class pc = Class.forName(type, true, Thread.currentThread().getContextClassLoader()); Constructor c = null; - Vector objects = new Vector(2); + Vector objects = new Vector<>(2); if (name != null) objects.add(name); if (actions != null) objects.add(actions); switch (objects.size()) { @@ -1722,8 +1722,7 @@ new PolicyParser.GrantEntry(signedby, codebase); // get the new Principals - LinkedList prins = - new LinkedList(); + LinkedList prins = new LinkedList<>(); TaggedList prinList = (TaggedList)getComponent(PE_PRIN_LIST); for (int i = 0; i < prinList.getItemCount(); i++) { prins.add((PolicyParser.PrincipalEntry)prinList.getObject(i)); @@ -1731,8 +1730,7 @@ ge.principals = prins; // get the new Permissions - Vector perms = - new Vector(); + Vector perms = new Vector<>(); TaggedList permList = (TaggedList)getComponent(PE_PERM_LIST); for (int i = 0; i < permList.getItemCount(); i++) { perms.addElement((PolicyParser.PermissionEntry)permList.getObject(i)); @@ -3649,7 +3647,7 @@ * This is a java.awt.List that bind an Object to each String it holds. */ class TaggedList extends List { - private java.util.List data = new LinkedList(); + private java.util.List data = new LinkedList<>(); public TaggedList(int i, boolean b) { super(i, b); } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/instrument/JPLISAgent.c --- a/jdk/src/share/instrument/JPLISAgent.c Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/instrument/JPLISAgent.c Thu Jan 13 11:02:28 2011 +0000 @@ -209,7 +209,7 @@ *agent_ptr = NULL; jnierror = (*vm)->GetEnv( vm, (void **) &jvmtienv, - JVMTI_VERSION); + JVMTI_VERSION_1_1); if ( jnierror != JNI_OK ) { initerror = JPLIS_INIT_ERROR_CANNOT_CREATE_NATIVE_AGENT; } else { @@ -990,7 +990,7 @@ } jnierror = (*agent->mJVM)->GetEnv( agent->mJVM, (void **) &retransformerEnv, - JVMTI_VERSION); + JVMTI_VERSION_1_1); if ( jnierror != JNI_OK ) { return NULL; } diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/src/share/javavm/export/jvmti.h --- a/jdk/src/share/javavm/export/jvmti.h Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/src/share/javavm/export/jvmti.h Thu Jan 13 11:02:28 2011 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,9 @@ JVMTI_VERSION_1 = 0x30010000, JVMTI_VERSION_1_0 = 0x30010000, JVMTI_VERSION_1_1 = 0x30010100, - - JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (1 * 0x100) + 102 /* version: 1.1.102 */ + JVMTI_VERSION_1_2 = 0x30010200, + + JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (2 * 0x100) + 1 /* version: 1.2.1 */ }; JNIEXPORT jint JNICALL @@ -1774,6 +1775,12 @@ jobject object, jlong* size_ptr); + /* 155 : Get Local Instance */ + jvmtiError (JNICALL *GetLocalInstance) (jvmtiEnv* env, + jthread thread, + jint depth, + jobject* value_ptr); + } jvmtiInterface_1; struct _jvmtiEnv { @@ -2031,6 +2038,12 @@ return functions->GetLocalObject(this, thread, depth, slot, value_ptr); } + jvmtiError GetLocalInstance(jthread thread, + jint depth, + jobject* value_ptr) { + return functions->GetLocalInstance(this, thread, depth, value_ptr); + } + jvmtiError GetLocalInt(jthread thread, jint depth, jint slot, @@ -2518,3 +2531,4 @@ #endif /* __cplusplus */ #endif /* !_JAVA_JVMTI_H_ */ + diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/com/sun/jdi/NativeInstanceFilter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/com/sun/jdi/NativeInstanceFilter.java Thu Jan 13 11:02:28 2011 +0000 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 6426034 + * @summary Instance filter doesn't filter event if it occurs in native method + * + * @author Keith McGuigan + * + * @library scaffold + * @run build JDIScaffold VMConnection + * @compile -XDignore.symbol.file NativeInstanceFilterTarg.java + * @run main/othervm NativeInstanceFilter + */ + +/* + * This test tests instance filters for events generated from a native method + */ + +import java.util.*; +import com.sun.jdi.*; +import com.sun.jdi.event.*; +import com.sun.jdi.request.*; + +public class NativeInstanceFilter extends JDIScaffold { + + static int unfilteredEvents = 0; + + public static void main(String args[]) throws Exception { + new NativeInstanceFilter().startTests(); + } + + public NativeInstanceFilter() { + super(); + } + + static EventRequestManager requestManager = null; + static MethodExitRequest request = null; + + private void listen() { + TargetAdapter adapter = new TargetAdapter() { + EventSet set = null; + ObjectReference instance = null; + + public boolean eventSetReceived(EventSet set) { + this.set = set; + return false; + } + + public boolean methodExited(MethodExitEvent event) { + String name = event.method().name(); + if (instance == null && name.equals("latch")) { + // Grab the instance (return value) and set up as filter + System.out.println("Setting up instance filter"); + instance = (ObjectReference)event.returnValue(); + requestManager.deleteEventRequest(request); + request = requestManager.createMethodExitRequest(); + request.addInstanceFilter(instance); + request.enable(); + } else if (instance != null && name.equals("intern")) { + // If not for the filter, this will be called twice + System.out.println("method exit event (String.intern())"); + ++unfilteredEvents; + } + set.resume(); + return false; + } + }; + addListener(adapter); + } + + + protected void runTests() throws Exception { + String[] args = new String[2]; + args[0] = "-connect"; + args[1] = "com.sun.jdi.CommandLineLaunch:main=NativeInstanceFilterTarg"; + + connect(args); + waitForVMStart(); + + // VM has started, but hasn't started running the test program yet. + requestManager = vm().eventRequestManager(); + ReferenceType referenceType = + resumeToPrepareOf("NativeInstanceFilterTarg").referenceType(); + + request = requestManager.createMethodExitRequest(); + request.enable(); + + listen(); + + vm().resume(); + + waitForVMDeath(); + + if (unfilteredEvents != 1) { + throw new Exception( + "Failed: Event from native frame not filtered out."); + } + System.out.println("Passed: Event filtered out."); + } +} diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/com/sun/jdi/NativeInstanceFilterTarg.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/com/sun/jdi/NativeInstanceFilterTarg.java Thu Jan 13 11:02:28 2011 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import sun.misc.Version; + +public class NativeInstanceFilterTarg { + + public static void main(String args[]) { + boolean runTest = jvmSupportsJVMTI_12x(); + String s1 = "abc"; + String s2 = "def"; + latch(s1); + s1.intern(); + if (runTest) { + s2.intern(); // this is the call that generates events that ought + // to be filtered out. + } else { + System.out.println("Neutering test since JVMTI 1.2 not supported"); + } + } + + // Used by debugger to get an instance to filter with + public static String latch(String s) { return s; } + + public static boolean jvmSupportsJVMTI_12x() { + // This fix requires the JVM to support JVMTI 1.2, which doesn't + // happen until HSX 20.0, build 05. + int major = Version.jvmMajorVersion(); + int minor = Version.jvmMinorVersion(); + int micro = Version.jvmMicroVersion(); + int build = Version.jvmBuildNumber(); + + return (major > 20 || major == 20 && + (minor > 0 || micro > 0 || build >= 5)); + } +} diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/IPv6.java --- a/jdk/test/sun/security/krb5/IPv6.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/IPv6.java Thu Jan 13 11:02:28 2011 +0000 @@ -78,8 +78,8 @@ try { Subject subject = new Subject(); Krb5LoginModule krb5 = new Krb5LoginModule(); - Map map = new HashMap(); - Map shared = new HashMap(); + Map map = new HashMap<>(); + Map shared = new HashMap<>(); map.put("debug", "true"); map.put("doNotPrompt", "true"); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/auto/CleanState.java --- a/jdk/test/sun/security/krb5/auto/CleanState.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/auto/CleanState.java Thu Jan 13 11:02:28 2011 +0000 @@ -49,11 +49,11 @@ final char[] password = OneKDC.PASS; char[] badpassword = "hellokitty".toCharArray(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("useTicketCache", "false"); map.put("doNotPrompt", "false"); map.put("tryFirstPass", "true"); - Map shared = new HashMap(); + Map shared = new HashMap<>(); shared.put("javax.security.auth.login.name", name); shared.put("javax.security.auth.login.password", badpassword); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/auto/Context.java --- a/jdk/test/sun/security/krb5/auto/Context.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/auto/Context.java Thu Jan 13 11:02:28 2011 +0000 @@ -117,8 +117,8 @@ out.name = user; out.s = new Subject(); Krb5LoginModule krb5 = new Krb5LoginModule(); - Map map = new HashMap(); - Map shared = new HashMap(); + Map map = new HashMap<>(); + Map shared = new HashMap<>(); if (pass != null) { map.put("useFirstPass", "true"); @@ -151,7 +151,7 @@ out.name = user; out.s = new Subject(); Krb5LoginModule krb5 = new Krb5LoginModule(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("doNotPrompt", "true"); map.put("useTicketCache", "false"); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java --- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java Thu Jan 13 11:02:28 2011 +0000 @@ -297,8 +297,8 @@ } Krb5LoginModule krb5 = new Krb5LoginModule(); - Map map = new HashMap(); - Map shared = new HashMap(); + Map map = new HashMap<>(); + Map shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/auto/KDC.java --- a/jdk/test/sun/security/krb5/auto/KDC.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/auto/KDC.java Thu Jan 13 11:02:28 2011 +0000 @@ -132,7 +132,7 @@ // Principal db. principal -> pass. A case-insensitive TreeMap is used // so that even if the client provides a name with different case, the KDC // can still locate the principal and give back correct salt. - private TreeMap passwords = new TreeMap + private TreeMap passwords = new TreeMap<> (String.CASE_INSENSITIVE_ORDER); // Realm name @@ -142,9 +142,9 @@ // Service port number private int port; // The request/response job queue - private BlockingQueue q = new ArrayBlockingQueue(100); + private BlockingQueue q = new ArrayBlockingQueue<>(100); // Options - private Map options = new HashMap(); + private Map options = new HashMap<>(); private Thread thread1, thread2, thread3; DatagramSocket u1 = null; @@ -537,7 +537,7 @@ } } - private Map policies = new HashMap(); + private Map policies = new HashMap<>(); public void setPolicy(String rule, String value) { if (value == null) { @@ -760,7 +760,7 @@ private byte[] processAsReq(byte[] in) throws Exception { ASReq asReq = new ASReq(in); int[] eTypes = null; - List outPAs = new ArrayList(); + List outPAs = new ArrayList<>(); try { System.out.println(realm + "> " + asReq.reqBody.cname + diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/auto/LoginModuleOptions.java --- a/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java Thu Jan 13 11:02:28 2011 +0000 @@ -135,8 +135,8 @@ throws Exception { Krb5LoginModule krb5 = new Krb5LoginModule(); Subject subject = new Subject(); - Map map = new HashMap(); - Map shared = new HashMap(); + Map map = new HashMap<>(); + Map shared = new HashMap<>(); int count = options.length / 2; for (int i = 0; i < count; i++) { diff -r 3af394bb6f59 -r 2c27ff4c062e jdk/test/sun/security/krb5/tools/KtabCheck.java --- a/jdk/test/sun/security/krb5/tools/KtabCheck.java Thu Jan 13 11:01:30 2011 +0000 +++ b/jdk/test/sun/security/krb5/tools/KtabCheck.java Thu Jan 13 11:02:28 2011 +0000 @@ -39,7 +39,7 @@ public static void main(String[] args) throws Exception { System.out.println("Checking " + Arrays.toString(args)); KeyTab ktab = KeyTab.getInstance(args[0]); - Set expected = new HashSet(); + Set expected = new HashSet<>(); for (int i=1; i