Hello Michael,

On Thu, Mar 15, 2007 at 09:35:59AM +0100, Michael Koch wrote:
> 
> Well I consider "jamvm -cp Test.jar Test" and "jamvm -jar Test.jar" not
> working a major issue. If I wouldn't, we wouldn't need a fix for this.
> These two are the main usecases for every Java runtime and should just
> work.

I don't deny it's a bug;)

The (later) problem is caused by an exception thrown in LogManager.

jamvm do not support Exception before the end of the VM init.

I think this is a bug in jamvm, which considers it is still in the
initialization when it executes the main class (when the class comes from
a jar).

(I've not deeply investigated it, but it is probably the main thread which
is started too early, or jamvm should allow Exception even if the
initialization is not finished)
Feel free to clone and reassign the clone to jamvm.
I don't think this jamvm bug is critical.
It can be reproduced with:
=================================================
public class Test {
    public static void main(String argv[]) {
        try { throw new java.lang.Exception("foo"); }
        catch (Exception e) { System.out.println("catched"); }
    }
}
=================================================



As the original issue is solved by 0.92-4, I had a look at the diff
between 0.91-3 and 0.92-4. I don't think the upstream changes can be
backported to t-p-u.

In 0.91-3,
    new URL(url).openStream();
throws an exception when url is a non existent file. And no exceptions is
thrown with 0.92-4.

The changes involve java/net/URL* and gnu/java/net/loader/* (e.g.
gnu/java/net/loader/FileURLLoader.java do not throw an exception if the
file does not exist).

I don't think it's worth reviewing the upstream diff (diffstat indicate
~2kloc for the above mentioned files; which could probably be reduced, but
need a deep understanding of what is done), and LogManager can safely test
if the file exists and fall back with a default properties file if the
file is not found (see attached patch).

I consider this part of the patch as an hack, but it is safe, and fix the
`jamvm -jar Test.jar' use case.

Kind Regards,
-- 
Nekral
diff -rauN ../0.91-3.orig/classpath-0.91/debian/changelog ./classpath-0.91/debian/changelog
--- ../0.91-3.orig/classpath-0.91/debian/changelog	2007-03-15 23:12:03.000000000 +0100
+++ ./classpath-0.91/debian/changelog	2007-03-16 01:38:37.000000000 +0100
@@ -1,3 +1,16 @@
+classpath (2:0.91-4) testing-proposed-updates; urgency=low
+
+  * java/util/logging/LogManager.java (readConfiguration): Explicitly test
+    if the logging.properties file exists without trying to catch an
+    exception. This is needed by jamvm, when it runs a jar.
+  * Merge change from upstream:
+    java/util/logging/LogManager.java (getLevelProperty): Check whether value
+    is null before passing to Level.parse(). This makes java.util.logging
+    work.
+    Closes: #413116
+
+ -- Nicolas FRANCOIS (Nekral) <[EMAIL PROTECTED]>  Sun, 11 Mar 2007 22:59:22 +0100
+
 classpath (2:0.91-3) unstable; urgency=low
 
   * Install header files to /usr/include/classpath.
diff -rauN ../0.91-3.orig/classpath-0.91/java/util/logging/LogManager.java ./classpath-0.91/java/util/logging/LogManager.java
--- ../0.91-3.orig/classpath-0.91/java/util/logging/LogManager.java	2006-04-03 10:59:53.000000000 +0200
+++ ./classpath-0.91/java/util/logging/LogManager.java	2007-03-15 23:05:36.000000000 +0100
@@ -494,6 +494,9 @@
       {
         String url = (System.getProperty("gnu.classpath.home.url")
                       + "/logging.properties");
+
+        if (new java.io.File(url).exists())
+        {
         try
           {
             inputStream = new URL(url).openStream();
@@ -502,6 +505,9 @@
           {
             inputStream=null;
           }
+        }
+        else
+          inputStream=null;
 
         // If no config file could be found use a default configuration.
         if(inputStream == null)
@@ -700,7 +706,11 @@
   {
     try
       {
-	return Level.parse(getLogManager().getProperty(propertyName));
+	String value = getLogManager().getProperty(propertyName);
+	if (value != null)
+	  return Level.parse(getLogManager().getProperty(propertyName));
+	else
+	  return defaultValue;
       }
     catch (Exception ex)
       {

Reply via email to