GenericsTest.java revision 1485
/*
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 4421040
* @summary JPDA: Add support for JSR-014 Generics
*
* @author jjh
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g GenericsTest.java
* @run main GenericsTest
*/
/********** target program **********/
class GenericsTarg {
int intField = 0;
//genField.print();
}
}
Gen1() {
}
return p1;
}
return str;
}
}
return "hi";
}
}
/********** test program **********/
public class GenericsTest extends TestScaffold {
static boolean useOld;
super(args);
}
/*
* The 1.5 FE must be able to talk to a 1.4 BE, ie, JDWP version <= 1.4.
* This is hard to test since this test file must be compiled with
* -source 1.5 which will cause its class file to be version 49 which
* won't run on a pre 1.5 JDK. We can simulate this though
* by passing
* -xjdk <pathname>
* to this test which causes the debuggee to be run on that JDK.
* This should be a version of 1.5 that accepts classfile version 49,
* but which still contains the 1.4 version of JDWP.
* This trick verifies that the calls to genericSignature() methods
* in the test do not cause the generic JDWP commands to be issued.
* The value to use for this is currently:
*/
useOld = true;
// Delete this arg
}
}
}
/********** test core **********/
/*
* Get to the top of main()
* to determine targetClass and mainThread
*/
{
/*
* Prove that arrays aren't broken and that
* null is returned if there is no generic signature
*/
failure("FAILED: Expected generic signature = null for "
}
}
{
// prove that primitives aren't broken.
}
{
// Verify genericSignature for a class
failure("FAILED: Expected generic signature for gen1: " +
}
}
{
// Verify genericSignature() for a field
// there is only one field
expected = "Ttt;";
failure("FAILED: Expected generic signature for field1: " +
}
}
{
// Verify genericSignature() for a method
// There is only uno
expected = "(Ttt;)Ttt;";
failure("FAILED: Expected generic signature for method1: " +
}
// Verify this is not a bridge method
failure("FAILED: Expected gen1.method1 to not be a bridge"
+ " method but it is");
}
// Verify genericSignature for a local var
//jjh Uncomment when generics for local vars are available from
//jjh javac and hotspot. See:
//jjh 4914602 LVT entries for classfile version > 49 must be converted
//jjh if (!useOld && !expected.equals(genSig)) {
//jjh failure("FAILED: Expected generic signature for local var: " +
//jjh expected + ", received: " + genSig);
//jjh }
}
}
{
// Verify genericSignature() for a method2
// There is only uno
expected = "null";
failure("FAILED: Expected generic signature for method2: " +
}
// Verify this is not a bridge method
failure("FAILED: Expected gen1.method2 to not be a bridge"
+ " method but it is");
}
// Verify genericSignature for a local var
expected = "null";
failure("FAILED: Expected generic signature for local var: " +
}
}
}
{
}
/*
* There should be two methods - the first is the
* method1 defined in Sub1, and the 2nd is a javac generated
* bridge method.
*/
failure("FAILED: Expected Sub1.method1 to be a bridge method"
+ " but it isn't");
}
}
{
// Verify genericSignature for a non generic class
failure("FAILED: Expected generic signature = null for "
}
}
{
// Verify genericSignature for a non generic field
failure("FAILED: Expected generic signature = null for "
}
}
{
// Verify genericSignature for a non generic method
failure("FAILED: Expected generic signature = null for "
}
}
if (0 == 1) {
}
/*
* resume the target listening for events
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("GenericsTest: passed");
} else {
throw new Exception("GenericsTest: failed");
}
}
}