Browse Source

move away from using helper methods on Member

tags/V1_6_7
aclement 14 years ago
parent
commit
21ce8f4a0e

+ 5
- 4
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java View File

* @return true if there is an overrides rather than a 'hides' relationship * @return true if there is an overrides rather than a 'hides' relationship
*/ */
static boolean isVisibilityOverride(int methodMods, ResolvedMember inheritedMethod, boolean inSamePackage) { static boolean isVisibilityOverride(int methodMods, ResolvedMember inheritedMethod, boolean inSamePackage) {
if (inheritedMethod.isStatic()) {
int inheritedModifiers = inheritedMethod.getModifiers();
if (Modifier.isStatic(inheritedModifiers)) {
return false; return false;
} }
if (methodMods == inheritedMethod.getModifiers()) {
if (methodMods == inheritedModifiers) {
return true; return true;
} }


if (inheritedMethod.isPrivate()) {
if (Modifier.isPrivate(inheritedModifiers)) {
return false; return false;
} }


boolean isPackageVisible = !inheritedMethod.isPrivate() && !inheritedMethod.isProtected() && !inheritedMethod.isPublic();
boolean isPackageVisible = !Modifier.isPrivate(inheritedModifiers) && !Modifier.isProtected(inheritedModifiers) && !Modifier.isPublic(inheritedModifiers);
if (isPackageVisible && !inSamePackage) { if (isPackageVisible && !inSamePackage) {
return false; return false;
} }

+ 2
- 2
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java View File

InstructionFactory fact = gen.getFactory(); InstructionFactory fact = gen.getFactory();
Type fieldType = BcelWorld.makeBcelType(field.getType()); Type fieldType = BcelWorld.makeBcelType(field.getType());


if (field.isStatic()) {
if (Modifier.isStatic(field.getModifiers())) {
il.append(InstructionFactory.createLoad(fieldType, 0)); il.append(InstructionFactory.createLoad(fieldType, 0));
il.append(fact.createFieldAccess(gen.getClassName(), field.getName(), fieldType, Constants.PUTSTATIC)); il.append(fact.createFieldAccess(gen.getClassName(), field.getName(), fieldType, Constants.PUTSTATIC));
} else { } else {
} else if (onInterface && gen.getType().isTopmostImplementor(onType)) { } else if (onInterface && gen.getType().isTopmostImplementor(onType)) {
// wew know that we can't be static since we don't allow statics on // wew know that we can't be static since we don't allow statics on
// interfaces // interfaces
if (field.isStatic()) {
if (Modifier.isStatic(field.getModifiers())) {
throw new RuntimeException("unimplemented"); throw new RuntimeException("unimplemented");
} }
weaver.addInitializer(this); weaver.addInitializer(this);

+ 8
- 7
weaver/src/org/aspectj/weaver/bcel/Utility.java View File



public static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature) { public static Instruction createSuperInvoke(InstructionFactory fact, BcelWorld world, Member signature) {
short kind; short kind;
if (signature.isInterface()) {
if (Modifier.isInterface(signature.getModifiers())) {
throw new RuntimeException("bad"); throw new RuntimeException("bad");
} else if (signature.isPrivate() || signature.getName().equals("<init>")) {
} else if (Modifier.isPrivate(signature.getModifiers()) || signature.getName().equals("<init>")) {
throw new RuntimeException("unimplemented, possibly bad"); throw new RuntimeException("unimplemented, possibly bad");
} else if (signature.isStatic()) {
} else if (Modifier.isStatic(signature.getModifiers())) {
throw new RuntimeException("bad"); throw new RuntimeException("bad");
} else { } else {
kind = Constants.INVOKESPECIAL; kind = Constants.INVOKESPECIAL;
// XXX don't need the world now // XXX don't need the world now
public static Instruction createInvoke(InstructionFactory fact, BcelWorld world, Member signature) { public static Instruction createInvoke(InstructionFactory fact, BcelWorld world, Member signature) {
short kind; short kind;
if (signature.isInterface()) {
int signatureModifiers = signature.getModifiers();
if (Modifier.isInterface(signatureModifiers)) {
kind = Constants.INVOKEINTERFACE; kind = Constants.INVOKEINTERFACE;
} else if (signature.isStatic()) {
} else if (Modifier.isStatic(signatureModifiers)) {
kind = Constants.INVOKESTATIC; kind = Constants.INVOKESTATIC;
} else if (signature.isPrivate() || signature.getName().equals("<init>")) {
} else if (Modifier.isPrivate(signatureModifiers) || signature.getName().equals("<init>")) {
kind = Constants.INVOKESPECIAL; kind = Constants.INVOKESPECIAL;
} else { } else {
kind = Constants.INVOKEVIRTUAL; kind = Constants.INVOKEVIRTUAL;


public static Instruction createGet(InstructionFactory fact, Member signature) { public static Instruction createGet(InstructionFactory fact, Member signature) {
short kind; short kind;
if (signature.isStatic()) {
if (Modifier.isStatic(signature.getModifiers())) {
kind = Constants.GETSTATIC; kind = Constants.GETSTATIC;
} else { } else {
kind = Constants.GETFIELD; kind = Constants.GETFIELD;

+ 5
- 3
weaver/testsrc/org/aspectj/weaver/MemberTestCase.java View File



package org.aspectj.weaver; package org.aspectj.weaver;


import java.lang.reflect.Modifier;

import junit.framework.TestCase; import junit.framework.TestCase;


import org.aspectj.testing.util.TestUtil; import org.aspectj.testing.util.TestUtil;
} }


private void isStaticTest(Member m, boolean b) { 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) { private void isConstructorTest(Member m, boolean b) {
assertEquals(m + " is constructor", b, m.getKind() == Member.CONSTRUCTOR); assertEquals(m + " is constructor", b, m.getKind() == Member.CONSTRUCTOR);
} }
private void isPrivateTest(Member m, boolean b) { 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) { 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) { private void returnTypeTest(Member m, UnresolvedType returnType) {
assertEquals(m + " return type", returnType, m.getReturnType()); assertEquals(m + " return type", returnType, m.getReturnType());

Loading…
Cancel
Save