ArrayIndexOutOfBoundsException with Lombok Beans

43 views
Skip to first unread message

Marcus Ilgner

unread,
Jan 27, 2010, 10:30:52 AM1/27/10
to Project Lombok
Hi there,

first let me say that I'm very excited after coming across Lombok
today. I was once again fed up with writing/generating boilerplate
code which just makes the code more difficult to read, so I thought
about writing something like this, did a Google search - and voila.
Lombo goodness!

In order to have PropertyChangeSupport in my objects, I also installed
the Lombok Beans plugin. As there's no contact information specified
on the site, I take the liberty to post here and hope for an answer :)
Everything works fine but it throws this exception upon every save,
which is a bit annoying. This happens only if I replace @Data with
@Bean:

java.lang.ArrayIndexOutOfBoundsException: 2
at org.eclipse.jdt.core.dom.ASTConverter.convertType
(ASTConverter.java:3333)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:
772)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:
450)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations
(ASTConverter.java:179)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:
2694)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations
(ASTConverter.java:184)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:
2694)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:
1264)
at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert
(CompilationUnitResolver.java:256)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST
(ASTParser.java:933)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:657)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run
(ASTProvider.java:544)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST
(ASTProvider.java:537)
at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST
(ASTProvider.java:478)
at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:
126)
at
org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager
$PartListenerGroup.calculateASTandInform
(SelectionListenerWithASTManager.java:169)
at
org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager
$3.run(SelectionListenerWithASTManager.java:154)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Also it would be great to have facade/proxy methods for [add|remove]
PropertyChangeListener(String,PropertyChangeListener)

Best regards
Marcus

David Goodenough

unread,
Jan 27, 2010, 11:15:21 AM1/27/10
to Project Lombok
Hi. I have not met that particular error, but I might have fixed it
along the way. Can you produce a simple test case and I will try it
against my current version. For Eclipse (but not Javac yet) I have
changed the fieldRef processor so that it builds the Generic returns
attributes of the fieldRef method from the data you give it.

As to the PropertyChangeListener methods, there are some new methods,
in an as yet unpublished version. I am in the middle of a change to
the HandleFieldRef code (which works in Eclipse but not Javac
currently) and so it might be touch difficult to produce you a new
version instantly. As you are using Eclipse as long as you do not
need Javac to work in the same way I could produce an interim version
for you now.

David

Marcus Ilgner

unread,
Jan 27, 2010, 11:48:45 AM1/27/10
to Project Lombok
Hi David,

thanks for the quick feedback. I have taken a closer look at the
circumstances under which the exception occurs.
It seems like it only gets thrown when enabling any actions in
"Preferences->Java->Editor->Save Actions"
Checking "Organize Imports" is enough to trip it; interestingly this
even happens if there are no actual unnecessary imports to remove.
If producing an interim version isn't too much trouble for you, I'd
appreciate it, but I can wait for a proper release also.

Greetings
Marcus

On 27 Jan., 17:15, David Goodenough <david.goodeno...@btconnect.com>
wrote:

David Goodenough

unread,
Jan 27, 2010, 12:44:58 PM1/27/10
to Project Lombok
That is truely bizaar. I do inspect the Import statements, but I do
not change them at all. I will do a few experiments to see if I can
track this down and then I will publish the new version. Are you in a
position to download a git version and build it yourself, or do you
want a binary version?

David

Marcus Ilgner

unread,
Jan 27, 2010, 1:40:25 PM1/27/10
to project...@googlegroups.com
A git version is fine.
Thanks for the quick feedback again!

Greetings
Marcus

David Goodenough

unread,
Jan 28, 2010, 6:08:31 AM1/28/10
to Project Lombok
I have pushed a new version to the public git repository (I think, I
am new to this git lark and keep getting things not quite right).
Please let me know how you get on.

NOTE 1- The Javac version in the git master is seriously broken, so
delombok is not functional. But Eclipse and ecj should work. Anyway
delombok does not seem to notice the changes I make in the handler and
so it is of little use with fieldRef.

NOTE 2- For the new Eclipse version rather than having to use
FieldRef.<Pojo,String>fieldRef(pojo.getField()) you now use fieldRef
(pojo.getField()) and the handler will work out the <Pojo,String> for
you.

NOTE 3- There is a new class ConvertingFieldRef with a static method
convert. There is also a FieldConverter which you subclass to do the
conversion. So if you have a target that requires a <Pojo,String> and
a source which has a value of Integer you would code convert(new
Int2String(),fieldRef(pojo.getValue())) where getValue returns an
Integer. Currently the converters are elsewhere, but I move them into
the project shortly.

David

On Jan 27, 6:40 pm, Marcus Ilgner <marcus.ilg...@gmail.com> wrote:
> A git version is fine.
> Thanks for the quick feedback again!
>
> Greetings
> Marcus
>
> On Wed, Jan 27, 2010 at 6:44 PM, David Goodenough
>

David Goodenough

unread,
Feb 1, 2010, 8:47:34 AM2/1/10
to Project Lombok
I have pushed a further version, as I think I have gotten to the
bottom of the original item in this thread, the
ArrayIndexOutOfBoundsException. Please let me know of this is still a
problem.

NOTE The javac handler is still broken in the git version.

On Jan 28, 11:08 am, David Goodenough <david.goodeno...@btconnect.com>
wrote:

Marcus Ilgner

unread,
Feb 1, 2010, 10:44:51 AM2/1/10
to project...@googlegroups.com
Great news! I just gave the new version a try and everything seems to
work as expected now!

All the best
Marcus

> --
> You received this message because you are subscribed to the Google
> Groups group for http://projectlombok.org/
>
> To post to this group, send email to project...@googlegroups.com
> To unsubscribe from this group, send email to
> project-lombo...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/project-lombok?hl=en

David Goodenough

unread,
Feb 1, 2010, 11:26:55 AM2/1/10
to Project Lombok
In my testing I have found that there are a few odd corner cases where
fieldRef does not seem to produce the right casting. In this case
declaring a FieldRef object explicitly and assigning to it and them
passing that object in to other methods seems to work if using the
fieldRef directly in the method does not. I have no idea why it does
not work, and my warnings that should come out when a resolution has
failed (which is the only time I do not set up the generics) do not
appear either.

I have also just fixed a small problem in the FieldRef object (again a
corner case you are probably not using) but you might want to be sure
you have the latest version.

David

On Feb 1, 3:44 pm, Marcus Ilgner <marcus.ilg...@gmail.com> wrote:
> Great news! I just gave the new version a try and everything seems to
> work as expected now!
>
> All the best
> Marcus
>
> On Mon, Feb 1, 2010 at 2:47 PM, David Goodenough
>

> > Groups group forhttp://projectlombok.org/

Reply all
Reply to author
Forward
0 new messages