Repository: mockito/mockito
Issue: Remove com.sun.* references
Labels: refactoring
java-9

Currently build with gradle 3.0-milestone-2 fails with:

```
:buildSrc:compileJava/mnt/homeold/szpak/cosie/code/inne/mockito/buildSrc/src/main/java/org/mockito/javadoc/JavadocExclude.java:4: error: package com.sun.tools.doclets.formats.html does not exist
import com.sun.tools.doclets.formats.html.HtmlDoclet;
                                         ^
/mnt/homeold/szpak/cosie/code/inne/mockito/buildSrc/src/main/java/org/mockito/javadoc/JavadocExclude.java:20: error: cannot find symbol
        return HtmlDoclet.optionLength(var0);
               ^
  symbol:   variable HtmlDoclet
  location: class JavadocExclude
/mnt/homeold/szpak/cosie/code/inne/mockito/buildSrc/src/main/java/org/mockito/javadoc/JavadocExclude.java:25: error: cannot find symbol
        return HtmlDoclet.start((RootDoc) Proxy.newProxyInstance(clz.getClassLoader(), clz.getInterfaces(), new ExcludeHandler(root)));
               ^
  symbol:   variable HtmlDoclet
  location: class JavadocExclude
/mnt/homeold/szpak/cosie/code/inne/mockito/buildSrc/src/main/java/org/mockito/javadoc/JavadocExclude.java:29: error: cannot find symbol
        return HtmlDoclet.validOptions(var0, var1);
               ^
  symbol:   variable HtmlDoclet
  location: class JavadocExclude
/mnt/homeold/szpak/cosie/code/inne/mockito/buildSrc/src/main/java/org/mockito/javadoc/JavadocExclude.java:33: error: cannot find symbol
        return HtmlDoclet.languageVersion();
               ^
  symbol:   variable HtmlDoclet
  location: class JavadocExclude
Note: /mnt/homeold/szpak/cosie/code/inne/mockito/buildSrc/src/main/java/org/mockito/javadoc/JavadocExclude.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
 FAILED
```

Related to #520.


Issue comments:
This doclet is required to skip generating Javadoc for internal classes. Is there a mention in the Java 9 jdk of this breaking change?

This seems the corresponding JIRA ticket: https://bugs.openjdk.java.net/browse/JDK-8154399

I'm on a mobile device so couldn't check much, but the ticket mention a replacement for `com.sun....Standard` with the rewritten javadoc tool (`jdk.javadoc.doclets.StandardDoclet`) I didn't saw yet the `HtmlDocklet` yet it should be there as well.

I will be taking a stab at this tomorrow after switching to Java 8.

I think we have to (in jdk9) to move to `StandardDoclet`: http://hg.openjdk.java.net/jdk9/dev/langtools/file/6077dc32728a/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java However, this class does not exist in jdk8 so I am not sure what our options are.

I think we could have both doclet in [javadoc.gradle](https://www.theguardian.com/lifeandstyle/2016/apr/29/how-to-have-a-great-conversation-with-someone-who-is-going-to-die)

``` java
if (JavaVersion.current().isJava9Compatible()) {
    options.doclet "org.mockito.javadoc.Java9JavadocExclude"
} else {
    options.doclet "org.mockito.javadoc.JavadocExclude"
}
```

[Gradle 3 `JavaVersion` javadoc](https://docs.gradle.org/current/javadoc/org/gradle/api/JavaVersion.html)

@bric3 Yes that was what I implemented at https://github.com/mockito/mockito/pull/639/files#diff-39cbd22b5198600bd49c364c42e0aaa9R17 :)

Has been fixed in several PRs and the doclet was later removed.

Pull request review comments:
I assume we already moved the baseline java8 so this should be safe. Nice.

Yup in https://github.com/mockito/mockito/commit/be755a3d9e8424e8587857390abbc07001644778 :smile: 


Patch that resolved the issue:
diff --git a/build.gradle b/build.gradle
index b432d9b62c..af1eebc19c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -122,7 +122,7 @@ apply from: 'gradle/release.gradle'
 apply from: "gradle/pom.gradle"
 
 task wrapper(type: Wrapper) {
-    gradleVersion = '2.14.1'
+    gradleVersion = '3.0'
 }
 
 task ciBuild {
diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle
index 921589844d..4387c965b1 100644
--- a/gradle/javadoc.gradle
+++ b/gradle/javadoc.gradle
@@ -54,9 +54,7 @@ task mockitoJavadoc(type: Javadoc) {
     """.replaceAll(/\r|\n/, ""))
     options.stylesheetFile file("src/javadoc/stylesheet.css")
 //    options.addStringOption('top', 'some html')
-    if (JavaVersion.current().isJava8Compatible()) {
-        options.addStringOption('Xdoclint:none', '-quiet')
-    }
+    options.addStringOption('Xdoclint:none', '-quiet')
 
     doLast {
         copy {
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 69ef29851a..08b5db1824 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Aug 19 18:41:31 PDT 2016
+#Sat Sep 17 14:22:48 CEST 2016
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
diff --git a/gradlew b/gradlew
index 9d82f78915..27309d9231 100755
--- a/gradlew
+++ b/gradlew
@@ -6,12 +6,30 @@
 ##
 ##############################################################################
 
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
 
 APP_NAME="Gradle"
 APP_BASE_NAME=`basename "$0"`
 
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"
 
@@ -30,6 +48,7 @@ die ( ) {
 cygwin=false
 msys=false
 darwin=false
+nonstop=false
 case "`uname`" in
   CYGWIN* )
     cygwin=true
@@ -40,26 +59,11 @@ case "`uname`" in
   MINGW* )
     msys=true
     ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
 esac
 
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
 # Determine the Java command to use to start the JVM.
@@ -85,7 +89,7 @@ location of your Java installation."
 fi
 
 # Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
     MAX_FD_LIMIT=`ulimit -H -n`
     if [ $? -eq 0 ] ; then
         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
diff --git a/gradlew.bat b/gradlew.bat
index 5f192121eb..832fdb6079 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -8,14 +8,14 @@
 @rem Set local scope for the variables with windows NT shell
 if "%OS%"=="Windows_NT" setlocal
 
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
 set DIRNAME=%~dp0
 if "%DIRNAME%" == "" set DIRNAME=.
 set APP_BASE_NAME=%~n0
 set APP_HOME=%DIRNAME%
 
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
 @rem Find java.exe
 if defined JAVA_HOME goto findJavaFromJavaHome
 


Test patch: