harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Luht (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1671) Tests for java -jar ... execution
Date Wed, 27 Dec 2006 11:25:23 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-1671?page=comments#action_12460979 ] 
            
Anton Luht commented on HARMONY-1671:
-------------------------------------

The failure happened because of several issues.

First:

The test contains class body manipulation - string 'FOO' is replaced with 'BOO', for example.
It turned out that 0xCAFEBABE sequence broke on Linux if we use approach like

new String(<class body bytes>).replaceAll("FOO", "BOO").getBytes()

import java.io.*; 

public class Test { 
    public static void main (String[] args) throws IOException { 
       byte[] b = getResource("Test.class");
       System.out.println(b[0]);
       String s = new String(b);
       System.out.println(s.getBytes()[0]);
    } 

        private static byte[] getResource(String resourceName) throws IOException {
                File resourceFile = new File(resourceName);
 
                //read whole resource data into memory
                byte[] resourceBody = new byte[(int) resourceFile.length()];
                FileInputStream fis = new FileInputStream(resourceFile);
                fis.read(resourceBody);
                fis.close();
 
                return resourceBody;
        }

} 



prints on Windows 
-54
-54

and on Linux
-54
-17

No playing with encoding (new String(byte[], String)) helped. So I've re-wrote replacing -
now it works with byte array.

One more note: this test passed on our implementation so either byte conversion works differently
on it or it ignores class signature bytes

Second issue: RI doesn't understand classpath in quotes:

:~> java -cp . Test
-54
-17
:~> java -cp . Test
-54
-17
:~> java -cp "." Test
-54
-17
:~> java -cp '"."' Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test
:~> 

I've removed surrounding classpath with quotes in Support_Exec.java

The test after patch passes on Windows and Linux






> Tests for java -jar ... execution
> ---------------------------------
>
>                 Key: HARMONY-1671
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1671
>             Project: Harmony
>          Issue Type: Test
>          Components: Classlib
>            Reporter: Anton Luht
>         Assigned To: Alexey Petrenko
>            Priority: Minor
>         Attachments: hyts_Bar.ser, hyts_Foo.ser, jar-exec.diff
>
>
> These are tests for -jar ... style Java execution. They contain regression tests for
bug 1562 + various execution options:
> - CLASSPATH environment variable
> - -cp 
> - -jar
> - Class-Path entry
> - Main-Class missing in jar (but found in jar referenced by Class-Path entry)
> - mix of .zip and .jar files in classpath
> All tests are positive - for the situations where class should be found (in other words,
no negative - for 'class not found' tests)
> This patch also contains changes to Support_Exec class to support envp variable
> *.ser files attached should be put to <classlib root>\support\src\test\java\tests\resources

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message