> Roedy Green schrieb:
>> I have heard in JDK 1.6 wil be a new way to invoke the Javac compiler
>> as a class and feed it source directly as strings. I could not find
>> any reference to this. Anyone got an URL or the keywords to find it?
>
> http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompilerTool.html
I miss a file system independent way to compile random created strings.
The created string have to be package independent or have to use an
temporarly
or for this compilation way reserved package.
Furthermore is neccessary to load the compiled class instantly.
It's self-evident to unload or rather to reload the compiled class
if a newer version exist.
Diese Grammatik wurde Ihnen praesentiert von
"Doener mit alles, 1,99 Euro auf der Altendorfer Strasse in Essen".

Signature
Heiner Kücker
www.heinerkuecker.de
www.control-and-command.de
Roedy Green - 18 Feb 2006 19:45 GMT
On Sat, 18 Feb 2006 02:04:25 +0100, "Heiner Kücker"
<mail@heinerkuecker.de> wrote, quoted or indirectly quoted someone who
said :
>I miss a file system independent way to compile random created strings.
that is not hard. Ensuring with 100% surely they are unique is harder.
See http://mindprod.com/jgloss/pseudorandom.html#STRINGS
Quoting from it:
Sometimes you want a random String to use as an
almost unique identifier. You could use code like this:
// generating random hex String up to 16 characters long
private static Random wheel = new Random(); // seed with time of day
// ...
/* To get numeric strings with digits 0-9 try this: */
String almostUniqueAndRandom = Long.toString( wheel.nextLong() &
Long.MAX_VALUE );
/* generate random hex Strings of form
* "0" .. "7fffffffffffffff", a maximum 16 characters long.
* representing 0..Long.MAX_VALUE
* Note there is no such method as Random.nextLong( long ),
* so you have to trim the result to 0..Long.MAX_VALUE yourself.
* To get strings with letters a-f and digits 0-9 try this: */
*/
String almostUniqueAndRandom = Long.toHexString( wheel.nextLong() &
Long.MAX_VALUE );
/* To get strings with letters a-z and digits 0-9 try this: */
String almostUniqueAndRandom = Long.toString( wheel.nextLong() &
Long.MAX_VALUE , 36 );
But what about collisions? How likely are you to run into problems
with uniqueness? In most cases it is highly unlikely you will get
duplicates even though Sun's generator generates many more collisions
than a theoretically perfect true random number generator. Internally
Sun's nextLong uses only a 32-bit generator and it does not cycle
through all possible 32-bit patterns. I have written code to compute
the theoretical possibility of a collision with a perfect true number
generator, and a simulator that exercises Sun's generator and tracks
how well it performs.
The code is posted at
http://mindprod.com/jgloss/pseudorandom.html#STRINGS

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
>http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompilerTool.html
That Javadoc is so frustrating. The classes don't have public
constructors, AND Sun keeps it "secret" where they have hidden static
factories.
I would like it if Javadoc did something to strongly encourage the
documenting of factory methods in the place where the constructor
would usually go.
on the class without a constructor you could say
@factory com.mindprod.example.Builder.create( long );
you could have multiple @factory entries.
You could also use the term @factory on a method by itself, declaring
it is a factory for its return type. That would generate Javadoc
notion both on the method that implement the factory and the Classes
it produces.
Details to be worked out so that it does not generate entries on
classes it could never actually generate even if it generates their
interfaces.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Thomas Hawtin - 19 Feb 2006 08:24 GMT
>> http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompilerTool.html
>
> That Javadoc is so frustrating. The classes don't have public
> constructors, AND Sun keeps it "secret" where they have hidden static
> factories.
Fortunately the JavaDocs were created with -use.
http://download.java.net/jdk6/docs/api/javax/tools/class-use/JavaCompilerTool.html
http://download.java.net/jdk6/docs/api/javax/tools/class-use/Tool.html
A few years ago I started a job by documenting the public API of the
company product. Unfortunately it used Collection for returning
collections. That meant I had to supplement the JavaDocs with
additional, untidy use information. The API was changed before release
to use arrays. With generics that would have been unnecessary.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Roedy Green - 19 Feb 2006 11:14 GMT
On Sun, 19 Feb 2006 08:42:49 +0000, Thomas Hawtin
<usenet@tackline.plus.com> wrote, quoted or indirectly quoted someone
who said :
>Fortunately the JavaDocs were created with -use.
>
>http://download.java.net/jdk6/docs/api/javax/tools/class-use/JavaCompilerTool.html
>http://download.java.net/jdk6/docs/api/javax/tools/class-use/Tool.html
This is so nuts. How long has it been there. I have been wanting this
since day 1 and never realised it was right under my nose.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Thomas Weidenfeller - 20 Feb 2006 08:45 GMT
>> http://download.java.net/jdk6/docs/api/javax/tools/class-use/JavaCompilerTool.html
>> http://download.java.net/jdk6/docs/api/javax/tools/class-use/Tool.html
>
> This is so nuts. How long has it been there. I have been wanting this
> since day 1 and never realised it was right under my nose.
The "Use" links are there since at least J2SE 1.3. They have been
mentioned here a few times.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/