changeset 3246:06c9978d2891

8034127: javac provide debug oriented toString() methods to InferenceContext and UndetVar Reviewed-by: jjg
author vromero
date Thu, 13 Mar 2014 17:36:51 +0000
parents d6f605b42729
children bd152504a538
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, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Mar 11 17:52:45 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Mar 13 17:36:51 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	Tue Mar 11 17:52:45 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 13 17:36:51 2014 +0000
@@ -2173,6 +2173,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());