douglasdrumond / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 1 forks source link

Problem with Swing component (JCheckBox, JRadioButton...) #89

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I write a very short program to expose the problem, cf. at the bottom.

What is the expected output? What do you see instead?
I see an exception instead of an Argument<JCheckBox> :

Exception in thread "main" net.sf.cglib.core.CodeGenerationException: 
java.lang.NullPointerException-->null
    at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
    at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
    at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
    at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:643)
    at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
    at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
    at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
    at ch.lambdaj.proxy.ProxyUtil.createProxy(ProxyUtil.java:49)
    at ch.lambdaj.function.argument.ArgumentsFactory.createPlaceholder(ArgumentsFactory.java:68)
    at ch.lambdaj.function.argument.ArgumentsFactory.registerNewArgument(ArgumentsFactory.java:58)
    at ch.lambdaj.function.argument.ArgumentsFactory.createArgument(ArgumentsFactory.java:50)
    at ch.lambdaj.function.argument.ProxyArgument.invoke(ProxyArgument.java:36)
    at ch.lambdaj.proxy.InvocationInterceptor.intercept(InvocationInterceptor.java:21)
    at rm.lambdaj.SwingTest$$EnhancerByCGLIB$$6b17588d.getCheckBox(<generated>)
    at rm.lambdaj.SwingTest.run(SwingTest.java:30)
    at rm.lambdaj.SwingTest.main(SwingTest.java:21)
Caused by: java.lang.NullPointerException
    at javax.swing.JToggleButton.<init>(JToggleButton.java:173)
    at javax.swing.JCheckBox.<init>(JCheckBox.java:174)
    at javax.swing.JCheckBox.<init>(JCheckBox.java:96)
    at $javax.swing.JCheckBox$$EnhancerByCGLIB$$c1e8df8e.<init>(<generated>)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
    ... 16 more

What version of the product are you using? On what operating system?
lambdaj-2.4-with-dependencies.jar on Eclipse/WinXp.

Please provide any additional information below.
The source code :

----------------
package rm.lambdaj;

import static ch.lambdaj.Lambda.on;
import static ch.lambdaj.function.argument.ArgumentsFactory.actualArgument;

import javax.swing.JCheckBox;
import javax.swing.JPanel;

import ch.lambdaj.function.argument.Argument;

public class SwingTest extends JPanel
{
    String aProperty = "the protervy value";

    JCheckBox checkBox = new JCheckBox();

    public static void main(final String[] args) throws NoSuchFieldException, SecurityException
    {
        final SwingTest app = new SwingTest();

        app.run();
    }

    private void run()
    {
        String prop = on(SwingTest.class).getaProperty();
        Argument<String> argProp = actualArgument(prop);
        System.out.println("aProperty : " + argProp);

        JCheckBox cb = on(SwingTest.class).getCheckBox();
        Argument<JCheckBox> argCB = actualArgument(cb);
        System.out.println("checkbox : " + argCB);
    }

    public JCheckBox getCheckBox()
    {
        return checkBox;
    }

    public String getaProperty()
    {
        return aProperty;
    }
}
----------------

Original issue reported on code.google.com by ronan.mi...@gmail.com on 11 Mar 2012 at 3:48

GoogleCodeExporter commented 9 years ago
Hi,

In fact, this problem is blocking for my use/acceptance of LambdaJ.

Regards,
Ronan.

Original comment by ronan.mi...@gmail.com on 16 Mar 2012 at 12:15