Mercurial > hg > graal-jvmci-8
diff jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java @ 23700:9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 18 Jun 2016 13:19:01 +0200 |
parents | 1d4ce2d19e52 |
children | 0bd91cd9869d |
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java Fri Jun 17 19:13:02 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java Sat Jun 18 13:19:01 2016 +0200 @@ -22,24 +22,34 @@ */ package jdk.vm.ci.meta; +/** + * Maps bytecode indexes to source line numbers. + * + * @see "https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.12" + */ public class LineNumberTable { private final int[] lineNumbers; private final int[] bci; + /** + * + * @param lineNumbers an array or source line numbers. This array is now owned by this object + * and should not be mutated by the caller. + * @param bci an array of bytecode indexes the same length at {@code lineNumbers} whose entries + * are sorted in ascending order. This array is now owned by this object and must not + * be mutated by the caller. + */ + @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `lineNumbers` and `bcis`") public LineNumberTable(int[] lineNumbers, int[] bci) { + assert bci.length == lineNumbers.length; this.lineNumbers = lineNumbers; this.bci = bci; } - public int[] getLineNumberEntries() { - return lineNumbers; - } - - public int[] getBciEntries() { - return bci; - } - + /** + * Gets a source line number for {@code atBci}. + */ public int getLineNumber(int atBci) { for (int i = 0; i < this.bci.length - 1; i++) { if (this.bci[i] <= atBci && atBci < this.bci[i + 1]) {