RFR JDK-8193325: StackFrameInfo::getByteCodeIndex returns wrong value if bci > 32767
Mandy Chung
mandy.chung at oracle.com
Mon Aug 12 19:01:36 UTC 2019
On 8/12/19 11:33 AM, Aleksey Shipilev wrote:
>> Alternatively, we can make bci an int (as Alekey suggests) that does not increase the object size:
>>
>> http://cr.openjdk.java.net/~mchung/jdk14/8193325/webrev.02/
> @Stable seems meaningless here, for the reasons Daniel points out. I believe "final int bci" is just as good and clean.
I am happy to keep it final field and the comment already indicates that
the field is set by the VM. It's initialized to -1 in case any accident
change that VM didn't set this field.
diff --git a/src/java.base/share/classes/java/lang/StackFrameInfo.java
b/src/java.base/share/classes/java/lang/StackFrameInfo.java
--- a/src/java.base/share/classes/java/lang/StackFrameInfo.java
+++ b/src/java.base/share/classes/java/lang/StackFrameInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights
reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -26,28 +26,31 @@
import jdk.internal.access.JavaLangInvokeAccess;
import jdk.internal.access.SharedSecrets;
+import jdk.internal.vm.annotation.Stable;
import java.lang.StackWalker.StackFrame;
import java.lang.invoke.MethodType;
class StackFrameInfo implements StackFrame {
- private final byte RETAIN_CLASS_REF = 0x01;
+ private final static byte RETAIN_CLASS_REF = 0x01;
private final static JavaLangInvokeAccess JLIA =
SharedSecrets.getJavaLangInvokeAccess();
private final byte flags;
- private final Object memberName;
- private final short bci;
+ private final Object memberName; // MemberName initialized by VM
+ private final int bci = -1; // BCI set by VM
private volatile StackTraceElement ste;
/*
- * Create StackFrameInfo for StackFrameTraverser and
LiveStackFrameTraverser
- * to use
+ * Construct an empty StackFrameInfo object that will be filled by
the VM
+ * during stack walking.
+ *
+ * @see StackStreamFactory.AbstractStackWalker#callStackWalk
+ * @see StackStreamFactory.AbstractStackWalker#fetchStackFrames
*/
StackFrameInfo(StackWalker walker) {
this.flags = walker.retainClassRef ? RETAIN_CLASS_REF : 0;
- this.bci = -1;
this.memberName = JLIA.newMemberName();
}
More information about the core-libs-dev
mailing list