Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java @ 3838:6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
Reviewed-by: kvn, twisti, jrose
author | never |
---|---|
date | Thu, 21 Jul 2011 08:38:25 -0700 |
parents | 0a8e0d4345b3 |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
3837:43f9d800f276 | 3838:6a991dcb52bb |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
70 public long getObjectSize() { | 70 public long getObjectSize() { |
71 return alignObjectSize(baseOffset + getLength() * elementSize); | 71 return alignObjectSize(baseOffset + getLength() * elementSize); |
72 } | 72 } |
73 | 73 |
74 public ConstantPoolCacheEntry getEntryAt(int i) { | 74 public ConstantPoolCacheEntry getEntryAt(int i) { |
75 if (Assert.ASSERTS_ENABLED) { | 75 if (i < 0 || i >= getLength()) throw new IndexOutOfBoundsException(i + " " + getLength()); |
76 Assert.that(0 <= i && i < getLength(), "index out of bounds"); | |
77 } | |
78 return new ConstantPoolCacheEntry(this, i); | 76 return new ConstantPoolCacheEntry(this, i); |
79 } | 77 } |
80 | 78 |
81 public static boolean isSecondaryIndex(int i) { return (i < 0); } | 79 public static boolean isSecondaryIndex(int i) { return (i < 0); } |
82 public static int decodeSecondaryIndex(int i) { return isSecondaryIndex(i) ? ~i : i; } | 80 public static int decodeSecondaryIndex(int i) { return isSecondaryIndex(i) ? ~i : i; } |
83 public static int encodeSecondaryIndex(int i) { return !isSecondaryIndex(i) ? ~i : i; } | 81 public static int encodeSecondaryIndex(int i) { return !isSecondaryIndex(i) ? ~i : i; } |
84 | 82 |
85 // secondary entries hold invokedynamic call site bindings | 83 // secondary entries hold invokedynamic call site bindings |
86 public ConstantPoolCacheEntry getSecondaryEntryAt(int i) { | 84 public ConstantPoolCacheEntry getSecondaryEntryAt(int i) { |
87 ConstantPoolCacheEntry e = new ConstantPoolCacheEntry(this, decodeSecondaryIndex(i)); | 85 int rawIndex = i; |
86 if (isSecondaryIndex(i)) { | |
87 rawIndex = decodeSecondaryIndex(i); | |
88 } | |
89 ConstantPoolCacheEntry e = getEntryAt(rawIndex); | |
88 if (Assert.ASSERTS_ENABLED) { | 90 if (Assert.ASSERTS_ENABLED) { |
89 Assert.that(e.isSecondaryEntry(), "must be a secondary entry"); | 91 Assert.that(e.isSecondaryEntry(), "must be a secondary entry:" + rawIndex); |
90 } | 92 } |
91 return e; | 93 return e; |
92 } | 94 } |
93 | 95 |
94 public ConstantPoolCacheEntry getMainEntryAt(int i) { | 96 public ConstantPoolCacheEntry getMainEntryAt(int i) { |
97 int primaryIndex = i; | |
95 if (isSecondaryIndex(i)) { | 98 if (isSecondaryIndex(i)) { |
96 // run through an extra level of indirection: | 99 // run through an extra level of indirection: |
97 i = getSecondaryEntryAt(i).getMainEntryIndex(); | 100 int rawIndex = decodeSecondaryIndex(i); |
101 primaryIndex = getEntryAt(rawIndex).getMainEntryIndex(); | |
98 } | 102 } |
99 ConstantPoolCacheEntry e = new ConstantPoolCacheEntry(this, i); | 103 ConstantPoolCacheEntry e = getEntryAt(primaryIndex); |
100 if (Assert.ASSERTS_ENABLED) { | 104 if (Assert.ASSERTS_ENABLED) { |
101 Assert.that(!e.isSecondaryEntry(), "must not be a secondary entry"); | 105 Assert.that(!e.isSecondaryEntry(), "must not be a secondary entry:" + primaryIndex); |
102 } | 106 } |
103 return e; | 107 return e; |
104 } | 108 } |
105 | 109 |
106 public int getIntAt(int entry, int fld) { | 110 public int getIntAt(int entry, int fld) { |