--- a/jdk/src/share/classes/sun/tools/asm/Assembler.java Wed Aug 07 12:13:34 2013 -0700
+++ b/jdk/src/share/classes/sun/tools/asm/Assembler.java Wed Aug 07 16:29:36 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -91,9 +91,9 @@
add(new Instruction(where, opc, flagNoCovered));
}
- static Vector SourceClassList = new Vector();
+ static Vector<String> SourceClassList = new Vector<>();
- static Vector TmpCovTable = new Vector();
+ static Vector<String> TmpCovTable = new Vector<>();
static int[] JcovClassCountArray = new int[CT_LAST_KIND + 1];
@@ -177,8 +177,8 @@
case opc_lookupswitch: {
SwitchData sw = (SwitchData)inst.value;
optimize(env, sw.defaultLabel);
- for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
- optimize(env, (Label)e.nextElement());
+ for (Enumeration<Label> e = sw.tab.elements() ; e.hasMoreElements();) {
+ optimize(env, e.nextElement());
}
return;
}
@@ -186,8 +186,8 @@
case opc_try: {
TryData td = (TryData)inst.value;
td.getEndLabel().pc = NEEDED;
- for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
- CatchData cd = (CatchData)e.nextElement();
+ for (Enumeration<CatchData> e = td.catches.elements() ; e.hasMoreElements();) {
+ CatchData cd = e.nextElement();
optimize(env, cd.getLabel());
}
break;
@@ -237,9 +237,11 @@
// Collect constants for arguments only
// if a local variable table is generated
if ((field != null) && env.debug_vars()) {
- if (field.getArguments() != null) {
- for (Enumeration e = field.getArguments().elements() ; e.hasMoreElements() ;) {
- MemberDefinition f = (MemberDefinition)e.nextElement();
+ @SuppressWarnings("unchecked")
+ Vector<MemberDefinition> v = (Vector<MemberDefinition>)field.getArguments();
+ if (v != null) {
+ for (Enumeration<MemberDefinition> e = v.elements() ; e.hasMoreElements() ;) {
+ MemberDefinition f = e.nextElement();
tab.put(f.getName().toString());
tab.put(f.getType().getTypeSignature());
}
@@ -355,16 +357,16 @@
case opc_lookupswitch: {
SwitchData sw = (SwitchData)inst.value;
balance(sw.defaultLabel, depth);
- for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
- balance((Label)e.nextElement(), depth);
+ for (Enumeration<Label> e = sw.tab.elements() ; e.hasMoreElements();) {
+ balance(e.nextElement(), depth);
}
return;
}
case opc_try: {
TryData td = (TryData)inst.value;
- for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
- CatchData cd = (CatchData)e.nextElement();
+ for (Enumeration<CatchData> e = td.catches.elements() ; e.hasMoreElements();) {
+ CatchData cd = e.nextElement();
balance(cd.getLabel(), depth + 1);
}
break;
@@ -383,9 +385,10 @@
if ((field != null) && field.getArguments() != null) {
int sum = 0;
- Vector v = field.getArguments();
- for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
- MemberDefinition f = ((MemberDefinition)e.nextElement());
+ @SuppressWarnings("unchecked")
+ Vector<MemberDefinition> v = (Vector<MemberDefinition>)field.getArguments();
+ for (Enumeration<MemberDefinition> e = v.elements(); e.hasMoreElements(); ) {
+ MemberDefinition f = e.nextElement();
sum += f.getType().stackSize();
}
maxvar = sum;
@@ -441,8 +444,8 @@
if (inst.opc == opc_try) {
TryData td = (TryData)inst.value;
writeExceptions(env, out, tab, inst.next, td.getEndLabel());
- for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
- CatchData cd = (CatchData)e.nextElement();
+ for (Enumeration<CatchData> e = td.catches.elements() ; e.hasMoreElements();) {
+ CatchData cd = e.nextElement();
//System.out.println("EXCEPTION: " + env.getSource() + ", pc=" + inst.pc + ", end=" + td.getEndLabel().pc + ", hdl=" + cd.getLabel().pc + ", tp=" + cd.getType());
out.writeShort(inst.pc);
out.writeShort(td.getEndLabel().pc);
@@ -463,11 +466,12 @@
* Write the coverage table
*/
public void writeCoverageTable(Environment env, ClassDefinition c, DataOutputStream out, ConstantPool tab, long whereField) throws IOException {
- Vector TableLot = new Vector(); /* Coverage table */
+ Vector<Cover> TableLot = new Vector<>(); /* Coverage table */
boolean begseg = false;
boolean begmeth = false;
+ @SuppressWarnings("deprecation")
long whereClass = ((SourceClass)c).getWhere();
- Vector whereTry = new Vector();
+ Vector<Long> whereTry = new Vector<>();
int numberTry = 0;
int count = 0;
@@ -484,8 +488,8 @@
}
if (!begseg && !inst.flagNoCovered ) {
boolean findTry = false;
- for (Enumeration e = whereTry.elements(); e.hasMoreElements();) {
- if ( ((Long)(e.nextElement())).longValue() == inst.where) {
+ for (Enumeration<Long> e = whereTry.elements(); e.hasMoreElements();) {
+ if (e.nextElement().longValue() == inst.where) {
findTry = true;
break;
}
@@ -546,7 +550,7 @@
}
case opc_try: {
- whereTry.addElement(new Long(inst.where));
+ whereTry.addElement(Long.valueOf(inst.where));
begseg = false;
break;
}
@@ -569,8 +573,8 @@
}
case opc_lookupswitch: {
SwitchData sw = (SwitchData)inst.value;
- for (Enumeration e = sw.sortedKeys(); e.hasMoreElements() ; ) {
- Integer v = (Integer)e.nextElement();
+ for (Enumeration<Integer> e = sw.sortedKeys(); e.hasMoreElements() ; ) {
+ Integer v = e.nextElement();
TableLot.addElement(new Cover(CT_CASE, sw.whereCase(v), inst.pc));
count++;
}
@@ -591,7 +595,7 @@
out.writeShort(count);
for (int i = 0; i < count; i++) {
- Lot = (Cover)TableLot.elementAt(i);
+ Lot = TableLot.elementAt(i);
ln = (Lot.Addr >> WHEREOFFSETBITS);
pos = (Lot.Addr << (64 - WHEREOFFSETBITS)) >> (64 - WHEREOFFSETBITS);
out.writeShort(Lot.NumCommand);
@@ -646,6 +650,7 @@
*/
public void GenVecJCov(Environment env, ClassDefinition c, long Time) {
+ @SuppressWarnings("deprecation")
String SourceFile = ((SourceClass)c).getAbsoluteName();
TmpCovTable.addElement(createClassJcovElement(env, c));
@@ -667,6 +672,7 @@
* generate file of coverage data
*/
+@SuppressWarnings("deprecation") // for JCovd.readLine() calls
public void GenJCov(Environment env) {
try {
@@ -686,14 +692,14 @@
while((CurrLine = JCovd.readLine()) != null ) {
if ( CurrLine.startsWith(JcovClassLine) ) {
first = true;
- for(Enumeration e = SourceClassList.elements(); e.hasMoreElements();) {
+ for(Enumeration<String> e = SourceClassList.elements(); e.hasMoreElements();) {
String clsName = CurrLine.substring(JcovClassLine.length());
int idx = clsName.indexOf(' ');
if (idx != -1) {
clsName = clsName.substring(0, idx);
}
- Class = (String)e.nextElement();
+ Class = e.nextElement();
if ( Class.compareTo(clsName) == 0) {
first = false;
break;
@@ -708,7 +714,7 @@
}
PrintStream CovFile = new PrintStream(new DataOutputStream(new FileOutputStream(outFile)));
CovFile.println(JcovMagicLine);
- for(Enumeration e = TmpCovTable.elements(); e.hasMoreElements();) {
+ for(Enumeration<String> e = TmpCovTable.elements(); e.hasMoreElements();) {
CovFile.println(e.nextElement());
}
CovFile.close();
@@ -821,16 +827,16 @@
case opc_lookupswitch: {
SwitchData sw = (SwitchData)inst.value;
flowFields(env, sw.defaultLabel, locals);
- for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
- flowFields(env, (Label)e.nextElement(), locals);
+ for (Enumeration<Label> e = sw.tab.elements() ; e.hasMoreElements();) {
+ flowFields(env, e.nextElement(), locals);
}
return;
}
case opc_try: {
- Vector catches = ((TryData)inst.value).catches;
- for (Enumeration e = catches.elements(); e.hasMoreElements();) {
- CatchData cd = (CatchData)e.nextElement();
+ Vector<CatchData> catches = ((TryData)inst.value).catches;
+ for (Enumeration<CatchData> e = catches.elements(); e.hasMoreElements();) {
+ CatchData cd = e.nextElement();
flowFields(env, cd.getLabel(), locals);
}
break;
@@ -851,9 +857,10 @@
// Initialize arguments
if ((field != null) && (field.getArguments() != null)) {
int reg = 0;
- Vector v = field.getArguments();
- for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
- MemberDefinition f = ((MemberDefinition)e.nextElement());
+ @SuppressWarnings("unchecked")
+ Vector<MemberDefinition> v = (Vector<MemberDefinition>)field.getArguments();
+ for (Enumeration<MemberDefinition> e = v.elements(); e.hasMoreElements(); ) {
+ MemberDefinition f = e.nextElement();
locals[reg] = f;
reg += f.getType().stackSize();
}
@@ -867,9 +874,10 @@
locals[i] = null;
if ((field != null) && (field.getArguments() != null)) {
int reg = 0;
- Vector v = field.getArguments();
- for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
- MemberDefinition f = ((MemberDefinition)e.nextElement());
+ @SuppressWarnings("unchecked")
+ Vector<MemberDefinition> v = (Vector<MemberDefinition>)field.getArguments();
+ for (Enumeration<MemberDefinition> e = v.elements(); e.hasMoreElements(); ) {
+ MemberDefinition f = e.nextElement();
locals[reg] = f;
lvtab.define(f, reg, 0, maxpc);
reg += f.getType().stackSize();
--- a/jdk/src/share/classes/sun/tools/asm/ConstantPool.java Wed Aug 07 12:13:34 2013 -0700
+++ b/jdk/src/share/classes/sun/tools/asm/ConstantPool.java Wed Aug 07 16:29:36 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,20 +42,20 @@
*/
public final
class ConstantPool implements RuntimeConstants {
- Hashtable hash = new Hashtable(101);
+ Hashtable<Object,ConstantPoolData> hash = new Hashtable<>(101);
/**
* Find an entry, may return 0
*/
public int index(Object obj) {
- return ((ConstantPoolData)hash.get(obj)).index;
+ return hash.get(obj).index;
}
/**
* Add an entry
*/
public void put(Object obj) {
- ConstantPoolData data = (ConstantPoolData)hash.get(obj);
+ ConstantPoolData data = hash.get(obj);
if (data == null) {
if (obj instanceof String) {
data = new StringConstantData(this, (String)obj);
@@ -87,8 +87,8 @@
// Make a list of all the constant pool items
for (int n = 0 ; n < 5 ; n++) {
int first = count;
- for (Enumeration e = hash.elements() ; e.hasMoreElements() ;) {
- ConstantPoolData data = (ConstantPoolData)e.nextElement();
+ for (Enumeration<ConstantPoolData> e = hash.elements() ; e.hasMoreElements() ;) {
+ ConstantPoolData data = e.nextElement();
if (data.order() == n) {
keys[count] = sortKey(data);
list[count++] = data;
--- a/jdk/src/share/classes/sun/tools/asm/Instruction.java Wed Aug 07 12:13:34 2013 -0700
+++ b/jdk/src/share/classes/sun/tools/asm/Instruction.java Wed Aug 07 16:29:36 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -274,9 +274,9 @@
case opc_lookupswitch: {
SwitchData sw = (SwitchData)value;
sw.defaultLabel = sw.defaultLabel.getDestination();
- for (Enumeration e = sw.tab.keys() ; e.hasMoreElements() ; ) {
- Integer k = (Integer)e.nextElement();
- Label lbl = (Label)sw.tab.get(k);
+ for (Enumeration<Integer> e = sw.tab.keys() ; e.hasMoreElements() ; ) {
+ Integer k = e.nextElement();
+ Label lbl = sw.tab.get(k);
sw.tab.put(k, lbl.getDestination());
}
@@ -389,8 +389,8 @@
return;
case opc_try:
- for (Enumeration e = ((TryData)value).catches.elements() ; e.hasMoreElements() ;) {
- CatchData cd = (CatchData)e.nextElement();
+ for (Enumeration<CatchData> e = ((TryData)value).catches.elements() ; e.hasMoreElements() ;) {
+ CatchData cd = e.nextElement();
if (cd.getType() != null) {
tab.put(cd.getType());
}
@@ -641,6 +641,7 @@
/**
* Generate code
*/
+ @SuppressWarnings("fallthrough")
void write(DataOutputStream out, ConstantPool tab) throws IOException {
switch (opc) {
case opc_try: case opc_label: case opc_dead:
@@ -770,8 +771,8 @@
}
out.writeInt(sw.defaultLabel.pc - pc);
out.writeInt(sw.tab.size());
- for (Enumeration e = sw.sortedKeys(); e.hasMoreElements() ; ) {
- Integer v = (Integer)e.nextElement();
+ for (Enumeration<Integer> e = sw.sortedKeys(); e.hasMoreElements() ; ) {
+ Integer v = e.nextElement();
out.writeInt(v.intValue());
out.writeInt(sw.get(v).pc - pc);
}
--- a/jdk/src/share/classes/sun/tools/asm/SwitchData.java Wed Aug 07 12:13:34 2013 -0700
+++ b/jdk/src/share/classes/sun/tools/asm/SwitchData.java Wed Aug 07 16:29:36 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,23 +39,23 @@
class SwitchData {
int minValue, maxValue;
Label defaultLabel = new Label();
- Hashtable tab = new Hashtable();
+ Hashtable<Integer,Label> tab = new Hashtable<>();
// JCOV
- Hashtable whereCaseTab = null;
+ Hashtable<Integer,Long> whereCaseTab = null;
// end JCOV
/**
* Get a label
*/
public Label get(int n) {
- return (Label)tab.get(new Integer(n));
+ return tab.get(n);
}
/**
* Get a label
*/
public Label get(Integer n) {
- return (Label)tab.get(n);
+ return tab.get(n);
}
/**
@@ -73,7 +73,7 @@
maxValue = n;
}
}
- tab.put(new Integer(n), lbl);
+ tab.put(Integer.valueOf(n), lbl);
}
/**
@@ -86,33 +86,35 @@
/**
* Return the keys of this enumaration sorted in ascending order
*/
- public synchronized Enumeration sortedKeys() {
+ public synchronized Enumeration<Integer> sortedKeys() {
return new SwitchDataEnumeration(tab);
}
// JCOV
public void initTableCase() {
- whereCaseTab = new Hashtable();
+ whereCaseTab = new Hashtable<Integer,Long>();
}
public void addTableCase(int index, long where) {
if (whereCaseTab != null)
- whereCaseTab.put(new Integer(index), new Long(where));
+ whereCaseTab.put(Integer.valueOf(index), Long.valueOf(where));
}
+ // this puts String key into Hashtable<Integer,Long>
+ @SuppressWarnings("unchecked")
public void addTableDefault(long where) {
if (whereCaseTab != null)
- whereCaseTab.put("default", new Long(where));
+ ((Hashtable)whereCaseTab).put("default", Long.valueOf(where));
}
public long whereCase(Object key) {
- Long i = (Long) whereCaseTab.get(key);
- return (i == null) ? 0 : i.longValue();
+ Long i = whereCaseTab.get(key);
+ return (i == null) ? 0L : i.longValue();
}
public boolean getDefault() {
- return (whereCase("default") != 0);
+ return (whereCase("default") != 0L);
}
// end JCOV
}
-class SwitchDataEnumeration implements Enumeration {
+class SwitchDataEnumeration implements Enumeration<Integer> {
private Integer table[];
private int current_index = 0;
@@ -121,11 +123,11 @@
* hash table will be an Integer, with the value being a label. The
* enumeration returns the keys in sorted order.
*/
- SwitchDataEnumeration(Hashtable tab) {
+ SwitchDataEnumeration(Hashtable<Integer,Label> tab) {
table = new Integer[tab.size()];
int i = 0;
- for (Enumeration e = tab.keys() ; e.hasMoreElements() ; ) {
- table[i++] = (Integer)e.nextElement();
+ for (Enumeration<Integer> e = tab.keys() ; e.hasMoreElements() ; ) {
+ table[i++] = e.nextElement();
}
Arrays.sort(table);
current_index = 0;
@@ -141,7 +143,7 @@
/**
* Return the next key.
*/
- public Object nextElement() {
+ public Integer nextElement() {
return table[current_index++];
}
}
--- a/jdk/src/share/classes/sun/tools/asm/TryData.java Wed Aug 07 12:13:34 2013 -0700
+++ b/jdk/src/share/classes/sun/tools/asm/TryData.java Wed Aug 07 16:29:36 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
*/
public final
class TryData {
- Vector catches = new Vector();
+ Vector<CatchData> catches = new Vector<>();
Label endLabel = new Label();
/**
@@ -51,7 +51,7 @@
* Get a label
*/
public CatchData getCatch(int n) {
- return (CatchData)catches.elementAt(n);
+ return catches.elementAt(n);
}
/**