Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ public void hardmsg(String key, Object... args) {
*/
@Override
public void errormsg(String key, Object... args) {
error(messageFormat(key, args));
error("%s", messageFormat(key, args));
}

/**
Expand Down
19 changes: 17 additions & 2 deletions test/langtools/jdk/jshell/ToolSimpleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/*
* @test
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154 8192979 8191842 8198573 8198801 8239536
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154 8192979 8191842 8198573 8198801 8239536 8210959
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
Expand All @@ -32,8 +32,9 @@
* @build KullaTesting TestingInputStream
* @run testng/othervm ToolSimpleTest
*/
import java.util.Arrays;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.function.Consumer;
Expand Down Expand Up @@ -112,6 +113,20 @@ public void testChainedThrow() {
);
}

@Test
public void testThrowWithPercent() {
test(
(a) -> assertCommandCheckOutput(a,
"URI u = new URI(\"http\", null, \"h\", -1, \"a\" + (char)0x04, null, null);", (s) ->
assertTrue(s.contains("URISyntaxException") && !s.contains("JShellTool"),
"Output: '" + s + "'")),
(a) -> assertCommandCheckOutput(a,
"throw new Exception(\"%z\")", (s) ->
assertTrue(s.contains("java.lang.Exception") && !s.contains("UnknownFormatConversionException"),
"Output: '" + s + "'"))
);
}

@Test
public void oneLineOfError() {
test(
Expand Down