# HG changeset patch # User Doug Simon # Date 1389696964 -3600 # Node ID a2aac83736100db6881cdc9c791e2e11ff858878 # Parent d368f55560599f09add93c6488e1368dca4549b4 more robust handling of errors in Constant.toString() diff -r d368f5556059 -r a2aac8373610 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java --- 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; }