Logging broken ?

Andreas Grunewald gruni@users.sourceforge.net
Wed Apr 6 12:32:00 GMT 2005


Hey,
now I compiled with
gcj -Dgnu.gcj.runtime.NameFinder.remove_unknown=true -g \
-Wall --main=Hello -o Hello.exe src/Hello.java
and modified Hello.java to
19: Logger tLog = Logger.getLogger("");
20: tLog.addHandler(logfile);
21: System.out.println("Now starting to LOG");
22: System.out.println("This is tLog " + tLog);
23: System.out.println("This is Level.Severe "+Level.SEVERE);
24: tLog.log(Level.SEVERE,"Simple log test");
This is the output, I ran it through the c++filt programm by just 
copying every line into c++filt:
Now starting to LOG
This is tLog java.util.logging.Logger@d68bb8
This is Level.Severe SEVERE
Exception in thread "main" java.lang.NullPointerException
 at Hello.go() (E:2004円-development2005円-extraextra\src\Hello.java:24)
 at Hello.main(java.lang.String[]) 
(E:2004円-development2005円-extraextra\src\Hello.java:13)
 at main (C:\DOKUME~1\GRUNEW~1\LOKALE~1\Temp\ccu6caaa.i:12)
Is there an easy way to send the standard out from hello.exe to the 
c++filt appilcation in a WindowsXP command shell (cmd.exe) window ?
As I'm still trying to fnd a way to use the gdb i just downloaded the 
Manual, maybe I can find out how to use it, eventhough I'm not expecting 
revolutionary new insights.
Andreas
PS This is the current hello.java as I ran it. I just introduced the 
go() method because I was unable to type in "[" brackets in gdb.
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class Hello {
 public static void main(String[] args) throws SecurityException, 
IOException {
 go();
 }
 public static void go() throws SecurityException, IOException{
 Handler logfile = new FileHandler("debug.log");
 logfile.setFormatter(new SimpleFormatter());
 Logger tLog = Logger.getLogger("");
 tLog.addHandler(logfile);
 System.out.println("Now starting to LOG");
 System.out.println("This is tLog " + tLog);
 System.out.println("This is Level.Severe "+Level.SEVERE);
 tLog.log(Level.SEVERE,"Simple log test");
 System.out.println("Method END");
 }
}
Ranjit Mathew wrote:
> On Apr 6, 2005 4:34 PM, Andrew Haley <aph@redhat.com> wrote:
>>>Andreas Grunewald writes:
>> > Thanks for the information that I had to put this into my path.
>> > But it didn't really help much, this is my output.
>> >
>> > NNow starting to LOG
>> > This is tLog java.util.logging.Logger@d68bb8
>> > Exception in thread "main" java.lang.NullPointerException
>> > at __ZN5Hello2goEv
>> > (E:2004円-development2005円-extraextra\src\Hello.java:23)
>> > at __ZN5Hello4mainEP6JArrayIPN4java4lang6StringEE
>> > (E:2004円-development2005円-extraextra\src\Hello.java:13)
>> > at _main (C:\DOKUME~1\GRUNEW~1\LOKALE~1\Temp\ccmocaaa.i:11)
>>>>But this is *tremendously* useful information! It tells us exactly
>>where the NullPointerException happens.
>>> Doesn't the old stack trace infrastructure
> prune out addresses for which it cannot get
> proper information from addr2line? If so, the
> stack trace could actually be misleading.
> The unadorned stack trace had many
> more entries if you notice. You had to set 
> the "gnu.gcj.runtime.NameFinder.remove_unknown"
> system property to "false" to get a complete
> trace.
>> Andreas, to do this, you need to use
> something like:
>> gcj -Dgnu.gcj.runtime.NameFinder.remove_unknown=true \
> --main=Hello Hello.java
>> BTW, for some reason c++filt is not
> displaying demangled names properly here.
> This stack trace can be filtered through
> "c++filt -s java --format java --strip-underscores"
> to get a better trace.
>>>>>There are only two things in there that might raise a
>>NullPointerException: Level.SEVERE, and the call to tLog.log.
>>> Since tLog was (successfully) referred to a 
> couple of lines before line #23 and SEVERE 
> is a final constant, this makes me suspect
> this stack trace.
>> My 2p.
> Ranjit.
>>>>Andrew.
>>>>>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /