changeset 2348:f35effa10297

8034127: javac provide debug oriented toString() methods to InferenceContext and UndetVar Reviewed-by: jjg
author vromero
date Wed, 19 Mar 2014 17:42:22 +0000
parents 27a3026256cd
children dac1b0a17386
files src/share/classes/com/sun/tools/javac/code/Type.java src/share/classes/com/sun/tools/javac/comp/Infer.java
diffstat 2 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 19 16:44:49 2014 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Mar 19 17:42:22 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -1481,8 +1481,21 @@
         }
 
         public String toString() {
-            if (inst != null) return inst.toString();
-            else return qtype + "?";
+            return (inst == null) ? qtype + "?" : inst.toString();
+        }
+
+        public String debugString() {
+            String result = "inference var = " + qtype + "\n";
+            if (inst != null) {
+                result += "inst = " + inst + '\n';
+            }
+            for (InferenceBound bound: InferenceBound.values()) {
+                List<Type> aboundList = bounds.get(bound);
+                if (aboundList.size() > 0) {
+                    result += bound + " = " + aboundList + '\n';
+                }
+            }
+            return result;
         }
 
         @Override
@@ -1492,8 +1505,7 @@
 
         @Override
         public Type baseType() {
-            if (inst != null) return inst.baseType();
-            else return this;
+            return (inst == null) ? this : inst.baseType();
         }
 
         /** get all bounds of a given kind */
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Mar 19 16:44:49 2014 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Mar 19 17:42:22 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -2119,6 +2119,12 @@
             //back-door to infer
             return Infer.this;
         }
+
+        @Override
+        public String toString() {
+            return "Inference vars: " + inferencevars + '\n' +
+                   "Undet vars: " + undetvars;
+        }
     }
 
     final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());