You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2016/09/28 08:54:50 UTC

[1/4] commons-rng git commit: Fixed the javadoc errors with Java 8

Repository: commons-rng
Updated Branches:
  refs/heads/master fcc9da888 -> fd22dc61f


Fixed the javadoc errors with Java 8


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/41830f7d
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/41830f7d
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/41830f7d

Branch: refs/heads/master
Commit: 41830f7d94bfdb53c04b5c76986f3272fe6cfe64
Parents: fcc9da8
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Wed Sep 28 10:05:47 2016 +0200
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Wed Sep 28 10:05:47 2016 +0200

----------------------------------------------------------------------
 .../org/apache/commons/rng/RandomSource.java    | 28 ++++++++------------
 .../rng/internal/source32/MersenneTwister.java  |  2 +-
 .../internal/source64/MersenneTwister64.java    |  2 +-
 .../commons/rng/internal/source64/TwoCmres.java |  5 ++--
 .../rng/internal/util/NumberFactory.java        | 17 ++++++------
 5 files changed, 24 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/RandomSource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/RandomSource.java b/src/main/java/org/apache/commons/rng/RandomSource.java
index 0c22419..27b67bb 100644
--- a/src/main/java/org/apache/commons/rng/RandomSource.java
+++ b/src/main/java/org/apache/commons/rng/RandomSource.java
@@ -23,8 +23,8 @@ import org.apache.commons.rng.internal.util.SeedFactory;
 
 /**
  * This class provides the API for creating generators of random numbers.
- * <p>
- * Usage examples:
+ * 
+ * <p>Usage examples:</p>
  * <pre><code>
  *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);
  * </code></pre>
@@ -41,7 +41,8 @@ import org.apache.commons.rng.internal.util.SeedFactory;
  * where the first argument to method {@code create} is the identifier
  * of the generator's concrete implementation, and the second the is the
  * (optional) seed.
- * <br>
+ *
+ * <p>
  * In the first form, a random seed will be {@link SeedFactory generated
  * automatically}; in the second form, a fixed seed is used; a random seed
  * is explicitly generated in the third form.
@@ -105,9 +106,11 @@ import org.apache.commons.rng.internal.util.SeedFactory;
  * or arrays of values, of {@code int} or {@code long} types) that can
  * be passed to the {@link RandomSource#create(RandomSource,Object,Object[])
  * generators factory method}.
- * <br>
+ * </p>
+ * <p>
  * Although the seed-generating methods defined in this class will likely
  * return different values each time they are called, there is no guarantee:
+ * </p>
  * <ul>
  *  <li>
  *   In any sub-sequence, it is <a href="https://en.wikipedia.org/wiki/Birthday_problem">
@@ -126,7 +129,6 @@ import org.apache.commons.rng.internal.util.SeedFactory;
  *   or <a href="http://simul.iro.umontreal.ca/testu01/tu01.html">TestU01</a>.
  *  </li>
  * </ul>
- * </p>
  *
  * <p>
  * The current implementations have no provision for producing non-overlapping
@@ -365,12 +367,10 @@ public enum RandomSource {
     /**
      * Creates a random number generator with a random seed.
      *
-     * <p>
-     * Example of usage:
+     * <p>Example of usage:</p>
      * <pre><code>
      *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);
      * </code></pre>
-     * </p>
      *
      * @param source RNG type.
      * @return the RNG.
@@ -382,15 +382,12 @@ public enum RandomSource {
     /**
      * Creates a random number generator with the given {@code seed}.
      *
-     * <p>
-     * Example of usage:
+     * <p>Example of usage:</p>
      * <pre><code>
      *  UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9);
      * </code></pre>
-     * </p>
      *
-     * <p>
-     * Valid types for the {@code seed} are:
+     * <p>Valid types for the {@code seed} are:</p>
      *  <ul>
      *   <li>{@code Integer} (or {@code int})</li>
      *   <li>{@code Long} (or {@code long})</li>
@@ -398,10 +395,8 @@ public enum RandomSource {
      *   <li>{@code long[]}</li>
      *   <li>{@code byte[]}</li>
      *  </ul>
-     * </p>
      *
-     * <p>
-     * Notes:
+     * <p>Notes:</p>
      * <ul>
      *  <li>
      *   When the seed type passed as argument is more complex (i.e. more
@@ -419,7 +414,6 @@ public enum RandomSource {
      *   {@code null}, the size of the generated array will be 128.
      *  </li>
      * </ul>
-     * </p>
      *
      * @param source RNG type.
      * @param seed Seed value.  It can be {@code null} (in which case a

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
index e53ac4e..0626a7d 100644
--- a/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
+++ b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
@@ -49,7 +49,7 @@ import org.apache.commons.rng.internal.util.NumberFactory;
  * and Takuji Nishimura. Here is their original copyright:
  * </p>
  *
- * <table border="0" width="80%" cellpadding="10" align="center" bgcolor="#E0E0E0">
+ * <table border="0" width="80%" cellpadding="10" style="background-color: #E0E0E0" summary="Mersenne Twister licence">
  * <tr><td>Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
  *     All rights reserved.</td></tr>
  *

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
index bee7ece..8943ba6 100644
--- a/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
+++ b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
@@ -35,7 +35,7 @@ import org.apache.commons.rng.internal.util.NumberFactory;
  * Here is their original copyright:
  * </p>
  *
- * <table border="0" width="80%" cellpadding="10" align="center" bgcolor="#E0E0E0">
+ * <table border="0" width="80%" cellpadding="10" style="background-color: #E0E0E0" summary="Mersenne Twister licence">
  * <tr><td>Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura,
  *     All rights reserved.</td></tr>
  *

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java b/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
index 8afe220..2427f60 100644
--- a/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
+++ b/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
@@ -23,13 +23,12 @@ import org.apache.commons.rng.internal.util.NumberFactory;
 
 /**
  * Random number generator designed by Mark D.&nbsp;Overton.
- * <p>
- *  It is one of the many generators described by the author in the following article series:
+ * 
+ * <p>It is one of the many generators described by the author in the following article series:</p>
  *  <ul>
  *   <li><a href="http://www.drdobbs.com/tools/fast-high-quality-parallel-random-number/229625477">Part one</a></li>
  *   <li><a href="http://www.drdobbs.com/tools/fast-high-quality-parallel-random-number/231000484">Part two</a></li>
  *  </ul>
- * </p>
  *
  * @since 1.0
  */

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java b/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
index b769db6..22f1d16 100644
--- a/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
+++ b/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
@@ -112,14 +112,14 @@ public final class NumberFactory {
 
     /**
      * Creates an {@code int} from a {@code long}, using the high order bits.
-     * <p>
-     * The returned value is such that if
+     * 
+     * <p>The returned value is such that if</p>
      * <pre><code>
      *  vL = extractLo(v);
      *  vH = extractHi(v);
      * </code></pre>
-     * then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}.
-     * </p>
+     * 
+     * <p>then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}.</p>
      *
      * @param v Number.
      * @return an {@code int} value made from the most significant bits
@@ -131,14 +131,15 @@ public final class NumberFactory {
 
     /**
      * Creates an {@code int} from a {@code long}, using the low order bits.
-     * <p>
-     * The returned value is such that if
+     * 
+     * <p>The returned value is such that if</p>
+     * 
      * <pre><code>
      *  vL = extractLo(v);
      *  vH = extractHi(v);
      * </code></pre>
-     * then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}.
-     * </p>
+     * 
+     * <p>then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}.</p>
      *
      * @param v Number.
      * @return an {@code int} value made from the least significant bits


Re: [RNG] How to write Javadoc (Was: ... commit: Fixed the javadoc errors with Java 8)

Posted by Gilles <gi...@harfang.homelinux.org>.
On Thu, 29 Sep 2016 10:55:07 +0200, Emmanuel Bourg wrote:
> Le 29/09/2016 � 01:37, Gilles a �crit :
>
>> The more so that the issue was encountered by several people
>> in different components, and IIRC now, the consensus (or
>> workaround) had been to indeed disable "doclint".
>
> This is a wise workaround, fixing old Javadocs is a waste of time, 
> but
> it isn't forbidden. If RNG had hundred of HTML errors I would have 
> just
> disabled doclint when "mvn javadoc:javadoc" is used, but here it was
> easy to fix.
>
>
>> when I raised the issue, and nobody gave a damn
>
> Probably because Javadoc formatting issues aren't important enough 
> for
> people to bother.
>
>
>> I've used <p></p> to create a _paragraph_:
>>  "a distinct section of a piece of writing, usually dealing
>>   with a single theme and indicated by a new line, indentation,
>>   or numbering"
>>
>> Your usage of <p>, even if compliant with the HTML spec, does
>> not comply with the above definition
>
> Maybe you should bring your concerns to the HTML Working Group then.

You known that this is not a very useful suggestion.

I've always assumed that <p> is for paragraph; obviously I
was wrong (for HTML and thus Javadoc).

In "xdoc", it seems that <p> can be used as I want.

IMHO, the term "paragraph" in the HTML spec is confusing
since a <p> that cannot be (fully) used as such.
The standardization committee surely knows that for a long
time, and is not going to change it now.

<div> is indeed what I should have used instead.

>> and makes the Javadoc difficult to read.
>
> The modification I made has no visual impact. These two snippets:
>
>   <p>TOTO list:
>   <ul>
>     <li>One</li>
>     <li>Two</li>
>     <li>Three</li>
>   </ul>
>   Have a nice day!</p>
>
> and:
>
>   <p>TOTO list:</p>
>   <ul>
>     <li>One</li>
>     <li>Two</li>
>     <li>Three</li>
>   </ul>
>   <p>Have a nice day!</p>
>
> are rendered identically in modern browsers.

That's not the point.
I think that developers read much more often the source code than
the rendered HTML (which is mostly for users); that's obviously
why I put emphasis on well and consistently formatted Javadoc.

> And the code readability
> isn't that different.

OK.
I don't agree.

I prefer:
    <div>
     TOTO list:
     <ul>
      <li>
       One (description is usually longer than one word)
      </li>
      <li>
       Two:
      </li>
      <li>
       Three
      </li>
     </ul>

     Have a nice day!
    </div>


>> Is there an HTML element which we can use to make a paragraph
>> (that would allow sample code or a list within it)?
>
> You can use a <div> to mix inline text and lists, but you lose the
> paragraph semantic and the top/bottom margins.

Thanks for the reminder.

Gilles

>
> Emmanuel Bourg
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [RNG] How to write Javadoc (Was: ... commit: Fixed the javadoc errors with Java 8)

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 29/09/2016 � 01:37, Gilles a �crit :

> The more so that the issue was encountered by several people
> in different components, and IIRC now, the consensus (or
> workaround) had been to indeed disable "doclint".

This is a wise workaround, fixing old Javadocs is a waste of time, but
it isn't forbidden. If RNG had hundred of HTML errors I would have just
disabled doclint when "mvn javadoc:javadoc" is used, but here it was
easy to fix.


> when I raised the issue, and nobody gave a damn

Probably because Javadoc formatting issues aren't important enough for
people to bother.


> I've used <p></p> to create a _paragraph_:
>  "a distinct section of a piece of writing, usually dealing
>   with a single theme and indicated by a new line, indentation,
>   or numbering"
> 
> Your usage of <p>, even if compliant with the HTML spec, does
> not comply with the above definition

Maybe you should bring your concerns to the HTML Working Group then.


> and makes the Javadoc difficult to read.

The modification I made has no visual impact. These two snippets:

  <p>TOTO list:
  <ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
  </ul>
  Have a nice day!</p>

and:

  <p>TOTO list:</p>
  <ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
  </ul>
  <p>Have a nice day!</p>

are rendered identically in modern browsers. And the code readability
isn't that different.


> Is there an HTML element which we can use to make a paragraph
> (that would allow sample code or a list within it)?

You can use a <div> to mix inline text and lists, but you lose the
paragraph semantic and the top/bottom margins.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [RNG] How to write Javadoc (Was: ... commit: Fixed the javadoc errors with Java 8)

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 29/09/2016 � 02:07, Gary Gregory a �crit :
> <p>
>   I agree that paragraphs should be written like this.
> </p>

Personally for paragraphs I prefer this more compact form:

  <p>Blah blah blah blah blah blah blah blah blah blah blah blah
  blah blah blah blah blah blah blah blah blah blah blah blah</p>

And with a blank line between paragraphs.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [RNG] How to write Javadoc (Was: ... commit: Fixed the javadoc errors with Java 8)

Posted by Gary Gregory <ga...@gmail.com>.
<p>
  I agree that paragraphs should be written like this.
</p>

Gary

On Wed, Sep 28, 2016 at 4:37 PM, Gilles <gi...@harfang.homelinux.org>
wrote:

>
> Thanks for the non-trivial details that make the change
> understandable.
>
> It would have been nice to post this information on the ML,
> before applying the changes.
> The more so that the issue was encountered by several people
> in different components, and IIRC now, the consensus (or
> workaround) had been to indeed disable "doclint".
>
> With this new specification (where laziness is not forgiven),
> it is even more important than it was (when I raised the
> issue, and nobody gave a damn) to decide together how to
> layout Javadoc comments (so that they are both readable in
> code and compliant).
>
> I've used <p></p> to create a _paragraph_:
>  "a distinct section of a piece of writing, usually dealing
>   with a single theme and indicated by a new line, indentation,
>   or numbering"
>
> Your usage of <p>, even if compliant with the HTML spec, does
> not comply with the above definition, and makes the Javadoc
> difficult to read.
>
> Is there an HTML element which we can use to make a paragraph
> (that would allow sample code or a list within it)?
>
>
> Gilles
>
>
> On Thu, 29 Sep 2016 00:59:48 +0200, Emmanuel Bourg wrote:
>
>> Le 28/09/2016 à 16:40, Gilles a écrit :
>>
>> They are not trivial issues, because they are not seen by everyone.
>>>
>>
>> I'm not sure I have the same definition of "trivial" in my dictionary :)
>>
>>
>> Below, you refer to HTML 5.
>>>
>>> Is the "javadoc" tool assuming that its input is valid HTML 5?
>>>
>>
>> Javadoc in Java 8 is HTML 4 compliant, it'll switch to HTML 5 in Java 9
>> (see JEP 224 [1]).
>>
>> But the rule I mentioned isn't new in HTML 5, it existed before:
>>
>> https://www.w3.org/TR/html401/struct/text.html#edef-P
>>
>> "The P element represents a paragraph. It cannot contain block-level
>> elements (including P itself)."
>>
>>
>> Several years ago, I raise the issue of writing "valid" HTML/XHTML.
>>>
>>> At the time, the answer had been that the Javadoc specification
>>> referred to an older HTML version, and that it was not going to
>>> change, and thus not worth updating the docs in any consistent
>>> way with the recommendation of W3C.
>>>
>>> Has that changed?
>>>
>>
>> It changed with Java 8 enforcing the correctness of the HTML output.
>>
>>
>> No, I purposefully removed that option before rerunning "mvn clean site"!
>>>
>>
>> Perhaps you've run into
>>>   https://issues.apache.org/jira/browse/RNG-1
>>>
>>> All I'm saying is that change must be clarified because it is definitely
>>> not "Java 8" as such that causes the trouble.
>>>
>>
>> Are you using OpenJDK 8 on Debian/Ubuntu? doclint is disabled by default
>> on these systems [2].
>>
>> Emmanuel Bourg
>>
>> [1] http://openjdk.java.net/jeps/224
>> [2]
>>
>> https://sources.debian.net/src/openjdk-8/8u102-b14.1-2/debia
>> n/patches/disable-doclint-by-default.diff/
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

[RNG] How to write Javadoc (Was: ... commit: Fixed the javadoc errors with Java 8)

Posted by Gilles <gi...@harfang.homelinux.org>.
Thanks for the non-trivial details that make the change
understandable.

It would have been nice to post this information on the ML,
before applying the changes.
The more so that the issue was encountered by several people
in different components, and IIRC now, the consensus (or
workaround) had been to indeed disable "doclint".

With this new specification (where laziness is not forgiven),
it is even more important than it was (when I raised the
issue, and nobody gave a damn) to decide together how to
layout Javadoc comments (so that they are both readable in
code and compliant).

I've used <p></p> to create a _paragraph_:
  "a distinct section of a piece of writing, usually dealing
   with a single theme and indicated by a new line, indentation,
   or numbering"

Your usage of <p>, even if compliant with the HTML spec, does
not comply with the above definition, and makes the Javadoc
difficult to read.

Is there an HTML element which we can use to make a paragraph
(that would allow sample code or a list within it)?


Gilles


On Thu, 29 Sep 2016 00:59:48 +0200, Emmanuel Bourg wrote:
> Le 28/09/2016 � 16:40, Gilles a �crit :
>
>> They are not trivial issues, because they are not seen by everyone.
>
> I'm not sure I have the same definition of "trivial" in my dictionary 
> :)
>
>
>> Below, you refer to HTML 5.
>>
>> Is the "javadoc" tool assuming that its input is valid HTML 5?
>
> Javadoc in Java 8 is HTML 4 compliant, it'll switch to HTML 5 in Java 
> 9
> (see JEP 224 [1]).
>
> But the rule I mentioned isn't new in HTML 5, it existed before:
>
> https://www.w3.org/TR/html401/struct/text.html#edef-P
>
> "The P element represents a paragraph. It cannot contain block-level
> elements (including P itself)."
>
>
>> Several years ago, I raise the issue of writing "valid" HTML/XHTML.
>>
>> At the time, the answer had been that the Javadoc specification
>> referred to an older HTML version, and that it was not going to
>> change, and thus not worth updating the docs in any consistent
>> way with the recommendation of W3C.
>>
>> Has that changed?
>
> It changed with Java 8 enforcing the correctness of the HTML output.
>
>
>> No, I purposefully removed that option before rerunning "mvn clean 
>> site"!
>
>> Perhaps you've run into
>>   https://issues.apache.org/jira/browse/RNG-1
>>
>> All I'm saying is that change must be clarified because it is 
>> definitely
>> not "Java 8" as such that causes the trouble.
>
> Are you using OpenJDK 8 on Debian/Ubuntu? doclint is disabled by 
> default
> on these systems [2].
>
> Emmanuel Bourg
>
> [1] http://openjdk.java.net/jeps/224
> [2]
> 
> https://sources.debian.net/src/openjdk-8/8u102-b14.1-2/debian/patches/disable-doclint-by-default.diff/
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [1/4] commons-rng git commit: Fixed the javadoc errors with Java 8

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 28/09/2016 � 16:40, Gilles a �crit :

> They are not trivial issues, because they are not seen by everyone.

I'm not sure I have the same definition of "trivial" in my dictionary :)


> Below, you refer to HTML 5.
> 
> Is the "javadoc" tool assuming that its input is valid HTML 5?

Javadoc in Java 8 is HTML 4 compliant, it'll switch to HTML 5 in Java 9
(see JEP 224 [1]).

But the rule I mentioned isn't new in HTML 5, it existed before:

https://www.w3.org/TR/html401/struct/text.html#edef-P

"The P element represents a paragraph. It cannot contain block-level
elements (including P itself)."


> Several years ago, I raise the issue of writing "valid" HTML/XHTML.
> 
> At the time, the answer had been that the Javadoc specification
> referred to an older HTML version, and that it was not going to
> change, and thus not worth updating the docs in any consistent
> way with the recommendation of W3C.
> 
> Has that changed?

It changed with Java 8 enforcing the correctness of the HTML output.


> No, I purposefully removed that option before rerunning "mvn clean site"!

> Perhaps you've run into
>   https://issues.apache.org/jira/browse/RNG-1
> 
> All I'm saying is that change must be clarified because it is definitely
> not "Java 8" as such that causes the trouble.

Are you using OpenJDK 8 on Debian/Ubuntu? doclint is disabled by default
on these systems [2].

Emmanuel Bourg

[1] http://openjdk.java.net/jeps/224
[2]
https://sources.debian.net/src/openjdk-8/8u102-b14.1-2/debian/patches/disable-doclint-by-default.diff/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [1/4] commons-rng git commit: Fixed the javadoc errors with Java 8

Posted by Gilles <gi...@harfang.homelinux.org>.
On Wed, 28 Sep 2016 15:39:44 +0200, Emmanuel Bourg wrote:
> Le 28/09/2016 � 15:06, Gilles a �crit :
>
>> I use Java 8 and did not get any errors when generating the apidocs.
>>
>> Unless I'm missing something, the above message does not correspond
>> to the change in this commit.
>>
>> The changes themselves contradict usage of the <p> HTML tag: <p> and
>> </p> enclose a paragraph, not a headline.
>>
>> So I think that this change should be reverted.
>>
>> Then please let us know what problems you encountered so we can
>> decide _together_ on how we want Javadoc to be written for this
>> component (and possibly others).
>
> Do we really need to decide together how to fix trivial Javadoc 
> issues?

They are not trivial issues, because they are not seen by everyone.

> I wanted to regenerate the Javadoc and I got several errors when 
> running
> "mvn javadoc:javadoc" on Windows 7 with Java 8u91 and Maven 3.3.9. 
> <ul>
> and <code> enclosed in <p> caused the issue (this is not allowed by 
> the
> HTML specification [1]).

Below, you refer to HTML 5.

Is the "javadoc" tool assuming that its input is valid HTML 5?

Several years ago, I raise the issue of writing "valid" HTML/XHTML.

At the time, the answer had been that the Javadoc specification
referred to an older HTML version, and that it was not going to
change, and thus not worth updating the docs in any consistent
way with the recommendation of W3C.

Has that changed?


> So I simply changed:
>
> <p>blah blah:
> <ul>
>   <li>Blah</li>
> </ul>
> </p>
>
> into the visually equivalent:
>
> <p>blah blah:</p>
> <ul>
>   <li>Blah</li>
> </ul>
>
> You didn't see the errors because -Xdoclint:none is enabled for the 
> site
> phase.

No, I purposefully removed that option before rerunning "mvn clean 
site"!

Perhaps you've run into
   https://issues.apache.org/jira/browse/RNG-1

All I'm saying is that change must be clarified because it is 
definitely
not "Java 8" as such that causes the trouble.


Gilles

>
> Emmanuel Bourg
>
> [1] https://www.w3.org/TR/html5/grouping-content.html#the-p-element
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [1/4] commons-rng git commit: Fixed the javadoc errors with Java 8

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 28/09/2016 � 15:06, Gilles a �crit :

> I use Java 8 and did not get any errors when generating the apidocs.
> 
> Unless I'm missing something, the above message does not correspond
> to the change in this commit.
> 
> The changes themselves contradict usage of the <p> HTML tag: <p> and
> </p> enclose a paragraph, not a headline.
> 
> So I think that this change should be reverted.
> 
> Then please let us know what problems you encountered so we can
> decide _together_ on how we want Javadoc to be written for this
> component (and possibly others).

Do we really need to decide together how to fix trivial Javadoc issues?
I wanted to regenerate the Javadoc and I got several errors when running
"mvn javadoc:javadoc" on Windows 7 with Java 8u91 and Maven 3.3.9. <ul>
and <code> enclosed in <p> caused the issue (this is not allowed by the
HTML specification [1]). So I simply changed:

<p>blah blah:
<ul>
  <li>Blah</li>
</ul>
</p>

into the visually equivalent:

<p>blah blah:</p>
<ul>
  <li>Blah</li>
</ul>

You didn't see the errors because -Xdoclint:none is enabled for the site
phase.

Emmanuel Bourg

[1] https://www.w3.org/TR/html5/grouping-content.html#the-p-element


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [1/4] commons-rng git commit: Fixed the javadoc errors with Java 8

Posted by Gilles <gi...@harfang.homelinux.org>.
Emmanuel,

On Wed, 28 Sep 2016 08:54:50 -0000, ebourg@apache.org wrote:
> Repository: commons-rng
> Updated Branches:
>   refs/heads/master fcc9da888 -> fd22dc61f
>
>
> Fixed the javadoc errors with Java 8

I use Java 8 and did not get any errors when generating the apidocs.

Unless I'm missing something, the above message does not correspond
to the change in this commit.

The changes themselves contradict usage of the <p> HTML tag: <p> and
</p> enclose a paragraph, not a headline.

So I think that this change should be reverted.

Then please let us know what problems you encountered so we can
decide _together_ on how we want Javadoc to be written for this
component (and possibly others).


Thanks,
Gilles

> Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
> Commit: 
> http://git-wip-us.apache.org/repos/asf/commons-rng/commit/41830f7d
> Tree: 
> http://git-wip-us.apache.org/repos/asf/commons-rng/tree/41830f7d
> Diff: 
> http://git-wip-us.apache.org/repos/asf/commons-rng/diff/41830f7d
>
> Branch: refs/heads/master
> Commit: 41830f7d94bfdb53c04b5c76986f3272fe6cfe64
> Parents: fcc9da8
> Author: Emmanuel Bourg <eb...@apache.org>
> Authored: Wed Sep 28 10:05:47 2016 +0200
> Committer: Emmanuel Bourg <eb...@apache.org>
> Committed: Wed Sep 28 10:05:47 2016 +0200
>
> 
> ----------------------------------------------------------------------
>  .../org/apache/commons/rng/RandomSource.java    | 28 
> ++++++++------------
>  .../rng/internal/source32/MersenneTwister.java  |  2 +-
>  .../internal/source64/MersenneTwister64.java    |  2 +-
>  .../commons/rng/internal/source64/TwoCmres.java |  5 ++--
>  .../rng/internal/util/NumberFactory.java        | 17 ++++++------
>  5 files changed, 24 insertions(+), 30 deletions(-)
> 
> ----------------------------------------------------------------------
>
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/RandomSource.java
> 
> ----------------------------------------------------------------------
> diff --git a/src/main/java/org/apache/commons/rng/RandomSource.java
> b/src/main/java/org/apache/commons/rng/RandomSource.java
> index 0c22419..27b67bb 100644
> --- a/src/main/java/org/apache/commons/rng/RandomSource.java
> +++ b/src/main/java/org/apache/commons/rng/RandomSource.java
> @@ -23,8 +23,8 @@ import 
> org.apache.commons.rng.internal.util.SeedFactory;
>
>  /**
>   * This class provides the API for creating generators of random 
> numbers.
> - * <p>
> - * Usage examples:
> + *
> + * <p>Usage examples:</p>
>   * <pre><code>
>   *  UniformRandomProvider rng = 
> RandomSource.create(RandomSource.MT);
>   * </code></pre>
> @@ -41,7 +41,8 @@ import 
> org.apache.commons.rng.internal.util.SeedFactory;
>   * where the first argument to method {@code create} is the 
> identifier
>   * of the generator's concrete implementation, and the second the is 
> the
>   * (optional) seed.
> - * <br>
> + *
> + * <p>
>   * In the first form, a random seed will be {@link SeedFactory 
> generated
>   * automatically}; in the second form, a fixed seed is used; a 
> random seed
>   * is explicitly generated in the third form.
> @@ -105,9 +106,11 @@ import 
> org.apache.commons.rng.internal.util.SeedFactory;
>   * or arrays of values, of {@code int} or {@code long} types) that 
> can
>   * be passed to the {@link 
> RandomSource#create(RandomSource,Object,Object[])
>   * generators factory method}.
> - * <br>
> + * </p>
> + * <p>
>   * Although the seed-generating methods defined in this class will 
> likely
>   * return different values each time they are called, there is no 
> guarantee:
> + * </p>
>   * <ul>
>   *  <li>
>   *   In any sub-sequence, it is <a
> href="https://en.wikipedia.org/wiki/Birthday_problem">
> @@ -126,7 +129,6 @@ import 
> org.apache.commons.rng.internal.util.SeedFactory;
>   *   or <a
> href="http://simul.iro.umontreal.ca/testu01/tu01.html">TestU01</a>.
>   *  </li>
>   * </ul>
> - * </p>
>   *
>   * <p>
>   * The current implementations have no provision for producing
> non-overlapping
> @@ -365,12 +367,10 @@ public enum RandomSource {
>      /**
>       * Creates a random number generator with a random seed.
>       *
> -     * <p>
> -     * Example of usage:
> +     * <p>Example of usage:</p>
>       * <pre><code>
>       *  UniformRandomProvider rng = 
> RandomSource.create(RandomSource.MT);
>       * </code></pre>
> -     * </p>
>       *
>       * @param source RNG type.
>       * @return the RNG.
> @@ -382,15 +382,12 @@ public enum RandomSource {
>      /**
>       * Creates a random number generator with the given {@code 
> seed}.
>       *
> -     * <p>
> -     * Example of usage:
> +     * <p>Example of usage:</p>
>       * <pre><code>
>       *  UniformRandomProvider rng =
> RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9);
>       * </code></pre>
> -     * </p>
>       *
> -     * <p>
> -     * Valid types for the {@code seed} are:
> +     * <p>Valid types for the {@code seed} are:</p>
>       *  <ul>
>       *   <li>{@code Integer} (or {@code int})</li>
>       *   <li>{@code Long} (or {@code long})</li>
> @@ -398,10 +395,8 @@ public enum RandomSource {
>       *   <li>{@code long[]}</li>
>       *   <li>{@code byte[]}</li>
>       *  </ul>
> -     * </p>
>       *
> -     * <p>
> -     * Notes:
> +     * <p>Notes:</p>
>       * <ul>
>       *  <li>
>       *   When the seed type passed as argument is more complex (i.e. 
> more
> @@ -419,7 +414,6 @@ public enum RandomSource {
>       *   {@code null}, the size of the generated array will be 128.
>       *  </li>
>       * </ul>
> -     * </p>
>       *
>       * @param source RNG type.
>       * @param seed Seed value.  It can be {@code null} (in which 
> case a
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
> 
> ----------------------------------------------------------------------
> diff --git
> 
> a/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
> 
> b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
> index e53ac4e..0626a7d 100644
> ---
> 
> a/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
> +++
> 
> b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
> @@ -49,7 +49,7 @@ import 
> org.apache.commons.rng.internal.util.NumberFactory;
>   * and Takuji Nishimura. Here is their original copyright:
>   * </p>
>   *
> - * <table border="0" width="80%" cellpadding="10" align="center"
> bgcolor="#E0E0E0">
> + * <table border="0" width="80%" cellpadding="10"
> style="background-color: #E0E0E0" summary="Mersenne Twister licence">
>   * <tr><td>Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji 
> Nishimura,
>   *     All rights reserved.</td></tr>
>   *
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
> 
> ----------------------------------------------------------------------
> diff --git
> 
> a/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
> 
> b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
> index bee7ece..8943ba6 100644
> ---
> 
> a/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
> +++
> 
> b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
> @@ -35,7 +35,7 @@ import 
> org.apache.commons.rng.internal.util.NumberFactory;
>   * Here is their original copyright:
>   * </p>
>   *
> - * <table border="0" width="80%" cellpadding="10" align="center"
> bgcolor="#E0E0E0">
> + * <table border="0" width="80%" cellpadding="10"
> style="background-color: #E0E0E0" summary="Mersenne Twister licence">
>   * <tr><td>Copyright (C) 2004, Makoto Matsumoto and Takuji 
> Nishimura,
>   *     All rights reserved.</td></tr>
>   *
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
> 
> ----------------------------------------------------------------------
> diff --git
> 
> a/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
> 
> b/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
> index 8afe220..2427f60 100644
> --- 
> a/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
> +++ 
> b/src/main/java/org/apache/commons/rng/internal/source64/TwoCmres.java
> @@ -23,13 +23,12 @@ import
> org.apache.commons.rng.internal.util.NumberFactory;
>
>  /**
>   * Random number generator designed by Mark D.&nbsp;Overton.
> - * <p>
> - *  It is one of the many generators described by the author in the
> following article series:
> + *
> + * <p>It is one of the many generators described by the author in
> the following article series:</p>
>   *  <ul>
>   *   <li><a
> 
> href="http://www.drdobbs.com/tools/fast-high-quality-parallel-random-number/229625477">Part
> one</a></li>
>   *   <li><a
> 
> href="http://www.drdobbs.com/tools/fast-high-quality-parallel-random-number/231000484">Part
> two</a></li>
>   *  </ul>
> - * </p>
>   *
>   * @since 1.0
>   */
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/41830f7d/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
> 
> ----------------------------------------------------------------------
> diff --git
> 
> a/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
> 
> b/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
> index b769db6..22f1d16 100644
> --- 
> a/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
> +++ 
> b/src/main/java/org/apache/commons/rng/internal/util/NumberFactory.java
> @@ -112,14 +112,14 @@ public final class NumberFactory {
>
>      /**
>       * Creates an {@code int} from a {@code long}, using the high
> order bits.
> -     * <p>
> -     * The returned value is such that if
> +     *
> +     * <p>The returned value is such that if</p>
>       * <pre><code>
>       *  vL = extractLo(v);
>       *  vH = extractHi(v);
>       * </code></pre>
> -     * then {@code v} is equal to {@link #makeLong(int,int)
> makeLong(vH, vL)}.
> -     * </p>
> +     *
> +     * <p>then {@code v} is equal to {@link #makeLong(int,int)
> makeLong(vH, vL)}.</p>
>       *
>       * @param v Number.
>       * @return an {@code int} value made from the most significant 
> bits
> @@ -131,14 +131,15 @@ public final class NumberFactory {
>
>      /**
>       * Creates an {@code int} from a {@code long}, using the low 
> order bits.
> -     * <p>
> -     * The returned value is such that if
> +     *
> +     * <p>The returned value is such that if</p>
> +     *
>       * <pre><code>
>       *  vL = extractLo(v);
>       *  vH = extractHi(v);
>       * </code></pre>
> -     * then {@code v} is equal to {@link #makeLong(int,int)
> makeLong(vH, vL)}.
> -     * </p>
> +     *
> +     * <p>then {@code v} is equal to {@link #makeLong(int,int)
> makeLong(vH, vL)}.</p>
>       *
>       * @param v Number.
>       * @return an {@code int} value made from the least significant 
> bits


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[2/4] commons-rng git commit: Added links to Wikipedia in the Javadoc

Posted by eb...@apache.org.
Added links to Wikipedia in the Javadoc


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/d4aa3b6b
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/d4aa3b6b
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/d4aa3b6b

Branch: refs/heads/master
Commit: d4aa3b6b38661e698c7c1952c53c1bd5752d0404
Parents: 41830f7
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Wed Sep 28 10:34:31 2016 +0200
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Wed Sep 28 10:34:31 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/rng/internal/source32/ISAACRandom.java  | 1 +
 .../java/org/apache/commons/rng/internal/source32/KISSRandom.java   | 1 +
 .../org/apache/commons/rng/internal/source32/MersenneTwister.java   | 1 +
 .../apache/commons/rng/internal/source32/MultiplyWithCarry256.java  | 1 +
 .../org/apache/commons/rng/internal/source64/MersenneTwister64.java | 1 +
 .../org/apache/commons/rng/internal/source64/XorShift1024Star.java  | 1 +
 6 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d4aa3b6b/src/main/java/org/apache/commons/rng/internal/source32/ISAACRandom.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source32/ISAACRandom.java b/src/main/java/org/apache/commons/rng/internal/source32/ISAACRandom.java
index 6e6a4db..79433c9 100644
--- a/src/main/java/org/apache/commons/rng/internal/source32/ISAACRandom.java
+++ b/src/main/java/org/apache/commons/rng/internal/source32/ISAACRandom.java
@@ -38,6 +38,7 @@ import org.apache.commons.rng.internal.util.NumberFactory;
  * @see <a href="http://burtleburtle.net/bob/rand/isaacafa.html">
  * ISAAC: a fast cryptographic pseudo-random number generator</a>
  *
+ * @see <a href="https://en.wikipedia.org/wiki/ISAAC_(cipher)">ISAAC (Wikipedia)</a>
  * @since 1.0
  */
 public class ISAACRandom extends IntProvider {

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d4aa3b6b/src/main/java/org/apache/commons/rng/internal/source32/KISSRandom.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source32/KISSRandom.java b/src/main/java/org/apache/commons/rng/internal/source32/KISSRandom.java
index 62ae60b..27bd085 100644
--- a/src/main/java/org/apache/commons/rng/internal/source32/KISSRandom.java
+++ b/src/main/java/org/apache/commons/rng/internal/source32/KISSRandom.java
@@ -26,6 +26,7 @@ import org.apache.commons.rng.internal.util.SeedFactory;
  * <a href="https://programmingpraxis.com/2010/10/05/george-marsaglias-random-number-generators/">here</a>
  * in a reply to the original post.
  *
+ * @see <a href="https://en.wikipedia.org/wiki/KISS_(algorithm)">KISS (Wikipedia)</a>
  * @since 1.0
  */
 public class KISSRandom extends IntProvider {

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d4aa3b6b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
index 0626a7d..baa0793 100644
--- a/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
+++ b/src/main/java/org/apache/commons/rng/internal/source32/MersenneTwister.java
@@ -82,6 +82,7 @@ import org.apache.commons.rng.internal.util.NumberFactory;
  * DAMAGE.</strong></td></tr>
  * </table>
  *
+ * @see <a href="https://en.wikipedia.org/wiki/Mersenne_Twister">Mersenne Twister (Wikipedia)</a>
  * @since 1.0
  */
 public class MersenneTwister extends IntProvider {

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d4aa3b6b/src/main/java/org/apache/commons/rng/internal/source32/MultiplyWithCarry256.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source32/MultiplyWithCarry256.java b/src/main/java/org/apache/commons/rng/internal/source32/MultiplyWithCarry256.java
index 58b48d1..e433b27 100644
--- a/src/main/java/org/apache/commons/rng/internal/source32/MultiplyWithCarry256.java
+++ b/src/main/java/org/apache/commons/rng/internal/source32/MultiplyWithCarry256.java
@@ -30,6 +30,7 @@ import org.apache.commons.rng.internal.util.SeedFactory;
  * that page</a>.
  * </p>
  *
+ * @see <a href="https://en.wikipedia.org/wiki/Multiply-with-carry">Multiply with carry (Wikipedia)</a>
  * @since 1.0
  */
 public class MultiplyWithCarry256 extends IntProvider {

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d4aa3b6b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
index 8943ba6..45a70d3 100644
--- a/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
+++ b/src/main/java/org/apache/commons/rng/internal/source64/MersenneTwister64.java
@@ -68,6 +68,7 @@ import org.apache.commons.rng.internal.util.NumberFactory;
  * DAMAGE.</strong></td></tr>
  * </table>
  *
+ * @see <a href="https://en.wikipedia.org/wiki/Mersenne_Twister">Mersenne Twister (Wikipedia)</a>
  * @since 1.0
  */
 public class MersenneTwister64 extends LongProvider {

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d4aa3b6b/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java b/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
index 18a5225..45aeb08 100644
--- a/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
+++ b/src/main/java/org/apache/commons/rng/internal/source64/XorShift1024Star.java
@@ -26,6 +26,7 @@ import org.apache.commons.rng.internal.util.NumberFactory;
  * @see <a href="http://xorshift.di.unimi.it/xorshift1024star.c">
  * Original source code</a>
  *
+ * @see <a href="https://en.wikipedia.org/wiki/Xorshift">Xorshift (Wikipedia)</a>
  * @since 1.0
  */
 public class XorShift1024Star extends LongProvider {


[3/4] commons-rng git commit: Link JDKRandom to java.util.Random

Posted by eb...@apache.org.
Link JDKRandom to java.util.Random


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/3dddd64b
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/3dddd64b
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/3dddd64b

Branch: refs/heads/master
Commit: 3dddd64b8fd4ea7771592a38e06d3708d8117315
Parents: d4aa3b6
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Wed Sep 28 10:34:53 2016 +0200
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Wed Sep 28 10:34:53 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/rng/internal/source32/JDKRandom.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/3dddd64b/src/main/java/org/apache/commons/rng/internal/source32/JDKRandom.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/source32/JDKRandom.java b/src/main/java/org/apache/commons/rng/internal/source32/JDKRandom.java
index 341cd3b..028469b 100644
--- a/src/main/java/org/apache/commons/rng/internal/source32/JDKRandom.java
+++ b/src/main/java/org/apache/commons/rng/internal/source32/JDKRandom.java
@@ -25,7 +25,7 @@ import java.io.ByteArrayInputStream;
 
 /**
  * A provider that uses the {@link Random#nextInt()} method of the JDK's
- * {@code Random} class as the source of randomness.
+ * {@link Random} class as the source of randomness.
  *
  * <p>
  * <b>Caveat:</b> All the other calls will be redirected to the methods


Re: [4/4] commons-rng git commit: Moved ProviderBuilder to the base package and made it package private

Posted by Gilles <gi...@harfang.homelinux.org>.
On Wed, 28 Sep 2016 19:55:21 -0500, Brent Worden wrote:
> On Wed, Sep 28, 2016 at 6:08 PM, Emmanuel Bourg <eb...@apache.org> 
> wrote:
>
>> Le 28/09/2016 � 17:11, Gilles a �crit :
>>
>> > This what you've done, but it doesn't say why.
>>
>> The class is only used by RandomSource, moving it to the same 
>> package
>> and marking it package private ensures that it can't be mistakenly 
>> used
>> (even if it's marked as internal).
>>
>> Emmanuel Bourg
>>
>>
> If it is only used by RandomSource, would making ProviderBuilder a 
> private,
> inner class provide better isolation and further prevent misuse?

Misuse cannot be prevented; if someone really wants to instantiate it,
he can. [And "misuse" is a strong word: what can one do with that 
class?
Why would someone use it in a way that brings no benefit whatsoever, a
way that would only jeopardize the future of his application?]

The point of putting "non-API" inside an "internal" package is to
clarify the design as much as possible:
* Users, don't use what's in "internal"!
* Contributors, you may need to fiddle with what's in there!

Singling out a class on the basis that in that one case we can use
the package-private feature blurs the design for no significant
advantage.

The same issue of protecting access is posed for all classes in the
"internal" package.
We prevent usage of that one class but not of the others.
If someone wants to shoot himself in the foot, he can do so with
all the other guns.

Consequently, I'm still against that change.


Gilles

>
> Brent


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [4/4] commons-rng git commit: Moved ProviderBuilder to the base package and made it package private

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 29/09/2016 � 02:55, Brent Worden a �crit :

> If it is only used by RandomSource, would making ProviderBuilder a private,
> inner class provide better isolation and further prevent misuse?

From a user point of view this would make no difference. A separate
package private class is as good as a static private inner class.

That said other simplifications are certainly possible, for example the
RandomSourceInternal enum in ProviderBuilder could be merged into
RandomSource. There is no benefit in duplicating this enumeration

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [4/4] commons-rng git commit: Moved ProviderBuilder to the base package and made it package private

Posted by Brent Worden <br...@gmail.com>.
On Wed, Sep 28, 2016 at 6:08 PM, Emmanuel Bourg <eb...@apache.org> wrote:

> Le 28/09/2016 à 17:11, Gilles a écrit :
>
> > This what you've done, but it doesn't say why.
>
> The class is only used by RandomSource, moving it to the same package
> and marking it package private ensures that it can't be mistakenly used
> (even if it's marked as internal).
>
> Emmanuel Bourg
>
>
If it is only used by RandomSource, would making ProviderBuilder a private,
inner class provide better isolation and further prevent misuse?

Brent

Re: [4/4] commons-rng git commit: Moved ProviderBuilder to the base package and made it package private

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 28/09/2016 � 17:11, Gilles a �crit :

> This what you've done, but it doesn't say why.

The class is only used by RandomSource, moving it to the same package
and marking it package private ensures that it can't be mistakenly used
(even if it's marked as internal).

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [4/4] commons-rng git commit: Moved ProviderBuilder to the base package and made it package private

Posted by Gilles <gi...@harfang.homelinux.org>.
Emmanuel,

On Wed, 28 Sep 2016 08:54:53 -0000, ebourg@apache.org wrote:
> Moved ProviderBuilder to the base package and made it package private

This what you've done, but it doesn't say why.

I previously noted that I was wary of crippling the Javadoc (if
the output would not show up for package-private classes).

As far as I can guess, there is no more interest[1] of putting this
at top-level than for any other.

As an internal class, its place is under "internal".

I typically think that such moves should either be discussed,
and/or performed in a branch, so that they are not forced on
everyone before other can understand it and agree on the
implications.

Please revert.


Gilles

[1] Rather less actually as it is quite low-level and frankly ugly.

> Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
> Commit: 
> http://git-wip-us.apache.org/repos/asf/commons-rng/commit/fd22dc61
> Tree: 
> http://git-wip-us.apache.org/repos/asf/commons-rng/tree/fd22dc61
> Diff: 
> http://git-wip-us.apache.org/repos/asf/commons-rng/diff/fd22dc61
>
> Branch: refs/heads/master
> Commit: fd22dc61fd0ea75563ed893ad4857595de58a5dc
> Parents: 3dddd64
> Author: Emmanuel Bourg <eb...@apache.org>
> Authored: Wed Sep 28 10:40:08 2016 +0200
> Committer: Emmanuel Bourg <eb...@apache.org>
> Committed: Wed Sep 28 10:40:08 2016 +0200
>
> 
> ----------------------------------------------------------------------
>  .../org/apache/commons/rng/ProviderBuilder.java | 379 
> ++++++++++++++++++
>  .../org/apache/commons/rng/RandomSource.java    |   2 +-
>  .../commons/rng/internal/ProviderBuilder.java   | 380 
> -------------------
>  .../commons/rng/internal/package-info.java      |   2 +-
>  4 files changed, 381 insertions(+), 382 deletions(-)
> 
> ----------------------------------------------------------------------
>
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/ProviderBuilder.java
> 
> ----------------------------------------------------------------------
> diff --git
> a/src/main/java/org/apache/commons/rng/ProviderBuilder.java
> b/src/main/java/org/apache/commons/rng/ProviderBuilder.java
> new file mode 100644
> index 0000000..76f1668
> --- /dev/null
> +++ b/src/main/java/org/apache/commons/rng/ProviderBuilder.java
> @@ -0,0 +1,379 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or 
> more
> + * contributor license agreements.  See the NOTICE file distributed 
> with
> + * this work for additional information regarding copyright 
> ownership.
> + * The ASF licenses this file to You under the Apache License, 
> Version 2.0
> + * (the "License"); you may not use this file except in compliance 
> with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, 
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> implied.
> + * See the License for the specific language governing permissions 
> and
> + * limitations under the License.
> + */
> +package org.apache.commons.rng;
> +
> +import java.util.Arrays;
> +import java.util.List;
> +import java.util.ArrayList;
> +import java.util.Map;
> +import java.util.HashMap;
> +import java.lang.reflect.Constructor;
> +import java.lang.reflect.InvocationTargetException;
> +
> +import org.apache.commons.rng.internal.util.SeedFactory;
> +import org.apache.commons.rng.internal.util.NoOpConverter;
> +import org.apache.commons.rng.internal.util.Int2Long;
> +import org.apache.commons.rng.internal.util.Long2Int;
> +import org.apache.commons.rng.internal.util.Long2IntArray;
> +import org.apache.commons.rng.internal.util.Long2LongArray;
> +import org.apache.commons.rng.internal.util.IntArray2LongArray;
> +import org.apache.commons.rng.internal.util.LongArray2IntArray;
> +import org.apache.commons.rng.internal.util.LongArray2Long;
> +import org.apache.commons.rng.internal.util.IntArray2Int;
> +import org.apache.commons.rng.internal.util.ByteArray2IntArray;
> +import org.apache.commons.rng.internal.util.ByteArray2LongArray;
> +import org.apache.commons.rng.internal.util.SeedConverter;
> +import org.apache.commons.rng.internal.util.SeedConverterComposer;
> +import org.apache.commons.rng.internal.source32.JDKRandom;
> +import org.apache.commons.rng.internal.source32.Well512a;
> +import org.apache.commons.rng.internal.source32.Well1024a;
> +import org.apache.commons.rng.internal.source32.Well19937a;
> +import org.apache.commons.rng.internal.source32.Well19937c;
> +import org.apache.commons.rng.internal.source32.Well44497a;
> +import org.apache.commons.rng.internal.source32.Well44497b;
> +import org.apache.commons.rng.internal.source32.ISAACRandom;
> +import org.apache.commons.rng.internal.source32.MersenneTwister;
> +import 
> org.apache.commons.rng.internal.source32.MultiplyWithCarry256;
> +import org.apache.commons.rng.internal.source32.KISSRandom;
> +import org.apache.commons.rng.internal.source64.SplitMix64;
> +import org.apache.commons.rng.internal.source64.XorShift1024Star;
> +import org.apache.commons.rng.internal.source64.TwoCmres;
> +import org.apache.commons.rng.internal.source64.MersenneTwister64;
> +
> +/**
> + * RNG builder.
> + * <p>
> + * It uses reflection to find the factory method of the RNG 
> implementation,
> + * and performs seed type conversions.
> + * </p>
> + */
> +class ProviderBuilder {
> +    /** Error message. */
> +    private static final String INTERNAL_ERROR_MSG = "Internal
> error: Please file a bug report";
> +    /** Length of the seed array (for random seed). */
> +    private static final int RANDOM_SEED_ARRAY_SIZE = 128;
> +    /** Seed converter. */
> +    private static final Long2Int LONG_TO_INT = new Long2Int();
> +    /** Seed converter. */
> +    private static final Int2Long INT_TO_LONG = new Int2Long();
> +    /** Seed converter. */
> +    private static final Long2IntArray LONG_TO_INT_ARRAY = new
> Long2IntArray(RANDOM_SEED_ARRAY_SIZE);
> +    /** Seed converter. */
> +    private static final Long2LongArray LONG_TO_LONG_ARRAY = new
> Long2LongArray(RANDOM_SEED_ARRAY_SIZE);
> +    /** Seed converter. */
> +    private static final LongArray2Long LONG_ARRAY_TO_LONG = new
> LongArray2Long();
> +    /** Seed converter. */
> +    private static final IntArray2Int INT_ARRAY_TO_INT = new 
> IntArray2Int();
> +    /** Seed converter. */
> +    private static final LongArray2IntArray LONG_ARRAY_TO_INT_ARRAY
> = new LongArray2IntArray();
> +    /** Seed converter. */
> +    private static final IntArray2LongArray INT_ARRAY_TO_LONG_ARRAY
> = new IntArray2LongArray();
> +    /** Seed converter. */
> +    private static final ByteArray2IntArray BYTE_ARRAY_TO_INT_ARRAY
> = new ByteArray2IntArray();
> +    /** Seed converter. */
> +    private static final ByteArray2LongArray
> BYTE_ARRAY_TO_LONG_ARRAY = new ByteArray2LongArray();
> +    /** Map to convert "Integer" seeds. */
> +    private static final Map<Class<?>, SeedConverter<Integer,?>> 
> CONV_INT =
> +        new HashMap<Class<?>, SeedConverter<Integer,?>>();
> +    /** Map to convert "int[]" seeds. */
> +    private static final Map<Class<?>, SeedConverter<int[],?>>
> CONV_INT_ARRAY =
> +        new HashMap<Class<?>, SeedConverter<int[],?>>();
> +    /** Map to convert "Long" seeds. */
> +    private static final Map<Class<?>, SeedConverter<Long,?>> 
> CONV_LONG =
> +        new HashMap<Class<?>, SeedConverter<Long,?>>();
> +    /** Map to convert "long[]" seeds. */
> +    private static final Map<Class<?>, SeedConverter<long[],?>>
> CONV_LONG_ARRAY =
> +        new HashMap<Class<?>, SeedConverter<long[],?>>();
> +    /** Map to convert "byte[]" seeds. */
> +    private static final Map<Class<?>, SeedConverter<byte[],?>>
> CONV_BYTE_ARRAY =
> +        new HashMap<Class<?>, SeedConverter<byte[],?>>();
> +
> +    static {
> +        // Input seed type is "Long".
> +        // Key is the implementation's "native" seed type.
> +        CONV_LONG.put(Integer.class, LONG_TO_INT);
> +        CONV_LONG.put(Long.class, new NoOpConverter<Long>());
> +        CONV_LONG.put(int[].class, LONG_TO_INT_ARRAY);
> +        CONV_LONG.put(long[].class, LONG_TO_LONG_ARRAY);
> +
> +        // Input seed type is "Integer".
> +        // Key is the implementation's "native" seed type.
> +        CONV_INT.put(Integer.class, new NoOpConverter<Integer>());
> +        CONV_INT.put(Long.class, INT_TO_LONG);
> +        CONV_INT.put(int[].class, new
> SeedConverterComposer<Integer,Long,int[]>(INT_TO_LONG,
> LONG_TO_INT_ARRAY));
> +        CONV_INT.put(long[].class, new
> SeedConverterComposer<Integer,Long,long[]>(INT_TO_LONG,
> LONG_TO_LONG_ARRAY));
> +
> +        // Input seed type is "int[]".
> +        // Key is the implementation's "native" seed type.
> +        CONV_INT_ARRAY.put(Integer.class, INT_ARRAY_TO_INT);
> +        CONV_INT_ARRAY.put(Long.class, new
> SeedConverterComposer<int[],Integer,Long>(INT_ARRAY_TO_INT,
> INT_TO_LONG));
> +        CONV_INT_ARRAY.put(int[].class, new NoOpConverter<int[]>());
> +        CONV_INT_ARRAY.put(long[].class, INT_ARRAY_TO_LONG_ARRAY);
> +
> +        // Input seed type is "long[]".
> +        // Key is the implementation's "native" seed type.
> +        CONV_LONG_ARRAY.put(Integer.class, new
> SeedConverterComposer<long[],Long,Integer>(LONG_ARRAY_TO_LONG,
> LONG_TO_INT));
> +        CONV_LONG_ARRAY.put(Long.class, LONG_ARRAY_TO_LONG);
> +        CONV_LONG_ARRAY.put(int[].class, LONG_ARRAY_TO_INT_ARRAY);
> +        CONV_LONG_ARRAY.put(long[].class, new 
> NoOpConverter<long[]>());
> +
> +        // Input seed type is "byte[]".
> +        // Key is the implementation's "native" seed type.
> +        CONV_BYTE_ARRAY.put(Integer.class, new
> SeedConverterComposer<byte[],int[],Integer>(BYTE_ARRAY_TO_INT_ARRAY,
> INT_ARRAY_TO_INT));
> +        CONV_BYTE_ARRAY.put(Long.class, new
> SeedConverterComposer<byte[],long[],Long>(BYTE_ARRAY_TO_LONG_ARRAY,
> LONG_ARRAY_TO_LONG));
> +        CONV_BYTE_ARRAY.put(int[].class, BYTE_ARRAY_TO_INT_ARRAY);
> +        CONV_BYTE_ARRAY.put(long[].class, BYTE_ARRAY_TO_LONG_ARRAY);
> +    }
> +
> +    /**
> +     * Class only contains static method.
> +     */
> +    private ProviderBuilder() {}
> +
> +    /**
> +     * Creates a RNG instance.
> +     *
> +     * @param source RNG specification.
> +     * @param seed Seed value.  It can be {@code null} (in which 
> case a
> +     * random value will be used).
> +     * @param args Additional arguments to the implementation's 
> constructor.
> +     * @return a new RNG instance.
> +     * @throws UnsupportedOperationException if the seed type is 
> invalid.
> +     */
> +    public static UniformRandomProvider create(RandomSourceInternal 
> source,
> +                                               Object seed,
> +                                               Object[] args) {
> +        // Convert seed to native type.
> +        final Object nativeSeed = createSeed(source, seed);
> +
> +        // Build a single array with all the arguments to be passed
> +        // (in the right order) to the constructor.
> +        final List<Object> all = new ArrayList<Object>();
> +        all.add(nativeSeed);
> +        if (args != null) {
> +            all.addAll(Arrays.asList(args));
> +        }
> +
> +        // Instantiate.
> +        return create(createConstructor(source), all.toArray());
> +    }
> +
> +    /**
> +     * Creates a native seed from any of the supported seed types.
> +     *
> +     * @param source Source.
> +     * @param seed Input seed.
> +     * @return the native seed.
> +     * @throw UnsupportedOperationException if the {@code seed} type
> is invalid.
> +     */
> +    private static Object createSeed(RandomSourceInternal source,
> +                                     Object seed) {
> +        Object nativeSeed = null;
> +
> +        if (seed == null) {
> +            // Create a random seed of the appropriate native type.
> +
> +            if (source.getSeed().equals(Integer.class)) {
> +                nativeSeed = SeedFactory.createInt();
> +            } else if (source.getSeed().equals(Long.class)) {
> +                nativeSeed = SeedFactory.createLong();
> +            } else if (source.getSeed().equals(int[].class)) {
> +                nativeSeed =
> SeedFactory.createIntArray(RANDOM_SEED_ARRAY_SIZE);
> +            } else if (source.getSeed().equals(long[].class)) {
> +                nativeSeed =
> SeedFactory.createLongArray(RANDOM_SEED_ARRAY_SIZE);
> +            } else {
> +                // Source's native type is not handled.
> +                throw new IllegalStateException(INTERNAL_ERROR_MSG);
> +            }
> +        } else {
> +            // Convert to native type.
> +
> +            if (seed instanceof Integer) {
> +                nativeSeed =
> CONV_INT.get(source.getSeed()).convert((Integer) seed);
> +            } else if (seed instanceof Long) {
> +                nativeSeed =
> CONV_LONG.get(source.getSeed()).convert((Long) seed);
> +            } else if (seed instanceof int[]) {
> +                nativeSeed =
> CONV_INT_ARRAY.get(source.getSeed()).convert((int[]) seed);
> +            } else if (seed instanceof long[]) {
> +                nativeSeed =
> CONV_LONG_ARRAY.get(source.getSeed()).convert((long[]) seed);
> +            } else if (seed instanceof byte[]) {
> +                nativeSeed =
> CONV_BYTE_ARRAY.get(source.getSeed()).convert((byte[]) seed);
> +            }
> +
> +            if (nativeSeed == null) {
> +                // Since the input seed was not null, getting here
> means that
> +                // no suitable converter is present in the maps.
> +                throw new
> UnsupportedOperationException("Unrecognized seed type");
> +            }
> +
> +            if (!source.isNativeSeed(nativeSeed)) {
> +                // Conversion setup is wrong.
> +                throw new IllegalStateException(INTERNAL_ERROR_MSG);
> +            }
> +        }
> +
> +        return nativeSeed;
> +    }
> +
> +    /**
> +     * Creates a constructor.
> +     *
> +     * @param source RNG specification.
> +     * @return a RNG constructor.
> +     */
> +    private static Constructor<?>
> createConstructor(RandomSourceInternal source) {
> +        try {
> +            return source.getRng().getConstructor(source.getArgs());
> +        } catch (NoSuchMethodException e) {
> +            // Info in "RandomSourceInternal" is inconsistent with 
> the
> +            // constructor of the implementation.
> +            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> +        }
> +    }
> +
> +    /**
> +     * Creates a RNG.
> +     *
> +     * @param rng RNG specification.
> +     * @param args Arguments to the implementation's constructor.
> +     * @return a new RNG instance.
> +     */
> +    private static UniformRandomProvider create(Constructor<?> rng,
> +                                                Object[] args) {
> +        try {
> +            return (UniformRandomProvider) rng.newInstance(args);
> +        } catch (InvocationTargetException e) {
> +            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> +        } catch (InstantiationException e) {
> +            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> +        } catch (IllegalAccessException e) {
> +            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> +        }
> +    }
> +
> +    /**
> +     * Identifiers of the generators.
> +     */
> +    public enum RandomSourceInternal {
> +        /** Source of randomness is {@link JDKRandom}. */
> +        JDK(JDKRandom.class,
> +            Long.class),
> +        /** Source of randomness is {@link Well512a}. */
> +        WELL_512_A(Well512a.class,
> +                   int[].class),
> +        /** Source of randomness is {@link Well1024a}. */
> +        WELL_1024_A(Well1024a.class,
> +                    int[].class),
> +        /** Source of randomness is {@link Well19937a}. */
> +        WELL_19937_A(Well19937a.class,
> +                     int[].class),
> +        /** Source of randomness is {@link Well19937c}. */
> +        WELL_19937_C(Well19937c.class,
> +                     int[].class),
> +        /** Source of randomness is {@link Well44497a}. */
> +        WELL_44497_A(Well44497a.class,
> +                     int[].class),
> +        /** Source of randomness is {@link Well44497b}. */
> +        WELL_44497_B(Well44497b.class,
> +                     int[].class),
> +        /** Source of randomness is {@link MersenneTwister}. */
> +        MT(MersenneTwister.class,
> +           int[].class),
> +        /** Source of randomness is {@link ISAACRandom}. */
> +        ISAAC(ISAACRandom.class,
> +              int[].class),
> +        /** Source of randomness is {@link SplitMix64}. */
> +        SPLIT_MIX_64(SplitMix64.class,
> +                     Long.class),
> +        /** Source of randomness is {@link XorShift1024Star}. */
> +        XOR_SHIFT_1024_S(XorShift1024Star.class,
> +                         long[].class),
> +        /** Source of randomness is {@link TwoCmres}. */
> +        TWO_CMRES(TwoCmres.class,
> +                  Integer.class),
> +        /**
> +         * Source of randomness is {@link TwoCmres} with explicit 
> selection
> +         * of the two subcycle generators.
> +         */
> +        TWO_CMRES_SELECT(TwoCmres.class,
> +                         Integer.class,
> +                         Integer.TYPE,
> +                         Integer.TYPE),
> +        /** Source of randomness is {@link MersenneTwister64}. */
> +        MT_64(MersenneTwister64.class,
> +              long[].class),
> +        /** Source of randomness is {@link MultiplyWithCarry256}. */
> +        MWC_256(MultiplyWithCarry256.class,
> +                int[].class),
> +        /** Source of randomness is {@link KISSRandom}. */
> +        KISS(KISSRandom.class,
> +             int[].class);
> +
> +        /** Source type. */
> +        private final Class<? extends UniformRandomProvider> rng;
> +        /** Data needed to build the generator. */
> +        private final Class<?>[] args;
> +
> +        /**
> +         * @param rng Source type.
> +         * @param args Data needed to create a generator instance.
> +         * The first element must be the native seed type.
> +         */
> +        RandomSourceInternal(Class<? extends UniformRandomProvider> 
> rng,
> +                             Class<?> ... args) {
> +            this.rng = rng;
> +            this.args = Arrays.copyOf(args, args.length);
> +        }
> +
> +        /**
> +         * @return the source type.
> +         */
> +        public Class<?> getRng() {
> +            return rng;
> +        }
> +
> +        /**
> +         * @return the seed type.
> +         */
> +        Class<?> getSeed() {
> +            return args[0];
> +        }
> +
> +        /**
> +         * @return the data needed to build the generator.
> +         */
> +        Class<?>[] getArgs() {
> +            return args;
> +        }
> +
> +        /**
> +         * Checks whether the type of given {@code seed} is the 
> native type
> +         * of the implementation.
> +         *
> +         * @param <SEED> Seed type.
> +         *
> +         * @param seed Seed value.
> +         * @return {@code true} if the seed can be passed to the 
> builder
> +         * for this RNG type.
> +         */
> +        public <SEED> boolean isNativeSeed(SEED seed) {
> +            return seed == null ?
> +                false :
> +                getSeed().equals(seed.getClass());
> +        }
> +    }
> +}
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/RandomSource.java
> 
> ----------------------------------------------------------------------
> diff --git a/src/main/java/org/apache/commons/rng/RandomSource.java
> b/src/main/java/org/apache/commons/rng/RandomSource.java
> index 27b67bb..efacdca 100644
> --- a/src/main/java/org/apache/commons/rng/RandomSource.java
> +++ b/src/main/java/org/apache/commons/rng/RandomSource.java
> @@ -17,7 +17,7 @@
>  package org.apache.commons.rng;
>
>  import java.util.Arrays;
> -import org.apache.commons.rng.internal.ProviderBuilder;
> +
>  import org.apache.commons.rng.internal.BaseProvider;
>  import org.apache.commons.rng.internal.util.SeedFactory;
>
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
> 
> ----------------------------------------------------------------------
> diff --git
> a/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
> b/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
> deleted file mode 100644
> index 93ad3d9..0000000
> --- 
> a/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
> +++ /dev/null
> @@ -1,380 +0,0 @@
> -/*
> - * Licensed to the Apache Software Foundation (ASF) under one or 
> more
> - * contributor license agreements.  See the NOTICE file distributed 
> with
> - * this work for additional information regarding copyright 
> ownership.
> - * The ASF licenses this file to You under the Apache License, 
> Version 2.0
> - * (the "License"); you may not use this file except in compliance 
> with
> - * the License.  You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, 
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> implied.
> - * See the License for the specific language governing permissions 
> and
> - * limitations under the License.
> - */
> -package org.apache.commons.rng.internal;
> -
> -import java.util.Arrays;
> -import java.util.List;
> -import java.util.ArrayList;
> -import java.util.Map;
> -import java.util.HashMap;
> -import java.lang.reflect.Constructor;
> -import java.lang.reflect.InvocationTargetException;
> -
> -import org.apache.commons.rng.UniformRandomProvider;
> -import org.apache.commons.rng.internal.util.SeedFactory;
> -import org.apache.commons.rng.internal.util.NoOpConverter;
> -import org.apache.commons.rng.internal.util.Int2Long;
> -import org.apache.commons.rng.internal.util.Long2Int;
> -import org.apache.commons.rng.internal.util.Long2IntArray;
> -import org.apache.commons.rng.internal.util.Long2LongArray;
> -import org.apache.commons.rng.internal.util.IntArray2LongArray;
> -import org.apache.commons.rng.internal.util.LongArray2IntArray;
> -import org.apache.commons.rng.internal.util.LongArray2Long;
> -import org.apache.commons.rng.internal.util.IntArray2Int;
> -import org.apache.commons.rng.internal.util.ByteArray2IntArray;
> -import org.apache.commons.rng.internal.util.ByteArray2LongArray;
> -import org.apache.commons.rng.internal.util.SeedConverter;
> -import org.apache.commons.rng.internal.util.SeedConverterComposer;
> -import org.apache.commons.rng.internal.source32.JDKRandom;
> -import org.apache.commons.rng.internal.source32.Well512a;
> -import org.apache.commons.rng.internal.source32.Well1024a;
> -import org.apache.commons.rng.internal.source32.Well19937a;
> -import org.apache.commons.rng.internal.source32.Well19937c;
> -import org.apache.commons.rng.internal.source32.Well44497a;
> -import org.apache.commons.rng.internal.source32.Well44497b;
> -import org.apache.commons.rng.internal.source32.ISAACRandom;
> -import org.apache.commons.rng.internal.source32.MersenneTwister;
> -import 
> org.apache.commons.rng.internal.source32.MultiplyWithCarry256;
> -import org.apache.commons.rng.internal.source32.KISSRandom;
> -import org.apache.commons.rng.internal.source64.SplitMix64;
> -import org.apache.commons.rng.internal.source64.XorShift1024Star;
> -import org.apache.commons.rng.internal.source64.TwoCmres;
> -import org.apache.commons.rng.internal.source64.MersenneTwister64;
> -
> -/**
> - * RNG builder.
> - * <p>
> - * It uses reflection to find the factory method of the RNG 
> implementation,
> - * and performs seed type conversions.
> - * </p>
> - */
> -public class ProviderBuilder {
> -    /** Error message. */
> -    private static final String INTERNAL_ERROR_MSG = "Internal
> error: Please file a bug report";
> -    /** Length of the seed array (for random seed). */
> -    private static final int RANDOM_SEED_ARRAY_SIZE = 128;
> -    /** Seed converter. */
> -    private static final Long2Int LONG_TO_INT = new Long2Int();
> -    /** Seed converter. */
> -    private static final Int2Long INT_TO_LONG = new Int2Long();
> -    /** Seed converter. */
> -    private static final Long2IntArray LONG_TO_INT_ARRAY = new
> Long2IntArray(RANDOM_SEED_ARRAY_SIZE);
> -    /** Seed converter. */
> -    private static final Long2LongArray LONG_TO_LONG_ARRAY = new
> Long2LongArray(RANDOM_SEED_ARRAY_SIZE);
> -    /** Seed converter. */
> -    private static final LongArray2Long LONG_ARRAY_TO_LONG = new
> LongArray2Long();
> -    /** Seed converter. */
> -    private static final IntArray2Int INT_ARRAY_TO_INT = new 
> IntArray2Int();
> -    /** Seed converter. */
> -    private static final LongArray2IntArray LONG_ARRAY_TO_INT_ARRAY
> = new LongArray2IntArray();
> -    /** Seed converter. */
> -    private static final IntArray2LongArray INT_ARRAY_TO_LONG_ARRAY
> = new IntArray2LongArray();
> -    /** Seed converter. */
> -    private static final ByteArray2IntArray BYTE_ARRAY_TO_INT_ARRAY
> = new ByteArray2IntArray();
> -    /** Seed converter. */
> -    private static final ByteArray2LongArray
> BYTE_ARRAY_TO_LONG_ARRAY = new ByteArray2LongArray();
> -    /** Map to convert "Integer" seeds. */
> -    private static final Map<Class<?>, SeedConverter<Integer,?>> 
> CONV_INT =
> -        new HashMap<Class<?>, SeedConverter<Integer,?>>();
> -    /** Map to convert "int[]" seeds. */
> -    private static final Map<Class<?>, SeedConverter<int[],?>>
> CONV_INT_ARRAY =
> -        new HashMap<Class<?>, SeedConverter<int[],?>>();
> -    /** Map to convert "Long" seeds. */
> -    private static final Map<Class<?>, SeedConverter<Long,?>> 
> CONV_LONG =
> -        new HashMap<Class<?>, SeedConverter<Long,?>>();
> -    /** Map to convert "long[]" seeds. */
> -    private static final Map<Class<?>, SeedConverter<long[],?>>
> CONV_LONG_ARRAY =
> -        new HashMap<Class<?>, SeedConverter<long[],?>>();
> -    /** Map to convert "byte[]" seeds. */
> -    private static final Map<Class<?>, SeedConverter<byte[],?>>
> CONV_BYTE_ARRAY =
> -        new HashMap<Class<?>, SeedConverter<byte[],?>>();
> -
> -    static {
> -        // Input seed type is "Long".
> -        // Key is the implementation's "native" seed type.
> -        CONV_LONG.put(Integer.class, LONG_TO_INT);
> -        CONV_LONG.put(Long.class, new NoOpConverter<Long>());
> -        CONV_LONG.put(int[].class, LONG_TO_INT_ARRAY);
> -        CONV_LONG.put(long[].class, LONG_TO_LONG_ARRAY);
> -
> -        // Input seed type is "Integer".
> -        // Key is the implementation's "native" seed type.
> -        CONV_INT.put(Integer.class, new NoOpConverter<Integer>());
> -        CONV_INT.put(Long.class, INT_TO_LONG);
> -        CONV_INT.put(int[].class, new
> SeedConverterComposer<Integer,Long,int[]>(INT_TO_LONG,
> LONG_TO_INT_ARRAY));
> -        CONV_INT.put(long[].class, new
> SeedConverterComposer<Integer,Long,long[]>(INT_TO_LONG,
> LONG_TO_LONG_ARRAY));
> -
> -        // Input seed type is "int[]".
> -        // Key is the implementation's "native" seed type.
> -        CONV_INT_ARRAY.put(Integer.class, INT_ARRAY_TO_INT);
> -        CONV_INT_ARRAY.put(Long.class, new
> SeedConverterComposer<int[],Integer,Long>(INT_ARRAY_TO_INT,
> INT_TO_LONG));
> -        CONV_INT_ARRAY.put(int[].class, new NoOpConverter<int[]>());
> -        CONV_INT_ARRAY.put(long[].class, INT_ARRAY_TO_LONG_ARRAY);
> -
> -        // Input seed type is "long[]".
> -        // Key is the implementation's "native" seed type.
> -        CONV_LONG_ARRAY.put(Integer.class, new
> SeedConverterComposer<long[],Long,Integer>(LONG_ARRAY_TO_LONG,
> LONG_TO_INT));
> -        CONV_LONG_ARRAY.put(Long.class, LONG_ARRAY_TO_LONG);
> -        CONV_LONG_ARRAY.put(int[].class, LONG_ARRAY_TO_INT_ARRAY);
> -        CONV_LONG_ARRAY.put(long[].class, new 
> NoOpConverter<long[]>());
> -
> -        // Input seed type is "byte[]".
> -        // Key is the implementation's "native" seed type.
> -        CONV_BYTE_ARRAY.put(Integer.class, new
> SeedConverterComposer<byte[],int[],Integer>(BYTE_ARRAY_TO_INT_ARRAY,
> INT_ARRAY_TO_INT));
> -        CONV_BYTE_ARRAY.put(Long.class, new
> SeedConverterComposer<byte[],long[],Long>(BYTE_ARRAY_TO_LONG_ARRAY,
> LONG_ARRAY_TO_LONG));
> -        CONV_BYTE_ARRAY.put(int[].class, BYTE_ARRAY_TO_INT_ARRAY);
> -        CONV_BYTE_ARRAY.put(long[].class, BYTE_ARRAY_TO_LONG_ARRAY);
> -    }
> -
> -    /**
> -     * Class only contains static method.
> -     */
> -    private ProviderBuilder() {}
> -
> -    /**
> -     * Creates a RNG instance.
> -     *
> -     * @param source RNG specification.
> -     * @param seed Seed value.  It can be {@code null} (in which 
> case a
> -     * random value will be used).
> -     * @param args Additional arguments to the implementation's 
> constructor.
> -     * @return a new RNG instance.
> -     * @throws UnsupportedOperationException if the seed type is 
> invalid.
> -     */
> -    public static UniformRandomProvider create(RandomSourceInternal 
> source,
> -                                               Object seed,
> -                                               Object[] args) {
> -        // Convert seed to native type.
> -        final Object nativeSeed = createSeed(source, seed);
> -
> -        // Build a single array with all the arguments to be passed
> -        // (in the right order) to the constructor.
> -        final List<Object> all = new ArrayList<Object>();
> -        all.add(nativeSeed);
> -        if (args != null) {
> -            all.addAll(Arrays.asList(args));
> -        }
> -
> -        // Instantiate.
> -        return create(createConstructor(source), all.toArray());
> -    }
> -
> -    /**
> -     * Creates a native seed from any of the supported seed types.
> -     *
> -     * @param source Source.
> -     * @param seed Input seed.
> -     * @return the native seed.
> -     * @throw UnsupportedOperationException if the {@code seed} type
> is invalid.
> -     */
> -    private static Object createSeed(RandomSourceInternal source,
> -                                     Object seed) {
> -        Object nativeSeed = null;
> -
> -        if (seed == null) {
> -            // Create a random seed of the appropriate native type.
> -
> -            if (source.getSeed().equals(Integer.class)) {
> -                nativeSeed = SeedFactory.createInt();
> -            } else if (source.getSeed().equals(Long.class)) {
> -                nativeSeed = SeedFactory.createLong();
> -            } else if (source.getSeed().equals(int[].class)) {
> -                nativeSeed =
> SeedFactory.createIntArray(RANDOM_SEED_ARRAY_SIZE);
> -            } else if (source.getSeed().equals(long[].class)) {
> -                nativeSeed =
> SeedFactory.createLongArray(RANDOM_SEED_ARRAY_SIZE);
> -            } else {
> -                // Source's native type is not handled.
> -                throw new IllegalStateException(INTERNAL_ERROR_MSG);
> -            }
> -        } else {
> -            // Convert to native type.
> -
> -            if (seed instanceof Integer) {
> -                nativeSeed =
> CONV_INT.get(source.getSeed()).convert((Integer) seed);
> -            } else if (seed instanceof Long) {
> -                nativeSeed =
> CONV_LONG.get(source.getSeed()).convert((Long) seed);
> -            } else if (seed instanceof int[]) {
> -                nativeSeed =
> CONV_INT_ARRAY.get(source.getSeed()).convert((int[]) seed);
> -            } else if (seed instanceof long[]) {
> -                nativeSeed =
> CONV_LONG_ARRAY.get(source.getSeed()).convert((long[]) seed);
> -            } else if (seed instanceof byte[]) {
> -                nativeSeed =
> CONV_BYTE_ARRAY.get(source.getSeed()).convert((byte[]) seed);
> -            }
> -
> -            if (nativeSeed == null) {
> -                // Since the input seed was not null, getting here
> means that
> -                // no suitable converter is present in the maps.
> -                throw new
> UnsupportedOperationException("Unrecognized seed type");
> -            }
> -
> -            if (!source.isNativeSeed(nativeSeed)) {
> -                // Conversion setup is wrong.
> -                throw new IllegalStateException(INTERNAL_ERROR_MSG);
> -            }
> -        }
> -
> -        return nativeSeed;
> -    }
> -
> -    /**
> -     * Creates a constructor.
> -     *
> -     * @param source RNG specification.
> -     * @return a RNG constructor.
> -     */
> -    private static Constructor<?>
> createConstructor(RandomSourceInternal source) {
> -        try {
> -            return source.getRng().getConstructor(source.getArgs());
> -        } catch (NoSuchMethodException e) {
> -            // Info in "RandomSourceInternal" is inconsistent with 
> the
> -            // constructor of the implementation.
> -            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> -        }
> -    }
> -
> -    /**
> -     * Creates a RNG.
> -     *
> -     * @param rng RNG specification.
> -     * @param args Arguments to the implementation's constructor.
> -     * @return a new RNG instance.
> -     */
> -    private static UniformRandomProvider create(Constructor<?> rng,
> -                                                Object[] args) {
> -        try {
> -            return (UniformRandomProvider) rng.newInstance(args);
> -        } catch (InvocationTargetException e) {
> -            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> -        } catch (InstantiationException e) {
> -            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> -        } catch (IllegalAccessException e) {
> -            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
> -        }
> -    }
> -
> -    /**
> -     * Identifiers of the generators.
> -     */
> -    public enum RandomSourceInternal {
> -        /** Source of randomness is {@link JDKRandom}. */
> -        JDK(JDKRandom.class,
> -            Long.class),
> -        /** Source of randomness is {@link Well512a}. */
> -        WELL_512_A(Well512a.class,
> -                   int[].class),
> -        /** Source of randomness is {@link Well1024a}. */
> -        WELL_1024_A(Well1024a.class,
> -                    int[].class),
> -        /** Source of randomness is {@link Well19937a}. */
> -        WELL_19937_A(Well19937a.class,
> -                     int[].class),
> -        /** Source of randomness is {@link Well19937c}. */
> -        WELL_19937_C(Well19937c.class,
> -                     int[].class),
> -        /** Source of randomness is {@link Well44497a}. */
> -        WELL_44497_A(Well44497a.class,
> -                     int[].class),
> -        /** Source of randomness is {@link Well44497b}. */
> -        WELL_44497_B(Well44497b.class,
> -                     int[].class),
> -        /** Source of randomness is {@link MersenneTwister}. */
> -        MT(MersenneTwister.class,
> -           int[].class),
> -        /** Source of randomness is {@link ISAACRandom}. */
> -        ISAAC(ISAACRandom.class,
> -              int[].class),
> -        /** Source of randomness is {@link SplitMix64}. */
> -        SPLIT_MIX_64(SplitMix64.class,
> -                     Long.class),
> -        /** Source of randomness is {@link XorShift1024Star}. */
> -        XOR_SHIFT_1024_S(XorShift1024Star.class,
> -                         long[].class),
> -        /** Source of randomness is {@link TwoCmres}. */
> -        TWO_CMRES(TwoCmres.class,
> -                  Integer.class),
> -        /**
> -         * Source of randomness is {@link TwoCmres} with explicit 
> selection
> -         * of the two subcycle generators.
> -         */
> -        TWO_CMRES_SELECT(TwoCmres.class,
> -                         Integer.class,
> -                         Integer.TYPE,
> -                         Integer.TYPE),
> -        /** Source of randomness is {@link MersenneTwister64}. */
> -        MT_64(MersenneTwister64.class,
> -              long[].class),
> -        /** Source of randomness is {@link MultiplyWithCarry256}. */
> -        MWC_256(MultiplyWithCarry256.class,
> -                int[].class),
> -        /** Source of randomness is {@link KISSRandom}. */
> -        KISS(KISSRandom.class,
> -             int[].class);
> -
> -        /** Source type. */
> -        private final Class<? extends UniformRandomProvider> rng;
> -        /** Data needed to build the generator. */
> -        private final Class<?>[] args;
> -
> -        /**
> -         * @param rng Source type.
> -         * @param args Data needed to create a generator instance.
> -         * The first element must be the native seed type.
> -         */
> -        RandomSourceInternal(Class<? extends UniformRandomProvider> 
> rng,
> -                             Class<?> ... args) {
> -            this.rng = rng;
> -            this.args = Arrays.copyOf(args, args.length);
> -        }
> -
> -        /**
> -         * @return the source type.
> -         */
> -        public Class<?> getRng() {
> -            return rng;
> -        }
> -
> -        /**
> -         * @return the seed type.
> -         */
> -        Class<?> getSeed() {
> -            return args[0];
> -        }
> -
> -        /**
> -         * @return the data needed to build the generator.
> -         */
> -        Class<?>[] getArgs() {
> -            return args;
> -        }
> -
> -        /**
> -         * Checks whether the type of given {@code seed} is the 
> native type
> -         * of the implementation.
> -         *
> -         * @param <SEED> Seed type.
> -         *
> -         * @param seed Seed value.
> -         * @return {@code true} if the seed can be passed to the 
> builder
> -         * for this RNG type.
> -         */
> -        public <SEED> boolean isNativeSeed(SEED seed) {
> -            return seed == null ?
> -                false :
> -                getSeed().equals(seed.getClass());
> -        }
> -    }
> -}
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/internal/package-info.java
> 
> ----------------------------------------------------------------------
> diff --git
> a/src/main/java/org/apache/commons/rng/internal/package-info.java
> b/src/main/java/org/apache/commons/rng/internal/package-info.java
> index dba9e64..e3590c9 100644
> --- a/src/main/java/org/apache/commons/rng/internal/package-info.java
> +++ b/src/main/java/org/apache/commons/rng/internal/package-info.java
> @@ -43,7 +43,7 @@
>   *
>   * <p>
>   * Each implementation must have an identifier in
> - * {@link
> org.apache.commons.rng.internal.ProviderBuilder.RandomSourceInternal}
> + * {@link 
> org.apache.commons.rng.ProviderBuilder.RandomSourceInternal}
>   * which must be referred to from the {@link
> org.apache.commons.rng.RandomSource public API}.
>   * </p>
>   */



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[4/4] commons-rng git commit: Moved ProviderBuilder to the base package and made it package private

Posted by eb...@apache.org.
Moved ProviderBuilder to the base package and made it package private


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/fd22dc61
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/fd22dc61
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/fd22dc61

Branch: refs/heads/master
Commit: fd22dc61fd0ea75563ed893ad4857595de58a5dc
Parents: 3dddd64
Author: Emmanuel Bourg <eb...@apache.org>
Authored: Wed Sep 28 10:40:08 2016 +0200
Committer: Emmanuel Bourg <eb...@apache.org>
Committed: Wed Sep 28 10:40:08 2016 +0200

----------------------------------------------------------------------
 .../org/apache/commons/rng/ProviderBuilder.java | 379 ++++++++++++++++++
 .../org/apache/commons/rng/RandomSource.java    |   2 +-
 .../commons/rng/internal/ProviderBuilder.java   | 380 -------------------
 .../commons/rng/internal/package-info.java      |   2 +-
 4 files changed, 381 insertions(+), 382 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/ProviderBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/ProviderBuilder.java b/src/main/java/org/apache/commons/rng/ProviderBuilder.java
new file mode 100644
index 0000000..76f1668
--- /dev/null
+++ b/src/main/java/org/apache/commons/rng/ProviderBuilder.java
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.commons.rng.internal.util.SeedFactory;
+import org.apache.commons.rng.internal.util.NoOpConverter;
+import org.apache.commons.rng.internal.util.Int2Long;
+import org.apache.commons.rng.internal.util.Long2Int;
+import org.apache.commons.rng.internal.util.Long2IntArray;
+import org.apache.commons.rng.internal.util.Long2LongArray;
+import org.apache.commons.rng.internal.util.IntArray2LongArray;
+import org.apache.commons.rng.internal.util.LongArray2IntArray;
+import org.apache.commons.rng.internal.util.LongArray2Long;
+import org.apache.commons.rng.internal.util.IntArray2Int;
+import org.apache.commons.rng.internal.util.ByteArray2IntArray;
+import org.apache.commons.rng.internal.util.ByteArray2LongArray;
+import org.apache.commons.rng.internal.util.SeedConverter;
+import org.apache.commons.rng.internal.util.SeedConverterComposer;
+import org.apache.commons.rng.internal.source32.JDKRandom;
+import org.apache.commons.rng.internal.source32.Well512a;
+import org.apache.commons.rng.internal.source32.Well1024a;
+import org.apache.commons.rng.internal.source32.Well19937a;
+import org.apache.commons.rng.internal.source32.Well19937c;
+import org.apache.commons.rng.internal.source32.Well44497a;
+import org.apache.commons.rng.internal.source32.Well44497b;
+import org.apache.commons.rng.internal.source32.ISAACRandom;
+import org.apache.commons.rng.internal.source32.MersenneTwister;
+import org.apache.commons.rng.internal.source32.MultiplyWithCarry256;
+import org.apache.commons.rng.internal.source32.KISSRandom;
+import org.apache.commons.rng.internal.source64.SplitMix64;
+import org.apache.commons.rng.internal.source64.XorShift1024Star;
+import org.apache.commons.rng.internal.source64.TwoCmres;
+import org.apache.commons.rng.internal.source64.MersenneTwister64;
+
+/**
+ * RNG builder.
+ * <p>
+ * It uses reflection to find the factory method of the RNG implementation,
+ * and performs seed type conversions.
+ * </p>
+ */
+class ProviderBuilder {
+    /** Error message. */
+    private static final String INTERNAL_ERROR_MSG = "Internal error: Please file a bug report";
+    /** Length of the seed array (for random seed). */
+    private static final int RANDOM_SEED_ARRAY_SIZE = 128;
+    /** Seed converter. */
+    private static final Long2Int LONG_TO_INT = new Long2Int();
+    /** Seed converter. */
+    private static final Int2Long INT_TO_LONG = new Int2Long();
+    /** Seed converter. */
+    private static final Long2IntArray LONG_TO_INT_ARRAY = new Long2IntArray(RANDOM_SEED_ARRAY_SIZE);
+    /** Seed converter. */
+    private static final Long2LongArray LONG_TO_LONG_ARRAY = new Long2LongArray(RANDOM_SEED_ARRAY_SIZE);
+    /** Seed converter. */
+    private static final LongArray2Long LONG_ARRAY_TO_LONG = new LongArray2Long();
+    /** Seed converter. */
+    private static final IntArray2Int INT_ARRAY_TO_INT = new IntArray2Int();
+    /** Seed converter. */
+    private static final LongArray2IntArray LONG_ARRAY_TO_INT_ARRAY = new LongArray2IntArray();
+    /** Seed converter. */
+    private static final IntArray2LongArray INT_ARRAY_TO_LONG_ARRAY = new IntArray2LongArray();
+    /** Seed converter. */
+    private static final ByteArray2IntArray BYTE_ARRAY_TO_INT_ARRAY = new ByteArray2IntArray();
+    /** Seed converter. */
+    private static final ByteArray2LongArray BYTE_ARRAY_TO_LONG_ARRAY = new ByteArray2LongArray();
+    /** Map to convert "Integer" seeds. */
+    private static final Map<Class<?>, SeedConverter<Integer,?>> CONV_INT =
+        new HashMap<Class<?>, SeedConverter<Integer,?>>();
+    /** Map to convert "int[]" seeds. */
+    private static final Map<Class<?>, SeedConverter<int[],?>> CONV_INT_ARRAY =
+        new HashMap<Class<?>, SeedConverter<int[],?>>();
+    /** Map to convert "Long" seeds. */
+    private static final Map<Class<?>, SeedConverter<Long,?>> CONV_LONG =
+        new HashMap<Class<?>, SeedConverter<Long,?>>();
+    /** Map to convert "long[]" seeds. */
+    private static final Map<Class<?>, SeedConverter<long[],?>> CONV_LONG_ARRAY =
+        new HashMap<Class<?>, SeedConverter<long[],?>>();
+    /** Map to convert "byte[]" seeds. */
+    private static final Map<Class<?>, SeedConverter<byte[],?>> CONV_BYTE_ARRAY =
+        new HashMap<Class<?>, SeedConverter<byte[],?>>();
+
+    static {
+        // Input seed type is "Long".
+        // Key is the implementation's "native" seed type.
+        CONV_LONG.put(Integer.class, LONG_TO_INT);
+        CONV_LONG.put(Long.class, new NoOpConverter<Long>());
+        CONV_LONG.put(int[].class, LONG_TO_INT_ARRAY);
+        CONV_LONG.put(long[].class, LONG_TO_LONG_ARRAY);
+
+        // Input seed type is "Integer".
+        // Key is the implementation's "native" seed type.
+        CONV_INT.put(Integer.class, new NoOpConverter<Integer>());
+        CONV_INT.put(Long.class, INT_TO_LONG);
+        CONV_INT.put(int[].class, new SeedConverterComposer<Integer,Long,int[]>(INT_TO_LONG, LONG_TO_INT_ARRAY));
+        CONV_INT.put(long[].class, new SeedConverterComposer<Integer,Long,long[]>(INT_TO_LONG, LONG_TO_LONG_ARRAY));
+
+        // Input seed type is "int[]".
+        // Key is the implementation's "native" seed type.
+        CONV_INT_ARRAY.put(Integer.class, INT_ARRAY_TO_INT);
+        CONV_INT_ARRAY.put(Long.class, new SeedConverterComposer<int[],Integer,Long>(INT_ARRAY_TO_INT, INT_TO_LONG));
+        CONV_INT_ARRAY.put(int[].class, new NoOpConverter<int[]>());
+        CONV_INT_ARRAY.put(long[].class, INT_ARRAY_TO_LONG_ARRAY);
+
+        // Input seed type is "long[]".
+        // Key is the implementation's "native" seed type.
+        CONV_LONG_ARRAY.put(Integer.class, new SeedConverterComposer<long[],Long,Integer>(LONG_ARRAY_TO_LONG, LONG_TO_INT));
+        CONV_LONG_ARRAY.put(Long.class, LONG_ARRAY_TO_LONG);
+        CONV_LONG_ARRAY.put(int[].class, LONG_ARRAY_TO_INT_ARRAY);
+        CONV_LONG_ARRAY.put(long[].class, new NoOpConverter<long[]>());
+
+        // Input seed type is "byte[]".
+        // Key is the implementation's "native" seed type.
+        CONV_BYTE_ARRAY.put(Integer.class, new SeedConverterComposer<byte[],int[],Integer>(BYTE_ARRAY_TO_INT_ARRAY, INT_ARRAY_TO_INT));
+        CONV_BYTE_ARRAY.put(Long.class, new SeedConverterComposer<byte[],long[],Long>(BYTE_ARRAY_TO_LONG_ARRAY, LONG_ARRAY_TO_LONG));
+        CONV_BYTE_ARRAY.put(int[].class, BYTE_ARRAY_TO_INT_ARRAY);
+        CONV_BYTE_ARRAY.put(long[].class, BYTE_ARRAY_TO_LONG_ARRAY);
+    }
+
+    /**
+     * Class only contains static method.
+     */
+    private ProviderBuilder() {}
+
+    /**
+     * Creates a RNG instance.
+     *
+     * @param source RNG specification.
+     * @param seed Seed value.  It can be {@code null} (in which case a
+     * random value will be used).
+     * @param args Additional arguments to the implementation's constructor.
+     * @return a new RNG instance.
+     * @throws UnsupportedOperationException if the seed type is invalid.
+     */
+    public static UniformRandomProvider create(RandomSourceInternal source,
+                                               Object seed,
+                                               Object[] args) {
+        // Convert seed to native type.
+        final Object nativeSeed = createSeed(source, seed);
+
+        // Build a single array with all the arguments to be passed
+        // (in the right order) to the constructor.
+        final List<Object> all = new ArrayList<Object>();
+        all.add(nativeSeed);
+        if (args != null) {
+            all.addAll(Arrays.asList(args));
+        }
+
+        // Instantiate.
+        return create(createConstructor(source), all.toArray());
+    }
+
+    /**
+     * Creates a native seed from any of the supported seed types.
+     *
+     * @param source Source.
+     * @param seed Input seed.
+     * @return the native seed.
+     * @throw UnsupportedOperationException if the {@code seed} type is invalid.
+     */
+    private static Object createSeed(RandomSourceInternal source,
+                                     Object seed) {
+        Object nativeSeed = null;
+
+        if (seed == null) {
+            // Create a random seed of the appropriate native type.
+
+            if (source.getSeed().equals(Integer.class)) {
+                nativeSeed = SeedFactory.createInt();
+            } else if (source.getSeed().equals(Long.class)) {
+                nativeSeed = SeedFactory.createLong();
+            } else if (source.getSeed().equals(int[].class)) {
+                nativeSeed = SeedFactory.createIntArray(RANDOM_SEED_ARRAY_SIZE);
+            } else if (source.getSeed().equals(long[].class)) {
+                nativeSeed = SeedFactory.createLongArray(RANDOM_SEED_ARRAY_SIZE);
+            } else {
+                // Source's native type is not handled.
+                throw new IllegalStateException(INTERNAL_ERROR_MSG);
+            }
+        } else {
+            // Convert to native type.
+
+            if (seed instanceof Integer) {
+                nativeSeed = CONV_INT.get(source.getSeed()).convert((Integer) seed);
+            } else if (seed instanceof Long) {
+                nativeSeed = CONV_LONG.get(source.getSeed()).convert((Long) seed);
+            } else if (seed instanceof int[]) {
+                nativeSeed = CONV_INT_ARRAY.get(source.getSeed()).convert((int[]) seed);
+            } else if (seed instanceof long[]) {
+                nativeSeed = CONV_LONG_ARRAY.get(source.getSeed()).convert((long[]) seed);
+            } else if (seed instanceof byte[]) {
+                nativeSeed = CONV_BYTE_ARRAY.get(source.getSeed()).convert((byte[]) seed);
+            }
+
+            if (nativeSeed == null) {
+                // Since the input seed was not null, getting here means that
+                // no suitable converter is present in the maps.
+                throw new UnsupportedOperationException("Unrecognized seed type");
+            }
+
+            if (!source.isNativeSeed(nativeSeed)) {
+                // Conversion setup is wrong.
+                throw new IllegalStateException(INTERNAL_ERROR_MSG);
+            }
+        }
+
+        return nativeSeed;
+    }
+
+    /**
+     * Creates a constructor.
+     *
+     * @param source RNG specification.
+     * @return a RNG constructor.
+     */
+    private static Constructor<?> createConstructor(RandomSourceInternal source) {
+        try {
+            return source.getRng().getConstructor(source.getArgs());
+        } catch (NoSuchMethodException e) {
+            // Info in "RandomSourceInternal" is inconsistent with the
+            // constructor of the implementation.
+            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
+        }
+    }
+
+    /**
+     * Creates a RNG.
+     *
+     * @param rng RNG specification.
+     * @param args Arguments to the implementation's constructor.
+     * @return a new RNG instance.
+     */
+    private static UniformRandomProvider create(Constructor<?> rng,
+                                                Object[] args) {
+        try {
+            return (UniformRandomProvider) rng.newInstance(args);
+        } catch (InvocationTargetException e) {
+            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
+        } catch (InstantiationException e) {
+            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
+        } catch (IllegalAccessException e) {
+            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
+        }
+    }
+
+    /**
+     * Identifiers of the generators.
+     */
+    public enum RandomSourceInternal {
+        /** Source of randomness is {@link JDKRandom}. */
+        JDK(JDKRandom.class,
+            Long.class),
+        /** Source of randomness is {@link Well512a}. */
+        WELL_512_A(Well512a.class,
+                   int[].class),
+        /** Source of randomness is {@link Well1024a}. */
+        WELL_1024_A(Well1024a.class,
+                    int[].class),
+        /** Source of randomness is {@link Well19937a}. */
+        WELL_19937_A(Well19937a.class,
+                     int[].class),
+        /** Source of randomness is {@link Well19937c}. */
+        WELL_19937_C(Well19937c.class,
+                     int[].class),
+        /** Source of randomness is {@link Well44497a}. */
+        WELL_44497_A(Well44497a.class,
+                     int[].class),
+        /** Source of randomness is {@link Well44497b}. */
+        WELL_44497_B(Well44497b.class,
+                     int[].class),
+        /** Source of randomness is {@link MersenneTwister}. */
+        MT(MersenneTwister.class,
+           int[].class),
+        /** Source of randomness is {@link ISAACRandom}. */
+        ISAAC(ISAACRandom.class,
+              int[].class),
+        /** Source of randomness is {@link SplitMix64}. */
+        SPLIT_MIX_64(SplitMix64.class,
+                     Long.class),
+        /** Source of randomness is {@link XorShift1024Star}. */
+        XOR_SHIFT_1024_S(XorShift1024Star.class,
+                         long[].class),
+        /** Source of randomness is {@link TwoCmres}. */
+        TWO_CMRES(TwoCmres.class,
+                  Integer.class),
+        /**
+         * Source of randomness is {@link TwoCmres} with explicit selection
+         * of the two subcycle generators.
+         */
+        TWO_CMRES_SELECT(TwoCmres.class,
+                         Integer.class,
+                         Integer.TYPE,
+                         Integer.TYPE),
+        /** Source of randomness is {@link MersenneTwister64}. */
+        MT_64(MersenneTwister64.class,
+              long[].class),
+        /** Source of randomness is {@link MultiplyWithCarry256}. */
+        MWC_256(MultiplyWithCarry256.class,
+                int[].class),
+        /** Source of randomness is {@link KISSRandom}. */
+        KISS(KISSRandom.class,
+             int[].class);
+
+        /** Source type. */
+        private final Class<? extends UniformRandomProvider> rng;
+        /** Data needed to build the generator. */
+        private final Class<?>[] args;
+
+        /**
+         * @param rng Source type.
+         * @param args Data needed to create a generator instance.
+         * The first element must be the native seed type.
+         */
+        RandomSourceInternal(Class<? extends UniformRandomProvider> rng,
+                             Class<?> ... args) {
+            this.rng = rng;
+            this.args = Arrays.copyOf(args, args.length);
+        }
+
+        /**
+         * @return the source type.
+         */
+        public Class<?> getRng() {
+            return rng;
+        }
+
+        /**
+         * @return the seed type.
+         */
+        Class<?> getSeed() {
+            return args[0];
+        }
+
+        /**
+         * @return the data needed to build the generator.
+         */
+        Class<?>[] getArgs() {
+            return args;
+        }
+
+        /**
+         * Checks whether the type of given {@code seed} is the native type
+         * of the implementation.
+         *
+         * @param <SEED> Seed type.
+         *
+         * @param seed Seed value.
+         * @return {@code true} if the seed can be passed to the builder
+         * for this RNG type.
+         */
+        public <SEED> boolean isNativeSeed(SEED seed) {
+            return seed == null ?
+                false :
+                getSeed().equals(seed.getClass());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/RandomSource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/RandomSource.java b/src/main/java/org/apache/commons/rng/RandomSource.java
index 27b67bb..efacdca 100644
--- a/src/main/java/org/apache/commons/rng/RandomSource.java
+++ b/src/main/java/org/apache/commons/rng/RandomSource.java
@@ -17,7 +17,7 @@
 package org.apache.commons.rng;
 
 import java.util.Arrays;
-import org.apache.commons.rng.internal.ProviderBuilder;
+
 import org.apache.commons.rng.internal.BaseProvider;
 import org.apache.commons.rng.internal.util.SeedFactory;
 

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java b/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
deleted file mode 100644
index 93ad3d9..0000000
--- a/src/main/java/org/apache/commons/rng/internal/ProviderBuilder.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.rng.internal;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.commons.rng.UniformRandomProvider;
-import org.apache.commons.rng.internal.util.SeedFactory;
-import org.apache.commons.rng.internal.util.NoOpConverter;
-import org.apache.commons.rng.internal.util.Int2Long;
-import org.apache.commons.rng.internal.util.Long2Int;
-import org.apache.commons.rng.internal.util.Long2IntArray;
-import org.apache.commons.rng.internal.util.Long2LongArray;
-import org.apache.commons.rng.internal.util.IntArray2LongArray;
-import org.apache.commons.rng.internal.util.LongArray2IntArray;
-import org.apache.commons.rng.internal.util.LongArray2Long;
-import org.apache.commons.rng.internal.util.IntArray2Int;
-import org.apache.commons.rng.internal.util.ByteArray2IntArray;
-import org.apache.commons.rng.internal.util.ByteArray2LongArray;
-import org.apache.commons.rng.internal.util.SeedConverter;
-import org.apache.commons.rng.internal.util.SeedConverterComposer;
-import org.apache.commons.rng.internal.source32.JDKRandom;
-import org.apache.commons.rng.internal.source32.Well512a;
-import org.apache.commons.rng.internal.source32.Well1024a;
-import org.apache.commons.rng.internal.source32.Well19937a;
-import org.apache.commons.rng.internal.source32.Well19937c;
-import org.apache.commons.rng.internal.source32.Well44497a;
-import org.apache.commons.rng.internal.source32.Well44497b;
-import org.apache.commons.rng.internal.source32.ISAACRandom;
-import org.apache.commons.rng.internal.source32.MersenneTwister;
-import org.apache.commons.rng.internal.source32.MultiplyWithCarry256;
-import org.apache.commons.rng.internal.source32.KISSRandom;
-import org.apache.commons.rng.internal.source64.SplitMix64;
-import org.apache.commons.rng.internal.source64.XorShift1024Star;
-import org.apache.commons.rng.internal.source64.TwoCmres;
-import org.apache.commons.rng.internal.source64.MersenneTwister64;
-
-/**
- * RNG builder.
- * <p>
- * It uses reflection to find the factory method of the RNG implementation,
- * and performs seed type conversions.
- * </p>
- */
-public class ProviderBuilder {
-    /** Error message. */
-    private static final String INTERNAL_ERROR_MSG = "Internal error: Please file a bug report";
-    /** Length of the seed array (for random seed). */
-    private static final int RANDOM_SEED_ARRAY_SIZE = 128;
-    /** Seed converter. */
-    private static final Long2Int LONG_TO_INT = new Long2Int();
-    /** Seed converter. */
-    private static final Int2Long INT_TO_LONG = new Int2Long();
-    /** Seed converter. */
-    private static final Long2IntArray LONG_TO_INT_ARRAY = new Long2IntArray(RANDOM_SEED_ARRAY_SIZE);
-    /** Seed converter. */
-    private static final Long2LongArray LONG_TO_LONG_ARRAY = new Long2LongArray(RANDOM_SEED_ARRAY_SIZE);
-    /** Seed converter. */
-    private static final LongArray2Long LONG_ARRAY_TO_LONG = new LongArray2Long();
-    /** Seed converter. */
-    private static final IntArray2Int INT_ARRAY_TO_INT = new IntArray2Int();
-    /** Seed converter. */
-    private static final LongArray2IntArray LONG_ARRAY_TO_INT_ARRAY = new LongArray2IntArray();
-    /** Seed converter. */
-    private static final IntArray2LongArray INT_ARRAY_TO_LONG_ARRAY = new IntArray2LongArray();
-    /** Seed converter. */
-    private static final ByteArray2IntArray BYTE_ARRAY_TO_INT_ARRAY = new ByteArray2IntArray();
-    /** Seed converter. */
-    private static final ByteArray2LongArray BYTE_ARRAY_TO_LONG_ARRAY = new ByteArray2LongArray();
-    /** Map to convert "Integer" seeds. */
-    private static final Map<Class<?>, SeedConverter<Integer,?>> CONV_INT =
-        new HashMap<Class<?>, SeedConverter<Integer,?>>();
-    /** Map to convert "int[]" seeds. */
-    private static final Map<Class<?>, SeedConverter<int[],?>> CONV_INT_ARRAY =
-        new HashMap<Class<?>, SeedConverter<int[],?>>();
-    /** Map to convert "Long" seeds. */
-    private static final Map<Class<?>, SeedConverter<Long,?>> CONV_LONG =
-        new HashMap<Class<?>, SeedConverter<Long,?>>();
-    /** Map to convert "long[]" seeds. */
-    private static final Map<Class<?>, SeedConverter<long[],?>> CONV_LONG_ARRAY =
-        new HashMap<Class<?>, SeedConverter<long[],?>>();
-    /** Map to convert "byte[]" seeds. */
-    private static final Map<Class<?>, SeedConverter<byte[],?>> CONV_BYTE_ARRAY =
-        new HashMap<Class<?>, SeedConverter<byte[],?>>();
-
-    static {
-        // Input seed type is "Long".
-        // Key is the implementation's "native" seed type.
-        CONV_LONG.put(Integer.class, LONG_TO_INT);
-        CONV_LONG.put(Long.class, new NoOpConverter<Long>());
-        CONV_LONG.put(int[].class, LONG_TO_INT_ARRAY);
-        CONV_LONG.put(long[].class, LONG_TO_LONG_ARRAY);
-
-        // Input seed type is "Integer".
-        // Key is the implementation's "native" seed type.
-        CONV_INT.put(Integer.class, new NoOpConverter<Integer>());
-        CONV_INT.put(Long.class, INT_TO_LONG);
-        CONV_INT.put(int[].class, new SeedConverterComposer<Integer,Long,int[]>(INT_TO_LONG, LONG_TO_INT_ARRAY));
-        CONV_INT.put(long[].class, new SeedConverterComposer<Integer,Long,long[]>(INT_TO_LONG, LONG_TO_LONG_ARRAY));
-
-        // Input seed type is "int[]".
-        // Key is the implementation's "native" seed type.
-        CONV_INT_ARRAY.put(Integer.class, INT_ARRAY_TO_INT);
-        CONV_INT_ARRAY.put(Long.class, new SeedConverterComposer<int[],Integer,Long>(INT_ARRAY_TO_INT, INT_TO_LONG));
-        CONV_INT_ARRAY.put(int[].class, new NoOpConverter<int[]>());
-        CONV_INT_ARRAY.put(long[].class, INT_ARRAY_TO_LONG_ARRAY);
-
-        // Input seed type is "long[]".
-        // Key is the implementation's "native" seed type.
-        CONV_LONG_ARRAY.put(Integer.class, new SeedConverterComposer<long[],Long,Integer>(LONG_ARRAY_TO_LONG, LONG_TO_INT));
-        CONV_LONG_ARRAY.put(Long.class, LONG_ARRAY_TO_LONG);
-        CONV_LONG_ARRAY.put(int[].class, LONG_ARRAY_TO_INT_ARRAY);
-        CONV_LONG_ARRAY.put(long[].class, new NoOpConverter<long[]>());
-
-        // Input seed type is "byte[]".
-        // Key is the implementation's "native" seed type.
-        CONV_BYTE_ARRAY.put(Integer.class, new SeedConverterComposer<byte[],int[],Integer>(BYTE_ARRAY_TO_INT_ARRAY, INT_ARRAY_TO_INT));
-        CONV_BYTE_ARRAY.put(Long.class, new SeedConverterComposer<byte[],long[],Long>(BYTE_ARRAY_TO_LONG_ARRAY, LONG_ARRAY_TO_LONG));
-        CONV_BYTE_ARRAY.put(int[].class, BYTE_ARRAY_TO_INT_ARRAY);
-        CONV_BYTE_ARRAY.put(long[].class, BYTE_ARRAY_TO_LONG_ARRAY);
-    }
-
-    /**
-     * Class only contains static method.
-     */
-    private ProviderBuilder() {}
-
-    /**
-     * Creates a RNG instance.
-     *
-     * @param source RNG specification.
-     * @param seed Seed value.  It can be {@code null} (in which case a
-     * random value will be used).
-     * @param args Additional arguments to the implementation's constructor.
-     * @return a new RNG instance.
-     * @throws UnsupportedOperationException if the seed type is invalid.
-     */
-    public static UniformRandomProvider create(RandomSourceInternal source,
-                                               Object seed,
-                                               Object[] args) {
-        // Convert seed to native type.
-        final Object nativeSeed = createSeed(source, seed);
-
-        // Build a single array with all the arguments to be passed
-        // (in the right order) to the constructor.
-        final List<Object> all = new ArrayList<Object>();
-        all.add(nativeSeed);
-        if (args != null) {
-            all.addAll(Arrays.asList(args));
-        }
-
-        // Instantiate.
-        return create(createConstructor(source), all.toArray());
-    }
-
-    /**
-     * Creates a native seed from any of the supported seed types.
-     *
-     * @param source Source.
-     * @param seed Input seed.
-     * @return the native seed.
-     * @throw UnsupportedOperationException if the {@code seed} type is invalid.
-     */
-    private static Object createSeed(RandomSourceInternal source,
-                                     Object seed) {
-        Object nativeSeed = null;
-
-        if (seed == null) {
-            // Create a random seed of the appropriate native type.
-
-            if (source.getSeed().equals(Integer.class)) {
-                nativeSeed = SeedFactory.createInt();
-            } else if (source.getSeed().equals(Long.class)) {
-                nativeSeed = SeedFactory.createLong();
-            } else if (source.getSeed().equals(int[].class)) {
-                nativeSeed = SeedFactory.createIntArray(RANDOM_SEED_ARRAY_SIZE);
-            } else if (source.getSeed().equals(long[].class)) {
-                nativeSeed = SeedFactory.createLongArray(RANDOM_SEED_ARRAY_SIZE);
-            } else {
-                // Source's native type is not handled.
-                throw new IllegalStateException(INTERNAL_ERROR_MSG);
-            }
-        } else {
-            // Convert to native type.
-
-            if (seed instanceof Integer) {
-                nativeSeed = CONV_INT.get(source.getSeed()).convert((Integer) seed);
-            } else if (seed instanceof Long) {
-                nativeSeed = CONV_LONG.get(source.getSeed()).convert((Long) seed);
-            } else if (seed instanceof int[]) {
-                nativeSeed = CONV_INT_ARRAY.get(source.getSeed()).convert((int[]) seed);
-            } else if (seed instanceof long[]) {
-                nativeSeed = CONV_LONG_ARRAY.get(source.getSeed()).convert((long[]) seed);
-            } else if (seed instanceof byte[]) {
-                nativeSeed = CONV_BYTE_ARRAY.get(source.getSeed()).convert((byte[]) seed);
-            }
-
-            if (nativeSeed == null) {
-                // Since the input seed was not null, getting here means that
-                // no suitable converter is present in the maps.
-                throw new UnsupportedOperationException("Unrecognized seed type");
-            }
-
-            if (!source.isNativeSeed(nativeSeed)) {
-                // Conversion setup is wrong.
-                throw new IllegalStateException(INTERNAL_ERROR_MSG);
-            }
-        }
-
-        return nativeSeed;
-    }
-
-    /**
-     * Creates a constructor.
-     *
-     * @param source RNG specification.
-     * @return a RNG constructor.
-     */
-    private static Constructor<?> createConstructor(RandomSourceInternal source) {
-        try {
-            return source.getRng().getConstructor(source.getArgs());
-        } catch (NoSuchMethodException e) {
-            // Info in "RandomSourceInternal" is inconsistent with the
-            // constructor of the implementation.
-            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
-        }
-    }
-
-    /**
-     * Creates a RNG.
-     *
-     * @param rng RNG specification.
-     * @param args Arguments to the implementation's constructor.
-     * @return a new RNG instance.
-     */
-    private static UniformRandomProvider create(Constructor<?> rng,
-                                                Object[] args) {
-        try {
-            return (UniformRandomProvider) rng.newInstance(args);
-        } catch (InvocationTargetException e) {
-            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
-        } catch (InstantiationException e) {
-            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
-        } catch (IllegalAccessException e) {
-            throw new IllegalStateException(INTERNAL_ERROR_MSG, e);
-        }
-    }
-
-    /**
-     * Identifiers of the generators.
-     */
-    public enum RandomSourceInternal {
-        /** Source of randomness is {@link JDKRandom}. */
-        JDK(JDKRandom.class,
-            Long.class),
-        /** Source of randomness is {@link Well512a}. */
-        WELL_512_A(Well512a.class,
-                   int[].class),
-        /** Source of randomness is {@link Well1024a}. */
-        WELL_1024_A(Well1024a.class,
-                    int[].class),
-        /** Source of randomness is {@link Well19937a}. */
-        WELL_19937_A(Well19937a.class,
-                     int[].class),
-        /** Source of randomness is {@link Well19937c}. */
-        WELL_19937_C(Well19937c.class,
-                     int[].class),
-        /** Source of randomness is {@link Well44497a}. */
-        WELL_44497_A(Well44497a.class,
-                     int[].class),
-        /** Source of randomness is {@link Well44497b}. */
-        WELL_44497_B(Well44497b.class,
-                     int[].class),
-        /** Source of randomness is {@link MersenneTwister}. */
-        MT(MersenneTwister.class,
-           int[].class),
-        /** Source of randomness is {@link ISAACRandom}. */
-        ISAAC(ISAACRandom.class,
-              int[].class),
-        /** Source of randomness is {@link SplitMix64}. */
-        SPLIT_MIX_64(SplitMix64.class,
-                     Long.class),
-        /** Source of randomness is {@link XorShift1024Star}. */
-        XOR_SHIFT_1024_S(XorShift1024Star.class,
-                         long[].class),
-        /** Source of randomness is {@link TwoCmres}. */
-        TWO_CMRES(TwoCmres.class,
-                  Integer.class),
-        /**
-         * Source of randomness is {@link TwoCmres} with explicit selection
-         * of the two subcycle generators.
-         */
-        TWO_CMRES_SELECT(TwoCmres.class,
-                         Integer.class,
-                         Integer.TYPE,
-                         Integer.TYPE),
-        /** Source of randomness is {@link MersenneTwister64}. */
-        MT_64(MersenneTwister64.class,
-              long[].class),
-        /** Source of randomness is {@link MultiplyWithCarry256}. */
-        MWC_256(MultiplyWithCarry256.class,
-                int[].class),
-        /** Source of randomness is {@link KISSRandom}. */
-        KISS(KISSRandom.class,
-             int[].class);
-
-        /** Source type. */
-        private final Class<? extends UniformRandomProvider> rng;
-        /** Data needed to build the generator. */
-        private final Class<?>[] args;
-
-        /**
-         * @param rng Source type.
-         * @param args Data needed to create a generator instance.
-         * The first element must be the native seed type.
-         */
-        RandomSourceInternal(Class<? extends UniformRandomProvider> rng,
-                             Class<?> ... args) {
-            this.rng = rng;
-            this.args = Arrays.copyOf(args, args.length);
-        }
-
-        /**
-         * @return the source type.
-         */
-        public Class<?> getRng() {
-            return rng;
-        }
-
-        /**
-         * @return the seed type.
-         */
-        Class<?> getSeed() {
-            return args[0];
-        }
-
-        /**
-         * @return the data needed to build the generator.
-         */
-        Class<?>[] getArgs() {
-            return args;
-        }
-
-        /**
-         * Checks whether the type of given {@code seed} is the native type
-         * of the implementation.
-         *
-         * @param <SEED> Seed type.
-         *
-         * @param seed Seed value.
-         * @return {@code true} if the seed can be passed to the builder
-         * for this RNG type.
-         */
-        public <SEED> boolean isNativeSeed(SEED seed) {
-            return seed == null ?
-                false :
-                getSeed().equals(seed.getClass());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/fd22dc61/src/main/java/org/apache/commons/rng/internal/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/rng/internal/package-info.java b/src/main/java/org/apache/commons/rng/internal/package-info.java
index dba9e64..e3590c9 100644
--- a/src/main/java/org/apache/commons/rng/internal/package-info.java
+++ b/src/main/java/org/apache/commons/rng/internal/package-info.java
@@ -43,7 +43,7 @@
  *
  * <p>
  * Each implementation must have an identifier in
- * {@link org.apache.commons.rng.internal.ProviderBuilder.RandomSourceInternal}
+ * {@link org.apache.commons.rng.ProviderBuilder.RandomSourceInternal}
  * which must be referred to from the {@link org.apache.commons.rng.RandomSource public API}.
  * </p>
  */