1.1 --- a/test/tools/javac/lib/DPrinter.java Thu Jan 31 19:31:37 2013 -0800 1.2 +++ b/test/tools/javac/lib/DPrinter.java Fri Feb 01 08:33:48 2013 -0800 1.3 @@ -210,7 +210,7 @@ 1.4 return; 1.5 } 1.6 1.7 - printString(label, ""); 1.8 + printString(label, hashString(annotations)); 1.9 1.10 indent(+1); 1.11 if (attributes == DECL_NOT_STARTED) 1.12 @@ -383,11 +383,12 @@ 1.13 case FULL: 1.14 indent(); 1.15 out.print(label); 1.16 - out.println(": " + String.format("0x%x", sym.kind) 1.17 - + "--" + Kinds.kindName(sym).name() 1.18 - + " " + sym.getKind() 1.19 + out.println(": " + 1.20 + info(sym.getClass(), 1.21 + String.format("0x%x--%s", sym.kind, Kinds.kindName(sym)), 1.22 + sym.getKind()) 1.23 + " " + sym.name 1.24 - + " " + String.format("#%x", sym.hashCode())); 1.25 + + " " + hashString(sym)); 1.26 1.27 indent(+1); 1.28 if (showSrc) { 1.29 @@ -401,7 +402,7 @@ 1.30 printSymbol("owner", sym.owner, Details.SUMMARY); 1.31 printType("type", sym.type, Details.SUMMARY); 1.32 printType("erasure", sym.erasure_field, Details.SUMMARY); 1.33 - sym.accept(symVisitor, true); 1.34 + sym.accept(symVisitor, null); 1.35 printAnnotations("annotations", sym.annotations, Details.SUMMARY); 1.36 indent(-1); 1.37 } 1.38 @@ -417,7 +418,13 @@ 1.39 printNull(label); 1.40 } else { 1.41 indent(); 1.42 - out.print(label + ": " + tree.getTag()); 1.43 + String ext; 1.44 + try { 1.45 + ext = tree.getKind().name(); 1.46 + } catch (Throwable t) { 1.47 + ext = "n/a"; 1.48 + } 1.49 + out.print(label + ": " + info(tree.getClass(), tree.getTag(), ext)); 1.50 if (showPositions) { 1.51 // We can always get start position, but to get end position 1.52 // and/or line+offset, we would need a JCCompilationUnit 1.53 @@ -456,13 +463,13 @@ 1.54 case FULL: 1.55 indent(); 1.56 out.print(label); 1.57 - out.println(": " + type.getTag() 1.58 - + " " + String.format("#%x", type.hashCode())); 1.59 + out.println(": " + info(type.getClass(), type.getTag(), type.getKind()) 1.60 + + " " + hashString(type)); 1.61 1.62 indent(+1); 1.63 printSymbol("tsym", type.tsym, Details.SUMMARY); 1.64 printObject("constValue", type.constValue(), Details.SUMMARY); 1.65 - type.accept(typeVisitor, true); 1.66 + type.accept(typeVisitor, null); 1.67 indent(-1); 1.68 } 1.69 } 1.70 @@ -472,6 +479,14 @@ 1.71 return (printer != null) ? printer.visit(type, locale) : String.valueOf(type); 1.72 } 1.73 1.74 + protected String hashString(Object obj) { 1.75 + return String.format("#%x", obj.hashCode()); 1.76 + } 1.77 + 1.78 + protected String info(Class<?> clazz, Object internal, Object external) { 1.79 + return String.format("%s,%s,%s", clazz.getSimpleName(), internal, external); 1.80 + } 1.81 + 1.82 private int indent = 0; 1.83 1.84 protected void indent() { 1.85 @@ -853,17 +868,16 @@ 1.86 1.87 // <editor-fold defaultstate="collapsed" desc="Symbol visitor"> 1.88 1.89 - protected Symbol.Visitor<Void,Boolean> symVisitor = new SymbolVisitor(); 1.90 + protected Symbol.Visitor<Void,Void> symVisitor = new SymbolVisitor(); 1.91 1.92 /** 1.93 * Default visitor class for Symbol objects. 1.94 * Note: each visitXYZ method ends by calling the corresponding 1.95 * visit method for its superclass. 1.96 */ 1.97 - class SymbolVisitor implements Symbol.Visitor<Void,Boolean> { 1.98 + class SymbolVisitor implements Symbol.Visitor<Void,Void> { 1.99 @Override 1.100 - public Void visitClassSymbol(ClassSymbol sym, Boolean impl) { 1.101 - if (impl) printImplClass(sym, ClassSymbol.class); 1.102 + public Void visitClassSymbol(ClassSymbol sym, Void ignore) { 1.103 printName("fullname", sym.fullname); 1.104 printName("flatname", sym.flatname); 1.105 printScope("members", sym.members_field); 1.106 @@ -871,55 +885,49 @@ 1.107 printFileObject("classfile", sym.classfile); 1.108 // trans-local? 1.109 // pool? 1.110 - return visitTypeSymbol(sym, false); 1.111 + return visitTypeSymbol(sym, null); 1.112 } 1.113 1.114 @Override 1.115 - public Void visitMethodSymbol(MethodSymbol sym, Boolean impl) { 1.116 - if (impl) printImplClass(sym, MethodSymbol.class); 1.117 + public Void visitMethodSymbol(MethodSymbol sym, Void ignore) { 1.118 // code 1.119 printList("params", sym.params); 1.120 printList("savedParameterNames", sym.savedParameterNames); 1.121 - return visitSymbol(sym, false); 1.122 + return visitSymbol(sym, null); 1.123 } 1.124 1.125 @Override 1.126 - public Void visitPackageSymbol(PackageSymbol sym, Boolean impl) { 1.127 - if (impl) printImplClass(sym, PackageSymbol.class); 1.128 + public Void visitPackageSymbol(PackageSymbol sym, Void ignore) { 1.129 printName("fullname", sym.fullname); 1.130 printScope("members", sym.members_field); 1.131 printSymbol("package-info", sym.package_info, Details.SUMMARY); 1.132 - return visitTypeSymbol(sym, false); 1.133 + return visitTypeSymbol(sym, null); 1.134 } 1.135 1.136 @Override 1.137 - public Void visitOperatorSymbol(OperatorSymbol sym, Boolean impl) { 1.138 - if (impl) printImplClass(sym, OperatorSymbol.class); 1.139 + public Void visitOperatorSymbol(OperatorSymbol sym, Void ignore) { 1.140 printInt("opcode", sym.opcode); 1.141 - return visitMethodSymbol(sym, false); 1.142 + return visitMethodSymbol(sym, null); 1.143 } 1.144 1.145 @Override 1.146 - public Void visitVarSymbol(VarSymbol sym, Boolean impl) { 1.147 - if (impl) printImplClass(sym, VarSymbol.class); 1.148 + public Void visitVarSymbol(VarSymbol sym, Void ignore) { 1.149 printInt("pos", sym.pos); 1.150 printInt("adm", sym.adr); 1.151 // data is a private field, and the standard accessors may 1.152 // mutate it as part of lazy evaluation. Therefore, use 1.153 // reflection to get the raw data. 1.154 printObject("data", getField(sym, VarSymbol.class, "data"), Details.SUMMARY); 1.155 - return visitSymbol(sym, false); 1.156 + return visitSymbol(sym, null); 1.157 } 1.158 1.159 @Override 1.160 - public Void visitTypeSymbol(TypeSymbol sym, Boolean impl) { 1.161 - if (impl) printImplClass(sym, TypeSymbol.class); 1.162 - return visitSymbol(sym, false); 1.163 + public Void visitTypeSymbol(TypeSymbol sym, Void ignore) { 1.164 + return visitSymbol(sym, null); 1.165 } 1.166 1.167 @Override 1.168 - public Void visitSymbol(Symbol sym, Boolean impl) { 1.169 - if (impl) printImplClass(sym, Symbol.class); 1.170 + public Void visitSymbol(Symbol sym, Void ignore) { 1.171 return null; 1.172 } 1.173 } 1.174 @@ -928,71 +936,62 @@ 1.175 1.176 // <editor-fold defaultstate="collapsed" desc="Type visitor"> 1.177 1.178 - protected Type.Visitor<Void,Boolean> typeVisitor = new TypeVisitor(); 1.179 + protected Type.Visitor<Void,Void> typeVisitor = new TypeVisitor(); 1.180 1.181 /** 1.182 * Default visitor class for Type objects. 1.183 * Note: each visitXYZ method ends by calling the corresponding 1.184 * visit method for its superclass. 1.185 */ 1.186 - public class TypeVisitor implements Type.Visitor<Void,Boolean> { 1.187 - public Void visitAnnotatedType(AnnotatedType type, Boolean impl) { 1.188 - if (impl) printImplClass(type, AnnotatedType.class); 1.189 + public class TypeVisitor implements Type.Visitor<Void,Void> { 1.190 + public Void visitAnnotatedType(AnnotatedType type, Void ignore) { 1.191 printList("typeAnnotations", type.typeAnnotations); 1.192 printType("underlyingType", type.underlyingType, Details.FULL); 1.193 - return visitType(type, false); 1.194 + return visitType(type, null); 1.195 } 1.196 1.197 - public Void visitArrayType(ArrayType type, Boolean impl) { 1.198 - if (impl) printImplClass(type, ArrayType.class); 1.199 + public Void visitArrayType(ArrayType type, Void ignore) { 1.200 printType("elemType", type.elemtype, Details.FULL); 1.201 - return visitType(type, false); 1.202 + return visitType(type, null); 1.203 } 1.204 1.205 - public Void visitCapturedType(CapturedType type, Boolean impl) { 1.206 - if (impl) printImplClass(type, CapturedType.class); 1.207 + public Void visitCapturedType(CapturedType type, Void ignore) { 1.208 printType("wildcard", type.wildcard, Details.FULL); 1.209 - return visitTypeVar(type, false); 1.210 + return visitTypeVar(type, null); 1.211 } 1.212 1.213 - public Void visitClassType(ClassType type, Boolean impl) { 1.214 - if (impl) printImplClass(type, ClassType.class); 1.215 + public Void visitClassType(ClassType type, Void ignore) { 1.216 printType("outer", type.getEnclosingType(), Details.SUMMARY); 1.217 printList("typarams", type.typarams_field); 1.218 printList("allparams", type.allparams_field); 1.219 printType("supertype", type.supertype_field, Details.SUMMARY); 1.220 printList("interfaces", type.interfaces_field); 1.221 printList("allinterfaces", type.all_interfaces_field); 1.222 - return visitType(type, false); 1.223 + return visitType(type, null); 1.224 } 1.225 1.226 - public Void visitErrorType(ErrorType type, Boolean impl) { 1.227 - if (impl) printImplClass(type, ErrorType.class); 1.228 + public Void visitErrorType(ErrorType type, Void ignore) { 1.229 printType("originalType", type.getOriginalType(), Details.FULL); 1.230 - return visitClassType(type, false); 1.231 + return visitClassType(type, null); 1.232 } 1.233 1.234 - public Void visitForAll(ForAll type, Boolean impl) { 1.235 - if (impl) printImplClass(type, ForAll.class); 1.236 + public Void visitForAll(ForAll type, Void ignore) { 1.237 printList("tvars", type.tvars); 1.238 return visitDelegatedType(type); 1.239 } 1.240 1.241 - public Void visitMethodType(MethodType type, Boolean impl) { 1.242 - if (impl) printImplClass(type, MethodType.class); 1.243 + public Void visitMethodType(MethodType type, Void ignore) { 1.244 printList("argtypes", type.argtypes); 1.245 printType("restype", type.restype, Details.FULL); 1.246 printList("thrown", type.thrown); 1.247 - return visitType(type, false); 1.248 + return visitType(type, null); 1.249 } 1.250 1.251 - public Void visitPackageType(PackageType type, Boolean impl) { 1.252 - if (impl) printImplClass(type, PackageType.class); 1.253 - return visitType(type, false); 1.254 + public Void visitPackageType(PackageType type, Void ignore) { 1.255 + return visitType(type, null); 1.256 } 1.257 1.258 - public Void visitTypeVar(TypeVar type, Boolean impl) { 1.259 - if (impl) printImplClass(type, TypeVar.class); 1.260 + public Void visitTypeVar(TypeVar type, Void ignore) { 1.261 // For TypeVars (and not subtypes), the bound should always be 1.262 // null or bot. So, only print the bound for subtypes of TypeVar, 1.263 // or if the bound is (erroneously) not null or bot. 1.264 @@ -1001,32 +1000,29 @@ 1.265 printType("bound", type.bound, Details.FULL); 1.266 } 1.267 printType("lower", type.lower, Details.FULL); 1.268 - return visitType(type, false); 1.269 + return visitType(type, null); 1.270 } 1.271 1.272 - public Void visitUndetVar(UndetVar type, Boolean impl) { 1.273 - if (impl) printImplClass(type, UndetVar.class); 1.274 + public Void visitUndetVar(UndetVar type, Void ignore) { 1.275 for (UndetVar.InferenceBound ib: UndetVar.InferenceBound.values()) 1.276 printList("bounds." + ib, type.getBounds(ib)); 1.277 printType("inst", type.inst, Details.SUMMARY); 1.278 return visitDelegatedType(type); 1.279 } 1.280 1.281 - public Void visitWildcardType(WildcardType type, Boolean impl) { 1.282 - if (impl) printImplClass(type, WildcardType.class); 1.283 + public Void visitWildcardType(WildcardType type, Void ignore) { 1.284 printType("type", type.type, Details.SUMMARY); 1.285 printString("kind", type.kind.name()); 1.286 printType("bound", type.bound, Details.SUMMARY); 1.287 - return visitType(type, false); 1.288 + return visitType(type, null); 1.289 } 1.290 1.291 protected Void visitDelegatedType(DelegatedType type) { 1.292 printType("qtype", type.qtype, Details.FULL); 1.293 - return visitType(type, false); 1.294 + return visitType(type, null); 1.295 } 1.296 1.297 - public Void visitType(Type type, Boolean impl) { 1.298 - if (impl) printImplClass(type, Type.class); 1.299 + public Void visitType(Type type, Void ignore) { 1.300 return null; 1.301 } 1.302 }