allan.jacobs@Eng 1997-02-28
All the JCK JNI tests are failing on Intel Solaris with JIT enabled. The
following is an isolate from one of those tests.
skinner% printenv LD_LIBRARY_PATH
.
skinner% printenv CLASSPATH
.:/set/sqe/java/JCK-11a/classes
skinner% ls -l libjckjni.so gsuc00101.class
-rw-rw-r-- 1 ajacobs staff 2239 Feb 28 11:48 gsuc00101.class
-rwxrwxr-x 1 ajacobs staff 7876 Feb 28 13:08 libjckjni.so*
skinner% ls -l gsuc00101.c gsuc00101.java Makefile
-rw-rw-r-- 1 ajacobs staff 356 Feb 28 11:48 Makefile
-rw-rw-r-- 1 ajacobs staff 4042 Feb 28 11:54 gsuc00101.c
-rw-rw-r-- 1 ajacobs staff 2061 Feb 28 11:47 gsuc00101.java
skinner% make libjckjni.so
cc -G -KPIC -o libjckjni.so -I/usr/java/include -I/usr/java/include/solaris gsuc00101.c
skinner% make gsuc00101.class
javac -J-Djava.compiler=none gsuc00101.java
skinner% java -Djava.compiler=none gsuc00101
skinner% echo $status
95
skinner% java -Djava.compiler=sunwjit gsuc00101
SIGSEGV 11* segmentation violation
si_signo [11]: SIGSEGV 11* segmentation violation
si_errno [0]: Error 0
si_code [1]: SEGV_ACCERR [addr: 0x283205cc]
stackbase=8047A30, stackpointer=80477F4
Full thread dump:
"Finalizer thread" (TID:0x80527220, sys_thread_t:0x81330da8, state:R) prio=1
"Async Garbage Collector" (TID:0x805271d8, sys_thread_t:0x8130eda8, state:R) prio=1
"Idle thread" (TID:0x80527190, sys_thread_t:0x812ecda8, state:R) prio=0
"Clock" (TID:0x805270d0, sys_thread_t:0x812cada8, state:CW) prio=12
"main" (TID:0x805270a8, sys_thread_t:0x806b498, state:R) prio=5 *current thread*
gsuc00101.check(Compiled Code)
gsuc00101.run(Compiled Code)
gsuc00101.main(Compiled Code)
Monitor Cache Dump:
Registered Monitor Dump:
PCMap lock: <unowned>
Thread queue lock: <unowned>
Name and type hash table lock: <unowned>
String intern lock: <unowned>
JNI global reference lock: <unowned>
BinClass lock: <unowned>
Class loading lock: <unowned>
Java stack lock: <unowned>
Code rewrite lock: <unowned>
Heap lock: <unowned>
Has finalization queue lock: <unowned>
Finalize me queue lock: <unowned>
Monitor IO lock: <unowned>
Child death monitor: <unowned>
Event monitor: <unowned>
I/O monitor: <unowned>
Alarm monitor: <unowned>
Waiting to be notified:
"Clock"
Sbrk lock: <unowned>
Monitor cache expansion lock: <unowned>
Monitor registry: owner "main" (0x806b498, 1 entry)
Thread Alarm Q:
Abort
skinner% ls -l gsuc00101.c gsuc00101.java Makefile
-rw-rw-r-- 1 ajacobs staff 356 Feb 28 11:48 Makefile
-rw-rw-r-- 1 ajacobs staff 4042 Feb 28 11:54 gsuc00101.c
-rw-rw-r-- 1 ajacobs staff 2061 Feb 28 11:47 gsuc00101.java
skinner% cat Makefile
libjckjni.so: gsuc00101.c
cc -G -KPIC -o libjckjni.so -I/usr/java/include -I/usr/java/include/solaris gsuc00101.c
gsuc00101.i: gsuc00101.c
cc -P -I/usr/java/include -I/usr/java/include/solaris gsuc00101.c
gsuc00101.class: gsuc00101.java
javac -J-Djava.compiler=none gsuc00101.java
gsuc00101.h: gsuc00101.class
javah -jni gsuc00101
skinner% cat gsuc00101.c
/* File: @(#)gsuc00101.c 1.3 97/01/29
Copyright 01/29/97 Sun Microsystems, Inc. All Rights Reserved
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <jni.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ALL_PRINT_TOGETHER
#define ALL_PRINT_TOGETHER
typedef struct _Bufprint {
int WasInit;
unsigned char * Buf;
int CntWr;
int CntRd;
} bufprint, *pbufprint;
#define QNT_BUF 1000
int jprintf (pbufprint ptr,...) {
va_list lst;
if (!(ptr->WasInit)) {
ptr->Buf = (unsigned char*)malloc(QNT_BUF);
if (ptr->Buf == NULL) {
return 0;
}
ptr->WasInit = 1;
ptr->CntWr = 0;
ptr->CntRd = 0;
}
if ((QNT_BUF - (ptr->CntWr % QNT_BUF)) < 100) {
ptr->Buf = (unsigned char*)realloc((void*)ptr->Buf, (size_t) (QNT_BUF * (ptr->CntWr/QNT_BUF + 2)));
if (ptr->Buf == NULL) {
return 0;
}
}
va_start( lst, ptr );
vsprintf( (char*)(ptr->Buf + ptr->CntWr), va_arg(lst,char*), lst );
ptr->CntWr += ( strlen((const char*)(ptr->Buf + ptr->CntWr)) + 1);
return 1;
}
unsigned char GetNextChar (pbufprint ptr) {
unsigned char ch;
if ( ptr->CntRd == ptr->CntWr) {
return (unsigned char)0;
}
ch = *(ptr->Buf + ptr->CntRd);
ptr->CntRd++;
return (ch==0)?'\n':ch;
}
unsigned char GetCharNumber (pbufprint ptr, int num) {
unsigned char ch;
if ( num >= ptr->CntWr) {
return (unsigned char)0;
}
ch = *(ptr->Buf + num);
return (ch==0)?'\n':ch;
}
void FreeBuf (pbufprint ptr) {
free(ptr->Buf);
ptr->CntRd = 0;
ptr->CntWr = 0;
ptr->WasInit = 0;
}
#endif
bufprint gsuc00101bp;
JNIEXPORT jchar JNICALL Java_gsuc00101_GetNextChar(
JNIEnv *env, jclass mainObject) {
return (GetNextChar(&gsuc00101bp));
}
JNIEXPORT jchar JNICALL Java_gsuc00101_GetCharNumber(
JNIEnv *env, jclass mainObject, jint num) {
return (GetCharNumber(&gsuc00101bp,num));
}
JNIEXPORT void JNICALL Java_gsuc00101_FreeBuf(
JNIEnv *env, jclass mainObject) {
FreeBuf(&gsuc00101bp);
}
#ifdef __cplusplus
#ifndef JNI_ENV_ARG
#define JNI_ENV_ARG(x,y) y
#define JNI_ENV_PTR(x) x
#endif
#else
#ifndef JNI_ENV_ARG
#define JNI_ENV_ARG(x,y) x,y
#define JNI_ENV_PTR(x) (*x)
#endif
#endif
JNIEXPORT jboolean JNICALL
Java_gsuc00101_gsuc00101valChars
(JNIEnv *env, jobject obj, jstring sval, jsize len, jchar cval) {
int i,j;
int curp;
jchar ch;
jboolean isCopy;
const jbyte* larr = (const jbyte*)(JNI_ENV_PTR(env) -> GetStringUTFChars(JNI_ENV_ARG(env, sval), &isCopy));
if (larr==NULL) {
jprintf(&gsuc00101bp," Cannot get string UTF chars!");
return JNI_FALSE;
}
if ((isCopy!=JNI_TRUE)&&(isCopy!=JNI_FALSE)) {
jprintf(&gsuc00101bp," Bad value of isCopy 1!");
return JNI_FALSE;
}
curp = 0;
for (i=0; i<len; i++) {
if (*(larr+curp)&0x80==0) {
ch = *(larr+curp);
curp++;
}
else {
if (*(larr+curp)&0xe0==0xc0) {
ch = ((*(larr+curp)&0x1f)<<6)+(*(larr+curp+1)&0x3f);
curp++;
curp++;
}
else {
ch = ((*(larr+curp)&0xf)<<12)+((*(larr+curp+1)&0x3f)<<6)+(*(larr+curp+2)&0x3f);
curp++;
curp++;
curp++;
}
}
if (ch!=(cval+i)) {
jprintf(&gsuc00101bp," Invalid value of char %x!", ch);
for (j=0;j < curp;j++) {
jprintf(&gsuc00101bp," %x",*(larr+j)&0xff);
}
return JNI_FALSE;
}
}
return JNI_TRUE;
}
JNIEXPORT jstring JNICALL
Java_gsuc00101_gsuc00101strChars
(JNIEnv *env, jobject obj, jstring val, jsize len) {
jboolean isCopy = 0;
const char* larr1;
jstring lstr1;
const char* larr2;
jstring lstr2;
larr1 = (const char*)(JNI_ENV_PTR(env) -> GetStringUTFChars(JNI_ENV_ARG(env, val), &isCopy));
if ((isCopy!=JNI_TRUE)&&(isCopy!=JNI_FALSE)) {
jprintf(&gsuc00101bp," Bad value of isCopy 2!");
return NULL;
}
lstr1 = JNI_ENV_PTR(env) -> NewStringUTF(JNI_ENV_ARG(env, larr1));
larr2 = (const char*)(JNI_ENV_PTR(env) -> GetStringUTFChars(JNI_ENV_ARG(env, lstr1), &isCopy));
if ((isCopy!=JNI_TRUE)&&(isCopy!=JNI_FALSE)) {
jprintf(&gsuc00101bp," Bad value of isCopy 3!");
return NULL;
}
lstr2 = JNI_ENV_PTR(env) -> NewStringUTF(JNI_ENV_ARG(env, larr2));
return (lstr2);
}
#ifdef __cplusplus
}
#endif
% cat gsuc00101.java
//File: @(#)gsuc00101.java 1.1 97/01/24
//Copyright 01/24/97 Sun Microsystems, Inc. All Rights Reserved
// package javasoft.sqe.tests.vm.gsuc001.gsuc00101;
import java.io.PrintStream;
public class gsuc00101 {
private static boolean res = false;
private static PrintStream lout;
gsuc00101 (PrintStream out) {
lout = out;
}
public static void main(String argv[])
{
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public native boolean gsuc00101valChars(String sval, int len, char cval);
public native String gsuc00101strChars(String val, int len);
static native char GetNextChar();
static native char GetCharNumber(int i);
static native void FreeBuf();
static String strFromC;
public static void printFromC () {
char ch;
strFromC = new String("");
while ( (ch = GetNextChar()) != (char)0) {
strFromC += ch;
}
if (strFromC.length() > 0) {
lout.println("Native code report");
lout.println(strFromC);
}
}
static {
try {
System.loadLibrary("gsuc00101");
}
catch ( UnsatisfiedLinkError e ) {
System.loadLibrary("jckjni");
}
}
private static void check( gsuc00101 tob ) {
String lstr1 = new String("\u0a41\u0a42\u0a43\u0a44\u0a45\u0a46\u0a47\u0a48\u0a49\u0a4a\u0a4b\u0a4c");
String lstr2 = new String("123456789012345678901234567890");
String lstr3 = new String("");
try {
if (!tob.gsuc00101valChars(lstr1, lstr1.length(),lstr1.charAt(0))) {
printFromC();
res = true;
}
lstr3 = tob.gsuc00101strChars(lstr2, lstr2.length());
} catch (Throwable e) {
res = true;
lout.println("Exception caught: " + e.getMessage() + ": " + e);
}
if (!lstr3.equals(lstr3)) {
res = true;
printFromC();
lout.println("Not equal strings");
}
}
public static int run(String argv[], PrintStream out) {
gsuc00101 tob = new gsuc00101(out);
check( tob );
if (res)
return 2/*STATUS_FAILED*/;
return 0/*STATUS_PASSED*/;
}
}