2

I get lots of errors when I try to compile already compiling code with Java 8 and maven 3.2.3 in a new machine. Example is as below,

/Users/lginnali/masters/independent-study-01/siddhi/modules/siddhi-extensions/siddhi-classifiers/src/main/java/org/wso2/siddhi/classifiers/trees/ht/Statistics.java:176: error: malformed HTML [ERROR] * For small arguments 0 < y < exp(-2), the program computes [ERROR] ^

My code looks like below (Its complaining about my commented lines).

/**
 * Returns the value, <tt>x</tt>, for which the area under the Normal
 * (Gaussian) probability density function (integrated from minus infinity to
 * <tt>x</tt>) is equal to the argument <tt>y</tt> (assumes mean is zero,
 * variance is one).
 * <p>
 * For small arguments <tt>0 < y < exp(-2)</tt>, the program computes
 * <tt>z = sqrt( -2.0 * log(y) )</tt>; then the approximation is
 * <tt>x = z - log(z)/z  - (1/z) P(1/z) / Q(1/z)</tt>. There are two rational
 * functions P/Q, one for <tt>0 < y < exp(-32)</tt> and the other for
 * <tt>y</tt> up to <tt>exp(-2)</tt>. For larger arguments,
 * <tt>w = y - 0.5</tt>, and <tt>x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2))</tt>.
 *
 * @param y0 the area under the normal pdf
 * @return the z-value
 */
public static double normalInverse(double y0) {

    double x, y, z, y2, x0, x1;
    int code;

    final double s2pi = Math.sqrt(2.0 * Math.PI);

    if (y0 <= 0.0) {
        throw new IllegalArgumentException();
    }
    if (y0 >= 1.0) {
        throw new IllegalArgumentException();
    }
    code = 1;
    y = y0;
    if (y > (1.0 - 0.13533528323661269189)) { /* 0.135... = exp(-2) */
        y = 1.0 - y;
        code = 0;
    }

    if (y > 0.13533528323661269189) {
        y = y - 0.5;
        y2 = y * y;
        x = y + y * (y2 * polevl(y2, P0, 4) / p1evl(y2, Q0, 8));
        x = x * s2pi;
        return (x);
    }

    x = Math.sqrt(-2.0 * Math.log(y));
    x0 = x - Math.log(x) / x;

    z = 1.0 / x;
    if (x < 8.0) {
        x1 = z * polevl(z, P1, 8) / p1evl(z, Q1, 8);
    } else {
        x1 = z * polevl(z, P2, 8) / p1evl(z, Q2, 8);
    }
    x = x0 - x1;
    if (code != 0) {
        x = -x;
    }
    return (x);
}

can someone please help me to resolve this ? Should I fix my code or is this something to do with Java 8.

Thanks


I switched back to Java 7 and it worked fine. Not sure yet I should change all of my comments to make it compile with Java 8 or I can tweak some Java option to make this compile, but I think its a bad idea. I will probably fix it to compile with Java 8 but I would like to know the motive behind this in Java 8 (trying to parse my comments and give errors during compilation).

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Lahiru
  • 679
  • 1
  • 6
  • 19
  • I didn't know the compiler is interpreting your JavaDoc, but try replacing the less than and greater than signs in your formulas with `<` and `>` – Philipp Gayret Nov 18 '14 at 14:44
  • possible duplicate of [JDK8 and Javadoc has become very strict](http://stackoverflow.com/questions/22528767/jdk8-and-javadoc-has-become-very-strict) – Philipp Gayret Nov 18 '14 at 14:45

1 Answers1

4

The problem is your HTML comment contains the line 0 < y < exp(-2) the less than symbol < is also the start of HTML tags so Javadoc thinks you are trying to make another HTML tag.

if you replace the less than sign with &lt; then it should work

0 &lt; y &lt; exp(-2)

Alternatively, you can use the {@code } javadoc tag to wrap your equations instead of <tt>. The code tag knows not to render what's inside as HTML

{@code 0 < y < exp(-2)}
dkatzel
  • 31,188
  • 3
  • 63
  • 67