[3635] in java-interest

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

Re: Instanciation by name

daemon@ATHENA.MIT.EDU (Sami Shaio)
Mon Nov 20 20:20:33 1995

Date: Sun, 19 Nov 1995 15:04:13 -0800
From: Sami.Shaio@Eng.Sun.COM (Sami Shaio)
To: java-interest@java.Eng.Sun.COM, michel@mmania.com

The syntax changed. Try the following:

	b = Class.forName("Class"+"A").newInstance();

--sami

|From michel@mmania.com Sun Nov 19 08:40:23 1995
|Date: Sun, 19 Nov 1995 16:55:48 +0100
|X-Sender: meyerm@mail.francenet.fr (Unverified)
|Mime-Version: 1.0
|To: java-interest@java
|From: michel@mmania.com (Michel MEYER)
|Subject: Instanciation by name
|X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
|
|One can read in the JAVA Specification (4.6 Object Creation -- the new
|Operator) that there is a form of the new operator which allows name
|instanciation, by default calling the default constructor.
|
|Here is what's written:
|
|/-------- begin quote
|
|A third form of allocator allows the class name to be provided as a String
|expression. The String is
|evaluated at runtime, and new returns an object of type Object, which must
|be cast to the desired type.
|
|b = new ( "Class"+"A" );
|
|In this case, the constructor without arguments is called.
|
|/-------- end quote
|
|However, I tryed this and I got an error message at compile time:
|
|
|test.java:7: 'new(...)' not supported.
|                add((A) new ("Class A"));
|                        ^
|
|
|So, as I understand it this feature is not yet implemented. As we are now
|already in beta, I am wondering if this will have any chance to be
|implemented in future releases, or is it a dropped feature ?
|
|Maybe I missed something ... in any case, I would appreciate any answer
|
|
|
|Michel (michel@mmania.com)
|
|########################################################
|##    The (virtual) Baguette: http://www.mmania.com   ##
|########################################################
|
|
|
|-
|This message was sent to the java-interest mailing list
|Info: send 'help' to java-interest-request@java.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