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.NoSuchFieldException: modifiers #565

Open
sobaya-0141 opened this issue Sep 2, 2022 · 10 comments · May be fixed by #1712
Open

java.lang.NoSuchFieldException: modifiers #565

sobaya-0141 opened this issue Sep 2, 2022 · 10 comments · May be fixed by #1712
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sobaya-0141
Copy link

sobaya-0141 commented Sep 2, 2022

Description
#171 Related
OpenJDK Runtime Environment Zulu18.32+11-CA (build 18.0.2+9)

Steps to Reproduce
./gradlew recordPaparazziDebug

java.lang.NoSuchFieldException: modifiers
	at java.base/java.lang.Class.getDeclaredField(Class.java:2642)
	at app.cash.paparazzi.Paparazzi.forcePlatformSdkVersion(Paparazzi.kt:388)
	at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:148)
	at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:122)
	at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:17)
	at com.google.testing.junit.testparameterinjector.PluggableTestRunner$ContextMethodRule$1.evaluate(PluggableTestRunner.java:420)
	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.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
	Suppressed: java.lang.reflect.InaccessibleObjectException: Unable to make private native java.lang.reflect.Field[] java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not "opens java.lang" to unnamed module @4b8f7a19
		at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
		at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
		at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:200)
		at java.base/java.lang.reflect.Method.setAccessible(Method.java:194)
		at app.cash.paparazzi.Paparazzi.forcePlatformSdkVersion(Paparazzi.kt:398)
@jrodbx
Copy link
Collaborator

jrodbx commented Sep 4, 2022

what version are you using? I think this should be fixed on master with #530, but it's unreleased, so I'd like to confirm whether there's work to be done here, or if this can be closed out.

@sobaya-0141
Copy link
Author

I am using version 1.0.0

I believe this problem is occurring with a specific Java distribution.
Because it occurred with Zulu18.32 and not with Temurin-18.0.2.1+1.

@jrodbx
Copy link
Collaborator

jrodbx commented Sep 5, 2022

Mind confirming the issue?

@DavidBrunow
Copy link

We are seeing a similar regression in Paparazzi as of this weekend. Reverting to a previous snapshot of Paparazzi did not resolve the issue for us but reverting to v1.0.0 did resolve it.

@michaelcspeed
Copy link

michaelcspeed commented Oct 3, 2022

We are seeing a similar regression in Paparazzi as of this weekend. Reverting to a previous snapshot of Paparazzi did not resolve the issue for us but reverting to v1.0.0 did resolve it.

@DavidBrunow 1.0.0 is the newest version of Paparazzi no? Did you mean something else?


I am also getting this error, and I tried with Temurin-18.0.2.1+1 and 19.

@mshearer123
Copy link

Seeing this as well

@TWiStErRob
Copy link
Contributor

Based on this answer there's workaround yet for Java 18+. However, following the future of the commit mentioned in #205's comment, they migrated to using Unsafe in powermock/powermock#1026 which may or may not work on Java 18 and 19.

As a workaround, you can try to set your Test task's toolchain to something lower:

tasks.withType(Test).configureEach {
    javaLauncher = javaToolchains.launcherFor {
        languageVersion = JavaLanguageVersion.of(11)
    }
}

@mshearer123
Copy link

Based on this answer there's workaround yet for Java 18+. However, following the future of the commit mentioned in #205's comment, they migrated to using Unsafe in powermock/powermock#1026 which may or may not work on Java 18 and 19.

As a workaround, you can try to set your Test task's toolchain to something lower:

tasks.withType(Test).configureEach {
    javaLauncher = javaToolchains.launcherFor {
        languageVersion = JavaLanguageVersion.of(11)
    }
}

Thanks, this has fixed the modifiers error, but now I get

 kotlin.UninitializedPropertyAccessException: lateinit property sessionParamsBuilder has not been initialized
        at app.cash.paparazzi.Paparazzi$Companion.getSessionParamsBuilder$paparazzi(Paparazzi.kt:626)
        at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:162)
        at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:124)
        at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)

Seems to be just locally (macOS). On our CI with the same java it works.

@TWiStErRob
Copy link
Contributor

Note, there might be a better workaround than toolchains: https://github.com/cashapp/paparazzi/pull/1030/files

Re sessionParamsBuilder, #486 looks related, but not necessarily the same problem. If that doesn't help, please consider opening a separate issue to keep this one focused on modifiers.

@jrodbx jrodbx added this to the 1.4 milestone Jan 22, 2024
@geoff-powell
Copy link
Collaborator

So I was able to build locally on versions 18 - 22 of java.

I have this branch running to test this in CI with all platforms. https://github.com/cashapp/paparazzi/actions/runs/11959970311

If it passes then I think this issue is no longer occuring.

@geoff-powell geoff-powell linked a pull request Nov 21, 2024 that will close this issue
@geoff-powell geoff-powell self-assigned this Nov 21, 2024
@geoff-powell geoff-powell added the bug Something isn't working label Nov 21, 2024
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

Successfully merging a pull request may close this issue.

7 participants