|
|
We have some code which builds OK with Sun's JDK 1.3 javac, but gives the following error message when built with JBuilder3: "cannot reference variable markerList before superclass constructor has been called". Will upgrading to JB4 solve this problem? |
|
(Paragraphs culled from a long and confusing thread... This is believed to be correct compiler behavior on JB's part.)
Gillmer Derge writes: When you define an inner class, the compiler adds a reference to the outer class object (usually called something like "this$0", use javap to see it). So when you refer to "markerList" what you're really saying is "this$0.markerList," and since "this$0" is an instance variable declared (implicitly) in this class, you're violating that rule. Now, I may be abusing the JLS by using that quote in a way in which Sun never intended, but I don't think it's clearly an abuse. You might want to try using "Counter.this.markerList" just to see whether that puts you into a different set of compiler rules that don't cause the error message, but I doubt it will help. The following quote from Section 8.8.5.1 of the Java Language Specification http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#229267 covers this issue.
An explicit constructor invocation statement in a constructor body may not refer to any instance variables or instance methods declared in this class or any superclass, or use this or super in any expression; otherwise, a compile-time error occurs. 2001-Sep-08 2:16pm gyles19@visi.com | |
| [Append to This Answer] | |
| 2001-Sep-08 2:16pm |
| ||||||||
|
Java Community
Java Tools |
Code Central JB OpenTools |
Community Recent Threads |
Borland Chat Chat FAQ |
||||||||||||||
|
Feature Matrices 3.0 | 3.5 | 4.0 5.0 | 6.0 | 7.0 |
Shop for JBuilder |
JBuilder Downloads and reg keys |
Report Piracy | ||||||||||||||
|
Online Manuals 4.0 | 5.0 | 6.0 7.0 |
Borland DevSupport's Bug/RFE Form Quality Central Client |
JB Patches & Updates |
JBuilder FAQs TIs | ||||||||||||||
|
JBuilder Newsgroups |
Tamaracka's News Archive |
Mr. Haki's JBuilder Machine |
JGuru's JBuilder FAQ |
||||||||||||||
|
Sun's Bug Parade |
|||||||||||||||||
|
|||||||||||||||||