Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException during code generation #416

Closed
mseitner opened this issue May 14, 2013 · 9 comments
Closed

ArrayIndexOutOfBoundsException during code generation #416

mseitner opened this issue May 14, 2013 · 9 comments
Milestone

Comments

@mseitner
Copy link

@mseitner mseitner commented May 14, 2013

No bug report - just in case somebody else might run into the same problem...

I just came across a weird problem during code generation due to missing generic type parameters. Consider the following class hierarchy:

@Entity
@Inheritance
public class A<T extends WhatEver> {

}

@Entity
public class B extends A { // note the missing type parameter

}

This resulted in the following exception:

java.lang.ArrayIndexOutOfBoundsException: 0
at java.util.Arrays$ArrayList.get(Arrays.java:2866)
at com.mysema.query.codegen.TypeResolver.resolveVar(TypeResolver.java:87)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:102)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:46)
at com.mysema.query.codegen.Property.createCopy(Property.java:81)
at com.mysema.query.codegen.EntityType.include(EntityType.java:226)
at com.mysema.query.apt.AbstractQuerydslProcessor.addSupertypeFields(AbstractQuerydslProcessor.java:423)
at com.mysema.query.apt.AbstractQuerydslProcessor.processAnnotations(AbstractQuerydslProcessor.java:176)
at com.mysema.query.apt.AbstractQuerydslProcessor.process(AbstractQuerydslProcessor.java:112)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
... 23 more

It would be nice if some additional error messages could be generated to give a better indication of the real problem.

@timowest
Copy link
Member

@timowest timowest commented May 14, 2013

Which Querydsl version are you using?

@mseitner
Copy link
Author

@mseitner mseitner commented May 14, 2013

Querydsl 3.1.1
Maven APT Plugin 1.0.9

I also added <showWarnings>true</showWarnings> to the pom but that didn't change anything.

@timowest
Copy link
Member

@timowest timowest commented May 15, 2013

Does WhatEver have parameters?

timowest added a commit that referenced this issue May 15, 2013
@mseitner
Copy link
Author

@mseitner mseitner commented May 15, 2013

IIRC it doesn't have params, but I will check that next Monday when I'm back in the office.

However in my case WhatEver is an abstract class, not an interface.


Von: Timo Westkämper [notifications@github.com]
Gesendet: Mittwoch, 15. Mai 2013 08:29
An: mysema/querydsl
Cc: Marian Seitner
Betreff: [Spam] Re: [querydsl] ArrayIndexOutOfBoundsException during code generation (#416)

Does WhatEver have parameters?


Reply to this email directly or view it on GitHubhttps://github.com//issues/416#issuecomment-17922163.

timowest added a commit that referenced this issue May 16, 2013
@timowest
Copy link
Member

@timowest timowest commented May 16, 2013

Could you check the example again? I couldn't replicate the issue.

@timowest
Copy link
Member

@timowest timowest commented May 20, 2013

Any update on the issue?

@mseitner
Copy link
Author

@mseitner mseitner commented May 21, 2013

I forgot that yesterday was a holiday, will try to reproduce the issue today!

@mseitner
Copy link
Author

@mseitner mseitner commented May 21, 2013

I managed to reproduce the problem and this is how my entities looked like:

// A bunch of permission classes, the "WhatEver" part

@Entity
@Inheritance
@DiscriminatorColumn(name = "CONTEXT")
public abstract class Permission {
    // some common stuff
}

@Entity
@DiscriminatorValue("CHANNEL")
public class ChannelPermission extends Permission {
    // CP specific stuff
}

@Entity
@DiscriminatorValue("SUBJECT")
public class SubjectPermission extends Permission {
    // SP specific stuff
}

// A bunch of role classes

@Entity
@Inheritance
@DiscriminatorColumn(name = "CONTEXT")
public abstract class Role<T extends Permission> {

    @ManyToMany(targetEntity = Permission.class)
    private final List<T> permissions = Lists.newArrayList();

}

@Entity
@DiscriminatorValue("CHANNEL")
public class ChannelRole extends Role<ChannelPermission> {
    // some constructors
}

@Entity
@DiscriminatorValue("SUBJECT")
public class SubjectRole extends Role { // missing type param, should be Role<SubjectPermission>
    // some constructors
}

As soon as I removed the <SubjectPermission> part the compilation failed with the above mentioned ArrayIndexOutOfBoundsException.

Please let me know if this helps somehow!

timowest added a commit that referenced this issue May 21, 2013
@timowest
Copy link
Member

@timowest timowest commented May 27, 2013

Released in 3.2.0

@timowest timowest closed this May 27, 2013
@timowest timowest added this to the 3.2.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants