Package: jython
Version: 2.1.0-20
Severity: normal

Using jython to interactively test the following java construct causes
a nullpointer exception

public class Globals{
   public static Object a;
   
   { //static initialzer
      a=new Object();
   }
}

public class B{
   public void print(){
      System.out.println(Globals.a.toString());
   }
}  

$ jython
>>> import Globals
>>> import B
>>> b = B()
>>> b.print()
Traceback (innermost last):
  File "<console>", line 1, in ?
java.lang.NullPointerException
        at B.print(B.java:3)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.  java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces  
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java  :160)
        at org.python.core.PyMethod.__call__(PyMethod.java:96)
        at org.python.core.PyObject.__call__(PyObject.java:258)
        at org.python.core.PyInstance.invoke(PyInstance.java:244)
        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:208)
        at org.python.core.PyCode.call(PyCode.java:14)
        at org.python.core.Py.runCode(Py.java:1135)
        at org.python.core.Py.exec(Py.java:1157)
        at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148)
        at 
org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter  .java:89)
        at 
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpret  
er.java:70)
        at 
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpret  
er.java:44)
        at org.python.util.InteractiveConsole.push(InteractiveConsole.java:83)
        at 
org.python.util.InteractiveConsole.interact(InteractiveConsole.java:6  2)
        at org.python.util.jython.main(jython.java:199)

java.lang.NullPointerException: java.lang.NullPointerException

The following sequence works as expected:

$ jython
>>> import Globals
>>> import B
>>> b = Globals()
>>> b = B()
>>> b.print()
[EMAIL PROTECTED]

--Ken Bloom

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages jython depends on:
ii  gij [java-virtual-machine 4:4.0.2-1      The GNU Java bytecode interpreter
ii  gij-4.0 [java1-runtime]   4.0.2-4        The GNU Java bytecode interpreter
ii  kaffe-pthreads [java1-run 2:1.1.6-3      A POSIX threads enabled version of
ii  libreadline-java          0.8.0.1-5      GNU readline and BSD editline wrap
ii  perl                      5.8.7-8        Larry Wall's Practical Extraction 
ii  python2.1                 2.1.3dfsg-3    An interactive high-level object-o
ii  sun-j2sdk1.5 [java2-runti 1.5.0+update02 Java(TM) 2 SDK, Standard Edition, 
ii  sun-j2sdk1.5debian [java2 0.18           Debian specific parts of Java(TM) 

Versions of packages jython recommends:
ii  gcj [java-compiler]       4:4.0.2-1      The GNU Java compiler
ii  gcj-4.0 [java-compiler]   4.0.2-4        The GNU compiler for Java(TM)
ii  kaffe-pthreads [java-comp 2:1.1.6-3      A POSIX threads enabled version of
ii  sun-j2sdk1.5 [java-compil 1.5.0+update02 Java(TM) 2 SDK, Standard Edition, 
ii  sun-j2sdk1.5debian [java- 0.18           Debian specific parts of Java(TM) 

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to