[683] in java-interest
java-interest-digest V1 #82
daemon@ATHENA.MIT.EDU (java-interest@java.sun.com@cs.prus)
Thu Jul 13 07:29:57 1995
From: java-interest@java.sun.com@cs.prusec.com
To: crusher.cs.prusec.com!java.sun.com!java-interest@java
Date: Thu, 13 Jul 95 09:57:57 GMT
Not-Delivered-To: due to 11 Transfer Failure
ORIGINAL MESSAGE ATTACHED
(rmail: Error # 22 'Surrogate command failed', rc = 1)
En-Route-To: !walter-ws.cs.prusec.com.#walter.hjelmar!walterh
======= Surrogate command =======
:smtpqer cs.prusec.com!java.sun.com!java-interest walter-ws.cs.prusec.com.#walter.hjelmar walterh
==== Start of stdout ===
==== Start of stderr ===
:UX:smtpqer: INFO: unknown host <walter-ws.cs.prusec.com.#walter.hjelmar>
En-Route-To: !walter-ws.cs.prusec.com.#walter.hjelmar!walterh
From smtp Thu Jul 13 05:57 EDT 1995
Received: from cs.prusec.com by prusec.prusec.com; Thu, 13 Jul 95 05:57 EDT
Received: from prufsg.cs.prusec.com by crusher.cs.prusec.com (AIX 3.2/UCB 5.64/4.03)
id AA04127; Thu, 13 Jul 1995 05:59:01 -0400
Received: from java.sun.com by prusec.prusec.com; Thu, 13 Jul 95 05:57 EDT
Received: (from majordom@localhost) by java (8.6.12/8.6.12) id UAA06713 for java-interest-digest-outgoing; Wed, 12 Jul 1995 20:43:01 -0700
From: java-interest@java.sun.com@cs.prusec.com
Date: Wed, 12 Jul 1995 20:43:01 -0700
Message-Id: <199507130343.UAA06713@java>
>From: owner-java-interest-digest@java.sun.com
To: java-interest-digest@java.sun.com
Subject: java-interest-digest V1 #82
Reply-To: java-interest@java.sun.com@cs.prusec.com
Errors-To: owner-java-interest-digest@java.sun.com@cs.prusec.com
Content-Length: 30649
Content-Type: text
Precedence: bulk
X-Info: To unsubscribe, send 'unsubscribe' to java-interest-digest-request@java.sun.com
java-interest-digest Thursday, 13 July 1995 Volume 01 : Number 082
In this issue:
Re: Categories in Java?
Re: Has the bytecode gone native?
[none]
2D-arrays
Re: novice DIBitmap question
Java compiler is trying too hard for me
Re: Categories in Java?
Re: Java compiler is trying too hard for me
Class.newInstance() question
Re: Java compiler is trying too hard for me
Re: Java compiler is trying too hard for me
Re: Java compiler is trying too hard for me
Appending to files...
Re: Java compiler is trying too hard for me
lifetime of objects
Re: lifetime of objects
a dumb native code question
Calling java from inside a Windows NT app
Re: Java compiler is trying too hard for me
Java compiler is trying too hard for me (fwd)
Re: Java compiler is trying too hard for me
problems running java programs under NT
getting the Graphics pkg
persistifying objects
----------------------------------------------------------------------
From: Andrew Rolfe <andrewr@crt.com>
Date: Wed, 12 Jul 95 07:25:17 -0500
Subject: Re: Categories in Java?
I for one agree with Mike Fleming that Obj-C like Categories would
be an excellent addition to the Java language. They are an
extremely useful tool; as much or more than Interfaces.
And Mike, I wouldn't give-in so easily to the security concern. I
have a feeling categories could be a security issue. However, since
this is a new language, I don't see why we couldn't allow class
designers to declare if a class "allows" categorization or not. Or,
it might be better to declare secure applet's instead of secure
classes. What do you think?
Anyway, it is something I would agree should be considered.
Andy--
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Andrew Rolfe
NationsBanc-CRT
andrewr@crt.com
------------------------------
From: hickey@oclc.org (Thomas Hickey)
Date: Wed, 12 Jul 1995 10:05:52 -0400
Subject: Re: Has the bytecode gone native?
Given sbk@netcom.com's posting on generating machine code from
bytecode, I couldn't resist trying it myself. I took a class file
parser (written in Java, of course) and made it generate simple
C-macros for the code attributes. sbk's example:
class Main2 {
public static void main(String argv[]) {
int a[], b[], c[], i, j;
a = new int[10000];
b = new int[10000];
c = new int[10000];
for (j=0; j<1000; j++)
for (i=0; i<10000; i++)
a[i] = b[i]+c[i];
}
}
generates code that looks like:
#include "java.h"
void main(java_lang_String[]) {
STACK(5);
LOCAL_DEF(0);
LOCAL_DEF(1);
LOCAL_DEF(2);
LOCAL_DEF(3);
LOCAL_DEF(4);
LOCAL_DEF(5);
SIPUSH(10000);
NEWARRAY(int);
ASTORE_N(1);
SIPUSH(10000);
NEWARRAY(int);
ASTORE_N(2);
SIPUSH(10000);
NEWARRAY(int);
ASTORE_N(3);
ICONST_0();
ISTORE(5);
GOTO(57);
LABEL(24):
ICONST_0();
.
.
.
and then by writing a bunch of macro's, I get compilable C++ code.
Here are sbk's times for his version (no bounds checking, no
optimizations):
C, gcc2.5.6 -O : 2.0u 0.0s 0:02 86% 0+0k 0+0io 0pf+0w
translator: 10.0u 0.0s 0:10 94% 0+0k 0+0io 0pf+0w
java interpreter: 60.0u 0.0s 1:03 94% 0+0k 0+0io 0pf+0w
Actually my java interpreter (alpha3 on a Sparc-10 running SunOS 5.4) takes
about 68 seconds to run the example.
The C++ version (unoptimized) takes 11 seconds WITHOUT doing bounds
checking, but by adding a couple of simple peephole optimizations (e.g.
collapsing the (ALOAD_N, ILOAD, IALOAD) sequence into a single macro
and thereby avoiding some pushes and pops, the execution time is
reduced to 8 seconds using gcc -O, and 7 seconds with gcc -O3, both
WITH bounds checking done on the array accesses.
This code isn't handling exceptions, but they shouldn't really slow
it down. Obviously, generating the machine code directly has the
advantage of avoiding the C++ compile, but in terms of efficiency,
I don't see much difference, and the C++ wins in portability.
- --Th
------------------------------
From: Francois BOUSSARD <francois@coplanet.fr>
Date: Wed, 12 Jul 1995 16:34:22 +0200
Subject: [none]
Hi java-ists (*-*).
Well, I tried to write some codes with 2-dimensional arrays
In java, the doc says that T[][] declares T as an array OF array ->
it's means - at my mind - that :
T[x][y] is an item
T[x] is an array of items
T is an array of arrays of items
Isn't there the meaning of this syntax ?
So, in my way, i though that line :
C T[][]=new C[40][];
would allocate all the elements T[x]=NULL.
So, after, i'd could do T[x][0]=new C[20];
Well, that's what i understood :-) .
In fact, when i tried this code below, i got-back the error message
added after code.
Is it a bug, or a mistake from me ?
//**************************** CODE
class c {
int x,y;
}
class o {
c tabc[][]=new c[40][];
public void Do(){
System.out.println("Do in :"+tabc+" [0] :"+tabc[0]);
tabc[0]=new c[5];
System.out.println("Do out");
}
}
class t {
public static void main (String args[]) {
o obj;
obj=new o();
obj.Do();
}
}
>************************************* Error received
Do in :class[40] [0] :<Null Object>
SIGSEGV 11* segmentation violation
si_signo [11]: SIGSEGV 11* segmentation violation
si_errno [0]: Error 0
si_code [1]: SEGV_ACCERR [addr: 0x5a]
stackbase=EFFFF9FC, stackpointer=EFFFF818
Full thread dump:
"Async Garbage Collector" (0x10267730): priority=1
"Finalizer thread" (0x102676d8): priority=1
"Idle thread" (0x102676c8): priority=0
"clock handler" (0x102676b8): priority=11
"main" (0x102676b0): priority=5 *current thread*
o.Do(t.java:12)
t.main(t.java:24)
Monitor Cache Dump:
Registered Monitor Dump:
Has finalization queue lock: unowned
Finalize me queue lock: unowned
Thread queue lock: unowned
Class lock: unowned
Java stack lock: unowned
Code rewrite lock: unowned
Heap lock: unowned
Allocation lock: unowned
Monitor registry: monitor owner: "main" (0x7e4b0)
Monitor cache lock: unowned
Event monitor: unowned
I/O monitor: unowned
Alarm monitor: unowned
Waiting to be notified:
"clock handler" (0x102676b8): priority=11
Thread Alarm Q:
>***********************************
Isn't it a beautifull error code : that's not so easy to get
one so detailed :
/!!!!!\
/ ~ ~ \
( 0 0 )
\ | /
\`-'/
`-'
Bye, see you soon <-> .
------------------------------
From: Francois BOUSSARD <francois@coplanet.fr>
Date: Wed, 12 Jul 1995 16:38:57 +0200
Subject: 2D-arrays
Hi java-ists (*-*).
Well, I tried to write some codes with 2-dimensional arrays
In java, the doc says that T[][] declares T as an array OF array ->
it's means - at my mind - that :
T[x][y] is an item
T[x] is an array of items
T is an array of arrays of items
Isn't there the meaning of this syntax ?
So, in my way, i though that line :
C T[][]=new C[40][];
would allocate all the elements T[x]=NULL.
So, after, i'd could do T[x][0]=new C[20];
Well, that's what i understood :-) .
In fact, when i tried this code below, i got-back the error message
added after code.
Is it a bug, or a mistake from me ?
//**************************** CODE
class c {
int x,y;
}
class o {
c tabc[][]=new c[40][];
public void Do(){
System.out.println("Do in :"+tabc+" [0] :"+tabc[0]);
tabc[0]=new c[5];
System.out.println("Do out");
}
}
class t {
public static void main (String args[]) {
o obj;
obj=new o();
obj.Do();
}
}
>************************************* Error received
Do in :class[40] [0] :<Null Object>
SIGSEGV 11* segmentation violation
si_signo [11]: SIGSEGV 11* segmentation violation
si_errno [0]: Error 0
si_code [1]: SEGV_ACCERR [addr: 0x5a]
stackbase=EFFFF9FC, stackpointer=EFFFF818
Full thread dump:
"Async Garbage Collector" (0x10267730): priority=1
"Finalizer thread" (0x102676d8): priority=1
"Idle thread" (0x102676c8): priority=0
"clock handler" (0x102676b8): priority=11
"main" (0x102676b0): priority=5 *current thread*
o.Do(t.java:12)
t.main(t.java:24)
Monitor Cache Dump:
Registered Monitor Dump:
Has finalization queue lock: unowned
Finalize me queue lock: unowned
Thread queue lock: unowned
Class lock: unowned
Java stack lock: unowned
Code rewrite lock: unowned
Heap lock: unowned
Allocation lock: unowned
Monitor registry: monitor owner: "main" (0x7e4b0)
Monitor cache lock: unowned
Event monitor: unowned
I/O monitor: unowned
Alarm monitor: unowned
Waiting to be notified:
"clock handler" (0x102676b8): priority=11
Thread Alarm Q:
>***********************************
Isn't it a beautifull error code : that's not so easy to get
one so detailed :
/!!!!!\
/ ~ ~ \
( 0 0 )
\ | /
\`-'/
`-'
Bye, see you soon <-> .
------------------------------
From: andrews@ajax.psc.edu (Phil Andrews)
Date: Wed, 12 Jul 1995 11:38:30 -0400
Subject: Re: novice DIBitmap question
From: masek@GEOLOGY.GEO.CORNELL.EDU (jeff masek)
> Subject: novice DIBitmap question
> This is a fairly simple problem, but I can't seem to get it to
> work...Having created a valid DIBitmap object, how do I get it to display
> on the screen?
>
> Right now I've got the following (unsucessful code) in an update method:
>
> im = createImage(500,500);
> myDisplayItem = new ImageDisplayItem(im);
> myDisplayItem.setImage(myBitMap);
> myDisplayItem.paint(im.win,0,0);
I went through a similar process and ended up displaying a DIBitmap by
delaying the creation of the image until the paint method handed me a Graphics
object g. I then created an image with
if (myImage == null) myImage = g.drawSurface.createImage(myDIBitmap);
and displayed it with
g.drawImage(myImage, x, y);
then storing it away for the next time paint was called.
No idea if it's a recommended procedure, but it's presently working.
- -Phil Andrews, andrews@psc.edu
------------------------------
From: li@deming.Jpl.Nasa.Gov (Tientien Li)
Date: Wed, 12 Jul 1995 08:54:23 -0700
Subject: Java compiler is trying too hard for me
Hi,
The Java compiler "javac" won't let me do the following type of code:
class smartjavac {
public void init() {
int x;
for (int i=0; i<3; i++) {
if (i == 0) x = i;
else if (i == 1) x = i;
else x = i;
}
System.out.println("ValueOfX is " + x );
}
}
The compiler print out the following message and won't generate
any class code.
smartjavac.java:9: Variable x may not have been initialized.
System.out.println("ValueOfX is " + x );
^
1 error
I've tried several compiler options including "-nowarn", but got the
same result.
Any fix for this problem?
- --
Tientien Li
li@deming.jpl.nasa.gov
------------------------------
From: Michael Lorton <mlorton@eshop.com>
Date: Wed, 12 Jul 1995 09:15:52 -0700
Subject: Re: Categories in Java?
I for one agree with Mike Fleming that Obj-C like Categories would
be an excellent addition to the Java language. They are an
extremely useful tool; as much or more than Interfaces.
And Mike, I wouldn't give-in so easily to the security concern. I
have a feeling categories could be a security issue. However, since
this is a new language, I don't see why we couldn't allow class
designers to declare if a class "allows" categorization or not.
Or if a category-added method were restricted to the public interface.
Obviously, there would you be some things you couldn't do, but that is
the whole point of privacy, isn't it, to make some things impossible?
M.
------------------------------
From: li@deming.Jpl.Nasa.Gov (Tientien Li)
Date: Wed, 12 Jul 1995 10:49:14 -0700
Subject: Re: Java compiler is trying too hard for me
>
> > The Java compiler "javac" won't let me do the following type of code:
> >
> > class smartjavac {
> > public void init() {
> > int x;
> > for (int i=0; i<3; i++) {
> > if (i == 0) x = i;
> > else if (i == 1) x = i;
> > else x = i;
> > }
> > System.out.println("ValueOfX is " + x );
> > }
> > }
>
> Try giving x an initial value. The compiler may think that it is possible
> that the loop may be executed 0 times, since compile-time determination
> is not always possible.
>
> Dan Evans
> dan.evans@peri.com
>
Dan,
OK, I agree with you its a good idea to initialize variables. From now on,
I'll try to init all local variable to make "javac" happy. However, this
problem is a bit more complicated, e.g., the "javac" will let the following
code thru:
class smartjavac {
int x; // x is now moved to outside....
public void init() {
for (int i=0; i<3; i++) {
if (i == 0) x = i;
else if (i == 1) x = i;
else x = i;
}
System.out.println("ValueOfX is " + x );
}
}
Looks like "javac" only check this condition for variables defined locally
within the current function scope.
- --
Tientien Li
li@deming.jpl.nasa.gov
------------------------------
From: "Anselm.BairdSmith" <Anselm.Baird_Smith@inria.fr>
Date: Wed, 12 Jul 1995 18:54:22 +0200
Subject: Class.newInstance() question
Hi,
I am using a class loader to load classes into my (java)
application. At the time I instantiate the loaded classes, I would
like to provide the instatiation method with some
parameters. As the newInstance() method of Class doesn't take any
parameters, I thought I would try to define a "Make" static method on
my loadable classes:
public class Loadable {
static Loadable Make (String param) {
return new Loadable (param) ;
}
Loadable (String param) {
...
}
}
Than, the module that loads classes does something like:
class = Class.forName ("Loadable") ; // or whatever
return class.Make ("paramater") ;
However, the compiler reports an error here, because it has no means to
know that the loaded class will respond to Make. Is there any way to
workaround this (such as casting class to the class of Loadable
objects), without turning into C-mode (as does javai.c for the main
method of the class it loads) ?
The only solution I can see is to turn to instances: having a clone
method:
public class Loadable {
Loadable clone (String param) { return new Loadable (param); }
}
and than:
class = Class.forName ("Loadable") ;
return ((Loadable) class.newInstance()).clone (param);
But I don't like it very much...
Anselm.
Anselm.BairdSmith@inria.fr - http://www.inria.fr/koala/abaird.html
------------------------------
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Date: Wed, 12 Jul 1995 11:25:07 -0800 (PDT)
Subject: Re: Java compiler is trying too hard for me
Hi Tientien,
> The Java compiler "javac" won't let me do the following type of code:
>
> class smartjavac {
> public void init() {
> int x;
> for (int i=0; i<3; i++) {
> if (i == 0) x = i;
> else if (i == 1) x = i;
> else x = i;
> }
> System.out.println("ValueOfX is " + x );
> }
> }
>
> The compiler print out the following message and won't generate
> any class code.
>
> smartjavac.java:9: Variable x may not have been initialized.
> System.out.println("ValueOfX is " + x );
> ^
> 1 error
>
> I've tried several compiler options including "-nowarn", but got the
> same result.
>
> Any fix for this problem?
You are required to initialize x. Just change the declaration of x
to "int x = 0;".
Have fun,
Arthur van Hoff
------------------------------
From: li@deming.Jpl.Nasa.Gov (Tientien Li)
Date: Wed, 12 Jul 1995 12:47:46 -0700 (PDT)
Subject: Re: Java compiler is trying too hard for me
Hi Arthur,
>
> You are required to initialize x. Just change the declaration of x
> to "int x = 0;".
>
OK, I think its a good idea to initialize all variables, and I'll do so now.
But why treat local variables differently from instance variables which are
automatically initialized.
see below, pointed out to me by Dan.Evans@peri.com.
> 4.2.1 Instance Variables
>
> All variables in a class declared outside the scope of a method and not marked
> static (see <A HREF="#17">Static Methods, Variables, and Initializers</A>) are
> instance variables. (Variables declared inside the scope of a method are
> considered local variables.) Instance variables can have modifiers (see
> <A HREF="#23">Modifiers</A>).
>
> Instance variables can be of any type and can have initializers. If an
> instance variable does not have an initializer, it is initialized to
> zero; boolean variables are initialized to false; and objects are initialized
> to null.
>
> i.e. it really is initialized to 0.
>
If the goal is to enforce the initialization of local variables, then why
not check this at the declaration time then at the time variables are used?
It is probably much easier to tell me:
int x;
^ error
instead of tracking all possible references of x, then tell me:
System.out.println( x );
^ error
- --
Tientien Li
li@deming.jpl.nasa.gov
------------------------------
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Date: Wed, 12 Jul 1995 13:15:11 -0800 (PDT)
Subject: Re: Java compiler is trying too hard for me
Hi Tientien,
> > > The Java compiler "javac" won't let me do the following type of code:
> > >
> > > class smartjavac {
> > > public void init() {
> > > int x;
> > > for (int i=0; i<3; i++) {
> > > if (i == 0) x = i;
> > > else if (i == 1) x = i;
> > > else x = i;
> > > }
> > > System.out.println("ValueOfX is " + x );
> > > }
> > > }
> >
> > Try giving x an initial value. The compiler may think that it is possible
> > that the loop may be executed 0 times, since compile-time determination
> > is not always possible.
> >
> > Dan Evans
> > dan.evans@peri.com
> >
>
> Dan,
>
> OK, I agree with you its a good idea to initialize variables. From now on,
> I'll try to init all local variable to make "javac" happy. However, this
> problem is a bit more complicated, e.g., the "javac" will let the following
> code thru:
>
> class smartjavac {
> int x; // x is now moved to outside....
> public void init() {
> for (int i=0; i<3; i++) {
> if (i == 0) x = i;
> else if (i == 1) x = i;
> else x = i;
> }
> System.out.println("ValueOfX is " + x );
> }
> }
>
> Looks like "javac" only check this condition for variables defined locally
> within the current function scope.
Instance variables are automatically initialized to 0 (or the equivalent
thereof).
Have fun,
Arthur van Hoff
------------------------------
From: mike.lee@gs.com (Mike Lee)
Date: Wed, 12 Jul 1995 16:13:20 -0400 (EDT)
Subject: Appending to files...
Isn't there a way to append to a file without resorting to writing
native codes?? It seems that none of the classes provided has
an option to open a file in append mode. How can this be?
I even tried to use a file name like ">>logs," but that didn't
work.
Thanks for any info...
------------------------------
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Date: Wed, 12 Jul 1995 13:21:57 -0800 (PDT)
Subject: Re: Java compiler is trying too hard for me
Hi Tientien,
> If the goal is to enforce the initialization of local variables, then why
> not check this at the declaration time then at the time variables are used?
> It is probably much easier to tell me:
>
> int x;
> ^ error
>
> instead of tracking all possible references of x, then tell me:
>
> System.out.println( x );
Sometimes you would initialize it anyway, for example:
int x;
if (...) {
x = 3;
} else {
x = 5;
}
System.out.println("x = " + x);
Initializing x in this case would be a waste of time.
Have fun,
Arthur van Hoff
------------------------------
From: ton@cc.gatech.edu (Lein Ton)
Date: Wed, 12 Jul 1995 16:27:03 -0400
Subject: lifetime of objects
Hi all,
I can remember that creating new objects in C++ within methods was one
of the most certain way of getting a core dump.
The next java program seems to work, but can I be sure that the
instances that created in add() of HtContainer have the same lifetime
as the hashtable in HtContainer?
Have fun,
Lein Ton
- ------------------------------------------------------------------------------
import java.util.*;
class test4 extends Hashtable {
static HtContainer aHtContainer; // container of a hashtable
public static void main(String args[]) {
aHtContainer = new HtContainer();
aHtContainer.output();
}
}
class HtContainer { // container of a hashtable
Hashtable ht;
public HtContainer() {
// create a new hastable, and fill it
ht = new Hashtable();
for (int i = 1; i<100; i++) {
add();
}
}
public void output() {
// show all the hashtable elements
for (Enumeration e = ht.elements(); e.hasMoreElements();)
{
((StringContainer)e.nextElement()).output();
}
}
public void add() {
// add a newly created element to ht
ht.put(Integer.toString(ht.size()),
new StringContainer(Integer.toString(ht.size())));
}
}
class StringContainer { // container for a String
String str;
public StringContainer(String aString) {
str=aString;
}
public void output() {
System.out.println(str);
}
}
------------------------------
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Date: Wed, 12 Jul 1995 13:58:22 -0800 (PDT)
Subject: Re: lifetime of objects
Hi Lein,
> I can remember that creating new objects in C++ within methods was one
> of the most certain way of getting a core dump.
> The next java program seems to work, but can I be sure that the
> instances that created in add() of HtContainer have the same lifetime
> as the hashtable in HtContainer?
Java uses a garbage collector. This means that you never have to worry
about the lifetime of objects. As long as you can reference them somehow
the are alive.
Have fun,
Arthur van Hoff
------------------------------
From: ekim@nyquist.bellcore.com (Michael Mills 21728)
Date: Wed, 12 Jul 1995 17:21:47 -0400 (EDT)
Subject: a dumb native code question
Hi,
There has been some discussion of converting Java bytecode to
sparc assembler and to C++. I am a little confused. From looking at the Java
white paper I have been under the impression that at some point
Java would do this for me on the fly. Does the white paper imply that this
will be a standard Java feature?
Thanks,
Mike
PS.
I have included a section from the white paper below:
High Performance
While the performance of interpreted bytecodes is usually more than adequate,
there are situations where higher performance is required. The bytecodes can be
translated on the fly (at runtime) into machine code for the particular CPU the
application is running on. For those accustomed to the normal design of a
compiler and dynamic loader, this is somewhat like putting the final machine code
generator in the dynamic loader.
The bytecode format was designed with generating machine codes in mind, so the
actual process of generating machine code is generally simple. Reasonably good
code is produced: it does automatic register allocation and the compiler does some
optimization when it produces the bytecodes.
In interpreted code we're getting about 300,000 method calls per second on an
Sun Microsystems SPARCStation 10. The performance of bytecodes converted to
machine code is almost indistinguishable from native C or C++.
------------------------------
From: spike@rmii.com (Michael A. Smith)
Date: Wed, 12 Jul 95 15:36 MDT
Subject: Calling java from inside a Windows NT app
Hello,
I'm trying to set up a Windows NT app that is based largely on the Microsoft
Foundation Classes (MFC) but has some interpreted pieces that are written in
java hooked into it. So far I can't figure out how to run the interpreter
from inside the Windows application. All the sample projects I've seen run
from the command line (e.g. C:> java classname). I think that the hotjava
browser is kicking off the interpreter from inside hotjava.exe, but I can't
find any documentation to tell me how the call should look in my own app.
Can any java experts out there provide me with some insight?
Thanks,
Michael Smith
------------------------------
From: Michael Lorton <mlorton@eshop.com>
Date: Wed, 12 Jul 1995 16:19:51 -0700
Subject: Re: Java compiler is trying too hard for me
> OK, I agree with you its a good idea to initialize variables.
I disagree. In the original situation, where one of several possible
initial values might be the correct one, the correct thing to do is what
Mr. Li did originally: leave it uninitialized until you know what to do.
It saves resources and avoids masking the failure to set the variable
correctly.
Unfortunately, a bug in the compiler prevented that, but
initialization was cheap, and you can check the code by hand.
Mr. Li's other point was correct: there are many cases where the
compiler cannot check for initialization.
M.
------------------------------
From: grover@ra.isisnet.com (Gary Joseph Bowdridge)
Date: Wed, 12 Jul 1995 20:46:55 -0300 (ADT)
Subject: Java compiler is trying too hard for me (fwd)
> Hi,
>
> The Java compiler "javac" won't let me do the following type of code:
>
> class smartjavac {
> public void init() {
> int x;
> for (int i=0; i<3; i++) {
> if (i == 0) x = i;
> else if (i == 1) x = i;
> else x = i;
> }
> System.out.println("ValueOfX is " + x );
> }
> }
>
> The compiler print out the following message and won't generate
> any class code.
>
> smartjavac.java:9: Variable x may not have been initialized.
> System.out.println("ValueOfX is " + x );
> ^
> 1 error
>
> I've tried several compiler options including "-nowarn", but got the
> same result.
>
> Any fix for this problem?
The compiler does not know that x is SURE to have a value assigned to
in at the point where it's value is used (the println line)
Instead of just declareing x, declare and initilize it with:
int x=0;
I don't know why variables don't initilize to "0" or null when
declared, but they don't, so you have to make certain that you
have all variables initilized before using them... doing this in
an "if" block is not good enough.. Even though you have if/else
and x WILL be defined in one of them, i assume the compiler can't
be bothered to check into such detail.
___
_gary_
------------------------------
From: weilerj@std.teradyne.com (Jason Weiler)
Date: Wed, 12 Jul 1995 17:19:49 -0700
Subject: Re: Java compiler is trying too hard for me
> Dan,
>
> OK, I agree with you its a good idea to initialize variables. From now on,
> I'll try to init all local variable to make "javac" happy. However, this
> problem is a bit more complicated, e.g., the "javac" will let the following
> code thru:
>
> class smartjavac {
> int x; // x is now moved to outside....
> public void init() {
> for (int i=0; i<3; i++) {
> if (i == 0) x = i;
> else if (i == 1) x = i;
> else x = i;
> }
> System.out.println("ValueOfX is " + x );
> }
> }
>
> Looks like "javac" only check this condition for variables defined locally
> within the current function scope.
Presumably, a constructor would init the variable in this case.
- -Jason Weiler
------------------------------
From: Muzaffer Kal <MuzoK@msn.com>
Date: Wed, 12 Jul 95 22:49:56 UT
Subject: problems running java programs under NT
I can run the helloworld test on my system but when I try to get something
more
complicated I get errors like "Access error: applet foo tried to read
dir_name" type
error. I know that I am missing some crucial (sp?) piece of
info but not exactly sure
what. Can someone send me detailed steps on how
to, say, run the performance test
samples on http://java.sun.com. (Graphics,
threads etc).
I'd really appreciate the help
thanks
------------------------------
From: Benjamin.Fry@Eng.Sun.COM (Benjamin Fry)
Date: Wed, 12 Jul 1995 19:29:57 -0700
Subject: getting the Graphics pkg
I can't seem to figure out how to get the Graphics data from anything
besides Update, Paint, or Repaint. Is there a way to do this? (I
understand the reasoning behind hiding it to everyone but these
functions, but..)
Otherwise, if I make changes on the screen, I'm using globals to find
out what changed when the applet finally gets redrawn, so I know how
the redraw should behave. Is there a better way of doing this? How
soon will offscreen graphics be available, or are they here already?
Thanks all,
ben
------------------------------
From: Dave Pare <mr-frog@midway.netgames.com>
Date: Wed, 12 Jul 1995 20:43:17 -0700
Subject: persistifying objects
So a usually reliable source has told me that there used to be support
for making java objects persistent, but it was removed due to problems
with security. I'm very interested in using the language, but it's
critical for me to be able to store a partial image of my current runtime
state to disk so that it can be subsequently restored. I've developed
a simple automated system for doing this under C++, and it's wonderfully
useful.
Based on my experience, I have suggestions as to how Java might proceed,
but since I haven't considered the security aspects of this for any longer
than about ten minutes, my suggestions would probably be silly, easily
shot down and do no more than waste everyone's time.
Therefore, I humbly request to know if:
a) some kind "internal" soul be willing to cough up information
regarding what was attempted in the past, along with the rationale was
that finally shot it down
b) anyone is working on any automated persistence system for Java at
this time
Thanks,
Dave Pare
------------------------------
End of java-interest-digest V1 #82
**********************************
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com