[888] in java-interest
Re: Native code creating java object instance problem
daemon@ATHENA.MIT.EDU (Jonathan Payne)
Mon Aug 14 00:41:59 1995
Date: Sun, 13 Aug 1995 17:59:19 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: R.A.Milowski-2@tc.umn.edu
Cc: java-interest@java.sun.com
In-Reply-To: <302e88f80b95002@maroon.tc.umn.edu> (message from R A Milowski on Sun, 13 Aug 1995 18:21:28 -0500 (CDT))
I'm not sure, but I don't see that you are creating an instance of
jsgml.MessageEvent. Instead all I see is you calling the
constructor. The constructor is just another method, I thought, so I
think you're supposed to make a new instance and then call the
constructor on the new instance. I could be very wrong, however.
Obj foo = new Obj(args);
is really
foo = allocate(Obj);
foo.<init>(args);
> From: R A Milowski <R.A.Milowski-2@tc.umn.edu>
> Date: Sun, 13 Aug 1995 18:21:28 -0500 (CDT)
> X-Mailer: ELM [version 2.4 PL23]
> Mime-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Sender: owner-java-interest@java.sun.com
> Precedence: bulk
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
> Content-Type: text/plain; charset=US-ASCII
> Content-Length: 1660
>
> 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
>
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com