[4276] in java-interest

home help back first fref pref prev next nref lref last post

java-interest-digest V1 #264

daemon@ATHENA.MIT.EDU (java.sun.com!owner-java-interest-d)
Fri Dec 15 13:17:01 1995

From: java.sun.com!owner-java-interest-digest@asoft.msk.su
Date: Wed, 15 Nov 1995 08:12:55 -0800
To: java-interest-digest@java.sun.com
Reply-To: java.sun.com!java-interest@asoft.msk.su

java-interest-digest    Wednesday, 15 November 1995    Volume 01 : Number 264

In this issue:

 	Re: declaration v.s. definition ambiguity
 	Re: declaration v.s. definition ambiguity
 	Re: Help - Error 4 
 	Re: Help - Error 4 
 	Re: protected is not?
 	Sun Java Training.
 	Re: protected is not?
 	Re: java threads.
 	java-interest-digest V1 #262
 	Re: protected is not? 
 	UDP with java.net.* (was: Can I do UDP/IP...)
 	Re: protected is not?
 	Java 101 question.
 	Inline methods
 	Re: Inline methods
 	Cambridge, Mass Java User Group Starting!
 	Re: Inline methods
 	Re: Help - Error 4 
 	Re: NS/Beta 2:"start: applet not intialized"
 	Q about TextField background
 	Native methods in apllets
 	How to get continuous data stream
 	Re: protected is not?
 	java-interest
 	Re: SunOS 4.1.X

----------------------------------------------------------------------

From: jazukow@rssi.rssi.com (John Zukowski)
Date: Tue, 14 Nov 1995 18:27:15 -0500
Subject: Re: declaration v.s. definition ambiguity

>>From: garya@village.org (Gary Aitken)
>>
>>It would be really 
>>nice if /** comments in the code could be preserved in the .class file (new 
>>option for javac?), and output by javap.  One could then program in a style 
>>which allowed shipping a .class file from which javap could extract a 
>>reliable, well documented api.
>
>I'm new to Java.  Why would you want to use a /** comment instead of //?
>Does it do something different?  How does /** differ from /*?
>

The /** comment is used by javadoc to automate the generation of some
documentation.  Stuff within /** is included.  Stuff within /* or //
is not.

John Zukowski
Rapid Systems Solutions
john.zukowski@rssi.com
http://www.rssi.com/java-info.html

------------------------------

From: garya@village.org (Gary Aitken)
Date: Tue, 14 Nov 1995 17:03:08 -0700
Subject: Re: declaration v.s. definition ambiguity

>>It would be really 
>>nice if /** comments in the code could be preserved in the .class file (new 
>>option for javac?), and output by javap.  One could then program in a style 
>>which allowed shipping a .class file from which javap could extract a 
>>reliable, well documented api.
>
>I'm new to Java.  Why would you want to use a /** comment instead of //?
>Does it do something different?  How does /** differ from /*?

Comments starting with /** are specifically reserved for automatically 
generated documentation.  If you look at the source in 
.../java/src/java/awt/*.java you will see examples of how it is used.
If you compare the text there with the html documentation for the same 
function, you'll notice some similarities...

Gary Aitken		garya@village.org

------------------------------

From: mmaston@stratacom.com (Michael Maston)
Date: 15 Nov 1995 00:05:16 GMT
Subject: Re: Help - Error 4 

Have you tried just invoking javac as:

javac NervousText.java

???

NOTE THE CAPITALIZATION.

Starting with the pre-beta they started requiring the name of the class
definition file to be the same as the name of the class itself.  Maybe javac
is looking at the input line of the invocation rather than the actual
filename in the directory listing (makes sense to me) and the comparison of
the strings fails there.

Good luck!

Michael C. Maston


------------------------------

From: Michael Lorton <mlorton@eshop.com>
Date: Tue, 14 Nov 1995 16:20:58 -0800
Subject: Re: Help - Error 4 

C:\java\demo\nervoustext>javac nervoustext.java
nervoustext.java:12: Warning: Public class NervousText must be 
defined in a file  called "NervousText.java".

You want a complete guess?
Try:

C:\java\demo\nervoustext>javac NervousText.java

If it doesn't work, sorry.  If it does, GET A REAL OS!

M.

------------------------------

From: David.Geary@Central.Sun.COM (David Geary)
Date: Tue, 14 Nov 1995 17:24:48 -0700
Subject: Re: protected is not?

> Hi,
> 
> protected variables can be accessed by the methods of its class and subclasses

  OK.

> apiece is an object of junk so apiece can access protected variable name.
> Change name to a private variable if you want name to be accessed only by
> the junk class.

  But it's being accessed in a method that is not in Junk or one of it's
subclasses.  (See your first statement).

  If the (Java) code below does not contain a bug, then protected in Java 
means something quite different than protected in C++.  Consider:

#include "iostream.h"

class junk
{
  protected:  int x;
};

class Protect
{
  doit() { junk aJunk; cerr << aJunk.x; }
}

int main()
{
  Protect p;

  p.doit();
}

rmtc >> CC tst.C
"tst.C", line 10: Error: x is not accessible from Protect::doit().

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 David Geary                         "In the backwater swirling
 geary@rmtc.Central.Sun.COM           there is something that'll never change"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


> > Here is a simple chunk of code that does not
> > seem to work properly.
> > 
> > class junk {
> >         protected String name;
> > 
> >         junk(String inName)
> >         {
> >                 name = new String(inName);
> >         }
> > }
> > 
> > class Protect {
> >         public static void main(String args[])
> >         {
> >                 junk apiece = new junk("piece of junk");
> > 
> >                 System.out.println(apiece.name);
> >         }
> > }
> > 
> > 
> > This code compiles and prints out the name of the
> > object.  The problem is that the compiler should not have
> > let me do this.  name is a protected variable. protected should
> > mean that inaccesible except to subclasses.
> > 
> > Any ideas or is this a bug?
> > 
> > I am using the beta for Win95.
> > 
> >  - Mike Daconta
> > 
> > -
> > This message was sent to the java-interest mailing list
> > Info: send 'help' to java-interest-request@java.sun.com
> ==============================================================================
> Edith Au                            Tel:    (212) 513 7777
> WWW Specialist                      Email:  edith@pencom.com
> Pencom Systems Incorporated         WWW:    http://www.pencomsi.com/~edith      
> 40 Fulton Street,
> NY, NY 10038
> ===============================================================================
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
> 


------------------------------

From: "Michael E. Mendis" <mmendis@meceng.coe.neu.edu>
Date: Tue, 14 Nov 1995 20:04:16 -0500 (EST)
Subject: Sun Java Training.

This is a reply to the resent message about the courses and dates.  I just
want to inform evetyone that they are not free.  They are about $1000+, I
foudn that out when I called.   I thought that they would be maybe a $100
or $200.  Well justa suggestion before you call up.

- -- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Mike Mendis			do { money --;	sleep --;   brain_cells --;
Northeastern University		     debt  ++;  laundry = 0;
mmendis@splinter.neu.edu               } while (college_student()); 

finger mmendis@splinter.coe.neu.edu for my pgp 2.6!
WWW: http://splinter.coe.neu.edu/~mmendis

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



------------------------------

From: Pat Niemeyer <pat@icon-stl.net>
Date: Tue, 14 Nov 1995 19:20:46 -0600 (CST)
Subject: Re: protected is not?

On Mon, 13 Nov 1995, Michael Daconta wrote:

> Here is a simple chunk of code that does not
> seem to work properly.
> 
> class junk {
>         protected String name;
> 
>         junk(String inName)
>         {
>                 name = new String(inName);
>         }
> }
> 
> class Protect {
>         public static void main(String args[])
>         {
>                 junk apiece = new junk("piece of junk");
> 
>                 System.out.println(apiece.name);
>         }
> }
> 
> 
> This code compiles and prints out the name of the
> object.  The problem is that the compiler should not have
> let me do this.  name is a protected variable. protected should
> mean that inaccesible except to subclasses.

Protected members are avaiable to subclasses and classes in the same *package*
or compilation unit.  If you put junk in a seperate package its protected 
members will not be accessible by Protect.  

I believe that this is the default permission if you don't use any modifiers.


Pat

------------------------------

From: Michael Lorton <mlorton@eshop.com>
Date: Tue, 14 Nov 1995 17:34:18 -0800
Subject: Re: java threads.

> 
> I then make my main function to create the seperate threads(I think).   
>  This is where I get my errors.  I'm not sure what I'm doing wrong.
> 
> class testanimate
>   {
>   public static void main(String args[])
>     {
>     new animate(8, 10, 10).start();
>     new animate(16, 10, 10).start();
>     }
>   }
> 

You don't start() a Runnable; you create a Thread with Runnable as
its argument.

	new Thread(new animate(8, 10, 10)).start();

I am not sure about the new class.method() either, but I don't have a
compiler or the spec handy.

M.



------------------------------

From: Patrick Taylor <patrick.taylor@template.com>
Date: Tue, 14 Nov 1995 20:50:53 -0500
Subject: java-interest-digest V1 #262

> From: juanda@edx1.educ.monash.edu.au (Juanda Ismail)
> Date: Tue, 14 Nov 1995 18:27:28 +1100
> Subject: Copyright Issues
> 
> Not a technical query, here folks, but one of legallity.
> 
> I'm using the "Nervous Text" applet where I've customised the wording of the
> text so that it reads the title of my home page. Just wondering if this is ok. 
> If not, I'll remove the page from the web.

I can't see this being a problem, but I don't know.  However, here's a
an improved version of NervousText called CrazyText that I put together.
Feel free to use it.


// CrazyText.java
// Patrick Taylor (taylor@us.net)
// Works with JDK 1.0 beta1.

/* Based on NervousText.java demo in the JDK 1.0 beta1 release,
   by Daniel Wyszynski.

   The differences:
   - NervousText isn't smart about its use of a proportional font.  It spaces
     all of the characters evenly.  To demonstrate, try giving it a string
     like "lllllllllllllllllllmmmmmmmmmmmmmmmmmmmm".  The m's get scrunched
     together, the l's are too far apart.  CrazyText fixes this.
   - CrazyText is very customizable.
   - CrazyText paints with a random color on each update.
   - By default, CrazyText doesn't clear the background on each update, which
     produces a nice effect since the color changes.
   - CrazyText resizes the applet to fit the text.  Unfortunately, this has
     no effect in Netscape 2.0 beta2, but does work in appletviewer.  You
     can click on the applet to see its desired size on the status line.
*/

import java.awt.Graphics;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Event;
import java.awt.Color;

public class CrazyText extends java.applet.Applet implements Runnable {

   // parameters
   String	text = "Java";	// string to be displayed
   int		delay = 100;	// # of milliseconds between updates
   int		delta = 5;	// "craziness" factor: max pixel offset
   boolean	clear = false;	// should background be cleared on update
   String	fontName = "TimesRoman";
   int		fontSize = 36;
   boolean	fontBold = true;
   boolean	fontItalic = false;

   // implementation
   char		chars[];	// individual chars in 'text'
   int		positions[];	// base horizontal position for each char
   FontMetrics	fm;
   Thread	thread = null;
   int		newWidth, newHeight;

   public void init() {

      String param;

      param = getParameter("text");
      if (param != null) { text = param; }

      param = getParameter("delay");
      if (param != null) { delay = Integer.parseInt(param); }

      param = getParameter("delta");
      if (param != null) { delta = Integer.parseInt(param); }

      param = getParameter("clear");
      if (param != null) { clear = param.equals("true"); }

      param = getParameter("fontName");
      if (param != null) { fontName = param; }

      param = getParameter("fontSize");
      if (param != null) { fontSize = Integer.parseInt(param); }

      param = getParameter("fontBold");
      if (param != null) { fontBold = param.equals("true"); }

      param = getParameter("fontItalic");
      if (param != null) { fontItalic = param.equals("true"); }

      int fontStyle = (fontBold   ? Font.BOLD   : 0) + 
		      (fontItalic ? Font.ITALIC : 0);
      setFont(new Font(fontName, fontStyle, fontSize));
      fm = getFontMetrics(getFont());

      chars = new char[text.length()];
      text.getChars(0, text.length(), chars, 0);

      positions = new int[text.length()];
      for (int i = 0; i < text.length(); i++) {
         positions[i] = fm.charsWidth(chars, 0, i);
      }

      newWidth  = delta * 2 + fm.stringWidth(text);
      newHeight = delta * 2 + getFont().getSize();

      // this works in appletviewer, but has no effect in Netscape 2.0 beta2
      resize(newWidth, newHeight);
   }

   public void start() {
      if (thread == null) {
	 thread = new Thread(this);
	 thread.start();
      }
   }

   public void stop() {
      thread = null;
   }

   public void run() {
      while (thread != null) {
	 try { Thread.sleep(delay); } catch (InterruptedException e) {}
	 repaint();
      }
   }

   public void paint(Graphics g) {
      g.setColor(new Color((float)Math.random(),
			   (float)Math.random(),
			   (float)Math.random()));
      for (int i = 0; i < text.length(); i++) {
	 int x = (int)(Math.random() * delta * 2) + positions[i];
	 int y = (int)(Math.random() * delta * 2) + fm.getAscent() - 1;
	 g.drawChars(chars, i, 1, x, y);
      }
   }
 
   public void update(Graphics g) {
      if (clear) {
	 super.update(g);
      } else {
         paint(g);
      }
   }

   public boolean mouseDown(Event evt, int x, int y) {
      showStatus( "I'd like my size to be " + newWidth + "x" + newHeight);
      return true;
   }
}

------------------------------

From: satoo@pfu.fujitsu.co.jp (satoh-HAL-osamu)
Date: Wed, 15 Nov 1995 11:46:28 +0900
Subject: Re: protected is not? 

> "protected" means that only extended class *and* other classes within
> the same package can access the identifier.  Packages in the same class
> are considered to be, well, "friendly".  This is one reason it is
> important to package your classes correctly

In "The Java Language Environment: White Paper", I can find:

	protected means that instance variable and methods
	so designated are accessible only to subclasses
	of that class, and nowhere else.

BUT, result of tests I did tell me that Ken is right.
Does the white paper miss?

SATOH Osamu
satoo@pfu.fujitsu.co.jp





------------------------------

From: michael@earthlight.com (Michael Slominski)
Date: Tue, 14 Nov 1995 19:40:14 +0800
Subject: UDP with java.net.* (was: Can I do UDP/IP...)

Thanks for the responses to my earlier UDP question. The answer seems
to be that there is no support for connectionless sockets in the
JDK-beta release (java.*) but the classes in sun.net.* that are
distributed with JDK-beta will do UDP sockets.

So now I need to know how to talk to the sun.net.* objects. I expect
that this information will be volatile, or the sun.net.* classes would
have been included with the other java.net.* classes, but that's ok because I
just want to play around with them. So what are the public
methods/objects of sun.net.DatagramPacket, sun.net.DatagramSocket, and
sun.net.MulticastSocket?

- -m

Mike Slominski
Earthlight Consulting
michael@earthlight.com

------------------------------

From: "Flint O'Brien" <flint@nando.net>
Date: Tue, 14 Nov 1995 23:17:33 -0500
Subject: Re: protected is not?

I hope this is incorrect. If "protected" is the same as "friendly,"
why have it at all. ("Friendly" is the default which allows access
to all in the same package.)

>"protected" means that only extended class *and* other classes 
>within the same package can access the identifier.  Packages in the 
>same class are considered to be, well, "friendly".  This is one 
>reason it is important to package your classes correctly

flint@nando.net

------------------------------

From: skeller@indra.com (Spencer A. Keller)
Date: Tue, 14 Nov 1995 21:34:58 -0700 (MST)
Subject: Java 101 question.

Hello,

Need some basic help with Java.  I am brand new to java and have down loaded
the latest Version 1.0 Beta for Windows NT (Intel).  I am trying to follow
the "tail map" to learn.  I had no problem getting the standalone "hello
world" program to run but To date I can not get the hello world applet to
from from the Hotjava browser.  In the "this is a draft" file under the
heading "Upgrades, Bug Fixes and Face-Lifts. Oh My!" it mentiones that all
the samples have been upgreaded to the Beta api except the "run" protocol
handler "Handler.java".  The trail map seems to indicate that I need this
"run": handler to execute my Hello world applet.  I tried to "upgrade by
hand" but got in way over my head.  So I guess my question(s) are:

1) Do I need the "run" handler to get my hello world applet to execute from
the browser?

2) If the answer is yes, is an updated verson availible yet?  Or what do I
need to change to update it?

Thanks very much.  (I'll get this some day.)

Spencer Keller


------------------------------

From: "Flint O'Brien" <flint@nando.net>
Date: Wed, 15 Nov 1995 00:02:39 -0500
Subject: Inline methods

I haven't heard anyone mention the lack of inlines in Java.
The use of inlines can significantly improve execution speed.

I realize one problem is that inlines are non-virtual methods
by nature. If they are resolved at compile time, you would have
to recompile when the class changes the inline definition. Java
has done a lot to fix the "Fragile" base class problem (see the
White Paper).

One solution is to resolve inlines at load time. This could even
be a user option (call the methods or patch in the inline code).

The loader could even decide what methods should be inline. The
criteria could be controlled by the user. For example, force all
methods that simply return data to be coded inline.

flint@nando.net

------------------------------

From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
Date: Tue, 14 Nov 1995 22:08:54 -0800
Subject: Re: Inline methods

Hi Flint,

> I haven't heard anyone mention the lack of inlines in Java.
> The use of inlines can significantly improve execution speed.
> 
> I realize one problem is that inlines are non-virtual methods
> by nature. If they are resolved at compile time, you would have
> to recompile when the class changes the inline definition. Java
> has done a lot to fix the "Fragile" base class problem (see the
> White Paper).
> 
> One solution is to resolve inlines at load time. This could even
> be a user option (call the methods or patch in the inline code).
> 
> The loader could even decide what methods should be inline. The
> criteria could be controlled by the user. For example, force all
> methods that simply return data to be coded inline.

The compiler when invoked with -O already inlines final methods,
private methods, and static methods. The result of this may not
pass the verifier test though.

Anyway, as you point out, a better solution is to inline methods
at runtime. There are a lot of lesson to be learned from the Self
incremental compiler...

Have fun,

	Arthur van Hoff

------------------------------

From: deluded@overbyte.virtumall.com (Ron D. Schmelzer)
Date: Wed, 15 Nov 1995 01:36:43 -0500 (EST)
Subject: Cambridge, Mass Java User Group Starting!

		****** ANNOUNCEMENT *****

VirtuMall,Inc. is considering sponsoring and helping start a Cambridge,
MA (and Boston) area Java User's Group. Right now, we are looking for
interest in forming such a group, if there is such interest, please
email us here at VirtuMall, at rschmel@virtumall.com. 

First meeting is planned for some point in December or January,
depending on interest, and will cover a variety of topics. There might
be some guest speakers if interest in that is also present. The
Cambridge Area Java Users Group (CAJUG) will present a forum for the
exchange of information, advice, experience, and ideas about Java and
related concepts. At each monthly meeting there will be discussion
forums, guest speakers, job opportunities, sponsored contests and games,
product preview opportunities, and a variety of other concepts that will
be explored at our first meeting.

Once again, please let me know if there is any interest in starting the
Cambridge Area Java User's Group. Reply to rschmel@virtumall.com.

Thanks for your attention, and thank you Java Team for a wonderful product!
Ron Schmelzer
President, VirtuMall, Inc.

P.S.: Is anyone else out there working with the Microsoft BlackBird
product? 
- -- 
Ron Schmelzer, President, VirtuMall, Inc. rschmel@virtumall.com
************* V I R T U M A L L *****************>8************************
Visit VirtuMall, the Net's most unique shopping mall: http://virtumall.com/
VirtuMall New Media Marketing, Breeding Ground of breakthrough Net Apps
or call 1-800-VMALL96 -> 1-800-862-5596
*************http://virtumall.com********(617) 497-8006********************

------------------------------

From: "Jeremy Fitzhardinge" <jeremy@suede.sw.oz.au>
Date: Wed, 15 Nov 1995 17:52:16 -0500
Subject: Re: Inline methods

On Nov 15, 12:02am, Flint O'Brien wrote:
> Subject: Inline methods
> I haven't heard anyone mention the lack of inlines in Java.
> The use of inlines can significantly improve execution speed.

The Java compiler treats "final" methods as being eligable for inlining if
they are small enough.

	J

------------------------------

From: Kenji Morita <kmorita@xpc.canon.co.jp>
Date: Wed, 15 Nov 95 16:43:06 +0900
Subject: Re: Help - Error 4 

> C:\java\demo\nervoustext>javac nervoustext.java
> nervoustext.java:12: Warning: Public class NervousText must be 

> defined in a file
>  called "NervousText.java".
> public class NervousText extends java.applet.Applet implements 

> Runnable {
>              ^
> 1 error

You should type
C:\java\demo\nervoustext>javac NervousText.java
                               ^      ^
- -----
Kenji

------------------------------

From: Edd Dumbill <edmundd@compnews.co.uk>
Date: Wed, 15 Nov 1995 08:12:39 +0000 (GMT)
Subject: Re: NS/Beta 2:"start: applet not intialized"

On Tue, 14 Nov 1995, R.Volkmann wrote:
> >Date: Mon, 13 Nov 1995 12:02:25 -0500
> I downloaded the JDK for Solaris but I don't have a file called moz2_0.car.
> Where do I get it.  Apparently I can't run Java applets from Netscape 2.0
> without it.

moz2_0.car comes with Netscape 2.0J. It should have been installed in
/usr/local/netscape/java/classes/moz2_0.car.

> | R. Mark Volkmann - Principal Specialist Programmer/Analyst                 |

Edd.

      Edd Dumbill - Software Engineer - PA Data Design - +44 1430 488224
    mailto:edmundd@padd.press.net - http://www.pa.press.net/people/edmundd
      and i like the way you're broken and i'll like you when you're old


------------------------------

From: pfu.fujitsu.co.jp!shira@fujitsuI.fujitsu.com
Date: Fri, 15 Dec 1995 14:57:44 JST
Subject: Q about TextField background

I have a question about background color of TextField.
I'd like to set certain color to TextField as background.
But when the TextField is editable, the color actually set
seems to be brighter than that I specified.

Following program set "white" for editable TextField background.
	TextField textField = new TextField(30);
	textField.setEditable(true);
	textField.setBackground(Color.lightGray); // be white

So, I have to write like:
	if (textField.isEditable()) {
	    textField.setColor(new Color(141, 141, 141)); // be lightGray
	} else {
	    textField.setColor(new Color(192, 192, 192)); // lightGray
	}

Is it a feature?
I'm using JDK beta on Solaris 2.4 if it helps.

Thank you.
- --
Kazuhisa SHIRAKAMI (shira@pfu.fujitsu.co.jp)
PFU Limited. Tokyo, Japan.

------------------------------

From: Otto <martini@psatit.ico.olivetti.com>
Date: Wed, 15 Nov 1995 03:16:33 -0800
Subject: Native methods in apllets

Can I call external C code (using native methods) from a Java Applet?
(I need to interface a Windows DLL for a particular demo with Java Applet - I'm
using Netscape 2.0.b2 on Windows 95)

If no, is there anything than can help me to solve this problem?

Thanks

Otto Martini


------------------------------

From: Aaron Aw <aaron@irdu.nus.sg>
Date: Wed, 15 Nov 1995 21:50:58 +0800 (WST)
Subject: How to get continuous data stream

Hi! I'm trying to get an applet to coninuously read a data stream from a 
file or URL site. How do I establish such a connection?? any examples?

thanks

Just Me,
Aaron Aw

- -------------------------------------------------------------------------------
Give me a break here...
E-Mail: aaron@irdu.nus.sg        Phone:(065) 772-8094
- -------------------------------------------------------------------------------



------------------------------

From: rajesht@boxer.com (Rajesh Thakkar)
Date: Wed, 15 Nov 1995 11:40:09 -0600
Subject: Re: protected is not?

>
>On Mon, 13 Nov 1995, Michael Daconta wrote:
>
>> Here is a simple chunk of code that does not
>> seem to work properly.
>> 
>> class junk {
>>         protected String name;
>> 
>>         junk(String inName)
>>         {
>>                 name = new String(inName);
>>         }
>> }
>> 
>> class Protect {
>>         public static void main(String args[])
>>         {
>>                 junk apiece = new junk("piece of junk");
>> 
>>                 System.out.println(apiece.name);
>>         }
>> }
>> 
>> 
>> This code compiles and prints out the name of the
>> object.  The problem is that the compiler should not have
>> let me do this.  name is a protected variable. protected should
>> mean that inaccesible except to subclasses.
>
>Protected members are avaiable to subclasses and classes in the same *package*
>or compilation unit.  If you put junk in a seperate package its protected 
>members will not be accessible by Protect.  
>
>I believe that this is the default permission if you don't use any modifiers.
>
>
>Pat

Having more than one class defined in a single 
package/compilation unit/module/....... makes them to be "friends"(C++)
automatically. So as suggested by Pat, if junk is compiled in a separate
package and then imported into the package where protect is defined, then
the access to 'apeice.name' from 'portect' class will fail.

Rajesh.


------------------------------

From: "Bill McCahey" <billmcc@wnm.univid.com>
Date: 15 Nov 1995 09:41:24 U
Subject: java-interest

                                          java-interest
                                          10:51 AM            11/12/95
unsubsribe interest billmcc@wnm.univid.com

------------------------------

From: John Smart <jsmart@smartny.com>
Date: Wed, 15 Nov 1995 11:12:19 -0500 (EST)
Subject: Re: SunOS 4.1.X

On Mon, 13 Nov 1995, Vitaly Promislov wrote:

We will look around the USA for you. Assume you will need
a Cyrillic version of Netscape. We are curious as our company in
New York builds language translators for messages and we are getting
interest in English->Russian. Is there an ISO Standard for Cyrillic.

==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+
///////  SMART Communications, Inc.      Home of the SMART Expert Editor - Max
  ///    885 Third Avenue, 29th Floor,   SMART Translators - French, Spanish
///      New York, NY 10022  U.S.A.      German, Portuguese, Greek and others.
//////   Tel: USA (212) 486-1894     Fax:  (212) 826-9775   VM (212) 230-3391
E-mail:  info@smartny.com      -|-  Real intelligence applied Artificially  -|
==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==+==

> Date: Mon, 13 Nov 95 13:14:00 ???
> From: Vitaly Promislov <vitaly@diogen.asc.rssi.ru>
> To: java-interest@java.Eng.Sun.COM
> Subject: SunOS 4.1.X
> 
> 
> Hi All
> Does anybody  can point to  successful port of JDK to SunOS
> architecture?
> 
> 
> 
>      Thank you
>          Vitaly Promislov.
> 
> ----------------------------------------------------------------------
> These are my opinions only, and do not reflect anything
> about my employer, Astro Space Center of  Russina Academy of Science. 
> ------------------------------------------------------------------------
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
> 

------------------------------

End of java-interest-digest V1 #264
***********************************



-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post