🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17963

Implementing the Parameter Constants

#17963
From: Grant Sayer
Date: Tue, 08 Sep 1998 00:00
45 lines
1686 bytes
Hi

I've got a language question when attempting to implement the Parameter
Constants pattern as written in a javaworld article (see:
http://www.javaworld.com/javaworld/javatips/jw-javatip50.html).
Basically this pattern is a way of providing type safety for constants
defined in a class.   A sample implementation is shown below:

public class ConTest implements ConTest.Parameters {

 public interface Parameters {
  WeekDay SUNDAY = new WeekDay(0);

  final class WeekDay {
   private final int weekday;

   private WeekDay(int i){
    weekday = i;
   }
  }
 }

 public ConTest(Parameters.WeekDay weekday){
 }


 public static void main(String[] args){
  ConTest con = new ConTest(ConTest.SUNDAY);
 }
}

The problem is that when implemented in JBuilder I get a compilation
error  for the line WeekDay SUNDAY = new WeekDay(0); whereby the
compiler complains

"variable this$0 might not have been initialized"

Yet in comparison, compiling & running with JDK 1.1.6 there are no
problems.

Is this a bug in the compiler for JBuilder (version 2.0) ?

Any comments are most welcome

Grant
Technical Details
Message-ID: <35F4F62C.188F6984@unsw.edu.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,dbee29e333f0dc17,start
X-Google-Attributes: gidf74b3,public
From: Grant Sayer <g.sayer@unsw.edu.au>
Subject: Implementing the Parameter Constants
Date: 1998/09/08
Message-ID: <35F4F62C.188F6984@unsw.edu.au>
X-Deja-AN: 388971926
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Reply-To: g.sayer@unsw.edu.au
Newsgroups: borland.public.jbuilder.java.language