Skip to content

Commit

Permalink
Generate correct signatures for panache entities
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jun 3, 2019
1 parent eaa0fbb commit 6fef5e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class EntityField {

final String name;
final String descriptor;
String signature;

public EntityField(String name, String descriptor) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ public ModelEnhancingClassVisitor(String className, ClassVisitor outputClassVisi
@Override
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
FieldVisitor superVisitor = super.visitField(access, name, descriptor, signature, value);
if (fields == null || !fields.containsKey(name))
EntityField ef = fields.get(name);
if (fields == null || ef == null)
return superVisitor;
ef.signature = signature;
// if we have a mapped field, let's add some annotations
return new FieldVisitor(Opcodes.ASM6, superVisitor) {
private Set<String> descriptors = new HashSet<>();
Expand Down Expand Up @@ -340,7 +342,7 @@ private void generateAccessors() {
String getterDescriptor = "()" + field.descriptor;
if (!methods.contains(getterName + "/" + getterDescriptor)) {
MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC,
getterName, getterDescriptor, null, null);
getterName, getterDescriptor, field.signature == null ? null : "()" + field.signature, null);
mv.visitCode();
mv.visitIntInsn(Opcodes.ALOAD, 0);
// Due to https://github.com/quarkusio/quarkus/issues/1376 we generate Hibernate read/write calls
Expand Down Expand Up @@ -385,7 +387,7 @@ private void generateAccessors() {
String setterDescriptor = "(" + field.descriptor + ")V";
if (!methods.contains(setterName + "/" + setterDescriptor)) {
MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC,
setterName, setterDescriptor, null, null);
setterName, setterDescriptor, field.signature == null ? null : "(" + field.signature + ")V", null);
mv.visitCode();
mv.visitIntInsn(Opcodes.ALOAD, 0);
int loadCode;
Expand Down

0 comments on commit 6fef5e5

Please sign in to comment.