< prev index next >

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/BytecodePosition.java

Print this page

        

*** 41,57 **** /** * Constructs a new object representing a given parent/caller, a given method, and a given BCI. * * @param caller the parent position * @param method the method ! * @param bci a BCI within the method */ public BytecodePosition(BytecodePosition caller, ResolvedJavaMethod method, int bci) { assert method != null; this.caller = caller; this.method = method; this.bci = bci; } /** * Converts this code position to a string representation. * --- 41,63 ---- /** * Constructs a new object representing a given parent/caller, a given method, and a given BCI. * * @param caller the parent position * @param method the method ! * @param bci a BCI such that {@code method.codeSize() == 0 || bci < method.getCodeSize()}. That ! * is, if code size is 0 then allow any value, otherwise the bci must be less than ! * the code size. */ public BytecodePosition(BytecodePosition caller, ResolvedJavaMethod method, int bci) { assert method != null; this.caller = caller; this.method = method; this.bci = bci; + int codeSize = method.getCodeSize(); + if (codeSize != 0 && bci >= codeSize) { + throw new IllegalArgumentException(String.format("bci %d is out of range for %s %d bytes", bci, method.format("%H.%n(%p)"), codeSize)); + } } /** * Converts this code position to a string representation. *
< prev index next >