jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rony G. Flatscher" <Rony.Flatsc...@wu-wien.ac.at>
Subject Problem on all Java versions (Re: Additional info (Re: Question on strange "java.lang.IllegalAccessException" in "EngineUtils.callBeanMethod(...)"
Date Wed, 12 Feb 2003 14:41:52 GMT
Hi there,

did test the following Java versions for Windows, downloaded from Sun:

    jdk1.1.8
    jdk1.2.2
    jdk1.3.1_06
    j2sdk1.4.1_01

The reported exception "java.lang.IllegalAccessException" occurs on all 
of them, when trying to invoke the public method "hasMoreElements()".

As I am still clueless as to why this exception is raised, I still am 
seeking for an explanation and/or hints/tips on this problem.

TIA,

---rony


Rony G. Flatscher wrote:

> Hi there,
>
> A very last piece of info: according to the 
> "Modifier.toString(m.getModifiers())", the method "[public boolean 
> java.util.Hashtable$Enumerator.hasMoreElements()]" is indeed "public". 
> Therefore, how could the exception "IllegalAccessException" possibly 
> occur?
> Would it help to switch the Java version (if this was a Java error)?
>
> Regards,
>
> ---rony
>
>
> Rony G. Flatscher wrote:
>
>> Hi there,
>>
>> here is some more information on this strange problem:
>>
>> Java version:
>> -------------------- cut here -----------------------
>> E:\rony\dev\bsf\bsf-2_2\lib\com\ibm\bsf\util>java -version
>> java version "1.3.1_06"
>> Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_06-b01)
>> Java HotSpot(TM) Client VM (build 1.3.1_06-b01, mixed mode)
>> -------------------- cut here -----------------------
>>
>> As you can see,
>>
>> 1) the correct method is found (see signature),
>> 2) the exception is raised by Method.invoke(), which is a native method.
>>
>> -------------------- cut here -----------------------
>>        9/14: [hasMoreElements]
>> ---
>> EngineUtils: 0000 //////////////// begin.
>> EngineUtils: 1111 //try ////////// begin.
>> EngineUtils: 1111 \try \\\\\ end.
>> EngineUtils: 0000 /// #2 ///////// begin. 
>> bean=[java.util.Hashtable$Enumerator@c23c12], 
>> args=[[Ljava.lang.Object;@c23de8], m=[public boolean 
>> java.util.Hashtable$Enumerator.hasMoreElements()]
>> EngineUtils: in last catch:
>>        e=java.lang.IllegalAccessException: 
>> java/util/Hashtable$Enumerator
>> EngineUtils: trace stack:
>> - - - - - - - - - - - -
>> java.lang.IllegalAccessException: java/util/Hashtable$Enumerator
>>        at java.lang.reflect.Method.invoke(Native Method)
>>        at 
>> com.ibm.bsf.util.EngineUtils.callBeanMethod(EngineUtils.java:160)
>>        at 
>> com.ibm.bsf.engines.rexx.RexxAndJava.javaCallBSF(RexxAndJava.java:1339)
>> - - - - - - - - - - - -
>> com.ibm.bsf.BSFException: method invocation failed: 
>> java.lang.IllegalAccessExcep
>> tion: java/util/Hashtable$Enumerator
>>        at 
>> com.ibm.bsf.util.EngineUtils.callBeanMethod(EngineUtils.java:170)
>>        at 
>> com.ibm.bsf.engines.rexx.RexxAndJava.javaCallBSF(RexxAndJava.java:1339)
>> "invoke": got exception [method invocation failed: 
>> java.lang.IllegalAccessException: java/util/Hashtable$Enumerator].
>> Exception in thread "main" com.ibm.bsf.BSFException: "invoke": object 
>> 'java.util.Hashtable$Enumerator@c23c12' - method [hasMoreElements], 
>> method not found!
>>        at 
>> com.ibm.bsf.engines.rexx.RexxAndJava.javaCallBSF(RexxAndJava.java:1349)
>>   263 *-* call BSF "invoke", "java.util.Hashtable$Enumerator@c23c12", 
>> "HASMOREELEMENTS"
>>   263 *-* interpret code        -- execute this dynamically created 
>> Rexx string
>>
>>     9 *-*   do while enum~hasMoreElements       -- loop over enumeration
>> Error 40 running 
>> e:\rony\dev\bsf\bsf-2_2\lib\com\ibm\bsf\engines\rexx\BSF.cls line 
>> 263:  Incorrect call to routine
>> Error 40.1:  External routine "BSF" failed
>> -------------------- cut here -----------------------
>>
>> The documentation of Method.invoke() states that: "If this Method 
>> object enforces Java language access control and the underlying 
>> method is inaccessible, the invocation throws an 
>> IllegalAccessException."
>>
>> Now, I am clueless. How could I possibly circumvent this (for me 
>> totally unexpected) behaviour?
>>
>> Is there a means available to me to have the method object *not* 
>> enforce "Java language access control" and if so, how?
>>
>> Again, if you have ideas/hints which could help me circumvent this 
>> exception, then please let me know.
>>
>> Regards & TIA,
>>
>> ---rony
>>
>>
>>
>>
>>
>>
>>
>>
>> Rony G. Flatscher wrote:
>>
>>> Hi there,
>>>
>>> for a non-Java  based scripting language (Rexx) I have been 
>>> extending the functionality on the BSF 2.2 version with the intent 
>>> to add that functionality to BSF 2.3 ASAP.
>>>
>>> Being in the final testing stages, I have run into a problem for 
>>> which I request some help/hints in this group of experts: while 
>>> trying to invoke the method "hasMoreElements" (has no arguments) on 
>>> an object of a class which implements the "Enumerator" interface I 
>>> ran into the following exception (in "EngineUtils.callBeanMethod()"):
>>>
>>> -------------------- cut here -----------------------
>>> bean=[java.util.Hashtable$Enumerator@63cb94], class=[class 
>>> java.util.Hashtable$Enumerator], iterating over methods:
>>>        0/14: [getClass]
>>>        1/14: [hashCode]
>>>        2/14: [equals]
>>>        3/14: [toString]
>>>        4/14: [notify]
>>>        5/14: [notifyAll]
>>>        6/14: [wait]
>>>        7/14: [wait]
>>>        8/14: [wait]
>>>        9/14: [hasMoreElements]
>>> ---
>>> com.ibm.bsf.BSFException: method invocation failed: 
>>> java.lang.IllegalAccessException: java/util/Hashtable$Enumerator
>>>        at 
>>> com.ibm.bsf.util.EngineUtils.callBeanMethod(EngineUtils.java:159)
>>>        at 
>>> com.ibm.bsf.engines.rexx.RexxAndJava.javaCallBSF(RexxAndJava.java:1339)
>>> -------------------- cut here -----------------------
>>>
>>> The above contains the printout of debug information showing the 
>>> methods of the Enumeration. The method found and to be executed via 
>>> "callBeanMethod" is "hasMoreElements".
>>>
>>> Now, needless to say, being able to use the methods defined by 
>>> interfaces is essential, hence I am very eager to solve this 
>>> problem. If anyone can provide some hints/tips/insights or ideas for 
>>> workarounds, I would *really*, *really* appreciate it a *lot*!
>>>
>>> TIA,
>>>
>>> ---rony
>>>
>>> P.S.:  The given line-number in EngineUtils.java should be 157, not 
>>> 159. The reason: I am using the patched version of EngineUtils which 
>>> therefore is able to deal with arguments of type "Character". In 
>>> this particular case no arguments are given for the Enumerator 
>>> method "hasMoreElements()".
>>>
>>> P.P.S.: I am trying to enumerate all the keys of the Properties 
>>> object received via the System class. Here's the Object Rexx code 
>>> (building on the procedural Rexx interface):
>>>
>>> -------------------- cut here -----------------------
>>> /* Object Rexx (message operator is the tilde: ~) */
>>>
>>> system=.bsf.cls~Class.JC~forName("string", "java.lang.System")  -- 
>>> get the class object for "System", o.k.
>>>
>>> properties = system~getProperties     -- get the System properties, 
>>> o.k.
>>> enum = properties~propertyNames       -- get an enumeration of the 
>>> property names, o.k.
>>>
>>> do while enum~hasMoreElements         -- loop over enumeration: BOMBS!
>>>   key = enum~nextElement             -- get next element
>>>   say "key:" key "value:" properties~getProperty("String", key)
>>> end
>>>
>>> ::requires "BSF.cls"                  -- get the Object Rexx support 
>>> for "bsf4rexx"
>>> -------------------- cut here -----------------------
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: bsf-dev-help@jakarta.apache.org
>>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: bsf-dev-help@jakarta.apache.org
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bsf-dev-help@jakarta.apache.org
>




Mime
View raw message