CDV ❯ Method.invoke doesn't seem to work
-
Bug
-
Status: Closed
-
2 Major
-
Resolution: Fixed
-
-
-
interfaces
-
Reporter: tgautier
-
December 15, 2007
-
0
-
Watchers: 0
-
July 27, 2012
-
February 28, 2012
Description
I’ll attach a reproducible test case if needed, but it appears that passing an array of arguments that came from a DSO that contains other DSOs doesn’t get expanded inside Method.invoke.
Manually resolving the array in place fixes the problem..
Comments
Geert Bevin 2007-12-17
Tim Eck 2007-12-17
I could easily believe that is busted. I think the code that reads the args[] is native, and can’t possibly be instrumented.
Might need to clone the args array (iff it is shared) when one is passed to Method.invoke(). Without a clone, it might interact with the memory manager in bad and racy ways.
Fiona OShea 2008-03-18
Is this fixed?
Fiona OShea 2008-04-29
Can you attach test case?
Fiona OShea 2008-08-12
This is a known issue, it wont’ work. We should have a test case for this. Not a high priority now.
Fiona OShea 2008-08-12
Fiona create a related DOC issue to add this to gotchas/known issues
Can you please add the test case you’re talking about? I tried writing one, but must have misunderstood something. This is what I wrote, and it works:
/* * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright * notice. All rights reserved. */ package com.tctest;
import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
import com.tc.object.config.ConfigVisitor; import com.tc.object.config.DSOClientConfigHelper; import com.tc.simulator.app.ApplicationConfig; import com.tc.simulator.listener.ListenerProvider; import com.tc.util.Assert; import com.tctest.runner.AbstractTransparentApp;
import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List;
public class MethodInvokeTestApp extends AbstractTransparentApp { private CyclicBarrier barrier; private final DataRoot root = new DataRoot();
public MethodInvokeTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { super(appId, cfg, listenerProvider); barrier = new CyclicBarrier(getParticipantCount()); }
public void run() { try { int index = barrier.barrier();
private void testMethod(int index) throws Exception { if (index == 0) { synchronized (root) { root.setList(new ArrayList()); root.setData(new DataWrapper1(new DataWrapper2(3487364))); } }
public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { config.getOrCreateSpec(CyclicBarrier.class.getName()); config.addWriteAutolock(“* “ + CyclicBarrier.class.getName() + “.(..)”); String testClass = MethodInvokeTestApp.class.getName(); config.getOrCreateSpec(testClass).addRoot(“barrier”, “barrier”).addRoot(“root”, “root”); String writeAllowedMethodExpression = “* “ + testClass + “.(..)”; config.addWriteAutolock(writeAllowedMethodExpression); config.addIncludePattern(testClass + “$*”); }
private static class DataWrapper2 { private int i;
private static class DataWrapper1 { private DataWrapper2 w;
private static class DataRoot { private List list; private DataWrapper1 data;