From: Oti <oh...@ya...> - 2004-10-05 09:12:11
|
Hello, even with the JDK1.5-enabled jython.jar from http://www.jython.org/jython-21-jar-MK4T.zip I cannot append a java.lang.String to a java.lang.StringBuffer when using JDK1.5.0: Jython 2.1 on java1.5.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> from java.lang import StringBuffer >>> from java.lang import String >>> s = String("a") >>> sb = StringBuffer() >>> sb.append(s) Traceback (innermost last): File "<console>", line 1, in ? java.lang.IllegalAccessException: Class org.python.core.PyReflectedFunction can not access a member of class java.lang.AbstractStringBuilder with modifiers "public" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) at java.lang.reflect.Method.invoke(Method.java:578) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java) at org.python.core.PyMethod.__call__(PyMethod.java) at org.python.core.PyObject.__call__(PyObject.java:270) at org.python.core.PyInstance.invoke(PyInstance.java:249) at org.python.pycode._pyx5.f$0(<console>:1) at org.python.pycode._pyx5.call_function(<console>) at org.python.core.PyTableCode.call(PyTableCode.java) at org.python.core.PyCode.call(PyCode.java) at org.python.core.Py.runCode(Py.java:1048) at org.python.core.Py.exec(Py.java:1067) at org.python.util.PythonInterpreter.exec(PythonInterpreter.java) at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java) at org.python.util.InteractiveConsole.push(InteractiveConsole.java) at org.python.util.InteractiveConsole.interact(InteractiveConsole.java) at org.python.util.jython.main(jython.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at CH.obj.Tools.ToolStarter.Main.callMain(Main.java:377) at CH.obj.Tools.ToolStarter.Main.start(Main.java:104) at CH.obj.Tools.ToolStarter.Main.main(Main.java:56) java.lang.IllegalAccessException: java.lang.IllegalAccessException: Class org.python.core.PyReflectedFunction can not access a member of class java.lang.AbstractStringBuilder with modifiers "public" >>> a hint may be found here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=51353, especially the following sentence: """The 1.4 compiler doesn't expect this scenario, and thus incorrectly pick the wrong method (due to ordering of methods in classfile). Extra checks are necessary so as to select the proper method.""" or here: http://www.coffee-bytes.com/servlet/ShowRecentEntries?id=2&page=5 """As most of you probably know, covariant return types (specifically, overriding a method with a subclassed return type) is not possible prior to 1.5; and is in fact part of the Generics enhancements. abstract class AbstractStringBuilder { // ... public abstract AbstractStringBuilder append(String toAppend); } public class StringBuffer extends AbstractStringBuilder { // ... public StringBuffer append(String toAppend) { /* ... */ } // ... }""" and Nice seems to have the same problem: http://confer09.condor-edv.com/nice@freenode/2004-09-17.html """ [nicec] Exception in thread "main" java.lang.IllegalAccessError: tried to access class java.lang.AbstractStringBuilder from class bossa.syntax.fun""" I have no clue how to solve this. At the moment the only way is to avoid StringBuffer.append() Thanks for comments and help! Oti. |