IllegalAccessException after updating 2.1 to 2.2

Daniel Zwolenski zonski at
Mon Aug 20 02:33:21 PDT 2012

Just for a point of reference, the Spring way of doing this (which is a
pretty good example in my opinion) is to mostly ignore method names and
just rely on the annotations. This avoids all the naming clash problems
like this one and generally gives the developer more freedom and control.

e.g. to have an 'initialise' method, you would call it whatever you want
('setupThisController') and just stick the @PostConstruct annotation on it.
For something that is injected you put the @Injected annotation on it, etc.

I think I've mentioned this before, but just in case I didn't, for most of
what FXML does regarding it's controller there are a whole lot of
pre-existing annotations that I would think make a lot of sense to re-use.

These are official java annotations, and used in a lot of other frameworks,
documented and generally well understood (i.e. use them in one framework
and you know how to use them in all the others). No need to reinvent the
wheel, and you are basically doing dependency injection and FXML is a
'container' of sorts.

Whatever floats your boat though, just mentioning it.

On Mon, Aug 20, 2012 at 7:15 PM, Werner Lehmann <
lehmann at> wrote:

> Hi Greg,
> bug report:**browse/RT-24380<>
> About ignoring the exception I have added a comment to the ticket:
>  I am worried about any public (legacy) initialize() methods which
>> will be called unexpectedly by the loader. It seems simple enough to
>> require @FXML on the method though. This would fix the problem, and
>> the exception does not have to be ignored. Of course, it would be
>> consistent to require the same for the resources and location fields.
> Rgds
> Werner
> On 17.08.2012 14:52, Greg Brown wrote:
>> Sorry about this. I thought that this had been fixed before the 2.2
>> release, but it was not. A similar issue was raised a while back
>> with respect to injection of the "location" and "resources" fields.
>> If a legacy class defined one of these fields and was not properly
>> annotated, injection would fail. This was fixed such that FXMLLoader
>> now ignores IllegalAccessException when injecting those fields, but
>> I did not think to make a similar change for the initialize()
>> method.
>> Can you please file a bug report? Thanks.
>> Greg

More information about the openjfx-dev mailing list