changeset 13627:a2aac8373610

more robust handling of errors in Constant.toString()
author Doug Simon <doug.simon@oracle.com>
date Tue, 14 Jan 2014 11:56:04 +0100
parents d368f5556059
children 110795e38ac6
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Mon Jan 13 23:03:12 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Tue Jan 14 11:56:04 2014 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.api.meta;
 
+import static com.oracle.graal.api.meta.MetaUtil.*;
+
 /**
  * Represents a constant (boxed) value, such as an integer, floating point number, or object
  * reference, within the compiler and across the compiler/runtime interface. Exports a set of
@@ -121,8 +123,13 @@
             return "illegal";
         } else {
             String annotationSuffix = "";
-            if (getKind() != Kind.Object && getPrimitiveAnnotation() != null) {
-                annotationSuffix = "{" + getPrimitiveAnnotation() + "}";
+            Object primitiveAnnotation = getPrimitiveAnnotation();
+            if (getKind() != Kind.Object && primitiveAnnotation != null) {
+                try {
+                    annotationSuffix = "{" + primitiveAnnotation + "}";
+                } catch (Throwable t) {
+                    annotationSuffix = "{" + getSimpleName(primitiveAnnotation.getClass(), true) + "@" + System.identityHashCode(primitiveAnnotation) + "}";
+                }
             }
             return getKind().getJavaName() + "[" + getKind().format(asBoxedValue()) + (getKind() != Kind.Object ? "|0x" + Long.toHexString(primitive) : "") + "]" + annotationSuffix;
         }