-
Bug
-
Resolution: Not an Issue
-
P1
-
None
-
1.0
-
x86
-
windows_nt
Name: szC45993 Date: 03/02/99
The Tonga/src/nsk/reflection/reflect00102 test (see sources below), which
uses JNI, indicates HotSpot Virtual Machine Error (HotSpot VM 1.0rc1).
Need to note that Classic VM (build JDK-1.2-V, native threads)
and HotSpot VM (1.0beta1, mixed mode, product build) work fine (see LOG below).
For bug demonstration, the following should be done by analogy:
LOG:
====
$ cd h:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/reflection/reflect00102
$ h:/ld25/java/dest/jdk1.1.6/win32/bin/javac.exe -d c:/zss/classes_my reflect00102.java
$ cl /D "WIN32" /D "_WINDOWS" /Ih:/ld13/java/sqe/JCK-12beta4/tests/vm/jni /Ih:/ld13/java/sqe/JCK-12beta4/tests/vm/jni/include /Ih:/ld13/java/sqe/JCK-12beta4/tests/vm/jni/include/win32 /LD reflect00102.c
[
OR:
$ cl /D "WIN32" /D "_WINDOWS" /Ih:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/additional/include /Ih:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/additional/include/win32 /LD reflect00102.c
]
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 11.00.7022 for 80x86
Copyright (C) Microsoft Corp 1984-1997. All rights reserved.
reflect00102.c
Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022
Copyright (C) Microsoft Corp 1992-1997. All rights reserved.
/out:reflect00102.dll
/dll
/implib:reflect00102.lib
reflect00102.obj
Creating library reflect00102.lib and object reflect00102.exp
$ c:/jdk1.2.ZSS02/bin/java -version
java version "1.2"
HotSpot VM (1.0beta1, mixed mode, product build)
$ c:/jdk1.2.ZSS02/bin/java -Xmixed -verify -Djava.library.path=h:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/reflection/reflect00102 reflect00102
$ echo $?
95
$ c:/jdk1.2.ZSS02/bin/java -classic -verify -Djava.library.path=h:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/reflection/reflect00102 reflect00102
$ echo $?
95
$ c:/jdk1.2.ZSS02/bin/java -version
java version "1.2"
HotSpot VM (1.0rc1, mixed mode, build F)
$ c:/jdk1.2.ZSS02/bin/java -Xmixed -verify -Djava.library.path=h:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/reflection/reflect00102 reflect00102
#
# HotSpot Virtual Machine Error, Unexpected exception occured
#
# EXCEPTION_ACCESS_VIOLATION#
[1] + Done(134) c:/jdk1.2.ZSS02/bin/java -Xmixed -verify -Djava.library.path=h:/ld24/java/zss/TONGA_WSs/testbase_js/src/nsk/reflection/reflect00102 reflect00102
135 Abort c:/jdk1.2.ZSS02/bin/java
$ env
CLASSPATH=.;.\\clss.zip;c:\zss\classes_my;h:\ld13\java\sqe\JCK-12beta4\classes;h:\ld13\java\sqe\JCK-12beta4\javatest.jar;.
COMPUTERNAME=JAVA4
ComSpec=C:\WINNT\system32\cmd.exe
HOME=C:/
HOMEDRIVE=C:
HOMEPATH=HotSpotBuildSpace=C:\builds
HotSpotWorkSpace=c:\hotspot_alpha2-l_core_win32_0806_src
include=c:\program files\devstudio\vc\include;c:\program files\devstudio\vc\atl\include;c:\program files\devstudio\vc\mfc\include;%include%
lib=c:\program files\devstudio\vc\lib;c:\program files\devstudio\vc\mfc\lib;%lib%
LOGONSERVER=\\JAVA4
MSDevDir=C:\Program Files\DevStudio\SharedIDE
NUMBER_OF_PROCESSORS=1
Os2LibPath=C:\WINNT\system32\os2\dll;
OS=Windows_NT
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 3 Stepping 4, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0304
ROOTDIR=c:
SHELL=c:/mksnt/sh.exe
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=C:\TEMP
TMP=C:\TEMP
TMPDIR=C:/TEMP
USERDOMAIN=JAVA4
USERNAME=Administrator
USERPROFILE=C:\WINNT\Profiles\Administrator
windir=C:\WINNT
_=c:\mksnt/env.exe
PATH=c:\zss\classes_my;c:\dos;c:\jdk1.2.ZSS02\bin;c:\mksnt;C:\WINAPP\mksnt;C:\WINNT\system32;C:\WINNT;h:\\ld13\\java\\sqe\\JCK-12beta4\\lib;c:\dos;c:\jdk1.2.ZSS02\bin;c:\program files\devstudio\sharedide\bin\ide;c:\program files\devstudio\sharedide\bin;c:\program files\devstudio\vc\bin
$
SOURCES:
========
//--------------------- reflect00102.java:
import java.lang.reflect.Field;
import java.io.PrintStream;
public class reflect00102 {
static {
try {
loadLib("reflect00102");
}
catch ( UnsatisfiedLinkError e ) {
loadLib("jckjni");
}
}
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
static void loadLib( String libName ) {
SecurityManager mgr = System.getSecurityManager();
boolean canLoad = true;
linkStatus=2/*STATUS_FAILED*/;
if( mgr != null ) {
try {
mgr.checkLink( libName );
} catch (SecurityException e) {
canLoad = false;
}
}
try {
System.loadLibrary( libName );
if (canLoad) {
cannotBeRun = null;
} else {
cannotBeRun = "Incorrectly loaded library: " + libName;
}
} catch (SecurityException e) {
if (!canLoad) {
linkStatus = 0/*STATUS_PASSED*/;
cannotBeRun = "Correctly prevented loadLibrary: " + libName;
} else {
cannotBeRun = "Incorrectly prevented loadLibrary: " + libName;
}
} catch (UnsatisfiedLinkError e) {
cannotBeRun = "Cannot find library: " + libName;
throw e;
}
}
static String cannotBeRun;
static int linkStatus;
native Field getFieldObject(String name);
int status = 0/*STATUS_PASSED*/;
PrintStream out;
boolean failed(String msg) {
status = 2/*STATUS_FAILED*/;
out.println(msg);
return false;
}
boolean exercise(String name) {
// let's get Filed object from native code
Field f = getFieldObject(name);
return true;
}
boolean check(boolean new_val) {
if (new_val!=valueToSet)
return failed("Wrong Field value after setBoolean(): "+new_val);
return true;
}
static final boolean valueToSet = false;
boolean pub_fld = true; // fin_fld;
public static int run(String argv[],PrintStream out) {
for (int argvi=0; argvi<argv.length; argvi++)
if (argv[argvi].equals("-loadLibraryAllowed"))
linkStatus = 2/*STATUS_FAILED*/;
if (cannotBeRun!=null) {
out.println(cannotBeRun);
return linkStatus;
}
reflect00102 x = new reflect00102();
x.out = out;
x.exercise("pub_fld");
return x.status;
}
}
//--------------------- reflect00102.c:
#include <stdlib.h>
#include <string.h>
#include "jckjni.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef JNI_ENV_ARG
#ifdef __cplusplus
#define JNI_ENV_ARG(x, y) y
#define JNI_ENV_PTR(x) x
#else
#define JNI_ENV_ARG(x,y) x, y
#define JNI_ENV_PTR(x) (*x)
#endif
#endif
static int reflect00102_statusStringLength = 0;
static char* reflect00102_statusString = (char*) 0;
#define reflect00102_GRANULARITY 1024
#define reflect00102_RESTRICTION 10000
JNIEXPORT jobject JNICALL Java_reflect00102_getFieldObject(
JNIEnv *env, jobject obj, jstring var_nm) {
const char* var_name;
jfieldID jfid;
jclass jc;
var_name = JNI_ENV_PTR(env) -> GetStringUTFChars(JNI_ENV_ARG(env,var_nm),0);
if (var_name == NULL) {
return NULL;
}
jc = JNI_ENV_PTR(env) -> GetObjectClass(JNI_ENV_ARG(env,obj));
if (jc == NULL) {
return NULL;
}
jfid = JNI_ENV_PTR(env) -> GetFieldID(JNI_ENV_ARG(env,jc),var_name,"Z");
if (jfid == NULL) {
return NULL;
}
/* now we're getting java.lang.reflect.Field object using ToReflectedField() */
return JNI_ENV_PTR(env) -> ToReflectedField(JNI_ENV_ARG(env, jc), jfid);
}
#ifndef JNI_OnLoad_12_DECLARED
#define JNI_OnLoad_12_DECLARED
jint jniOnLoadVersion = 0;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return (jniOnLoadVersion = JNI_VERSION_1_2);
}
#endif /* JNI_OnLoad_12_DECLARED */
#ifdef __cplusplus
}
#endif
//---------------------
======================================================================