/*
* 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 5024104
* @summary Test ReferenceType.majorVersion(), minorVersion, constantPoolCount and ConstantPool apis.
*
* @author Swamy Venkataramanappa
*
* @run build TestScaffold VMConnection
* @run compile -g ConstantPoolInfo.java
* @run main ConstantPoolInfo
*/
/********** target program **********/
class ConstantPoolTarg {
// used to test the constant pool entry
}
}
/********** test program **********/
int cpool_count;
byte[] cpbytes;
static int expectedMajorVersion;
static int expectedMinorVersion;
static int expectedCpoolCount;
/* Class File Constants */
super(args);
}
}
/********** test core **********/
/*
* Get to the top of main()
* to determine targetClass and mainThread
*/
String targPathname = System.getProperty("test.classes") + File.separator + "ConstantPoolTarg.class";
/* Test constant pool apis
*/
if (vm().canGetClassFileVersion()) {
+ "expected value :" + expectedMajorVersion);
}
+ "expected value :" + expectedMinorVersion);
}
} else {
}
if (vm().canGetConstantPool()) {
try {
printcp();
} catch (IOException x){
}
if (expectedCpoolCount != cpool_count) {
+ "expected value :" + expectedCpoolCount);
}
} else {
}
/*
* resume until end
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("ConstantPoolInfo: passed");
} else {
throw new Exception("ConstantPoolInfo: failed");
}
}
boolean found = false;
for (int i = 1; i < cpool_count; i++) {
switch(tag) {
case CONSTANT_UTF8:
// "Howdy!" is an expected constant pool entry
// of test program. It should exist.
found = true;
}
break;
case CONSTANT_INTEGER:
break;
case CONSTANT_FLOAT:
break;
case CONSTANT_LONG:
break;
case CONSTANT_DOUBLE:
break;
case CONSTANT_CLASS:
break;
case CONSTANT_STRING:
break;
case CONSTANT_FIELD:
break;
case CONSTANT_METHOD:
break;
case CONSTANT_INTERFACEMETHOD:
break;
case CONSTANT_NAMEANDTYPE:
break;
case 0:
default:
}
}
if (!found) {
failure("expected string \"Howdy!\" not found in constant pool");
}
}
/**
* Read classfile
*/
try{
}catch (FileNotFoundException ee) {
failure("cant read file");
failure("fatal error");
failure("fatal exception");
}
}
/**
* Read major, minor and cp count.
*/
if (magic != JAVA_MAGIC) {
failure("fatal bad class file format");
}
} // end read()
}