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

Fix native image metadata (fixes #923) #931

Merged
merged 5 commits into from
Jan 23, 2024
Merged
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
15 changes: 5 additions & 10 deletions graal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,15 @@
<dependencies>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId>
<artifactId>jline-terminal-jni</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-console</artifactId>
</dependency>

<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<artifactId>jline-reader</artifactId>
</dependency>

<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<groupId>org.jline</groupId>
<artifactId>jline-console</artifactId>
</dependency>

<dependency>
Expand Down Expand Up @@ -110,6 +104,7 @@
<buildArgs>--no-fallback
--report-unsupported-elements-at-runtime
--allow-incomplete-classpath
-H:+UnlockExperimentalVMOptions
-H:ReflectionConfigurationFiles=reflection-config.json</buildArgs>
</configuration>
<executions>
Expand Down
10 changes: 9 additions & 1 deletion graal/src/main/java/org/jline/demo/graal/Graal.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.file.Paths;
import java.util.*;
import java.util.function.Supplier;
import java.util.logging.LogManager;

import org.jline.builtins.ConfigurationPath;
import org.jline.console.impl.Builtins;
Expand All @@ -25,6 +26,7 @@
import org.jline.terminal.Terminal;
import org.jline.terminal.Terminal.Signal;
import org.jline.terminal.TerminalBuilder;
import org.jline.terminal.spi.TerminalExt;
import org.jline.utils.OSUtils;
import org.jline.widget.TailTipWidgets;
import org.jline.widget.TailTipWidgets.TipType;
Expand All @@ -34,6 +36,11 @@ public class Graal {

public static void main(String[] args) {
try {
// Init log
String fname = System.getProperty("java.util.logging.config.file");
if (fname != null) {
LogManager.getLogManager().readConfiguration();
}
Supplier<Path> workDir = () -> Paths.get(System.getProperty("user.dir"));
//
// Parser & Terminal
Expand Down Expand Up @@ -95,7 +102,8 @@ public static void main(String[] args) {
//
// REPL-loop
//
System.out.println(terminal.getName() + ": " + terminal.getType());
System.out.println(terminal.getName() + ": " + terminal.getType() + ", provider="
+ ((TerminalExt) terminal).getProvider().name());
while (true) {
try {
systemRegistry.cleanUp(); // reset output streams
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args = -H:+UnlockExperimentalVMOptions -H:ResourceConfigurationResources=${.}/resource-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"resources": [
{"pattern": "org/jline/jansi/jansi.properties"},
{"pattern": "org/jline/jansi/jansi.txt"}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
[
{
"name": "org.jline.nativ.CLibrary",
"fields": [
{ "name": "TCSANOW" },
{ "name": "TCSADRAIN" },
{ "name": "TCSAFLUSH" },
{ "name": "TIOCGWINSZ" },
{ "name": "TIOCSWINSZ" }
]
},
{
"name": "org.jline.nativ.CLibrary$Termios",
"fields": [
{ "name": "SIZEOF" },
{ "name": "c_iflag" },
{ "name": "c_oflag" },
{ "name": "c_cflag" },
{ "name": "c_lflag" },
{ "name": "c_cc" },
{ "name": "c_ispeed" },
{ "name": "c_ospeed" }
]
},
{
"name": "org.jline.nativ.CLibrary$WinSize",
"fields": [
{ "name": "SIZEOF" },
{ "name": "ws_row" },
{ "name": "ws_col" },
{ "name": "ws_xpixel" },
{ "name": "ws_ypixel" }
]
},
{
"name": "org.jline.nativ.Kernel32",
"fields": [
{ "name": "FOREGROUND_BLUE" },
{ "name": "FOREGROUND_GREEN" },
{ "name": "FOREGROUND_RED" },
{ "name": "FOREGROUND_INTENSITY" },
{ "name": "BACKGROUND_BLUE" },
{ "name": "BACKGROUND_GREEN" },
{ "name": "BACKGROUND_RED" },
{ "name": "BACKGROUND_INTENSITY" },
{ "name": "COMMON_LVB_LEADING_BYTE" },
{ "name": "COMMON_LVB_TRAILING_BYTE" },
{ "name": "COMMON_LVB_GRID_HORIZONTAL" },
{ "name": "COMMON_LVB_GRID_LVERTICAL" },
{ "name": "COMMON_LVB_GRID_RVERTICAL" },
{ "name": "COMMON_LVB_REVERSE_VIDEO" },
{ "name": "COMMON_LVB_UNDERSCORE" },
{ "name": "FORMAT_MESSAGE_FROM_SYSTEM" },
{ "name": "STD_INPUT_HANDLE" },
{ "name": "STD_OUTPUT_HANDLE" },
{ "name": "STD_ERROR_HANDLE" },
{ "name": "INVALID_HANDLE_VALUE," }
]
},
{
"name": "org.jline.nativ.Kernel32$SMALL_RECT",
"fields": [
{ "name": "SIZEOF" },
{ "name": "left" },
{ "name": "top" },
{ "name": "right" },
{ "name": "bottom" }
]
},
{
"name": "org.jline.nativ.Kernel32$COORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "x" },
{ "name": "y" }
]
},
{
"name": "org.jline.nativ.Kernel32$CONSOLE_SCREEN_BUFFER_INFO",
"fields": [
{ "name": "SIZEOF" },
{ "name": "size" },
{ "name": "cursorPosition" },
{ "name": "attributes" },
{ "name": "window" },
{ "name": "maximumWindowSize" }
]
},
{
"name": "org.jline.nativ.Kernel32$CHAR_INFO",
"fields": [
{ "name": "SIZEOF" },
{ "name": "attributes" },
{ "name": "unicodeChar" }
]
},
{
"name": "org.jline.nativ.Kernel32$KEY_EVENT_RECORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "CAPSLOCK_ON" },
{ "name": "NUMLOCK_ON" },
{ "name": "SCROLLLOCK_ON" },
{ "name": "ENHANCED_KEY" },
{ "name": "LEFT_ALT_PRESSED" },
{ "name": "LEFT_CTRL_PRESSED" },
{ "name": "RIGHT_ALT_PRESSED" },
{ "name": "RIGHT_CTRL_PRESSED" },
{ "name": "SHIFT_PRESSED" },
{ "name": "keyDown" },
{ "name": "repeatCount" },
{ "name": "keyCode" },
{ "name": "scanCode" },
{ "name": "uchar" },
{ "name": "controlKeyState" }
]
},
{
"name": "org.jline.nativ.Kernel32$MOUSE_EVENT_RECORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "FROM_LEFT_1ST_BUTTON_PRESSED" },
{ "name": "FROM_LEFT_2ND_BUTTON_PRESSED" },
{ "name": "FROM_LEFT_3RD_BUTTON_PRESSED" },
{ "name": "FROM_LEFT_4TH_BUTTON_PRESSED" },
{ "name": "RIGHTMOST_BUTTON_PRESSED" },
{ "name": "CAPSLOCK_ON" },
{ "name": "NUMLOCK_ON" },
{ "name": "SCROLLLOCK_ON" },
{ "name": "ENHANCED_KEY" },
{ "name": "LEFT_ALT_PRESSED" },
{ "name": "LEFT_CTRL_PRESSED" },
{ "name": "RIGHT_ALT_PRESSED" },
{ "name": "RIGHT_CTRL_PRESSED" },
{ "name": "SHIFT_PRESSED" },
{ "name": "DOUBLE_CLICK" },
{ "name": "MOUSE_HWHEELED" },
{ "name": "MOUSE_MOVED" },
{ "name": "MOUSE_WHEELED" },
{ "name": "mousePosition" },
{ "name": "buttonState" },
{ "name": "controlKeyState" },
{ "name": "eventFlags" }
]
},
{
"name": "org.jline.nativ.Kernel32$WINDOW_BUFFER_SIZE_RECORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "size" }
]
},
{
"name": "org.jline.nativ.Kernel32$FOCUS_EVENT_RECORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "setFocus" }
]
},
{
"name": "org.jline.nativ.Kernel32$MENU_EVENT_RECORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "commandId" }
]
},
{
"name": "org.jline.nativ.Kernel32$INPUT_RECORD",
"fields": [
{ "name": "SIZEOF" },
{ "name": "KEY_EVENT" },
{ "name": "MOUSE_EVENT" },
{ "name": "WINDOW_BUFFER_SIZE_EVENT" },
{ "name": "FOCUS_EVENT" },
{ "name": "MENU_EVENT" },
{ "name": "eventType" },
{ "name": "keyEvent" },
{ "name": "mouseEvent" },
{ "name": "windowBufferSizeEvent" },
{ "name": "menuEvent" },
{ "name": "focusEvent" }
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args = -H:+UnlockExperimentalVMOptions -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json -H:JNIConfigurationResources=${.}/jni-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name" : "org.jline.native.CLibrary",
"allDeclaredConstructors" : false,
"allPublicConstructors" : false,
"allDeclaredMethods" : false,
"allPublicMethods" : false,
"allDeclaredFields" : true,
"allPublicFields" : true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args = -H:+UnlockExperimentalVMOptions -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name" : "org.jline.terminal.impl.ffm.FfmTerminalProvider",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : false,
"allPublicMethods" : false,
"allDeclaredFields" : false,
"allPublicFields" : false
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"resources": [
{"pattern": "META-INF/services/org/jline/terminal/provider/.*"}
]
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Args = -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Args = -H:+UnlockExperimentalVMOptions -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Args = -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Args = -H:+UnlockExperimentalVMOptions -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jline.terminal.spi.Pty;
import org.jline.terminal.spi.SystemStream;
import org.jline.terminal.spi.TerminalProvider;
import org.jline.utils.Log;
import org.jline.utils.OSUtils;

public class JniTerminalProvider implements TerminalProvider {
Expand Down Expand Up @@ -137,6 +138,7 @@ public boolean isSystemStream(SystemStream stream) {
return isPosixSystemStream(stream);
}
} catch (Throwable t) {
Log.debug("Exception while checking system stream (this may disable the JNI provider)", t);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Args = -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Args = -H:+UnlockExperimentalVMOptions -H:ResourceConfigurationResources=${.}/resource-config.json -H:ReflectionConfigurationResources=${.}/reflection-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,9 @@ private Terminal doBuild() throws IOException {
if (terminal == null && (forceDumb || dumb == null || dumb)) {
if (!forceDumb && dumb == null) {
if (Log.isDebugEnabled()) {
Log.warn("input is tty: {}", system.get(SystemStream.Input));
Log.warn("output is tty: {}", system.get(SystemStream.Output));
Log.warn("error is tty: {}", system.get(SystemStream.Error));
Log.warn("input is tty: " + system.get(SystemStream.Input));
Log.warn("output is tty: " + system.get(SystemStream.Output));
Log.warn("error is tty: " + system.get(SystemStream.Error));
Log.warn("Creating a dumb terminal", exception);
} else {
Log.warn(
Expand Down
2 changes: 1 addition & 1 deletion terminal/src/main/java/org/jline/utils/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static LogRecord createRecord(final Level level, final Object... messages) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
for (int i = 0; i < messages.length; i++) {
// Special handling for the last message if its a throwable, render its stack on the next line
// Special handling for the last message if it's a throwable, render its stack on the next line
if (i + 1 == messages.length && messages[i] instanceof Throwable) {
cause = (Throwable) messages[i];
} else {
Expand Down
Loading
Loading