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)



Hi, I don't have problem with founding workaround of this case
for example changing private constructor's modifier to protected is easiest one
I'm just curious which tool has a bug (I mean javac or CW)

as I found in java language specification (6.6.8):
"A private class member or constructor is accessible only within the class body in which the member is declared and is not inherited by subclasses"
so it's looks like that anonymous inner class can access private constructor of
the enclosing class (as I understood Andy Lee mentioned it earlier), so CW has a problem
and I have to report a bug

thanks


On Monday, November 25, 2002, at 01:43 PM, Greg Guerin wrote:

Dmitry Markman <email@hidden> wrote:

public class AlignCommand extends AbstractCommand {
public static abstract class Alignment {
public final static Alignment LEFTS = new Alignment("Lefts") {
public void moveBy(Figure f, Rectangle anchor) {
Rectangle rr = f.displayBox();
f.moveBy(anchor.x-rr.x, 0);
}
};

private Alignment(String newDescription) {
...
}
public abstract void moveBy(Figure f, Rectangle anchor);
}
}

I think the way to avoid the problem is to not declare Alignment as
abstract, and to define Alignment.moveBy() as an empty method by default,
with an override in each anonymous subclass. Since all the possible
definitions of Alignment's subclasses are entirely under your control in
exactly one source file, I don't see how you're gaining anything by
declaring it abstract.

I'm wondering if CW may be tripping over the combination of a private
constructor, an abstract superclass, and an anonymous inner class. If you
eliminate the 'abstract' qualifier, and CW still won't compile with the
private constructor, then it could be a bug.

I still think it would be worthwhile to run 'javap' on the output of
'javac', to discover what it's doing about the private constructor. I
suspect it's being promoted to the package-visibility, since the compiler
can't really synthesize an accessor-method that replaces a constructor.
Constructors have the special magic name "<init>", and an arbitrary
synthesized name can't be used as a proxy. In that respect, constructors
are different from any other members that the compiler has to deal with in
synthesizing inner-class accesses.

If javac is promoting the private constructor to package-visibility, then
declaring it private isn't gaining you anything. So just having it be
package-visibility in the source would solve the problem.

-- GG
_______________________________________________
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.


Dmitry Markman, PhD
The Concord Consortium, Concord MA
978-371-1327
_______________________________________________
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: 
 >Re: problem with compiling abstract class with CW (MAC OS X) (From: Greg Guerin <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.