Java lang nosuchfielderror companion

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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.NoSuchFieldError: Companion #432

java.lang.NoSuchFieldError: Companion #432

Comments

Describe the bug
It started to happen after upgrading Intellij IDEA(Community Edition) to version 2022.3.3 Build #IC-223.8836.41.
The error would cause AceJump quit and not function any more.

java.lang.NoSuchFieldError: Companion at org.acejump.action.AceAction.actionPerformed(AceAction.kt:34) at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:327) at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:47) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:584) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$9(IdeKeyEventDispatcher.java:706) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105) at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$10(IdeKeyEventDispatcher.java:706) at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:350) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.doPerformActionInner(IdeKeyEventDispatcher.java:703) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:647) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:595) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:478) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:467) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:225) at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:815) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:750) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113) at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:838) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92) 

To Reproduce
Steps to reproduce the behavior:

  1. Use Intellij IDEA and open any file.
  2. Use command + ; to trigger AceJump
  3. Error will pop up
Читайте также:  Which java classes are immutable

Desktop (please complete the following information):

  • OS: MacOS 13.2 (22D49), Apple M1 Pro
  • IDE: Intellij IDEA(Community Edition) 2022.3.3 Build #IC-223.8836.41
  • AceJump version: 3.8.12

The text was updated successfully, but these errors were encountered:

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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.NoSuchFieldError: Companion when in a kotlin only module / kotlin(«jvm») plugin #5818

java.lang.NoSuchFieldError: Companion when in a kotlin only module / kotlin(«jvm») plugin #5818

Comments

I have a modularised project, where the api layer is separated into its own module. As this has no dependency on the Android SDK, I have made it a kotlin only module. This has the kotlin jvm plugin as shown below in the build file. This results in a java.lang.NoSuchFieldError: Companion error when I try to use MockWebServer (only this, everything else works fine).

Using kotlin dsl in the build file, the build.gradle.kts file looks like this:

And here is the snippet of my unit test. The line where I instantiate MockWebServer() fails with the NoSuchFieldError: Companion:

java.lang.NoSuchFieldError: Companion at okhttp3.internal.Util.(Util.kt:69) at okhttp3.mockwebserver.MockWebServer.(MockWebServer.kt:101) at com.mobilleo.data.webapi.service.core.user.LoginServiceTest.(LoginServiceTest.kt:29) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:260) at org.junit.runners.BlockJUnit4ClassRunner$2.runReflectiveCall(BlockJUnit4ClassRunner.java:309) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Process finished with exit code 255 

After various experiments, I have discovered the following:

  • Rolling back the okhttp3 libraries to version 3.x.x removes this error, but then I lose a lot of needed features of okhttp3 that I need, for interceptors, authenticators etc. etc.
  • I believe retrofit uses okhttp3 3.14, however prior to me trying to use MockWebServer, I had no issue with the okttp3:logging-interceptor using 4.4.0
  • When I switch the module to a kotlin android module, it works as expected. So changing build file to the following:

My instinct tells me it’s some difference between the way kotlin android compiles the Kotlin, with Companion objects or static methods etc., compared with when just using the kotlin jvm compiler, but I confess to not knowing enough about what happens ‘under the hood’ with all this.

The text was updated successfully, but these errors were encountered:

Источник

java.lang.NoSuchFieldError: Companion when using `influx-client-reactive` and `quarkus`

java.lang.NoSuchFieldError: Companion when using `influx-client-reactive` and `quarkus`

Error occurs when instantiating a client

 InfluxDBClientReactive influxDBClient = InfluxDBClientReactiveFactory.create( influxConf.url(), influxConf.username(), influxConf.password().toCharArray()); 

dependency is excluded from quarkus-bom

implementation enforcedPlatform("$:$:$") < exclude group: "com.squareup.okhttp3", module: "okhttp" >implementation "com.influxdb:influxdb-client-reactive:6.4.0" 

otherwise (3.x.x) is forced and would cause

'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)' java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType) 
Companion java.lang.NoSuchFieldError: Companion at okhttp3.internal.Util.(Util.kt:70) at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239) at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1634) at okhttp3.HttpUrl$Companion.parse(HttpUrl.kt:1643) at okhttp3.HttpUrl.parse(HttpUrl.kt) at com.influxdb.client.InfluxDBClientOptions$Builder$ParsedUrl.(InfluxDBClientOptions.java:689) at com.influxdb.client.InfluxDBClientOptions$Builder$ParsedUrl.(InfluxDBClientOptions.java:681) at com.influxdb.client.InfluxDBClientOptions$Builder.connectionString(InfluxDBClientOptions.java:504) at com.influxdb.client.InfluxDBClientOptions$Builder.url(InfluxDBClientOptions.java:288) at com.influxdb.client.reactive.InfluxDBClientReactiveFactory.create(InfluxDBClientReactiveFactory.java:105) 

Solution – 1

This issue led me to think that com.squareup.okio:okio might also play a role here.

com.squareup.okio:okio:1.17.2 --- io.quarkus:quarkus-bom:2.11.2.Final --- runtimeClasspath com.squareup.okio:okio:3.0.0 -> 1.17.2 --- com.squareup.okhttp3:okhttp:4.10.0 

That Options.of is a call to method in that dependency and not Optional from java. That there is nothing strange here other than some quarkus necromancy forced for fabric8io/kubernetes-client

exclude group: "com.squareup.okio", module: "okio" 

Источник

java.lang.NoSuchFieldError: Companion when using `influx-client-reactive` and `quarkus`

java.lang.NoSuchFieldError: Companion when using `influx-client-reactive` and `quarkus`

Error occurs when instantiating a client

 InfluxDBClientReactive influxDBClient = InfluxDBClientReactiveFactory.create( influxConf.url(), influxConf.username(), influxConf.password().toCharArray()); 

dependency is excluded from quarkus-bom

implementation enforcedPlatform("$:$:$") < exclude group: "com.squareup.okhttp3", module: "okhttp" >implementation "com.influxdb:influxdb-client-reactive:6.4.0" 

otherwise (3.x.x) is forced and would cause

'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)' java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType) 
Companion java.lang.NoSuchFieldError: Companion at okhttp3.internal.Util.(Util.kt:70) at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239) at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1634) at okhttp3.HttpUrl$Companion.parse(HttpUrl.kt:1643) at okhttp3.HttpUrl.parse(HttpUrl.kt) at com.influxdb.client.InfluxDBClientOptions$Builder$ParsedUrl.(InfluxDBClientOptions.java:689) at com.influxdb.client.InfluxDBClientOptions$Builder$ParsedUrl.(InfluxDBClientOptions.java:681) at com.influxdb.client.InfluxDBClientOptions$Builder.connectionString(InfluxDBClientOptions.java:504) at com.influxdb.client.InfluxDBClientOptions$Builder.url(InfluxDBClientOptions.java:288) at com.influxdb.client.reactive.InfluxDBClientReactiveFactory.create(InfluxDBClientReactiveFactory.java:105) 

Solution – 1

This issue led me to think that com.squareup.okio:okio might also play a role here.

com.squareup.okio:okio:1.17.2 --- io.quarkus:quarkus-bom:2.11.2.Final --- runtimeClasspath com.squareup.okio:okio:3.0.0 -> 1.17.2 --- com.squareup.okhttp3:okhttp:4.10.0 

That Options.of is a call to method in that dependency and not Optional from java. That there is nothing strange here other than some quarkus necromancy forced for fabric8io/kubernetes-client

exclude group: "com.squareup.okio", module: "okio" 

Источник

Оцените статью