/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4105080
* @summary Activation retry during a remote method call to an activatable
* object can cause infinite recursion in some situations. The
* RemoteRef contained in the ActivatableRef should never be
* an ActivatableRef, but another type.
* (Needs /othervm to evade JavaTest security manager --aecolley)
* @author Ann Wollrath
*
* @bug 4164971
* Main test class hasa non-public constructor to ensure
* functionality is in place
*
* @library ../../../testlibrary
* @build TestLibrary RMID ActivateMe CheckActivateRef_Stub
* @run main/othervm/policy=security.policy/timeout=240 -Djava.rmi.server.ignoreStubClasses=true CheckActivateRef
* @run main/othervm/policy=security.policy/timeout=240 -Djava.rmi.server.ignoreStubClasses=false CheckActivateRef
*/
public class CheckActivateRef
extends Activatable
implements ActivateMe, Runnable
{
throws ActivationException, RemoteException
{
super(id, 0);
}
public void ping()
{}
/**
* Spawns a thread to deactivate the object.
*/
{
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* unexport the object forcibly.
*/
public void run() {
}
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
// test should tolerate certain types of failures
int failures = 0;
int i = 0;
"no policy"));
try {
// start an rmid.
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// activation groups
p.put("java.security.policy",
p.put("java.security.manager",
/*
* Activate an object by registering its object
* descriptor and invoking a method on the
* stub returned from the register call.
*/
new ActivationGroupDesc(p, null);
{
throw new RuntimeException("proxy is not dynamic proxy");
}
/*
* Loop a bunch of times to force activator to
* spawn VMs (groups)
*/
try {
for (; i < 7; i++) {
/*
* Fix for 4277196: if we got an inactive group
* exception, it is likely that we accidentally
* invoked a method on an old activation
* group. Give some time for the group to go away
* and then retry the activation.
*/
try {
} catch (RemoteException e) {
(detail instanceof ActivationException) &&
{
try {
} catch (InterruptedException ex) {
}
} else {
throw e;
}
}
/*
* Now that object is activated, check to make sure that
* the RemoteRef inside the stub's ActivatableRef
* is *not* an ActivatableRef.
*/
if (obj instanceof RemoteStub) {
} else {
throw new RuntimeException("unknown proxy type");
}
ff.setAccessible(true);
return ff;
}
});
if (insideRef instanceof ActivatableRef) {
} else {
}
/*
* Clean up object too.
*/
try {
// give activation group time to go away
} catch (InterruptedException e) {
}
}
// account for test's activation race condition
if ((failures ++) >= 3) {
throw ue;
}
} else {
throw ue;
}
}
// test only needs to pass 3 times in 7
if (i < 4) {
TestLibrary.bomb(e);
}
} catch (Exception e) {
} finally {
}
}
}