Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate class error when using apache commons Pair without importing java.util.Map #627

Open
mattstermiller opened this issue Oct 17, 2024 · 14 comments

Comments

@mattstermiller
Copy link

Describe the bug
Using manifold-ext and the Pair type from org.apache.commons:commons-lang3 WITHOUT any import of java.util.Map causes a duplicate class compiler error:

java/util/Map.java:5: error: duplicate class: java.util.Map
public abstract interface Map<K, V> extends manifold.ext.rt.api.ICallHandler {

Simply adding import java.util.Map; to any java file in the project makes the error go away. But this is certainly not obvious and turns up as an unused import and could be auto-removed by some IDEs.

To Reproduce
Steps to reproduce the behavior:

  1. Extract zip: duplicate-class.zip
  2. Run ./gradlew assemble

Expected behavior
Project should compile without error.

Desktop (please complete the following information):

  • OS Type & Version: Windows 11
  • Java/JDK version: Oracle JDK 17
  • Manifold version: 2024.1.36 (also 2022.1.38)
@rsmckinney
Copy link
Member

@mattstermiller thanks for reporting this. A fix is on the way.

@rsmckinney
Copy link
Member

During testing the issue appears only with Java 8. As a sanity check are you using Java 8? Thanks.

rsmckinney added a commit that referenced this issue Oct 21, 2024
- one-off temporary fix, exclusive to Java 8: ensure top-level java.util.Map class loads before inner class Entry
@mattstermiller
Copy link
Author

No, I'm using Oracle's Java 17:

> java --version
java 17.0.9 2023-10-17 LTS
Java(TM) SE Runtime Environment (build 17.0.9+11-LTS-201)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.9+11-LTS-201, mixed mode, sharing)

@rsmckinney
Copy link
Member

What version of gradle?

@mattstermiller
Copy link
Author

> ./gradlew --version

------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------

Build time:   2021-12-22 12:37:54 UTC
Revision:     6f556c80f945dc54b50e0be633da6c62dbe8dc71

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.9 (Oracle Corporation 17.0.9+11-LTS-201)
OS:           Windows 11 10.0 amd64

@mattstermiller
Copy link
Author

I just updated my wrapper to the latest 8.10.2 and the issue persists.

@rsmckinney
Copy link
Member

Please try with release 2024.1.37. I will continue to try to reproduce on JDKs greater than 8.

@mattstermiller
Copy link
Author

A clean and build with these dependency updates gave the same error.

    implementation("systems.manifold:manifold-ext-rt:2024.1.37")
    annotationProcessor("systems.manifold:manifold-ext:2024.1.37")

@rsmckinney
Copy link
Member

Are you using the duplicate-class.zip example? Using that I can only repro w JDK 8

@rsmckinney
Copy link
Member

rsmckinney commented Oct 23, 2024

Screenshots for illustrating a successful JDK 17 build.

image

image

image

@mattstermiller
Copy link
Author

Yes, I am using the same example I posted. Just to be sure, I re-downloaded and opened it from there. Same error.

My gradle settings look mostly the same:
image

Are there any other local environment things I should check?

Thanks for looking into this, by the way.

@rsmckinney
Copy link
Member

Did you set your Project SDK and Language level?

image

@rsmckinney
Copy link
Member

if you are building from the command line, ensure you are performing a clean build. Also make sure there aren't any stray java daemon processes that gradle could be using in error. Otherwise, it should work. If it doesn't, try making a project from scratch by placing the build.gradle file in an empty directory and loading it in IJ as a project. Then add your source file and ensure gradle etc. is setup correctly.

apply plugin: 'java'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    implementation("org.apache.commons:commons-lang3:3.17.0")
    implementation("systems.manifold:manifold-ext-rt:2024.1.37")
    annotationProcessor("systems.manifold:manifold-ext:2024.1.37")
}

tasks.withType(JavaCompile) {
    options.compilerArgs += ['-Xplugin:Manifold']
}

@mattstermiller
Copy link
Author

Here's my project settings:

image

I tried several other SDKs in my list which are based on java 11 or 17 (clean then build) and they all fail with the same duplicate class error. I've made sure there are no other gradle daemons or java processes running. As far as making a project from scratch, that's what I've already done for this minimal repro project I provided.

rsmckinney added a commit that referenced this issue Dec 14, 2024
- revise fix for #627, use reflection to enable compiling manifold itself with jdk 11+ only for building Xxx_11.java11+ source files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants