Project

General

Profile

Bug #4073

code size limit exceeded

Added by Ovidiu Maxiniuc about 5 years ago. Updated about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version:

History

#1 Updated by Ovidiu Maxiniuc about 5 years ago

Today I added some new functionality to FWD and suddenly the client started to abend with

java.lang.NullPointerException
    at com.sun.proxy.$Proxy2.getSessionTooltips(Unknown Source)
    at com.goldencode.p2j.ui.chui.ThinClient.setSessionTooltips(ThinClient.java:3408)
    at com.goldencode.p2j.main.ClientCore.start(ClientCore.java:346)
    at com.goldencode.p2j.main.ClientCore.start(ClientCore.java:163)
    at com.goldencode.p2j.main.ClientDriver.start(ClientDriver.java:250)
    at com.goldencode.p2j.main.CommonDriver.process(CommonDriver.java:444)
    at com.goldencode.p2j.main.ClientDriver.process(ClientDriver.java:144)
    at com.goldencode.p2j.main.ClientDriver.main(ClientDriver.java:313)

This was quite known to me, but I did not exactly recalled why this happens. In fact, this NPE can be thrown because of a lot of factors because this is the first access to session internal data so all initializations occur here. I turned to server and investigated. I found the following hidden (I had to manually print it out because, by default is not displayed) exception:

java.lang.ExceptionInInitializerError
    at com.goldencode.p2j.util.HandleResource.<init>(HandleResource.java:136)
    at com.goldencode.p2j.util.HandleChain.<init>(HandleChain.java:225)
    at com.goldencode.p2j.util.HandleChain.<init>(HandleChain.java:198)
    at com.goldencode.p2j.util.HandleChain.<init>(HandleChain.java:185)
    at com.goldencode.p2j.ui.GenericWidget.<init>(GenericWidget.java:410)
    at com.goldencode.p2j.ui.BaseEntity.<init>(BaseEntity.java:225)
    at com.goldencode.p2j.ui.PaneEntity.<init>(PaneEntity.java:106)
    at com.goldencode.p2j.ui.WindowWidget.<init>(WindowWidget.java:197)
    at com.goldencode.p2j.ui.LogicalTerminal.init(LogicalTerminal.java:1255)
    at com.goldencode.p2j.security.ContextLocal.initializeValue(ContextLocal.java:655)
    at com.goldencode.p2j.security.ContextLocal.get(ContextLocal.java:494)
    at com.goldencode.p2j.security.ContextLocal.get(ContextLocal.java:430)
    at com.goldencode.p2j.ui.LogicalTerminal.locate(LogicalTerminal.java:11168)
    at com.goldencode.p2j.ui.LogicalTerminal.lambda$initialize$6(LogicalTerminal.java:12282)
    at com.goldencode.p2j.util.TransactionManager$ContextContainer.obtain(TransactionManager.java:10112)
    at com.goldencode.p2j.util.TransactionManager.isHeadless(TransactionManager.java:2549)
    at com.goldencode.p2j.util.ErrorManager$ServerDataAccess.isHeadless(ErrorManager.java:2705)
    at com.goldencode.p2j.util.ErrorManager.isHeadless(ErrorManager.java:2120)
    at com.goldencode.p2j.util.SessionUtils$1.initialValue(SessionUtils.java:153)
    at com.goldencode.p2j.util.SessionUtils$1.initialValue(SessionUtils.java:137)
    at com.goldencode.p2j.security.ContextLocal.get(ContextLocal.java:492)
    at com.goldencode.p2j.security.ContextLocal.get(ContextLocal.java:430)
    at com.goldencode.p2j.util.SessionUtils.getSessionTooltips(SessionUtils.java:858)
    at com.goldencode.p2j.ui.LogicalTerminal.getSessionTooltips(LogicalTerminal.java:15403)
    at com.goldencode.p2j.ui.LogicalTerminalMethodAccess.invoke(Unknown Source)
    at com.goldencode.p2j.util.MethodInvoker.invoke(MethodInvoker.java:156)
    at com.goldencode.p2j.net.Dispatcher.processInbound(Dispatcher.java:757)
    at com.goldencode.p2j.net.Conversation.block(Conversation.java:412)
    at com.goldencode.p2j.net.Conversation.run(Conversation.java:232)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: code size limit exceeded
    at sun.misc.ProxyGenerator.generateStaticInitializer(ProxyGenerator.java:1261)
    at sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:484)
    at sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:339)
    at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:639)
    at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
    at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
    at java.lang.reflect.WeakCache.get(WeakCache.java:127)
    at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
    at com.goldencode.p2j.util.handle.<clinit>(handle.java:335)
    ... 30 more

My question was: Are we reaching some upper limit (var1.code.size() > 65535) with the handle hierarchy?

Constantin responded by email:

I think the problem is with the HandleCommon interface - if you added a new interface there, we might reach a limit... see this, the bug looks reported but not solved: https://bugs.openjdk.java.net/browse/JDK-7189284

Try switching to our custom ProxyFactory.getProxy, and see how it behaves.

I was able to confirm this: meanwhile, I temporarily removed (commented out) one of the existing inetrfaces from extended interfaces in HandleCommon so FWD works now for me. I will try the custom proxy factory later and let you know of the outcome.

#2 Updated by Ovidiu Maxiniuc about 5 years ago

I found the following patch to work fine:

--- src/com/goldencode/p2j/util/handle.java
+++ patched/src/com/goldencode/p2j/util/handle.java
@@ -1,4 +1,3 @@
-      ClassLoader cl = MultiClassLoader.class.getClassLoader();
-      Class<?>[] ifaces = new Class<?>[] { HandleCommon.class };
-      InvalidAttributeAccess handler = new InvalidAttributeAccess();
-      invalidAttrAccessProxy = (HandleCommon) Proxy.newProxyInstance(cl, ifaces, handler);
+      invalidAttrAccessProxy = ProxyFactory.getProxy(handle.class, 
+                                                     new Class<?>[] { HandleCommon.class },
+                                                     new InvalidAttributeAccess());

I will add it to my currently assigned branch (3809c). If you encounter the NPE from description please use this until it gets into trunk.

#3 Updated by Ovidiu Maxiniuc about 5 years ago

While working with the new proxy I encountered the following exception:

Caused by: java.lang.AbstractMethodError: Method com/goldencode/p2j/util/$__Proxy0.name()Lcom/goldencode/p2j/util/character; is abstract
        at com.goldencode.p2j.util.$__Proxy0.name(Unknown Source)
        [...] 

I will investigate this issue tomorrow.

#4 Updated by Ovidiu Maxiniuc about 5 years ago

Apparently, the exception was caused because the proxy was implementing only the declaring methods. In HandleCommon there are none, all methods being declared in its super-interfaces. I changed the factory method to one more explicit and, after recompiling the project, the AbstractMethodError is gone.

Here is the new patch (without the H-entry and imports updates). Notice the InvalidAttributeAccess must be public in order to be accessed from the inside.

--- src/com/goldencode/p2j/util/handle.java
+++ patched/src/com/goldencode/p2j/util/handle.java
@@ -329,10 +331,9 @@

    static
    {
-      ClassLoader cl = MultiClassLoader.class.getClassLoader();
-      Class<?>[] ifaces = new Class<?>[] { HandleCommon.class };
-      InvalidAttributeAccess handler = new InvalidAttributeAccess();
-      invalidAttrAccessProxy = (HandleCommon) Proxy.newProxyInstance(cl, ifaces, handler);
+      invalidAttrAccessProxy = ProxyFactory.getProxy(InvalidAttributeAccess.class,
+                                                     new Class<?>[] { HandleCommon.class },
+                                                     false, null);
    }

    /**
@@ -3601,7 +3602,7 @@
    /**
     * Handler for the {@link #invalidAttrAccessProxy} proxy.
     */
-   private static class InvalidAttributeAccess
+   public static class InvalidAttributeAccess
    implements InvocationHandler
    {
       /**

#5 Updated by Constantin Asofiei about 5 years ago

Ovidiu, do you have a final fix for this?

#6 Updated by Ovidiu Maxiniuc about 5 years ago

The update from note4 looks fine in my tests.

Also available in: Atom PDF