commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Aymé (JIRA) <j...@apache.org>
Subject [jira] Issue Comment Edited: (IO-155) use NIO for copyFile when running on java 1.4
Date Thu, 10 Jan 2008 15:03:34 GMT

    [ https://issues.apache.org/jira/browse/IO-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557663#action_12557663
] 

julien.ayme@gmail.com edited comment on IO-155 at 1/10/08 7:02 AM:
---------------------------------------------------------

The given patch will still throw a NoClassDefFoundError: java.nio.channels.FileChannel on
class initialisation if run under Java 1.3, since it will try to find a ref to FileChannel
when loading the FileUtils class (due to its presence in the methods doCopyFile and closeQuietly(Channel)).

In order to circumvent this error, the simpler solution is to create a new class FileUtils14.java,
which contains exactly the code which uses 1.4 features,
and delegate to this class if isJava4 is true.

(The trick is that if isJava14 is false, the FileUtils14.class will not be loaded into the
ClassLoader (the execution of code does not need to), and so the NoClassDefFoundError will
not be thrown).

      was (Author: julien.ayme@gmail.com):
    The given patch will still throw a NoClassDefFoundError: java.nio.channels.FileChannel
on class initialisation if run under Java 1.3, since it will try to find a ref to FileChannel
when loading the FileUtils class (due to its presence in the methods doCopyFile and closeQuietly(Channel)).

In order to circumvent this error, the simpler solution is to create a new class FileUtils14.java,
which contains exactly the code which uses 1.4 features,
and delegate to this class if isJava4 is true.

(The trick is that if isJava14 is false, the FileUtils14.class will not be loaded into the
ClassLoader (the execution of code does not need to), and so the NoClassDefFoundError will
not be thrown).

The new FileUtils14.java fill follow
  
> use NIO for copyFile when running on java 1.4
> ---------------------------------------------
>
>                 Key: IO-155
>                 URL: https://issues.apache.org/jira/browse/IO-155
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 1.4
>            Reporter: nicolas de loof
>            Priority: Trivial
>             Fix For: AFTER-1.4
>
>         Attachments: IO-155.patch
>
>
> CopyFile can rely on java.nio when runtime is java 1.4 +

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message