Skip to content

Commit 59f4223

Browse files
authored
Merge pull request #207 from ebean-orm/feature/206
#206 Fix Signature when adding interface to class
2 parents 65f27aa + 4936e76 commit 59f4223

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

ebean-agent/src/main/java/io/ebean/enhance/common/VisitUtil.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
import io.ebean.enhance.asm.MethodVisitor;
44
import io.ebean.enhance.asm.Opcodes;
55

6-
public class VisitUtil implements Opcodes {
6+
public final class VisitUtil implements Opcodes {
7+
8+
/**
9+
* Append the interfaceType to the existing class signature.
10+
*/
11+
public static String signatureAppend(String signature, String interfaceType) {
12+
if (signature == null) {
13+
return 'L' + interfaceType + ';';
14+
} else {
15+
return signature + 'L' + interfaceType + ';';
16+
}
17+
}
718

819
/**
920
* Helper method for visiting an int value.

ebean-agent/src/main/java/io/ebean/enhance/entity/ClassAdapterEntity.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import io.ebean.enhance.asm.FieldVisitor;
66
import io.ebean.enhance.asm.MethodVisitor;
77
import io.ebean.enhance.asm.Opcodes;
8-
import io.ebean.enhance.common.ClassMeta;
9-
import io.ebean.enhance.common.EnhanceConstants;
10-
import io.ebean.enhance.common.EnhanceContext;
11-
import io.ebean.enhance.common.NoEnhancementRequiredException;
8+
import io.ebean.enhance.common.*;
129

1310
import static io.ebean.enhance.Transformer.EBEAN_ASM_VERSION;
1411

@@ -58,21 +55,22 @@ public void visit(int version, int access, String name, String signature, String
5855
skipMockitoMock(name);
5956
classMeta.setClassName(name, superName);
6057

61-
String[] c = new String[interfaces.length + 1];
58+
String[] newInterfaces = new String[interfaces.length + 1];
6259
for (int i = 0; i < interfaces.length; i++) {
63-
c[i] = interfaces[i];
64-
if (c[i].equals(C_ENTITYBEAN)) {
60+
newInterfaces[i] = interfaces[i];
61+
if (newInterfaces[i].equals(C_ENTITYBEAN)) {
6562
throw new NoEnhancementRequiredException();
6663
}
67-
if (c[i].equals(C_SCALAOBJECT)) {
64+
if (newInterfaces[i].equals(C_SCALAOBJECT)) {
6865
classMeta.setScalaInterface(true);
6966
}
70-
if (c[i].equals(C_GROOVYOBJECT)) {
67+
if (newInterfaces[i].equals(C_GROOVYOBJECT)) {
7168
classMeta.setGroovyInterface(true);
7269
}
7370
}
7471
// add the EntityBean interface
75-
c[c.length - 1] = C_ENTITYBEAN;
72+
newInterfaces[newInterfaces.length - 1] = C_ENTITYBEAN;
73+
String newSignature = VisitUtil.signatureAppend(signature, C_ENTITYBEAN);
7674
if (classMeta.isLog(8)) {
7775
classMeta.log("... add EntityBean interface");
7876
}
@@ -87,7 +85,7 @@ public void visit(int version, int access, String name, String signature, String
8785
classMeta.setSuperMeta(superMeta);
8886
}
8987
}
90-
super.visit(version, access, name, signature, superName, c);
88+
super.visit(version, access, name, newSignature, superName, newInterfaces);
9189
}
9290

9391
/**

ebean-agent/src/main/java/io/ebean/enhance/transactional/ClassAdapterTransactional.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
import io.ebean.enhance.asm.FieldVisitor;
66
import io.ebean.enhance.asm.Label;
77
import io.ebean.enhance.asm.MethodVisitor;
8-
import io.ebean.enhance.common.AlreadyEnhancedException;
9-
import io.ebean.enhance.common.AnnotationInfo;
10-
import io.ebean.enhance.common.AnnotationInfoVisitor;
11-
import io.ebean.enhance.common.ClassMeta;
12-
import io.ebean.enhance.common.EnhanceConstants;
13-
import io.ebean.enhance.common.EnhanceContext;
14-
import io.ebean.enhance.common.NoEnhancementRequiredException;
8+
import io.ebean.enhance.common.*;
159
import io.ebean.enhance.querybean.TypeQueryUtil;
1610

1711
import java.util.*;
@@ -154,7 +148,8 @@ public void visit(int version, int access, String name, String signature, String
154148

155149
// Add the EnhancedTransactional interface
156150
newInterfaces[newInterfaces.length - 1] = EnhanceConstants.C_ENHANCEDTRANSACTIONAL;
157-
super.visit(version, access, name, signature, superName, newInterfaces);
151+
String newSignature = VisitUtil.signatureAppend(signature, C_ENHANCEDTRANSACTIONAL);
152+
super.visit(version, access, name, newSignature, superName, newInterfaces);
158153
}
159154

160155
/**

0 commit comments

Comments
 (0)