Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime warnings in tool output about illegal reflective access #695

Closed
gitfineon opened this issue May 15, 2019 · 4 comments
Closed

Runtime warnings in tool output about illegal reflective access #695

gitfineon opened this issue May 15, 2019 · 4 comments

Comments

@gitfineon
Copy link
Contributor

Upgraded my project to the use "execute" commandline and it works, but I get some warnings in the beginning.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by picocli.CommandLine$Help$Ansi (file:/C:/Users/.../ext/picocli/picocli.jar) to field java.io.FilterOutputStream.out
WARNING: Please consider reporting this to the maintainers of picocli.CommandLine$Help$Ansi
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

For reference:

openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.2+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.2+9, mixed mode)

With jdk1.8.0_181 in eclipse these warnings do not show up!

public class Tool implements Runnable {

	@Option(names = { "-h", "--help" }, usageHelp = true, description = "Display this help message")
	private boolean usageHelpRequested = false;

	@Option(names = { "-v", "--verbose" }, description = { "Enable verbose output" })
	boolean verboseMode = false;

	public void run() {
		...
	}

	public static void main(String[] args) {

		// Prepare PrintWriter with auto-flush option
		PrintWriter out = new PrintWriter(System.out, true);
		PrintWriter err = new PrintWriter(System.err, true);
		// ColorScheme auto-detection of ANSI terminals
		Ansi ansi = Help.Ansi.AUTO;

		CommandLine cmd = new CommandLine(new Tool())
				// set output
				.setOut(out).setErr(err)
				// disable clustering support for short options (e.g. -hv)
				.setPosixClusteredShortOptionsAllowed(false)
				// set color scheme
				.setColorScheme(Help.defaultColorScheme(ansi));

		// Register default result handler and default exception handler.
		int exitCode = cmd.execute(args);

		System.exit(exitCode);
	}
}

Thank you for providing this great framework.

@remkop
Copy link
Owner

remkop commented May 16, 2019

The solution is to revert this commit and reflect on the org.fusesource.jansi.AnsiConsole class instead of on java.io.FilterOutputStream.

The out field in AnsiConsole is public, so this will not generate "illegal reflective access operation" warnings.

@gitfineon
Copy link
Contributor Author

Mhh, the warnings came up on a windows machine. I tried to reproduce the issue on a linux machine but the warnings didn't came up. The linux machine has

openjdk 11.0.3 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

I don't want to downgrade, but I can try to upgrade the windows machine to the latest AdoptOpenJDK 11 release if it helps.

@remkop
Copy link
Owner

remkop commented May 16, 2019

Don’t worry. I think I know what to do with this ticket.

@gitfineon
Copy link
Contributor Author

Updated openJDK on windows machine in the meantime, tried hotspot and openj9 jvm. The warnings are still there. thx

@remkop remkop closed this as completed in b959294 May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants