Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gradle: Passing arguments to compiler and javadoc. (Getting rid of "warning: sun.misc.Unsafe is internal proprietary API and may be removed in a future release")
apply plugin: 'java'
compileJava {
// This only works when forking and passing 'javac' as an executable
options.compilerArgs << '-XDignore.symbol.file'
options.fork = true
options.forkOptions.executable = 'javac'
javadoc {
// These get ignored
// options.addStringOption('XDignore.symbol.file', null)
// options.addStringOption('XDignore.symbol.file')
// This one fails build - I am assuming it's trying to parse ''
// options.addStringOption('XDignore.symbol.file')
// This works, but it's an ugly hack
options.addStringOption('XDignore.symbol.file', '-quiet')
<?xml version="1.0" encoding="UTF-8"?>
<project name="gradleTest" basedir=".">
<property name="dir.main.src" value="src/main/java"/>
<property name="" value="build/classes/main"/>
<property name="" value="build/docs/javadoc"/>
<target name="clean">
<delete dir="build"/>
<target name="compileJava">
<mkdir dir="${}"/>
<javac destdir="${}"
<compilerarg value="-XDignore.symbol.file"/>
<src path="${dir.main.src}"/>
<target name="javadoc">
<javadoc sourcepath="${dir.main.src}"
<arg value="-XDignore.symbol.file"/>
//Should be placed in './src/main/java/org/bore/sample' directory
package org.bore.sample;
import sun.misc.Unsafe;
public class Sample {
public int foo() {
return Unsafe.getUnsafe().pageSize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.