With some more testing I discovered I get this IllegalAccessError when I try
to access an inherited protected method from some (Handler) inlined inner
class :
Calling addMonths() allways fail with this Exception :
public class SDTMonthSelector extends MonthSelector {
private ListBox mois;
...
mois.addChangeHandler( new ChangeHandler()
{
public void onChange( ChangeEvent event )
{
int indexSelectionne = mois.getSelectedIndex();
int numMois = Integer.parseInt( mois.getValue(
indexSelectionne ) );
int offset = numMois - getNumMoisFromDate(
getModel().getCurrentMonth() );
addMonths( offset );
}
} );
Just overriding the method with a super.delegate fix the issue :
@Override
protected void addMonths( int numMonths )
{
super.addMonths( numMonths );
}
Based on my knowledge of Java method visibility the InnerClass -> class ->
parent protected method is valid (and the eclipse compiler doesn't warn
about this)
No idea if this is a compiler or JRE issue (I'm using SUN JDK 6 u11 on
Windows 2000)
On Thu, Mar 5, 2009 at 7:03 PM, nicolas de loof <[email protected]>wrote:
> I'll make some more tests and try to isolate the issue.Thanks
>
>
> On Thu, Mar 5, 2009 at 6:52 PM, John LaBanca <[email protected]> wrote:
>
>> I don't know what to make of this bug. It could be a Java compiler issue
>> or a JVM issue. From the code, it looks like you are accessing the package
>> protected super class from a different package in an anonymous class.
>> That's a lot of levels of permission to go through even if it should be
>> valid. The weird thing is that line 194 also makes a call directly to a
>> method in the package protected super class, and that works fine.
>>
>> Can you try adding a protected refreshAll() method to SDTMonthSelector()
>> as a possible workaround. I'm not sure if it'll work, but it might:
>>
>>> protected void refreshAll() {
>>> super.refreshAll();
>>> }
>>>
>>
>>
>> Thanks,
>> John LaBanca
>> [email protected]
>>
>>
>> On Thu, Mar 5, 2009 at 11:09 AM, nicolas de loof <
>> [email protected]> wrote:
>>
>>> From eclipse compiler point of view I can extend MonthSelector, but I
>>> then have the reported exception running the widget in hosted mode.
>>> Just can't understand what's wrong with this...
>>>
>>>
>>> On Thu, Mar 5, 2009 at 4:56 PM, John LaBanca <[email protected]>wrote:
>>>
>>>> You should have access to the methods in DatePickerComponent through
>>>> MonthSelector, at least it appears so in Eclipse and in my test case.
>>>>
>>>> Also, howa re you setting the internal datePicker field?
>>>> DatePickerComponent#setDatePicker() is package protected, so I don't see
>>>> how
>>>> you can be calling it. It looks like you would need to override all of the
>>>> methods in DatePickerComponent for it to work. I agree that we need to
>>>> make
>>>> DatePickerComponent public, or at least make setDatePicker() protected.
>>>>
>>>> If you send me the code for SDTMonthSelector, I'll take a closer look.
>>>>
>>>> Thanks,
>>>> John LaBanca
>>>> [email protected]
>>>>
>>>>
>>>>
>>>> On Thu, Mar 5, 2009 at 8:01 AM, nicolas de loof <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>> I try to customize the GWT 1.6 DatePicker and I've created a
>>>>> "STDMonthSelector" that extends MonthSelector
>>>>>
>>>>> I the get this error running the hosted browser. It seems some
>>>>> securityController checks me trying to access methods
>>>>> in DatePickerComponent, but according to Java type hierarchy this is
>>>>> expected to be valid. Is there some curious limitation with this ? In such
>>>>> case, why isn't DatePickerComponent public ?
>>>>>
>>>>> Cheers,
>>>>> Nicolas
>>>>>
>>>>> My stacktrace :
>>>>>
>>>>> [FATAL] Uncaught Exception:
>>>>>
>>>>> java.lang.IllegalAccessError:
>>>>>
>>>>> tried to access class
>>>>> com.google.gwt.user.datepicker.client.DatePickerComponent from class
>>>>> com.myapp.ui.baseComponent.SDTMonthSelector
>>>>>
>>>>> at com.myapp.ui.baseComponent.SDTMonthSelector.access$3(*
>>>>> SDTMonthSelector.java:1*)
>>>>>
>>>>> at com.sfr.myapp.ui.baseComponent.SDTMonthSelector$3.onChange(*
>>>>> SDTMonthSelector.java:195*)
>>>>>
>>>>> at com.google.gwt.event.dom.client.ChangeEvent.dispatch(*
>>>>> ChangeEvent.java:54*)
>>>>>
>>>>> at com.google.gwt.event.dom.client.ChangeEvent.dispatch(*
>>>>> ChangeEvent.java:1*)
>>>>>
>>>>> at
>>>>> com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(*
>>>>> HandlerManager.java:65*)
>>>>>
>>>>> at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(
>>>>> *HandlerManager.java:53*)
>>>>>
>>>>> at com.google.gwt.event.shared.HandlerManager.fireEvent(*
>>>>> HandlerManager.java:178*)
>>>>>
>>>>> at com.google.gwt.user.client.ui.Widget.fireEvent(*Widget.java:51*)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---