Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Ant build failed (AbstractPainter.class error)

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    14

    Default Ant build failed (AbstractPainter.class error)

    Having an issue building out from source. On a mac, using jenv to run java 1.6. Error follows. Any help would be appreciated.

    Code:
    $ java -version
    java version "1.6.0_65"
    Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468)
    Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
    $
    $ ant
    Buildfile: /Users/<me>/Code/KoLmafia/kolmafia-code/build.xml
    
    start:
    
    init:
    
    svn-version:
    
    gitsvn-version:
    
    version:
         [echo] Current revision: 19527M
    
    debug:
    
    init:
    
    svn-version:
    
    gitsvn-version:
    
    version:
         [echo] Current revision: 19527M
    
    compile:
        [javac] Compiling 1393 source files to /Users/<me>/Code/KoLmafia/kolmafia-code/build
        [javac] /Users/<me>/Code/KoLmafia/kolmafia-code/lib/org/jdesktop/swingx/JXLabel.java:71: cannot access org.jdesktop.swingx.painter.AbstractPainter
        [javac] bad class file: /Users/<me>/Code/KoLmafia/kolmafia-code/build/org/jdesktop/swingx/painter/AbstractPainter.class
        [javac] class file has wrong version 52.0, should be 50.0
        [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
        [javac] import org.jdesktop.swingx.painter.AbstractPainter;
        [javac]                                   ^
        [javac] Compile failed; see the compiler error output for details.
    
    BUILD FAILED
    /Users/<me>/Code/KoLmafia/kolmafia-code/build.xml:363: The following error occurred while executing this line:
    /Users/<me>/Code/KoLmafia/kolmafia-code/build.xml:149: Failed to compile third-party libraries
    
    Total time: 5 seconds

  2. #2
    Junior Member
    Join Date
    Oct 2008
    Posts
    14

    Default

    ...aaaaand nevermind, just deleted and re-checked out from source, everything built just fine. Move along, nothing to see here.

  3. #3
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,891

    Default

    That looks like you built with java 1.8 first (class file version 52.0 is when it was built targetting java 1.8), and then didn't clean fully before rebuilding with 1.6.

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,517

    Default

    I build with 1.8 on a Mac. No need to downgrade to 1.6 to build.

  5. #5
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Posts
    141

    Default

    I built with Java 13, since I had it on my machine, and I only found one change that was needed in swingx ErrorSupport.java. It's 100% not needed, but if you all ever decide to move to a new target version, it's easy enough for amateurs like me to do...

  6. #6
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,790

    Default

    I built with Java 13, since I had it on my machine, and I only found one change that was needed in swingx ErrorSupport.java. It's 100% not needed, but if you all ever decide to move to a new target version, it's easy enough for amateurs like me to do...
    Originally Posted by MCroft View Post
    I'm lazy and would rather ask than reconfigure my machine and try. What happens if you make the change so things compile under Java 13 and then uninstall Java 13 and build under something earlier, say Java 11? I don't think we want to do anything that requires all of the devs and other home builders to update. Thanks.
    Well, thank you.
    Originally Posted by Veracity View Post

  7. #7
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Posts
    141

    Default

    It fails, because the fix (as I implemented it) is a lambda expression so it requires Java 8. If kolmafia ever switches Java 8, then this can be changed.

    Code:
    Index: lib/org/jdesktop/swingx/error/ErrorSupport.java
    ===================================================================
    --- lib/org/jdesktop/swingx/error/ErrorSupport.java	(revision 19728)
    +++ lib/org/jdesktop/swingx/error/ErrorSupport.java	(working copy)
    @@ -67,7 +67,8 @@
          * added.
          */
         public ErrorListener[] getErrorListeners() {
    -        return listeners.toArray(null);
    +
    +        return listeners.stream().toArray(n -> new ErrorListener[n]);
         }
     
         /**
    Here's what happens to source and target = 1.6 if you have this change.
    Code:
    compile:
        [javac] Compiling 1545 source files to /Users/mcroft/projects/kolmafia/build
        [javac] /Users/mcroft/projects/kolmafia/lib/org/jdesktop/swingx/error/ErrorSupport.java:71: error: lambda expressions are not supported in -source 1.6
        [javac]         return listeners.stream().toArray(n -> new ErrorListener[n]);
        [javac]                                             ^
        [javac]   (use -source 8 or higher to enable lambda expressions)
        [javac] 1 error
        [javac] Compile failed; see the compiler error output for details.
    Java 13 error with original source.
    Code:
        [javac] /Users/mcroft/projects/kolmafia/lib/org/jdesktop/swingx/error/ErrorSupport.java:70: error: reference to toArray is ambiguous
        [javac] 		return listeners.toArray(null);
        [javac] 		                ^
        [javac]   both method <T#1>toArray(IntFunction<T#1[]>) in Collection and method <T#2>toArray(T#2[]) in List match
        [javac]   where T#1,T#2 are type-variables:
        [javac]     T#1 extends Object declared in method <T#1>toArray(IntFunction<T#1[]>)
        [javac]     T#2 extends Object declared in method <T#2>toArray(T#2[])

  8. #8
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Posts
    141

    Default

    fully converting it to 13 (or 8) would probably want to look at some of the deprecated methods that javac warns of, but in terms of compiling and running it was successful with 13.0.2 and OpenJ9 instead of HotSpot.

  9. #9
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,517

    Default

    I would like to be able to use Java 8 features, including lambda expressions.
    I wonder how many of our users are not running Java 8?

    Java SE 6 was released December 2006 and hit its end-of-life date on December 2018
    Java SE 7 was released in July 2011 and is end-of-life on July 2022
    Java SE 8 was released in March 2014 and is end-of-life on March 2025

    If we advance our target version requirement, I'd suggest we go straight to 8.

  10. #10
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Posts
    141

    Default

    I'd be in favor of a newer target version (surprise!).

    The reason I fixed swingx instead of updating swingx (and letting them fix it) was that there is no more recent version of swingx. Luckily it was a one-line fix.

    It'll be interesting to see what libraries would need updating. I would definitely want to see LTS releases when updating (8 and 11, for example).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •