Issue511493
Created on 2002-01-31.23:21:25 by wr0ngway, last changed 2003-01-03.00:52:31 by kevinbutler.
File name |
Uploaded |
Description |
Edit |
Remove |
diff
|
wr0ngway,
2002-01-31.23:21:25
|
patch for jython/Lib/jxxload_help/PathVFSJavaLoader.java |
|
|
msg561 (view) |
Author: Matthew Conway (wr0ngway) |
Date: 2002-01-31.23:21:25 |
|
The jreload Module does not read in the entire class
file due to incorrect usage of InputStream.read().
The following example will fail unless the attached
patch is applied. Edit the value of toolsjar to point
to the tools.jar from your jdk, or use some other
large class file from somewhere else. The patch also
adds a getResourceAsStream() method for finding
resources from the loadset.
from jreload import makeLoadSet
from java.lang import System
toolsjar = "/path/to/jdk/lib/tools.jar"
makeLoadSet('myls', [toolsjar])
# Any large class file causes a ClassFormatError
from myls.com.sun.tools.corba.se.idl import Parser
print "Success"
|
msg562 (view) |
Author: Kevin J. Butler (kevinbutler) |
Date: 2002-03-07.17:29:57 |
|
Logged In: YES
user_id=117665
I'm uncomfortable with a couple of aspects of this patch -
the use of a member variable 'buf' makes the class loading
process not thread safe (can ClassLoaders be used in
multiple threads?). Also, this will retain a buffer as large
as the largest class loaded in the process.
It would probably be better to have a getBytes method
something like:
protected byte[] getBytes( InputStream s )
{
int bufsize=4096;
byte[] buf = new byte[ bufsize ];
ByteArrayOutputStream out = new ByteArrayOutputStream(
bufsize );
int count;
while( true )
{
count = in.read( buf, 0, bufsize );
if ( count < 0 )
break;
out.write( buf, 0, count );
}
return out.getBytes();
}
|
msg563 (view) |
Author: Matthew Conway (wr0ngway) |
Date: 2002-03-07.19:37:23 |
|
Logged In: YES
user_id=407214
Kevin's getBytes() is definately a cleaner/better solution.
|
msg564 (view) |
Author: Samuele Pedroni (pedronis) |
Date: 2002-03-07.20:02:41 |
|
Logged In: YES
user_id=61408
I think other code in the codebase may share similar
problems and benefit from the approach.
[Note to self: role of JVM/library bugs?]
|
msg565 (view) |
Author: Kevin J. Butler (kevinbutler) |
Date: 2003-01-03.00:52:31 |
|
Logged In: YES
user_id=117665
Replaced the broken code in PathVFSLoader.java and similar
code in SyspathJavaLoader.java and imp.java.
|
|
Date |
User |
Action |
Args |
2002-01-31 23:21:25 | wr0ngway | create | |
|