• 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

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();

  testMethod(index);

} catch (Throwable t) {
  notifyError(t);
}   \}

private void testMethod(int index) throws Exception { if (index == 0) { synchronized (root) { root.setList(new ArrayList()); root.setData(new DataWrapper1(new DataWrapper2(3487364))); } }

barrier.barrier();

if (index == 1) {
  synchronized (root) {
    List list = root.getList();
    Assert.assertEquals(0, list.size());
    Method m = list.getClass().getDeclaredMethod("add", new Class[] {Object.class});
    m.invoke(list, new Object[] {root.getData()});
    Assert.assertEquals(1, list.size());
    Assert.assertEquals(3487364, ((DataWrapper1)list.iterator().next()).getW().getI());
  }
}

barrier.barrier();   \}

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;

public DataWrapper2(int i) {
  this.i = i;
}

public int getI() {
  return i;
}

public void setI(int i) {
  this.i = i;
}   \}

private static class DataWrapper1 { private DataWrapper2 w;

public DataWrapper1(DataWrapper2 w) {
  super();
  this.w = w;
}

public DataWrapper2 getW() {
  return w;
}

public void setW(DataWrapper2 w) {
  this.w = w;
}   \}

private static class DataRoot { private List list; private DataWrapper1 data;

public List getList() {
  return list;
}

public DataWrapper1 getData() {
  return data;
}

public void setList(List list) {
  this.list = list;
}

public void setData(DataWrapper1 data) {
  this.data = data;
}   \} \}

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