Community
Participate
Working Groups
When running the app on android, We get a IllegalAccessError runtime crash. I have attached the AJ project that does binary weaving. woven jar:- woven.jar Test code:- public static boolean isIntentAvailable(Context ctx, Intent intent) { final PackageManager mgr = ctx.getPackageManager(); List<ResolveInfo> list = citrix.android.content.pm.PackageManager.queryIntentActivities((Object)mgr, intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; } Runtime logs:- 03-13 07:27:00.810: I/PackageManager(376): Running dexopt on: com.citrix.androidapiexerciser 03-13 07:27:01.028: I/dalvikvm(25631): DexOpt: illegal method access (call Lcom/test/PackageManagerAspect;.$SWITCH_TABLE$com$test2$PolicyProviderConstants$OpenInPolicyValues ()[I from Lcitrix/android/content/pm/PackageManager;) 03-13 07:27:01.247: D/dalvikvm(25631): DexOpt: load 95ms, verify+opt 236ms, 1105036 bytes 03-13 07:27:01.341: W/PackageManager(376): Code path for pkg : com.citrix.androidapiexerciser changing from /data/app/com.citrix.androidapiexerciser-1.apk to /data/app/com.citrix.androidapiexerciser-2.apk 03-13 07:27:01.341: I/ActivityManager(376): Force stopping package com.citrix.androidapiexerciser appid=10116 user=-1 03-13 07:27:01.341: W/PackageManager(376): Resource path for pkg : com.citrix.androidapiexerciser changing from /data/app/com.citrix.androidapiexerciser-1.apk to /data/app/com.citrix.androidapiexerciser-2.apk 03-13 07:27:01.341: W/PackageManager(376): Skipping provider name com.citrix.androidapiexerciser.MyContentProvider (in package com.citrix.androidapiexerciser): name already used by com.citrix.androidapiexerciser 03-10 15:30:26.619: W/dalvikvm(1737): threadid=1: thread exiting with uncaught exception (group=0x41af2700) 03-10 15:30:26.627: E/AndroidRuntime(1737): FATAL EXCEPTION: main 03-10 15:30:26.627: E/AndroidRuntime(1737): java.lang.IllegalAccessError: tried to access method com.citrix.APIContainment.aspects.PackageManagerAspect.$SWITCH_TABLE$com$citrix$APIContainment$policies$PolicyProviderConstants$OpenInPolicyValues:(Ljava/lang/Object;Landroid/content/Intent;ILcom/citrix/APIContainment/aspects/PackageManagerAspect;Landroid/content/Intent;ILorg/aspectj/runtime/internal/AroundClosure;)Ljava/lang/Object; from class citrix.android.content.pm.PackageManager 03-10 15:30:26.627: E/AndroidRuntime(1737): at citrix.android.content.pm.PackageManager.queryIntentActivities_aroundBody3$advice(Unknown Source) 03-10 15:30:26.627: E/AndroidRuntime(1737): at citrix.android.content.pm.PackageManager.queryIntentActivities(Unknown Source) 03-10 15:30:26.627: E/AndroidRuntime(1737): at com.citrix.androidapiexerciser.APIApp.isIntentAvailable(APIApp.java:65) 03-10 15
Created attachment 240836 [details] Test AJ Project The attached AJ project generates the woven jar.
When I made this synthetic method "public" by decompiling and recompiling the jar, I was able to avoid the IllegalAccessError. I think the quick and safer fix in aspectj would be to make all the synthetic methods "public" # direct methods .method static synthetic $SWITCH_TABLE$com$test2$PolicyProviderConstants$OpenInPolicyValues()[I
The simple workaround here is to move the switch statement from the advice into a helper method: Object around()... switch (foo) { ... } } to Object around()... compute() } public void compute() { switch (foo) { ... } } (but it is only a workaround). JDT is building some of the synthetics here, it isn't just AspectJ. Normally an accessor would be generated for a method that needs raised visibility and that doesn't seem to be happening here. Making all synthetics public is probably a step too far.
Suggested workaround of moving the body into a seperate helper method works.