This commit is contained in:
Tim Bell 2008-05-28 00:02:28 -07:00
commit 92579e1577
13 changed files with 187 additions and 74 deletions

@ -1606,7 +1606,7 @@ public class JavacFileManager implements StandardJavaFileManager {
/** @deprecated see bug 6410637 */
@Deprecated
public String getPath() {
return entry.getName() + "(" + entry + ")";
return zipName + "(" + entry.getName() + ")";
}
public long getLastModified() {

@ -1,3 +1,28 @@
/*
* Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.tools.javac.zip;
import java.io.*;

@ -1,3 +1,28 @@
/*
* Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.tools.javac.zip;
import java.io.File;

@ -58,7 +58,7 @@ public class ClassData implements RuntimeConstants {
private String superclassname;
private int source_cpx=0;
private byte tags[];
private Hashtable indexHashAscii = new Hashtable();
private Hashtable<Object,Integer> indexHashAscii = new Hashtable<Object,Integer>();
private String pkgPrefix="";
private int pkgPrefixLen=0;
@ -167,19 +167,19 @@ public class ClassData implements RuntimeConstants {
switch(tags[i] = tag) {
case CONSTANT_UTF8:
String str=in.readUTF();
indexHashAscii.put(cpool[i] = str, new Integer(i));
indexHashAscii.put(cpool[i] = str, i);
break;
case CONSTANT_INTEGER:
cpool[i] = new Integer(in.readInt());
cpool[i] = Integer.valueOf(in.readInt());
break;
case CONSTANT_FLOAT:
cpool[i] = new Float(in.readFloat());
cpool[i] = Float.valueOf(in.readFloat());
break;
case CONSTANT_LONG:
cpool[i++] = new Long(in.readLong());
cpool[i++] = Long.valueOf(in.readLong());
break;
case CONSTANT_DOUBLE:
cpool[i++] = new Double(in.readDouble());
cpool[i++] = Double.valueOf(in.readDouble());
break;
case CONSTANT_CLASS:
case CONSTANT_STRING:
@ -365,7 +365,7 @@ public class ClassData implements RuntimeConstants {
* Returns the access of this class or interface.
*/
public String[] getAccess(){
Vector v = new Vector();
Vector<String> v = new Vector<String>();
if ((access & ACC_PUBLIC) !=0) v.addElement("public");
if ((access & ACC_FINAL) !=0) v.addElement("final");
if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract");

@ -45,7 +45,7 @@ public class FieldData implements RuntimeConstants {
int value_cpx=0;
boolean isSynthetic=false;
boolean isDeprecated=false;
Vector attrs;
Vector<AttrData> attrs;
public FieldData(ClassData cls){
this.cls=cls;
@ -60,7 +60,7 @@ public class FieldData implements RuntimeConstants {
descriptor_index = in.readUnsignedShort();
// Read the attributes
int attributes_count = in.readUnsignedShort();
attrs=new Vector(attributes_count);
attrs=new Vector<AttrData>(attributes_count);
for (int i = 0; i < attributes_count; i++) {
int attr_name_index=in.readUnsignedShort();
if (cls.getTag(attr_name_index)!=CONSTANT_UTF8) continue;
@ -99,7 +99,7 @@ public class FieldData implements RuntimeConstants {
* Returns access of a field.
*/
public String[] getAccess(){
Vector v = new Vector();
Vector<String> v = new Vector<String>();
if ((access & ACC_PUBLIC) !=0) v.addElement("public");
if ((access & ACC_PRIVATE) !=0) v.addElement("private");
if ((access & ACC_PROTECTED) !=0) v.addElement("protected");

@ -63,7 +63,7 @@ class InnerClassData implements RuntimeConstants {
* Returns the access of this class or interface.
*/
public String[] getAccess(){
Vector v = new Vector();
Vector<String> v = new Vector<String>();
if ((access & ACC_PUBLIC) !=0) v.addElement("public");
if ((access & ACC_FINAL) !=0) v.addElement("final");
if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract");

@ -653,7 +653,7 @@ public class JavapPrinter {
case CONSTANT_METHOD:
case CONSTANT_INTERFACEMETHOD:
case CONSTANT_FIELD: {
CPX2 x = (CPX2)(cls.getCpoolEntry(cpx));
CPX2 x = cls.getCpoolEntry(cpx);
if (x.cpx1 == cls.getthis_cpx()) {
// don't print class part for local references
cpx=x.cpx2;
@ -851,7 +851,7 @@ public class JavapPrinter {
case CONSTANT_INTERFACEMETHOD:
case CONSTANT_FIELD: {
// CPX2 x=(CPX2)(cpool[cpx]);
CPX2 x = (CPX2)(cls.getCpoolEntry(cpx));
CPX2 x = cls.getCpoolEntry(cpx);
if (x.cpx1 == cls.getthis_cpx()) {
// don't print class part for local references
cpx=x.cpx2;

@ -35,9 +35,9 @@ import java.io.*;
*
* @author Sucheta Dambalkar (Adopted code from old javap)
*/
public class Main{
public class Main {
private Vector classList = new Vector();
private Vector<String> classList = new Vector<String>();
private PrintWriter out;
JavapEnvironment env = new JavapEnvironment();
private static boolean errorOccurred = false;
@ -201,7 +201,7 @@ public class Main{
*/
private void displayResults() {
for (int i = 0; i < classList.size() ; i++ ) {
String Name = (String)classList.elementAt(i);
String Name = classList.elementAt(i);
InputStream classin = env.getFileInputStream(Name);
try {

@ -43,14 +43,14 @@ public class MethodData {
int descriptor_index;
int attributes_count;
byte[] code;
Vector exception_table = new Vector(0);
Vector lin_num_tb = new Vector(0);
Vector loc_var_tb = new Vector(0);
Vector<TrapData> exception_table = new Vector<TrapData>(0);
Vector<LineNumData> lin_num_tb = new Vector<LineNumData>(0);
Vector<LocVarData> loc_var_tb = new Vector<LocVarData>(0);
StackMapTableData[] stackMapTable;
StackMapData[] stackMap;
int[] exc_index_table=null;
Vector attrs=new Vector(0);
Vector code_attrs=new Vector(0);
Vector<AttrData> attrs=new Vector<AttrData>(0);
Vector<AttrData> code_attrs=new Vector<AttrData>(0);
int max_stack, max_locals;
boolean isSynthetic=false;
boolean isDeprecated=false;
@ -165,7 +165,7 @@ public class MethodData {
*/
void readExceptionTable (DataInputStream in) throws IOException {
int exception_table_len=in.readUnsignedShort();
exception_table=new Vector(exception_table_len);
exception_table=new Vector<TrapData>(exception_table_len);
for (int l = 0; l < exception_table_len; l++) {
exception_table.addElement(new TrapData(in, l));
}
@ -177,7 +177,7 @@ public class MethodData {
void readLineNumTable (DataInputStream in) throws IOException {
int attr_len = in.readInt(); // attr_length
int lin_num_tb_len = in.readUnsignedShort();
lin_num_tb=new Vector(lin_num_tb_len);
lin_num_tb=new Vector<LineNumData>(lin_num_tb_len);
for (int l = 0; l < lin_num_tb_len; l++) {
lin_num_tb.addElement(new LineNumData(in));
}
@ -189,7 +189,7 @@ public class MethodData {
void readLocVarTable (DataInputStream in) throws IOException {
int attr_len=in.readInt(); // attr_length
int loc_var_tb_len = in.readUnsignedShort();
loc_var_tb = new Vector(loc_var_tb_len);
loc_var_tb = new Vector<LocVarData>(loc_var_tb_len);
for (int l = 0; l < loc_var_tb_len; l++) {
loc_var_tb.addElement(new LocVarData(in));
}
@ -237,7 +237,7 @@ public class MethodData {
*/
public String[] getAccess(){
Vector v = new Vector();
Vector<String> v = new Vector<String>();
if ((access & ACC_PUBLIC) !=0) v.addElement("public");
if ((access & ACC_PRIVATE) !=0) v.addElement("private");
if ((access & ACC_PROTECTED) !=0) v.addElement("protected");

@ -26,8 +26,6 @@
package sun.tools.javap;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Vector;
@ -36,14 +34,14 @@ public class Tables implements Constants {
/**
* Define mnemocodes table.
*/
static Hashtable mnemocodes = new Hashtable(301, 0.5f);
static Hashtable<String,Integer> mnemocodes = new Hashtable<String,Integer>(301, 0.5f);
static String opcExtNamesTab[]=new String[128];
static String opcPrivExtNamesTab[]=new String[128];
static void defineNonPriv(int opc, String mnem) {
mnemocodes.put(opcExtNamesTab[opc]=mnem, new Integer(opc_nonpriv*256+opc));
mnemocodes.put(opcExtNamesTab[opc]=mnem, opc_nonpriv*256+opc);
}
static void definePriv(int opc, String mnem) {
mnemocodes.put(opcPrivExtNamesTab[opc]="priv_"+mnem, new Integer(opc_priv*256+opc));
mnemocodes.put(opcPrivExtNamesTab[opc]="priv_"+mnem, opc_priv*256+opc);
}
static void defineExt(int opc, String mnem) {
defineNonPriv(opc, mnem);
@ -51,28 +49,28 @@ public class Tables implements Constants {
}
static { int k;
for (k=0; k<opc_wide; k++) {
mnemocodes.put(opcNamesTab[k], new Integer(k));
mnemocodes.put(opcNamesTab[k], k);
}
for (k=opc_wide+1; k<opcNamesTab.length; k++) {
mnemocodes.put(opcNamesTab[k], new Integer(k));
mnemocodes.put(opcNamesTab[k], k);
}
mnemocodes.put("invokenonvirtual", new Integer(opc_invokespecial));
mnemocodes.put("invokenonvirtual", opc_invokespecial);
mnemocodes.put("iload_w", new Integer(opc_iload_w));
mnemocodes.put("lload_w", new Integer(opc_lload_w));
mnemocodes.put("fload_w", new Integer(opc_fload_w));
mnemocodes.put("dload_w", new Integer(opc_dload_w));
mnemocodes.put("aload_w", new Integer(opc_aload_w));
mnemocodes.put("istore_w", new Integer(opc_istore_w));
mnemocodes.put("lstore_w", new Integer(opc_lstore_w));
mnemocodes.put("fstore_w", new Integer(opc_fstore_w));
mnemocodes.put("dstore_w", new Integer(opc_dstore_w));
mnemocodes.put("astore_w", new Integer(opc_astore_w));
mnemocodes.put("ret_w", new Integer(opc_ret_w));
mnemocodes.put("iinc_w", new Integer(opc_iinc_w));
mnemocodes.put("iload_w", opc_iload_w);
mnemocodes.put("lload_w", opc_lload_w);
mnemocodes.put("fload_w", opc_fload_w);
mnemocodes.put("dload_w", opc_dload_w);
mnemocodes.put("aload_w", opc_aload_w);
mnemocodes.put("istore_w", opc_istore_w);
mnemocodes.put("lstore_w", opc_lstore_w);
mnemocodes.put("fstore_w", opc_fstore_w);
mnemocodes.put("dstore_w", opc_dstore_w);
mnemocodes.put("astore_w", opc_astore_w);
mnemocodes.put("ret_w", opc_ret_w);
mnemocodes.put("iinc_w", opc_iinc_w);
mnemocodes.put("nonpriv", new Integer(opc_nonpriv));
mnemocodes.put("priv", new Integer(opc_priv));
mnemocodes.put("nonpriv", opc_nonpriv);
mnemocodes.put("priv", opc_priv);
defineExt(0, "load_ubyte");
defineExt(1, "load_byte");
@ -183,7 +181,7 @@ public class Tables implements Constants {
}
public static int opcode(String mnem) {
Integer Val=(Integer)(mnemocodes.get(mnem));
Integer Val=mnemocodes.get(mnem);
if (Val == null) return -1;
return Val.intValue();
}
@ -191,7 +189,7 @@ public class Tables implements Constants {
/**
* Initialized keyword and token Hashtables
*/
static Vector keywordNames = new Vector(40);
static Vector<String> keywordNames = new Vector<String>(40);
private static void defineKeywordName(String id, int token) {
if (token>=keywordNames.size()) {
@ -202,7 +200,7 @@ public class Tables implements Constants {
public static String keywordName(int token) {
if (token==-1) return "EOF";
if (token>=keywordNames.size()) return null;
return (String)keywordNames.elementAt(token);
return keywordNames.elementAt(token);
}
static {
defineKeywordName("ident", IDENT);
@ -217,15 +215,15 @@ public class Tables implements Constants {
defineKeywordName("RBRACE", RBRACE);
}
static Hashtable keywords = new Hashtable(40);
static Hashtable<String,Integer> keywords = new Hashtable<String,Integer>(40);
public static int keyword(String idValue) {
Integer Val=(Integer)(keywords.get(idValue));
if (Val == null) return IDENT;
return Val.intValue();
Integer val=keywords.get(idValue);
if (val == null) return IDENT;
return val.intValue();
}
private static void defineKeyword(String id, int token) {
keywords.put(id, new Integer(token));
keywords.put(id, token);
defineKeywordName(id, token);
}
static {
@ -275,8 +273,8 @@ public class Tables implements Constants {
/**
* Define tag table.
*/
private static Vector tagNames = new Vector(10);
private static Hashtable Tags = new Hashtable(10);
private static Vector<String> tagNames = new Vector<String>(10);
private static Hashtable<String,Integer> Tags = new Hashtable<String,Integer>(10);
static {
defineTag("Asciz",CONSTANT_UTF8);
defineTag("int",CONSTANT_INTEGER);
@ -291,7 +289,7 @@ public class Tables implements Constants {
defineTag("NameAndType",CONSTANT_NAMEANDTYPE);
}
private static void defineTag(String id, int val) {
Tags.put(id, new Integer(val));
Tags.put(id, val);
if (val>=tagNames.size()) {
tagNames.setSize(val+1);
}
@ -299,10 +297,10 @@ public class Tables implements Constants {
}
public static String tagName(int tag) {
if (tag>=tagNames.size()) return null;
return (String)tagNames.elementAt(tag);
return tagNames.elementAt(tag);
}
public static int tagValue(String idValue) {
Integer Val=(Integer)(Tags.get(idValue));
Integer Val=Tags.get(idValue);
if (Val == null) return 0;
return Val.intValue();
}
@ -310,8 +308,8 @@ public class Tables implements Constants {
/**
* Define type table. These types used in "newarray" instruction only.
*/
private static Vector typeNames = new Vector(10);
private static Hashtable Types = new Hashtable(10);
private static Vector<String> typeNames = new Vector<String>(10);
private static Hashtable<String,Integer> Types = new Hashtable<String,Integer>(10);
static {
defineType("int",T_INT);
defineType("long",T_LONG);
@ -324,28 +322,28 @@ public class Tables implements Constants {
defineType("short",T_SHORT);
}
private static void defineType(String id, int val) {
Types.put(id, new Integer(val));
Types.put(id, val);
if (val>=typeNames.size()) {
typeNames.setSize(val+1);
}
typeNames.setElementAt(id, val);
}
public static int typeValue(String idValue) {
Integer Val=(Integer)(Types.get(idValue));
Integer Val=Types.get(idValue);
if (Val == null) return -1;
return Val.intValue();
}
public static String typeName(int type) {
if (type>=typeNames.size()) return null;
return (String)typeNames.elementAt(type);
return typeNames.elementAt(type);
}
/**
* Define MapTypes table.
* These constants used in stackmap tables only.
*/
private static Vector mapTypeNames = new Vector(10);
private static Hashtable MapTypes = new Hashtable(10);
private static Vector<String> mapTypeNames = new Vector<String>(10);
private static Hashtable<String,Integer> MapTypes = new Hashtable<String,Integer>(10);
static {
defineMapType("bogus", ITEM_Bogus);
defineMapType("int", ITEM_Integer);
@ -358,20 +356,20 @@ public class Tables implements Constants {
defineMapType("uninitialized", ITEM_NewObject);
}
private static void defineMapType(String id, int val) {
MapTypes.put(id, new Integer(val));
MapTypes.put(id, val);
if (val>=mapTypeNames.size()) {
mapTypeNames.setSize(val+1);
}
mapTypeNames.setElementAt(id, val);
}
public static int mapTypeValue(String idValue) {
Integer Val=(Integer)(MapTypes.get(idValue));
Integer Val=MapTypes.get(idValue);
if (Val == null) return -1;
return Val.intValue();
}
public static String mapTypeName(int type) {
if (type>=mapTypeNames.size()) return null;
return (String)mapTypeNames.elementAt(type);
return mapTypeNames.elementAt(type);
}
}

@ -79,7 +79,7 @@ public class TypeSignature {
* Returns java type signature of a parameter.
*/
public String getParametersHelper(String parameterdes){
Vector parameters = new Vector();
Vector<String> parameters = new Vector<String>();
int startindex = -1;
int endindex = -1;
String param = "";
@ -187,7 +187,7 @@ public class TypeSignature {
int i;
for(i = 0; i < parameters.size(); i++){
parametersignature += (String)parameters.elementAt(i);
parametersignature += parameters.elementAt(i);
if(i != parameters.size()-1){
parametersignature += ", ";
}

@ -24,7 +24,7 @@ public class T6589361 {
Iterable<JavaFileObject> files = fm.list(StandardLocation.PLATFORM_CLASS_PATH, "java.lang", set, false);
for (JavaFileObject file : files) {
if (file.toString().startsWith("java" + File.separator + "lang" + File.separator + "Object.class")) {
if (file.toString().contains("java" + File.separator + "lang" + File.separator + "Object.class")) {
String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
if (!str.equals("java.lang.Object")) {
throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");

@ -0,0 +1,65 @@
/*
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6705935
* @summary javac reports path name of entry in ZipFileIndex incorectly
*/
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.tools.javac.util.*;
public class T6705935 {
public static void main(String... args) throws Exception {
new T6705935().run();
}
public void run() throws Exception {
File java_home = new File(System.getProperty("java.home"));
if (java_home.getName().equals("jre"))
java_home = java_home.getParentFile();
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
JavaFileManager fm = c.getStandardFileManager(null, null, null);
for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
"java.lang",
Collections.singleton(JavaFileObject.Kind.CLASS),
false)) {
String p = ((BaseFileObject)fo).getPath();
int bra = p.indexOf("(");
int ket = p.indexOf(")");
//System.err.println(bra + "," + ket + "," + p.length());
if (bra == -1 || ket != p.length() -1)
throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
String part1 = p.substring(0, bra);
String part2 = p.substring(bra + 1, ket);
//System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
throw new Exception("bad path: " + p);
}
}
}