[887] in java-interest
Native code creating java object instance problem
daemon@ATHENA.MIT.EDU (R A Milowski)
Sun Aug 13 23:56:27 1995
From: R A Milowski <R.A.Milowski-2@tc.umn.edu>
To: java-interest@java.sun.com
Date: Sun, 13 Aug 1995 18:21:28 -0500 (CDT)
Hello all,
I'm having a bit of trouble getting C++ code to create a Java object
instance. It seems to give me back the object handle but it doesn't
call the objects constructor.
Here is an extract from my code:
ClassClass *MessageEventClass = FindClass(0,"jsgml/MessageEvent",TRUE);
if (!MessageEventClass) {
cerr << "Cannot find class jsgml.MessageEvent" << endl;
}
Hjava_lang_String *js = makeJavaString("blah",4);
// This just doesn't seem to work properly
Hjava_lang_Object *obj = execute_java_constructor(
0,
"jsgml/MessageEvent",
MessageEventClass,
"(Ljava/lang/String;)V",
js
);
if (obj) {
// Then, this doesn't work because the above object isn't constructed
execute_java_dynamic_method(
0,
(Hjava_lang_Object *)pegimpl_->jhandler,
"handle",
"(Ljsgml/Event;)V",
obj
);
} else {
cerr << "Cannot create jsgml.MessageEvent object.";
}
The object I am trying to create is declared as follows:
package jsgml;
import java.lang.util;
import jsgml.Event;
class MessageEvent implements Event {
public String message;
public MessageEvent(String s) {
message = s;
System.out.println("MessageEvent(String s) called.");
}
public int type() {
return EventType.Message;
}
public String raw() {
return "";
}
}
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com