Bug 98366 - gij throws NullPointerException on java.lang.Runtime.addShutdownHook()
Summary: gij throws NullPointerException on java.lang.Runtime.addShutdownHook()
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libgcj
Version: 9
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-07-01 18:33 UTC by Patrick Melo
Modified: 2007-04-18 16:55 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-07 14:14:32 UTC
Embargoed:


Attachments (Terms of Use)

Description Patrick Melo 2003-07-01 18:33:10 UTC
Description of problem:
The java.lang.Runtime.addShutdownHook() method causes gij to throw a 
NullPointerException. This does not occur on the sun java interpreter.  In 
fact, the documentation for addShutdownHook 
(http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html) does not not 
indicate that NullPointerException can even be thrown.

Version-Release number of selected component (if applicable):
libgcj-3.2.2-5

How reproducible:
Every time.

Steps to Reproduce:
1. Compile the sample program using the sun jdk.
2. Run the class using gij.
3.
    
Actual results:
A java.lang.NullPointerException is thrown.

Expected results:
Program should run normally as it does with the sun interpreter.

Additional info:
-----Attachment-----
sh-2.05b$ gij --version
gij (GNU libgcj) version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----Attachment-----
sh-2.05b$ make
/usr/java/j2sdk1.4.1_03/bin/javac GijTest.java
-----Attachment-----
sh-2.05b$ make test1
gij GijTest
Adding shutdown hook.
Exception in thread "main" java.lang.NullPointerException
   at 0x4021aef2: _Jv_ThrowSignal (/usr/lib/./libgcj.so.3)
   at 0x4021af26: ?? (??:0)
   at 0xbfffdd24: ?? (??:0)
   at 0x40229471: _Jv_ResolvePoolEntry(java.lang.Class, int) 
(/usr/lib/./libgcj.
so.3)
   at 0x40230699: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) 
(/usr/l
ib/./libgcj.so.3)
   at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, 
_Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
   at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) 
(/us
r/lib/./libgcj.so.3)
   at 0x4038305c: ?? (??:0)
   at 0x40242dd8: gnu.gcj.runtime.FirstThread.call_main() 
(/usr/lib/./libgcj.so.
3)
   at 0x402ad02d: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
   at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
   at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte const, int, byte const, 
bool
ean) (/usr/lib/./libgcj.so.3)
   at 0x08048910: ?? (??:0)
   at 0x420156a4: __libc_start_main (/lib/tls/libc.so.6)
   at 0x080486c1: ?? (??:0)
make: *** [test1] Error 1
-----Attachment-----
sh-2.05b$ make test2
/usr/java/j2sdk1.4.1_03/bin/java GijTest
Adding shutdown hook.
Shutdown hook added.
Goodbye World.
-----Attachment-----
sh-2.05b$ cat makefile
JAVA_HOME=/usr/java/j2sdk1.4.1_03
CLASSPATH=.

all:
        $(JAVA_HOME)/bin/javac GijTest.java
test1:
        gij GijTest
test2:
        $(JAVA_HOME)/bin/java GijTest
clean:
        rm *.class
-----Attachment-----
sh-2.05b$ cat GijTest.java
public class GijTest
{
  public static void main(String args[])
  {
    Thread thread =
    new Thread() { public void run() {System.out.println("Goodbye World.");} };
    if (thread == null)
      System.out.println("Thread is null.");
    Runtime runtime = Runtime.getRuntime();
    if (runtime == null)
      System.out.println("Runtime is null.");
    System.out.println("Adding shutdown hook.");
    runtime.addShutdownHook(thread);
    System.out.println("Shutdown hook added.");
  }
}
sh-2.05b$

Comment 1 Jakub Jelinek 2004-10-07 14:14:32 UTC
Works just fine with current libgcj:

rpm -q gcc-java libgcj
gcc-java-3.4.2-2
libgcj-3.4.2-2
libgcj-3.4.2-2
$ gcj -C GijTest.java
$ CLASSPATH=. gij GijTest
Adding shutdown hook.
Shutdown hook added.
Goodbye World.


Note You need to log in before you can comment on or make changes to this bug.