Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with compiling abstract class with CW (MAC OS X)



Dmitry Markman wrote:
|Hi, I tried to compile open source project JHotDraw
|http://jhotdraw.sourceforge.net
|
|But CodeWarrior reports compiler error in one case.
|Here is a pattern that is very similar to pattern used in JHotDraw:
|
|public abstract class TrivialApplication {
|
| public TrivialApplication ta = new TrivialApplication("test"){
| public void abstractMethod(Object foo){
| }
| };
| private TrivialApplication(String str){//private!
| }
| public abstract void abstractMethod(Object foo);
|}
|
| ...
|
|Compiler creates TrivialApplication$1 class (unanimous inner class)
|that derived from abstract class
|TrivialApplication, but constructor is private so it is inaccessible
|from
|children class, right?
|If so, why javac tolerates that case?

To add another variation, Java permits one constructor to call another, so the private constructor might be getting called from a public one:

public abstract class TrivialApplication {

public TrivialApplication ta = new TrivialApplication("test"){
public void abstractMethod(Object foo){
}
};
private TrivialApplication(String str){//private!
}
public abstract void abstractMethod(Object foo);

public TrivialApplication(Date d)
{ this(d.toString());
// other initialization
}
}

(This might be done if the private constructor performs initialization shared between multiple public constructors.)

Given this, it's probably more trouble than it's worth to diagnose the situation (especially as any real problem will be revealed when the "new TrivialApplication(...)" call fails).

Glen Fisher
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >problem with compiling abstract class with CW (MAC OS X) (From: Dmitry Markman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.