< prev index next >

src/java.base/share/classes/java/lang/StackFrameInfo.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -24,32 +24,35 @@
  */
 package java.lang;
 
 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 and bci initialized by VM
+    private @Stable int bci;            // zero represents invalid BCI
     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();
     }
 
     // package-private called by StackStreamFactory to skip
     // the capability check

@@ -90,11 +93,11 @@
     public int getByteCodeIndex() {
         // bci not available for native methods
         if (isNativeMethod())
             return -1;
 
-        return bci;
+        return bci-1;
     }
 
     @Override
     public String getFileName() {
         return toStackTraceElement().getFileName();
< prev index next >