summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-05-15 09:39:24 -0400
committerStephan Herrmann2018-05-15 09:39:24 -0400
commit0a09d8b86ece9ff5f47edf424bbce73ff19998d8 (patch)
tree14b721e7d330b712077ebef9b5ab59fff5f9f6d9
parenta6bfbf6cb88ef7f7ed7154f6237dec2ebe763af3 (diff)
downloadorg.eclipse.objectteams-0a09d8b86ece9ff5f47edf424bbce73ff19998d8.tar.gz
org.eclipse.objectteams-0a09d8b86ece9ff5f47edf424bbce73ff19998d8.tar.xz
org.eclipse.objectteams-0a09d8b86ece9ff5f47edf424bbce73ff19998d8.zip
Bug 534608 - Stack overflow in MethodInfo.getModifers() after recent
changes in JDT - fix regression in IncrementalTests.testPhantomRole()
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java16
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/WordValueAttribute.java13
2 files changed, 10 insertions, 19 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
index 2bb2ddf11..fdd41d732 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
@@ -72,6 +72,7 @@ public class MethodInfo extends ClassFileStruct implements IBinaryMethod, Compar
protected long version;
//{ObjectTeams: method level attributes:
+ private static final long HAVE_OT_MODIFIERS = 1l << 32;
/* After reading a method its attributes are stored here. */
private LinkedList<AbstractAttribute> methodAttributes = new LinkedList<AbstractAttribute>();
// more bits decoded from attributes:
@@ -508,7 +509,7 @@ private synchronized void readExceptionAttributes() {
private synchronized void readModifierRelatedAttributes() {
int flags = u2At(0);
//{ObjectTeams:
- int otFlags = 0;
+ long otFlags = 0;
// SH}
int attributesCount = u2At(6);
int readOffset = 8;
@@ -544,10 +545,10 @@ private synchronized void readModifierRelatedAttributes() {
}
//{ObjectTeams: combine sets of modifiers
if (otFlags != 0) {
- if ((otFlags & ExtraCompilerModifiers.AccVisibilityMASK) != 0) {
+ if ((otFlags & HAVE_OT_MODIFIERS) != 0) {
flags &= ~ExtraCompilerModifiers.AccVisibilityMASK; // replace those bits
}
- flags |= otFlags;
+ flags |= (otFlags & 0xffffffff);
}
// SH}
this.accessFlags = flags;
@@ -562,7 +563,7 @@ private synchronized void readModifierRelatedAttributes() {
* @param aStructOffset (subtract when indexing via constantPoolOffsets)
* @param someConstantPoolOffsets
*/
- int readOTAttribute(
+ long readOTAttribute(
char[] attributeName,
MethodInfo info,
int readOffset,
@@ -573,12 +574,12 @@ private synchronized void readModifierRelatedAttributes() {
return 0; // optimization only.
if (CharOperation.equals(attributeName, MODIFIERS_NAME))
{
- return WordValueAttribute.readModifiers(info, readOffset);
+ return readOTModifiers(info, readOffset);
// not added to _readAttributes because evaluated immediately.
}
else if (CharOperation.equals(attributeName, ROLECLASS_METHOD_MODIFIERS_NAME))
{
- return WordValueAttribute.readModifiers(info, readOffset);
+ return readOTModifiers(info, readOffset);
// not added to _readAttributes because evaluated immediately.
}
else if (CharOperation.equals(attributeName, CALLS_BASE_CTOR))
@@ -602,6 +603,9 @@ private synchronized void readModifierRelatedAttributes() {
return 0;
}
+ long readOTModifiers(MethodInfo info, int readOffset) {
+ return info.u2At(readOffset) | HAVE_OT_MODIFIERS;
+ }
// SH}
/**
* Answer the size of the receiver in bytes.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/WordValueAttribute.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/WordValueAttribute.java
index 93b5a1a5f..e12d62e90 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/WordValueAttribute.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/WordValueAttribute.java
@@ -180,19 +180,6 @@ public class WordValueAttribute
}
/**
- * Read the value of a "Modifiers" or "RoleClassMethodModifiers" attribute from byte code.
- * @param method method to read from
- * @param readOffset where to read
- * @return the modifier flags
- */
- public static int readModifiers(
- MethodInfo method,
- int readOffset)
- {
- return method.u2At(readOffset);
- }
-
- /**
* just like readModifiers(MethodInfo,int)
*/
public static void readModifiers(FieldInfo field, int readOffset) {