Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      Description

      I just created IO-139 for a StringBuilder Writer implementation that requies JDK 1.5. So I thought I would look at the impact on IO of 1) Removing all deprecations and 2) Making appropriate JDK 1.5 changes (generics, using StringBuilder and new Appendable for Writers). Below is a summary, thought it could be a starting point for discussion about IO 2.0

      1) DEPRECATIONS

      • CopyUtils
      • FileCleaner
      • WildcardFilter
      • FileSystemUtils freeSpace(String)
      • IOUtils toByteArray(String), toString(byte[]), toString(byte[], String)

      2) JDK 1.5

      • ConditionalFileFilter List (and also AndFileFilter and OrFileFilter implementations
      • getFileFilters() and setFileFilters() use generic List<IOFileFilter>
      • Constructor for NameFileFilter, PrefixFileFilter, SuffixFileFilter, WildcardFileFilter use generic List<String>
      • replace StringBuffer with StringBuilder where appropriate (FilenameUtils, FileSystemUtils, HexDump,IOUtils
      • FileUtils
      • convertFileCollectionToFileArray() --> Collection<File>
      • listFiles() --> Collection<File>
      • listFiles() --> Collection<File>
      • writeStringToFile String-->CharSequence (JDK 1.4+)
      • ProxyReader - add read(CharBuffer)
      • IOUtils
      • readLines(Reader) return List<String>
      • toInputStream(String) --> toInputStream(CharSequence) (JDK 1.4+)
      • write(String data, OutputStream) and write(StringBuffer data, OutputStream) --> write(CharSequence data, OutputStream)
      • write(String, Writer) and write(StringBuffer, Writer) --> write(CharSequence data, Writer)
      • LineIterator Iterator --> Iterator<String
      • NullWriter - add "Appendable" methods
      • ProxyWriter - add "Appendable" methods

        Activity

        Hide
        Niall Pemberton added a comment -

        Attaching a patch with the changes described.

        Show
        Niall Pemberton added a comment - Attaching a patch with the changes described.
        Hide
        Stephen Colebourne added a comment -

        I support this, provided that the result is placed in a different package - org.apache.commons.io5.

        Show
        Stephen Colebourne added a comment - I support this, provided that the result is placed in a different package - org.apache.commons.io5.
        Hide
        Niall Pemberton added a comment -

        OK I've applied all the JDK 1.5 changes, except I added the "CharSequence" flavour methods to IOUtils and FileUtils, rather than changing the signature of the existing methods:

        So far AFAIK none of these are incompatible changes - clirr is only showing an issue with the LineIterator next() method returning a String rather than Object - but I think this is a false positive?

        Stephen mentioned a couple of other points (Collections to Iterable, and removing arrays) here:
        http://commons.markmail.org/message/xcplvzf3p4odbckx

        Show
        Niall Pemberton added a comment - OK I've applied all the JDK 1.5 changes, except I added the "CharSequence" flavour methods to IOUtils and FileUtils, rather than changing the signature of the existing methods: Use generics: http://svn.apache.org/viewvc?view=rev&revision=619103 Use StringBuilder (non-sync) in place of StringBuffer : http://svn.apache.org/viewvc?view=rev&revision=619112 Add new JDK 1.5 Read/Writer methods: http://svn.apache.org/viewvc?view=rev&revision=619135 Add CharSequence flavour methods to IOUtils / FileUtils: http://svn.apache.org/viewvc?view=rev&revision=619188 Replace StringWriter with StringBuilderWriter in IOUtils: http://svn.apache.org/viewvc?view=rev&revision=619195 So far AFAIK none of these are incompatible changes - clirr is only showing an issue with the LineIterator next() method returning a String rather than Object - but I think this is a false positive? Stephen mentioned a couple of other points (Collections to Iterable, and removing arrays) here: http://commons.markmail.org/message/xcplvzf3p4odbckx
        Hide
        Jukka Zitting added a comment -

        Are there other Java 5 updates we should do?

        Show
        Jukka Zitting added a comment - Are there other Java 5 updates we should do?
        Hide
        Niall Pemberton added a comment -

        There was talk, but no concrete proposal/patches put forward

        Show
        Niall Pemberton added a comment - There was talk, but no concrete proposal/patches put forward
        Hide
        Sebb added a comment -

        What about fixing the various raw types? e.g. Collection<String> instead of just Collection.

        Show
        Sebb added a comment - What about fixing the various raw types? e.g. Collection<String> instead of just Collection.
        Hide
        Niall Pemberton added a comment -

        Hmm, for generic types I was guided by eclipse's warnings, but I only had WARN set for "Unchecked generic type operation" and not "Usage of raw type" as well - these are now fixed:

        http://svn.apache.org/viewvc?view=rev&revision=634474

        thanks

        Niall

        Show
        Niall Pemberton added a comment - Hmm, for generic types I was guided by eclipse's warnings, but I only had WARN set for "Unchecked generic type operation" and not "Usage of raw type" as well - these are now fixed: http://svn.apache.org/viewvc?view=rev&revision=634474 thanks Niall
        Hide
        Sebb added a comment -
        Show
        Sebb added a comment - See also: http://svn.apache.org/viewvc?view=rev&revision=634483 http://svn.apache.org/viewvc?view=rev&revision=634485 which were the remaining raw types in the java tree.
        Hide
        Sebb added a comment -

        Eclipse still complains about:

        PhantomReference is a raw type. References to generic type PhantomReference<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 222
        ReferenceQueue is a raw type. References to generic type ReferenceQueue<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 47
        ReferenceQueue is a raw type. References to generic type ReferenceQueue<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 47
        ReferenceQueue is a raw type. References to generic type ReferenceQueue<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 241
        Type safety: The constructor PhantomReference(Object, ReferenceQueue) belongs to the raw type PhantomReference. References to generic type PhantomReference<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 242

        It also suggests adding @Override markers to all methods that override others (avoids problems with spelling mistakes etc).

        Also to add @Deprecated to all deprecated methods (no idea why this is necessary)

        There's also a whole load of Java 5 fixes that could be made to the test tree as well...

        Show
        Sebb added a comment - Eclipse still complains about: PhantomReference is a raw type. References to generic type PhantomReference<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 222 ReferenceQueue is a raw type. References to generic type ReferenceQueue<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 47 ReferenceQueue is a raw type. References to generic type ReferenceQueue<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 47 ReferenceQueue is a raw type. References to generic type ReferenceQueue<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 241 Type safety: The constructor PhantomReference(Object, ReferenceQueue) belongs to the raw type PhantomReference. References to generic type PhantomReference<T> should be parameterized commons-io-rw/src/java/org/apache/commons/io FileCleaningTracker.java line 242 It also suggests adding @Override markers to all methods that override others (avoids problems with spelling mistakes etc). Also to add @Deprecated to all deprecated methods (no idea why this is necessary) There's also a whole load of Java 5 fixes that could be made to the test tree as well...
        Hide
        Benjamin Bentmann added a comment -

        Also to add @Deprecated to all deprecated methods (no idea why this is necessary)

        Unlike the related javadoc tag, the annotation @Deprecated will be part of the bytecode and allows compilers to output deprecation warnings without access to sources/javadocs.

        Show
        Benjamin Bentmann added a comment - Also to add @Deprecated to all deprecated methods (no idea why this is necessary) Unlike the related javadoc tag, the annotation @Deprecated will be part of the bytecode and allows compilers to output deprecation warnings without access to sources/javadocs.
        Hide
        Benjamin Bentmann added a comment -

        Will there be a backported artifact that is still compatible with Java 1.4 (using Retroweaver or Retrotranslator)?

        Show
        Benjamin Bentmann added a comment - Will there be a backported artifact that is still compatible with Java 1.4 (using Retroweaver or Retrotranslator )?
        Hide
        Niall Pemberton added a comment -

        There was some discussion on the scope when moving to JDK 1.5, but since noone has done anything concrete I'm closing this as fixed

        Show
        Niall Pemberton added a comment - There was some discussion on the scope when moving to JDK 1.5, but since noone has done anything concrete I'm closing this as fixed

          People

          • Assignee:
            Niall Pemberton
            Reporter:
            Niall Pemberton
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development