From 21ce8f4a0e6784b4442fa5150d71fbf849008b97 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 17 Nov 2009 16:40:31 +0000 Subject: [PATCH] move away from using helper methods on Member --- .../org/aspectj/weaver/bcel/BcelClassWeaver.java | 9 +++++---- .../org/aspectj/weaver/bcel/BcelTypeMunger.java | 4 ++-- weaver/src/org/aspectj/weaver/bcel/Utility.java | 15 ++++++++------- .../org/aspectj/weaver/MemberTestCase.java | 8 +++++--- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 0abbc9911..bd96c5101 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -681,18 +681,19 @@ class BcelClassWeaver implements IClassWeaver { * @return true if there is an overrides rather than a 'hides' relationship */ static boolean isVisibilityOverride(int methodMods, ResolvedMember inheritedMethod, boolean inSamePackage) { - if (inheritedMethod.isStatic()) { + int inheritedModifiers = inheritedMethod.getModifiers(); + if (Modifier.isStatic(inheritedModifiers)) { return false; } - if (methodMods == inheritedMethod.getModifiers()) { + if (methodMods == inheritedModifiers) { return true; } - if (inheritedMethod.isPrivate()) { + if (Modifier.isPrivate(inheritedModifiers)) { return false; } - boolean isPackageVisible = !inheritedMethod.isPrivate() && !inheritedMethod.isProtected() && !inheritedMethod.isPublic(); + boolean isPackageVisible = !Modifier.isPrivate(inheritedModifiers) && !Modifier.isProtected(inheritedModifiers) && !Modifier.isPublic(inheritedModifiers); if (isPackageVisible && !inSamePackage) { return false; } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 8622c9f70..e52ab22eb 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -619,7 +619,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { InstructionFactory fact = gen.getFactory(); Type fieldType = BcelWorld.makeBcelType(field.getType()); - if (field.isStatic()) { + if (Modifier.isStatic(field.getModifiers())) { il.append(InstructionFactory.createLoad(fieldType, 0)); il.append(fact.createFieldAccess(gen.getClassName(), field.getName(), fieldType, Constants.PUTSTATIC)); } else { @@ -1792,7 +1792,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { } else if (onInterface && gen.getType().isTopmostImplementor(onType)) { // wew know that we can't be static since we don't allow statics on // interfaces - if (field.isStatic()) { + if (Modifier.isStatic(field.getModifiers())) { throw new RuntimeException("unimplemented"); } weaver.addInitializer(this); diff --git a/weaver/src/org/aspectj/weaver/bcel/Utility.java b/weaver/src/org/aspectj/weaver/bcel/Utility.java index 638e9c06c..e5a760339 100644 --- a/weaver/src/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/org/aspectj/weaver/bcel/Utility.java @@ -128,11 +128,11 @@ public class Utility { public static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature) { short kind; - if (signature.isInterface()) { + if (Modifier.isInterface(signature.getModifiers())) { throw new RuntimeException("bad"); - } else if (signature.isPrivate() || signature.getName().equals("")) { + } else if (Modifier.isPrivate(signature.getModifiers()) || signature.getName().equals("")) { throw new RuntimeException("unimplemented, possibly bad"); - } else if (signature.isStatic()) { + } else if (Modifier.isStatic(signature.getModifiers())) { throw new RuntimeException("bad"); } else { kind = Constants.INVOKESPECIAL; @@ -145,11 +145,12 @@ public class Utility { // XXX don't need the world now public static Instruction createInvoke(InstructionFactory fact, BcelWorld world, Member signature) { short kind; - if (signature.isInterface()) { + int signatureModifiers = signature.getModifiers(); + if (Modifier.isInterface(signatureModifiers)) { kind = Constants.INVOKEINTERFACE; - } else if (signature.isStatic()) { + } else if (Modifier.isStatic(signatureModifiers)) { kind = Constants.INVOKESTATIC; - } else if (signature.isPrivate() || signature.getName().equals("")) { + } else if (Modifier.isPrivate(signatureModifiers) || signature.getName().equals("")) { kind = Constants.INVOKESPECIAL; } else { kind = Constants.INVOKEVIRTUAL; @@ -165,7 +166,7 @@ public class Utility { public static Instruction createGet(InstructionFactory fact, Member signature) { short kind; - if (signature.isStatic()) { + if (Modifier.isStatic(signature.getModifiers())) { kind = Constants.GETSTATIC; } else { kind = Constants.GETFIELD; diff --git a/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java b/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java index e2efebe25..962f2cad7 100644 --- a/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/MemberTestCase.java @@ -15,6 +15,8 @@ package org.aspectj.weaver; +import java.lang.reflect.Modifier; + import junit.framework.TestCase; import org.aspectj.testing.util.TestUtil; @@ -145,16 +147,16 @@ public class MemberTestCase extends TestCase { } private void isStaticTest(Member m, boolean b) { - assertEquals(m + " is static", b, m.isStatic()); + assertEquals(m + " is static", b, Modifier.isStatic(m.getModifiers())); } private void isConstructorTest(Member m, boolean b) { assertEquals(m + " is constructor", b, m.getKind() == Member.CONSTRUCTOR); } private void isPrivateTest(Member m, boolean b) { - assertEquals(m + " is private", b, m.isPrivate()); + assertEquals(m + " is private", b, Modifier.isPrivate(m.getModifiers())); } private void isInterfaceTest(Member m, boolean b) { - assertEquals(m + " is interface", b, m.isInterface()); + assertEquals(m + " is interface", b, Modifier.isInterface(m.getModifiers())); } private void returnTypeTest(Member m, UnresolvedType returnType) { assertEquals(m + " return type", returnType, m.getReturnType()); -- 2.39.5