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

java.lang.NoClassDefFoundError: java/util/function/BiFunction #69

Closed
levant916 opened this issue Jul 31, 2020 · 5 comments
Closed

java.lang.NoClassDefFoundError: java/util/function/BiFunction #69

levant916 opened this issue Jul 31, 2020 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@levant916
Copy link

using lingua version :

<dependency>
	<groupId>com.github.pemistahl</groupId>
	<artifactId>lingua</artifactId>
	<version>1.0.1</version>
</dependency>

using code :

private static final LanguageDetector detector =
		LanguageDetectorBuilder.fromLanguages(Language.KOREAN, Language.JAPANESE).build();
detector.computeLanguageConfidenceValues("안녕하세요");

error message :

objc[47695]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java (0x1051664c0) and /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1051e04e0). One of the two will be used. Which one is undefined.

java.lang.NoClassDefFoundError: java/util/function/BiFunction

	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at com.github.pemistahl.lingua.api.LanguageDetector.addCharCount(LanguageDetector.kt:409)
	at com.github.pemistahl.lingua.api.LanguageDetector.detectLanguageWithRules$lingua(LanguageDetector.kt:234)
	at com.github.pemistahl.lingua.api.LanguageDetector.computeLanguageConfidenceValues(LanguageDetector.kt:145)
	at com.github.pemistahl.lingua.api.LanguageDetector.detectLanguageOf(LanguageDetector.kt:100)
	at com.naver.labs.smt.api.translator.bo.TranslatorBoTest.test(TranslatorBoTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: java.lang.ClassNotFoundException: java.util.function.BiFunction
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 39 more
@levant916 levant916 changed the title It doesn't work on java7(using Bifunction in java8) [help]It doesn't work on java7(using Bifunction in java8) Jul 31, 2020
@pemistahl pemistahl added the bug Something isn't working label Aug 2, 2020
@pemistahl pemistahl added this to the Lingua 1.0.2 milestone Aug 2, 2020
@pemistahl pemistahl changed the title [help]It doesn't work on java7(using Bifunction in java8) java.lang.NoClassDefFoundError: java/util/function/BiFunction Aug 2, 2020
@pemistahl
Copy link
Owner

pemistahl commented Aug 2, 2020

Hi @levant916, thank you for using Lingua and for opening this issue.

I can confirm that this is a bug. This is because the LanguageDetector uses the Java method java.util.Map.merge() internally which is only supported by Java >= 1.8. I will replace it by an appropriate Kotlin method. After this change, the library should run on Java 1.6 and 1.7 as it was originally intended.

Only the FilesWriter classes will need Java 1.8 at least because I make use of the NIO api. But if you don't want to create your own language models, you should be fine with Java < 1.8.

@ghost
Copy link

ghost commented Aug 3, 2020

@pemistahl
What if it has to be Java 8? I'm trying to integrate it inside a project that is already using Java 8

@pemistahl
Copy link
Owner

@roi3363 There won't be any problems with Java >= 8. This issue was opened because of problems with Java < 8. The library is supposed to work with Java >= 6.

@ghost
Copy link

ghost commented Aug 3, 2020

image
Am I missing something?

@pemistahl
Copy link
Owner

@roi3363 Can you please open a new issue for your specific problem? In that new issue, please state your project configuration including your build script if any, including any third-party dependencies you are using. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants