ben-manes/concurrentlinkedhashmap

build problem with OpenJDK 1,8

Closed this issue · 10 comments

hi,
any idea?
[INFO] Skipping ConcurrentLinkedHashMap
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.792 s
[INFO] Finished at: 2015-03-13T15:41:59+00:00
[INFO] Final Memory: 17M/181M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project concurrentlinkedhashmap-lru: Compilation failure: Compilation failure:
[ERROR] /builddir/build/BUILD/concurrentlinkedhashmap-concurrentlinkedhashmap-lru-1.4.2/src/main/java/com/googlecode/concurrentlinkedhashmap/ConcurrentHashMapV8.java:[3769,48] spliterator() in com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.KeySetView cannot implement spliterator() in java.util.Set
[ERROR] return type com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.ConcurrentHashMapSpliterator is not compatible with java.util.Spliterator
[ERROR] /builddir/build/BUILD/concurrentlinkedhashmap-concurrentlinkedhashmap-lru-1.4.2/src/main/java/com/googlecode/concurrentlinkedhashmap/ConcurrentHashMapV8.java:[3832,48] spliterator() in com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.ValuesView cannot implement spliterator() in java.util.Collection
[ERROR] return type com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.ConcurrentHashMapSpliterator is not compatible with java.util.Spliterator
[ERROR] /builddir/build/BUILD/concurrentlinkedhashmap-concurrentlinkedhashmap-lru-1.4.2/src/main/java/com/googlecode/concurrentlinkedhashmap/ConcurrentHashMapV8.java:[3927,61] spliterator() in com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.EntrySetView cannot implement spliterator() in java.util.Set
[ERROR] return type com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.ConcurrentHashMapSpliterator<java.util.Map.Entry<K,V>> is not compatible with java.util.Spliterator<java.util.Map.Entry<K,V>>
[ERROR] -> [Help 1]

This project is JDK6 compatible so it is preferred to build with that JVM to avoid accidental incompatibilities. If you use a mac then you'll find jenv handy and if on linux then update-alternatives.

We embed a backport of the rewritten ConcurrentHashMap for performance reasons. The failure is because the additional default methods in Java 8 collections (e.g. spliterator) has a different method signature than the backport's version. The compiler sees this as bad method overloading and fails.

The fix is to either remove these extra methods from the backport, switch to JDK8's version, or require compiling with an older JVM. It seemed less error prone, even if confusing, to choose the latter.

Caffeine is a JDK8 rewrite intended to be the replacement for this and Guava's cache. If you are interested in helping development then that's the ideal project to explore. If your goal was to explore and understand the basic algorithms, then ConcurrentLinkedHashMap is better by being simpler and more straightforward due to its limited feature set.

If you wanted to embed the ConcurrentLinkedHashMap into your project, then please re-open to discuss if we should strip these methods. Many projects like to copy the code in, sometimes with minor modifications, instead of having an explicit dependency. A cleaner way is to shade the dependency by byte-code rewriting during the build. Surprisingly few do that so I'm open to modifying the backport if desired.

thanks for your reply.
we use, in fedora, as dependency of Apache Solr. i already fix
removing the whole ConcurrentHashMapV8.java for this reason
http://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries#Why_no_Bundled_Libraries.
i used directly java.util.concurrent.ConcurrentHashMap
In fedora we don't have anymore jdk < 1.8, and soon we import 1.9.
about Caffeine for our license policy javax.cache:cache-api is not free, and non-distributable [1]
regards

other packages policy:
http://fedoraproject.org/wiki/Packaging:Guidelines#No_inclusion_of_pre-built_binaries_or_libraries
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1010293#c4

Okay, sounds good.

Note that Caffeine's JCache is an optional package and not required. So when that project matures, if Solr migrated it would use the native API instead of the JSR abstraction. That is preferable anyways since the JCache specification is utter garbage and the TCK is almost useless.

@ben-manes I am facing the same issue.
Can you tell me a simple way to go around this?
Caffeine is working fine for me but I need to make this work so that I can understand the algorithm behind this.

Hi @Arafatk

This was built using Java 6, so that would explain the problems. The issue is because we embedded ConcurrentHashMapV8 which is Java 8's version, prior to that JDK release. It was a significantly improvement to the hashtable, but now could be dropped and use j.u.c.ConcurrentHashMap again. That would resolve the compilation failures due to signature conflicts, which doesn't occur at runtime so it's been safe as an older artifact.

If you remove ConcurrentHashMapV8 then it should build fine. Does that work for you?

Hi @ben-manes ,
Thanks for the fast response it compiles well now but I still face an issue with testing.
I am sorry if this is a trivial question but can you tell me a work around for this?


mvn compile -U
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.4.3-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 398, column 19
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[WARNING] The project com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.4.3-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[INFO] 
[INFO] --< com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru >--
[INFO] Building ConcurrentLinkedHashMap 1.4.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml (1.1 kB at 513 B/s)
n [INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ concurrentlinkedhashmap-lru ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ concurrentlinkedhashmap-lru ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/arafat/Desktop/concurrentlinkedhashmap/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ concurrentlinkedhashmap-lru ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- animal-sniffer-maven-plugin:1.14:check (check-java16-sun) @ concurrentlinkedhashmap-lru ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java16-sun:1.0
test [INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.437 s
[INFO] Finished at: 2019-05-15T00:58:30+05:30
[INFO] ------------------------------------------------------------------------
[n] ~/D/concurrentlinkedhashmap ☭ master ● (^._.^)ノ彡ミ彡ミ
⫸  mvn test 
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.4.3-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 398, column 19
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[WARNING] The project com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.4.3-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[INFO] 
[INFO] --< com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru >--
[INFO] Building ConcurrentLinkedHashMap 1.4.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ concurrentlinkedhashmap-lru ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ concurrentlinkedhashmap-lru ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/arafat/Desktop/concurrentlinkedhashmap/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ concurrentlinkedhashmap-lru ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- animal-sniffer-maven-plugin:1.14:check (check-java16-sun) @ concurrentlinkedhashmap-lru ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java16-sun:1.0
[INFO] 
[INFO] --- maven-bundle-plugin:2.5.3:manifest (bundle-manifest) @ concurrentlinkedhashmap-lru ---
[WARNING] Manifest com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.4.3-SNAPSHOT : Unused Import-Package instructions: [sun.misc.*] 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ concurrentlinkedhashmap-lru ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ concurrentlinkedhashmap-lru ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18:test (default-test) @ concurrentlinkedhashmap-lru ---
[INFO] Surefire report directory: /Users/arafat/Desktop/concurrentlinkedhashmap/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite

Results :




Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.758 s
[INFO] Finished at: 2019-05-15T01:01:54+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18:test (default-test) on project concurrentlinkedhashmap-lru: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18:test failed: There was an error in the forked process
[ERROR] org.testng.TestNGException: 
[ERROR] Cannot instantiate class com.googlecode.concurrentlinkedhashmap.benchmark.CacheBenchmark
[ERROR]         at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:37)
[ERROR]         at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:372)
[ERROR]         at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:284)
[ERROR]         at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:109)
[ERROR]         at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:184)
[ERROR]         at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
[ERROR]         at org.testng.TestRunner.initMethods(TestRunner.java:394)
[ERROR]         at org.testng.TestRunner.init(TestRunner.java:228)
[ERROR]         at org.testng.TestRunner.init(TestRunner.java:198)
[ERROR]         at org.testng.TestRunner.<init>(TestRunner.java:147)
[ERROR]         at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:508)
[ERROR]         at org.testng.SuiteRunner.init(SuiteRunner.java:142)
[ERROR]         at org.testng.SuiteRunner.<init>(SuiteRunner.java:106)
[ERROR]         at org.testng.TestNG.createSuiteRunner(TestNG.java:1116)
[ERROR]         at org.testng.TestNG.createSuiteRunners(TestNG.java:1103)
[ERROR]         at org.testng.TestNG.runSuitesLocally(TestNG.java:955)
[ERROR]         at org.testng.TestNG.run(TestNG.java:900)
[ERROR]         at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:295)
[ERROR]         at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
[ERROR]         at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:90)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] Caused by: java.lang.reflect.InvocationTargetException
[ERROR]         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[ERROR]         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[ERROR]         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[ERROR]         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[ERROR]         at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:28)
[ERROR]         ... 22 more
[ERROR] Caused by: java.lang.Error: Unresolved compilation problems: 
[ERROR]         The import org.cachebench cannot be resolved
[ERROR]         The import org.cachebench cannot be resolved
[ERROR]         The import org.cachebench cannot be resolved
[ERROR]         The import org.cachebench cannot be resolved
[ERROR]         The import org.cachebench cannot be resolved
[ERROR]         CacheWrapper cannot be resolved to a type
[ERROR]         CacheBenchmarkRunner cannot be resolved
[ERROR]         ChartGen cannot be resolved to a type
[ERROR]         PutGetChartGenerator cannot be resolved to a type
[ERROR]         The method init(Map) of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method setUp() of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method put(List<String>, Object, Object) of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method get(List<String>, Object) of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method empty() of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method getNumMembers() of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method getInfo() of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method getReplicatedData(List<String>, String) of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method startTransaction() of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method endTransaction(boolean) of type CacheBenchmark must override or implement a supertype method
[ERROR]         The method tearDown() of type CacheBenchmark must override or implement a supertype method
[ERROR]         CsvStatisticReportGenerator cannot be resolved to a type
[ERROR]         The method setOutputFile(String) of type CacheBenchmark.CustomCsvStatisticReportGenerator must override or implement a supertype method
[ERROR]         output cannot be resolved or is not a field
[ERROR] 
[ERROR]         at com.googlecode.concurrentlinkedhashmap.benchmark.CacheBenchmark.<init>(CacheBenchmark.java:26)
[ERROR]         ... 27 more
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[n] ~/D/concurrentlinkedhashmap ☭ master ● (^._.^)ノ彡ミ彡ミ
⫸  

Ah yes, this is in the NOTES file. We used a RedHat dependency that wasn't published yet, I think it eventually because JBoss' RadarGun but I had lost track of it.

$ mvn install:install-file \
    -Dfile=lib/cache-benchmark/benchmark-fwk.jar \
    -DpomFile=lib/cache-benchmark/pom.xml

Using this patch (which I think is what you did) and installing that dependency, it works. I guess the Maven build isn't backwards compatible and of course is stale after so many years.

clhm.patch.txt

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.634 s
[INFO] Finished at: 2019-05-14T12:44:23-07:00
[INFO] ------------------------------------------------------------------------

Hi @ben-manes ,
The patch is really nice and the test and compilation works fine with it.
Thanks a lot.

I hope it's cool if I ask you a few more questions about the repo.

Sure, happy to. You are welcome to email me directly if that helps.

It looks like I haven't actively worked on this repository since 2012-13, but should be familar enough to answer most things.