harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3362) [classlib][EUT] 3 tests fail in org.eclipse.jface.tests.databinding suit
Date Wed, 30 May 2007 12:25:16 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500117
] 

Mikhail Markov commented on HARMONY-3362:
-----------------------------------------

Nellya, great thanks for the problem localization!

I've compared our and RI's implementation of dynamically generated Proxy classes and found
that Harmony is using Class.getMethod(String, Class[]) to get the method to be passed to InvocationHandler
(see org.apache.harmony.luni.internal.reflect.ProxyClassFile.genCallGetMethod() method).
The simple test indeed demonstrates that getMethod() returs 2 different instances of Method
which are not equal if use "==" operation:
import java.lang.reflect.*;

public class Test {
    public static void main(String[] args) throws Exception {
        Class cl = new Test().getClass();
        Method m1 = cl.getMethod("f", new Class[0]);
        Method m2 = cl.getMethod("f", new Class[0]);
        System.out.println("m1 == m2: " + (m1 == m2) + ", equals: " + m1.equals(m2));
    }

    public static void f() {
    }
}

So It seems that RI stored methods in private fields of dynamically generated Proxy class
and just supply them to InvocationHandler.
Here is the test demonstrating this:
import java.lang.reflect.*;

public class Test {
    public static void main(String[] args) throws Exception {
        TestInterface obj = (TestInterface) Proxy.newProxyInstance(
                TestInterface.class.getClassLoader(), 
                new Class[] {TestInterface.class}, 
                (InvocationHandler)new TestInvocationHandler());

        printClassInfo(obj.getClass());
    }

    public static void printClassInfo(Class c) {
        Field[] f = c.getDeclaredFields();
        System.out.println("Fields: ");

        for (int i = 0; i < f.length; ++i) {
            System.out.println("    " + f[i]);
        }
        Method[] m = c.getDeclaredMethods();
        System.out.println("Methods: ");

        for (int i = 0; i < m.length; ++i) {
            System.out.println("    " + m[i]);
        }
    }
}

Output on RI:
Fields:
    private static java.lang.reflect.Method $Proxy0.m2
    private static java.lang.reflect.Method $Proxy0.m0
    private static java.lang.reflect.Method $Proxy0.m3
    private static java.lang.reflect.Method $Proxy0.m1
Methods:
    public final int $Proxy0.hashCode()
    public final boolean $Proxy0.equals(java.lang.Object)
    public final java.lang.String $Proxy0.toString()
    public final void $Proxy0.f()

Output on Harmony:
Fields:
Methods:
    public final boolean $Proxy0.equals(java.lang.Object)
    public final int $Proxy0.hashCode()
    public final java.lang.String $Proxy0.toString()
    public final void $Proxy0.f()

I did not find requirements for dynamic proxy class to transfer equal (by "==" operator means)
methods to InvocationHandler.invoke() method, but RI's approach seems reasonable to me from
performance point of view.
So, i tend to rework our Proxy code generator to implement the similar feature.

> [classlib][EUT] 3 tests fail in org.eclipse.jface.tests.databinding suit
> ------------------------------------------------------------------------
>
>                 Key: HARMONY-3362
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3362
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Aleksey Ignatenko
>
> 3 tests fail in org.eclipse.jface.tests.databinding suit.
> 1. testAddChangeListener
> unexpected method call: handleChange 
> junit.framework.AssertionFailedError: unexpected method call: handleChange
> at org.eclipse.jface.tests.databinding.util.Mocks$MockInvocationHandler.invoke(Mocks.java:136)
> at org.eclipse.jface.tests.databinding.util.$Proxy0.handleChange(Unknown Source)
> at org.eclipse.jface.internal.databinding.provisional.observable.AbstractObservable.fireChange(AbstractObservable.java:142)
> at org.eclipse.jface.internal.databinding.provisional.observable.value.AbstractObservableValue.fireValueChange(AbstractObservableValue.java)
> at org.eclipse.jface.tests.databinding.ObservableTest$MyObservable.fireChange(ObservableTest.java:31)
> at org.eclipse.jface.tests.databinding.ObservableTest.testAddChangeListener(ObservableTest.java:72)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:326)
> at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:203)
> at org.eclipse.test.CoreTestApplication.runTests(CoreTestApplication.java)
> at org.eclipse.test.CoreTestApplication.run(CoreTestApplication.java:31)
> at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:77)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:66)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:396)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
> at org.eclipse.core.launcher.Main.run(Main.java:975)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> at org.apache.harmony.vm.JarRunner.main(JarRunner.java:80)
> 2-3. testBindValueModel,  testBindValueTarget
> unexpected method call: getValueType 
> junit.framework.AssertionFailedError: unexpected method call: getValueType
> at org.eclipse.jface.tests.databinding.util.Mocks$MockInvocationHandler.invoke(Mocks.java:136)
> at org.eclipse.jface.tests.databinding.util.$Proxy1.getValueType(Unknown Source)
> at org.eclipse.jface.internal.databinding.provisional.factories.DefaultBindingFactory.createBinding(DefaultBindingFactory.java:49)
> at org.eclipse.jface.internal.databinding.provisional.DataBindingContext.doCreateBinding(DataBindingContext.java:263)
> at org.eclipse.jface.internal.databinding.provisional.DataBindingContext.bind(DataBindingContext.java)
> at org.eclipse.jface.tests.databinding.DatabindingContextTest.testBindValueModel(DatabindingContextTest.java:183)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> at org.eclipse.jface.tests.databinding.DatabindingContextTest.runTest(DatabindingContextTest.java)
> at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:326)
> at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:203)
> at org.eclipse.test.CoreTestApplication.runTests(CoreTestApplication.java)
> at org.eclipse.test.CoreTestApplication.run(CoreTestApplication.java:31)
> at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:77)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:66)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:396)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
> at org.eclipse.core.launcher.Main.run(Main.java:975)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
> at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> at org.apache.harmony.vm.JarRunner.main(JarRunner.java:80)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message