2011-07-18 73 views
2

我有一個奇怪的問題與truezip。 我運行下面的代碼:truezip問題 - 當調試時,拋出一個奇怪的異常

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(); 
    } 

時,我只要運行它 - 它運行正常。但是當我調試時,在行 TFile.setDefaultArchiveDetector(新的TArchiveDetector(「zip」))滿足一個「斷點」(不是我設置的一個)。

以下堆棧:

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  
FsDriverLocator.get() line: 59 
TArchiveDetector.<init>(FsDriverProvider, String) line: 125 
TArchiveDetector.<init>(String) line: 105 
TArchiveDetector.<clinit>() line: 80  
Test.main(String[]) line: 12  

在第二行的arg: 拋出java.lang.ClassNotFoundException:java.nio.file.Path

現在,我真的沒有這個接口,但是這是java.nio2的一部分,據我所知,TrueZip不需要這個。

有什麼想法嗎?

感謝

回答

2

似乎TrueZIP嘗試使用新的NIO Java中的類7

似乎這樣做,通過動態加載類叫做JSE7,可能回落至當經典NIO失敗了。

所以即使引發異常,它也會被TrueZIP本身處理(被捕獲並採取行動),並且用戶永遠不會看到出錯的地方。

有問題的代碼位於名爲de.schlichtherle.truezip.JSE7的類中。

它有一個靜態初始化塊,它嘗試訪問類java.nio.file.Path(只存在於Java 7中)。當它得到NoClassDefFoundError(通常是因爲該類不存在),那麼static final字段AVAILABLE將被設置爲false(這反過來導致新的NIO驅動程序不被加載)。

+1

對,JSE7類用於測試TrueZIP是否可以在其TrueZIP驅動程序文件中使用NIO.2 API來訪問平臺文件系統。這不是一個錯誤,這是一個功能。 –

相關問題