Fixes #29
This commit is contained in:
@@ -96,6 +96,22 @@ public class ClassRenamer {
|
||||
super.visit(version, access, newname, signature, superName, interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInnerClass(String name, String outername, String innerName, int access) {
|
||||
super.visitInnerClass(renameRetargetIfNecessary(name), renameRetargetIfNecessary(outername), renameRetargetIfNecessary(innerName), access);
|
||||
}
|
||||
|
||||
private String renameRetargetIfNecessary(String string) {
|
||||
String value = retargets.get(string);
|
||||
if (value!=null) {
|
||||
return value;
|
||||
}
|
||||
if (string.indexOf(oldname) != -1) {
|
||||
return string.replace(oldname, newname);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int flags, String name, String descriptor, String signature, String[] exceptions) {
|
||||
if (descriptor.indexOf(oldname) != -1) {
|
||||
|
||||
@@ -66,10 +66,11 @@ public class TypeDescriptorExtractor {
|
||||
private List<FieldMember> fieldsRequiringAccessors = new ArrayList<FieldMember>();
|
||||
private List<FieldMember> fields = new ArrayList<FieldMember>();
|
||||
private List<String> finalInHierarchy = new ArrayList<String>();
|
||||
|
||||
|
||||
public ExtractionVisitor(boolean isReloadableType) {
|
||||
this.isReloadableType = isReloadableType;
|
||||
}
|
||||
|
||||
|
||||
public TypeDescriptor getTypeDescriptor() {
|
||||
if (isReloadableType) {
|
||||
@@ -270,7 +271,13 @@ public class TypeDescriptorExtractor {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void visitAttribute(Attribute arg0) {
|
||||
public void visitAttribute(Attribute attribute) {
|
||||
}
|
||||
|
||||
public void visitInnerClass(String name, String outername, String innerName, int access) {
|
||||
if (name.equals(typename)) {
|
||||
this.flags = access;
|
||||
}
|
||||
}
|
||||
|
||||
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
|
||||
@@ -280,10 +287,6 @@ public class TypeDescriptorExtractor {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void visitInnerClass(String arg0, String arg1, String arg2, int arg3) {
|
||||
}
|
||||
|
||||
// For each method, copy it into the new class making appropriate adjustments
|
||||
/**
|
||||
* Visit a method in the class and build an appropriate representation for it to include in the extracted output.
|
||||
|
||||
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springsource.loaded.GlobalConfiguration;
|
||||
import org.springsource.loaded.ReloadableType;
|
||||
@@ -433,4 +435,26 @@ public class ReloadableTypeTests extends SpringLoadedTests {
|
||||
retrieveRename("basic.Basic", "basic.Basic003"));
|
||||
assertEquals(2, rc);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void innerTypesLosingStaticModifier() throws Exception {
|
||||
TypeRegistry typeRegistry = getTypeRegistry("inners.Outer$Inner");
|
||||
byte[] sc = loadBytesForClass("inners.Outer$Inner");
|
||||
ReloadableType rtype = typeRegistry.addType("inners.Outer$Inner", sc);
|
||||
|
||||
Class<?> simpleClass = rtype.getClazz();
|
||||
Result r = null;
|
||||
|
||||
r = runUnguarded(simpleClass, "foo");
|
||||
assertEquals("foo!", r.returnValue);
|
||||
assertTrue(Modifier.isPublic((Integer)runUnguarded(simpleClass, "getModifiers").returnValue));
|
||||
assertTrue(Modifier.isStatic((Integer)runUnguarded(simpleClass, "getModifiers").returnValue));
|
||||
|
||||
rtype.loadNewVersion("002", retrieveRename("inners.Outer$Inner", "inners.Outer2$Inner2"));
|
||||
|
||||
r = runUnguarded(simpleClass, "foo");
|
||||
assertEquals("bar!", r.returnValue);
|
||||
assertTrue(Modifier.isPublic((Integer)runUnguarded(simpleClass, "getModifiers").returnValue));
|
||||
assertTrue(Modifier.isStatic((Integer)runUnguarded(simpleClass, "getModifiers").returnValue));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user