[3700] in java-interest

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

Protected is Default? (was Re: Dependencies)

daemon@ATHENA.MIT.EDU (David Geary)
Wed Nov 22 15:46:47 1995

Date: Wed, 22 Nov 1995 10:00:41 -0700
From: David.Geary@Central.Sun.COM (David Geary)
To: mlorton@eshop.com, David.Geary@Central.Sun.COM
Cc: java-interest@java.Eng.Sun.COM

Folks,

  Thanks for all your help on getting two classes that depend upon
each other to compile; I've finally gotten things to work.  Seems I had
a combination of import stupidity (my own) coupled with CLASSPATH misadventures.

  Except ...

  I was under the impression that the default access modifier was protected.
In java.awt.Container:

    Container() {
    }

  So, Container() should be protected, meaning that it can only be accessed
by classes in the same package OR subclasses in a different package, correct?

  I've got this:


trilby >> cat foo/A.java
package foo;

import java.awt.Container;

class A extends Container {
   B b = null;
}

  When I try and compile A.java:


trilby >> javac foo/A.java    
foo/A.java:5: No constructor matching Container() found in class java.awt.Container.
class A extends Container {
      ^
1 error


  If I change Container's default constructor access modifier to protected
explicitly:

	// In Container.java:

	protected Container() {
	}


  and then recompile Container.java, I get:


trilby >> javac foo/A.java
trilby >>


  What's the deal?  Is protected not the default access modifier?
I'm using the BETA release on Solaris 2.4, BTW.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 David Geary                                  "I'm a bad man; I do what I can"
 geary@rmtc.Central.Sun.COM      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
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