开发者

problem with truezip - when debuging, a strange exception is thrown

i have a strange problem with truezip. i run the following code:

    TFile.setDefaultArchiveDetector(new TArchiveDetector("zip"));
    String zipFile = "c:\\test\\test.zip";
    TFile dstZip = new TFile(zipFile);
    TFile newFile = new TFile("c:\\test\\c.txt");

    try {
        newFile.cp_rp(dstZip);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

when i just run it - it runs ok.

but when i debug, a "breakpoint" (not one i set) is met in line TFile.setDefaultArchiveDetector(new TArchiveDetector("zip"));

with the following stack:

Thread [main] (Suspended (exception ClassNotFoundException))    
URLClassLoader$1.run() line: not available [local variables unavailable]    
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext)     line: not available [native method]   
Launcher$AppClassLoader(URLClassLoader).findClass(String) line: not available   
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
Launcher$AppClassLoader.loadClass(String, boolean) line: not available  
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available  
JSE7.<clinit>() line: 35    
FileDriver.getPriority() line: 57   
FsDriverLocator$Boot.<clinit>() line: 85    
FsDriv开发者_JAVA百科erLocator.get() line: 59  
TArchiveDetector.<init>(FsDriverProvider, String) line: 125 
TArchiveDetector.<init>(String) line: 105   
TArchiveDetector.<clinit>() line: 80    
Test.main(String[]) line: 12    

the arg in the second line is: java.lang.ClassNotFoundException: java.nio.file.Path

now, I truly don't have this interface, but this is part of java.nio2 and as far as i know of, TrueZip doesn't requires this.

any idea?

thanks


It seems that TrueZIP tries to use the new NIO classes in Java 7.

It seems to do so by dynamically loading a class called JSE7 and probably falling back to classic NIO when that fails.

So even though the exception is thrown, it's handled (caught and acted upon) by TrueZIP itself and the user won't ever see that something went wrong.

The code in question is in the class named de.schlichtherle.truezip.JSE7.

It has a static initializer block, that tries to access the class java.nio.file.Path (that only exists in Java 7). When it gets a NoClassDefFoundError (usually because the class does not exist), then the static final field AVAILABLE will be set to false (which in turn leads to the new NIO driver not to be loaded).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜