# HG changeset patch # User Doug Simon # Date 1377101755 -7200 # Node ID 7040c65689c5f093cda720fe225b7ebf00cbdcdb # Parent f88427168d193631deb59aaf2719ee2c5129ebf9 slightly weakened check in HotSpotResolvedJavaField.readConstantField() diff -r f88427168d19 -r 7040c65689c5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Wed Aug 21 16:03:35 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Wed Aug 21 18:15:55 2013 +0200 @@ -81,6 +81,14 @@ } /** + * Compares two {@link StackTraceElement}s for equality, ignoring differences in + * {@linkplain StackTraceElement#getLineNumber() line number}. + */ + private static boolean equalsIgnoringLine(StackTraceElement left, StackTraceElement right) { + return left.getClassName().equals(right.getClassName()) && left.getMethodName().equals(right.getMethodName()) && left.getFileName().equals(right.getFileName()); + } + + /** * If the compiler is configured for AOT mode, {@link #readConstantValue(Constant)} should be * only called for snippets or replacements. */ @@ -96,11 +104,14 @@ } catch (NoSuchMethodException | SecurityException e) { throw new GraalInternalError(e); } - StackTraceElement makeGraphSTE = makeGraphMethod.asStackTraceElement(1); - StackTraceElement initSTE = initMethod.asStackTraceElement(30); + StackTraceElement makeGraphSTE = makeGraphMethod.asStackTraceElement(0); + StackTraceElement initSTE = initMethod.asStackTraceElement(0); - for (StackTraceElement element : new Exception().getStackTrace()) { - if (makeGraphSTE.equals(element) || initSTE.equals(element)) { + StackTraceElement[] stackTrace = new Exception().getStackTrace(); + for (StackTraceElement element : stackTrace) { + // Ignoring line numbers should not weaken this check too much while at + // the same time making it more robust against source code changes + if (equalsIgnoringLine(makeGraphSTE, element) || equalsIgnoringLine(initSTE, element)) { return true; } } @@ -160,7 +171,7 @@ @Override public Constant readConstantValue(Constant receiver) { - assert !AOTCompilation.getValue() || isCalledForSnippets(); + assert !AOTCompilation.getValue() || isCalledForSnippets() : receiver; if (receiver == null) { assert Modifier.isStatic(flags);