Multiple similar errors on running ant tests

Hi all!
I am running ant tests without making any changes to the code. And a lot of tests are failing with the same error as below. I've tried doing a fresh clone but I'm still running into the same problem.
Steps followed :

  1. git submodule update --init
  2. ant clean
  3. ant MakeAuthKey
  4. ant
  5. ant tests

It gives the following error :

java.lang.IllegalAccessException: no such field: org.robolectric.internal.bytecode.ProxyMaker$GeneratedProxy/702529866.__proxy__/android.content.res.Configuration/putField

junit.framework.AssertionFailedError: java.lang.IllegalAccessException: no such field: org.robolectric.internal.bytecode.ProxyMaker$GeneratedProxy/702529866.__proxy__/android.content.res.Configuration/putField at org.robolectric.internal.bytecode.ProxyMaker.createProxyFactory(ProxyMaker.java:100) at org.robolectric.internal.bytecode.ProxyMaker$1.computeValue(ProxyMaker.java:45) at org.robolectric.internal.bytecode.ProxyMaker$1.computeValue(ProxyMaker.java:43) at java.lang.ClassValue.getFromHashMap(ClassValue.java:227) at java.lang.ClassValue.getFromBackup(ClassValue.java:209) at java.lang.ClassValue.get(ClassValue.java:115) at org.robolectric.internal.bytecode.ProxyMaker.createProxy(ProxyMaker.java:51) at org.robolectric.internal.bytecode.ShadowImpl.createProxy(ShadowImpl.java:34) at org.robolectric.internal.bytecode.ShadowImpl.directlyOn(ShadowImpl.java:28) at org.robolectric.shadow.api.Shadow.directlyOn(Shadow.java:46) at org.robolectric.shadows.ShadowConfiguration.setToDefaults(ShadowConfiguration.java:48) at android.content.res.Configuration.setToDefaults(Configuration.java) at android.content.res.Configuration.__constructor__(Configuration.java:426) at android.content.res.Configuration.<init>(Configuration.java) at org.robolectric.shadows.ShadowResources.getSystem(ShadowResources.java:85) at android.content.res.Resources.getSystem(Resources.java) at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:80) at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:290) at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:203) at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:109) at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:36) at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:63)Caused by: java.lang.IllegalAccessException: no such field: org.robolectric.internal.bytecode.ProxyMaker$GeneratedProxy/702529866.__proxy__/android.content.res.Configuration/putField at java.lang.invoke.MemberName.makeAccessException(MemberName.java:867) at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1003) at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1377) at java.lang.invoke.MethodHandles$Lookup.findSetter(MethodHandles.java:1048) at org.robolectric.internal.bytecode.ProxyMaker.createProxyFactory(ProxyMaker.java:85) at org.robolectric.internal.bytecode.ProxyMaker$1.computeValue(ProxyMaker.java:45) at org.robolectric.internal.bytecode.ProxyMaker$1.computeValue(ProxyMaker.java:43) at java.lang.ClassValue.getFromHashMap(ClassValue.java:227) at java.lang.ClassValue.getFromBackup(ClassValue.java:209) at java.lang.ClassValue.get(ClassValue.java:115) at org.robolectric.internal.bytecode.ProxyMaker.createProxy(ProxyMaker.java:51) at org.robolectric.internal.bytecode.ShadowImpl.createProxy(ShadowImpl.java:34) at org.robolectric.internal.bytecode.ShadowImpl.directlyOn(ShadowImpl.java:28) at org.robolectric.shadow.api.Shadow.directlyOn(Shadow.java:46) at org.robolectric.shadows.ShadowConfiguration.setToDefaults(ShadowConfiguration.java:48) at android.content.res.Configuration.setToDefaults(Configuration.java) at android.content.res.Configuration.$robo$__constructor__(Configuration.java:426)Caused by: java.lang.LinkageError: loader constraint violation: when resolving field "__proxy__" the class loader (instance of <bootloader>) of the referring class, org/robolectric/internal/bytecode/ProxyMaker$GeneratedProxy, and the class loader (instance of org/robolectric/internal/bytecode/SandboxClassLoader) for the field's resolved type, android/content/res/Configuration, have different Class objects for that type at java.lang.invoke.MethodHandleNatives.resolve(Native Method) at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975) at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)

How can I solve this? Thanks in advance!

I don't think I've seen this error before. Can you confirm that both java and java -version output java 1.8? Are you building the sources with modifications (e.g., having added a new library)?


Screenshot from 2021-02-09 17-55-36
Yeah the java version is 1.8 and I've not modified or added any part of the code (as visible in the git status screenshot). I've even tried this in another device to check if the problem is limited to the device.
I have a solution for the bug in the issue #2408 and have tested it manually but I am unable to verify if my changes are causing any other issues because of this ant tests error. So while I work on solving this ant tests error, is there another way to verify my changes?

Do you also get this error if you try the Vagrant setup?

Yes, I have done it using the vagrant setup only.
I run the following commands :

  1. vagrant up
  2. vagrant ssh
  3. git submodule update --init
  4. ant
  5. ant test

Can you point me to a branch where the code is hosted?

I run it on my local machine. I see these errors in a fresh clone of the main repo (https://github.com/mit-cml/appinventor-sources) as well. I reckon it's happening because of some issue in my setup but I am unable to point it out.

Well if the issue is happening in Vagrant then it might be something else. I'll try a clean build and see if I can reproduce.

1 Like

Alright. I've reproduced the issue locally. I'm not sure yet though what is causing the problem.

1 Like

I found this on a quick google search, I'm not sure how we can upgrade robolectric version to check this solution out.

@ewpatton should we make a GitHub issue for this?

I've filed one here:

If the changes you're making don't affect those tests, I would say ignore it for now. They don't fail on the Jenkins setup since it uses a slightly older JDK version, so once we review your changes it will run the tests.