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

Null Pointer Exception with infocmp warning #550

Closed
konteal opened this issue Jul 6, 2020 · 4 comments
Closed

Null Pointer Exception with infocmp warning #550

konteal opened this issue Jul 6, 2020 · 4 comments
Labels
Milestone

Comments

@konteal
Copy link

konteal commented Jul 6, 2020

The terminal I use is rxvt-unicode-256color and starting the Scala interpreter in it immediately gives a null pointer exception, see https://pastebin.com/WMbSRTgk. The readline I get then fails to interpret control keys such as Home, End, Delete and Backspace, giving back control sequences like [~7 and so.

However, running infocmp -C rxvt-unicode-256color works just fine in my terminal. I asked on a Scala chatroom about this and have been told that this may be a JLine bug, so I’m reporting this here in case he’s right.

So far, exporting another terminal, as inexport TERM=xterm-256color will mitigate the problem: The null pointer exception disappears and the readline I get only fails with Home and End, other control keys work fine.

@SethTisue
Copy link

previously in this area: #533

@gnodet
Copy link
Member

gnodet commented Jul 6, 2020

Ah, the rxvt files have been wrongly named when added in the source tree. @mattirn could you rename them so that the extension is .caps and not .cap ?

@mattirn
Copy link
Collaborator

mattirn commented Jul 6, 2020

Thanks @gnodet, after renaming rxvt files:

 % ./build demo
Launching Gogo JLine...
Classpath: /home/matti/git/jline3b/demo/target/classes:/home/matti/git/jline3b/demo/target/lib/jline-groovy-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/jline-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/jline-terminal-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/jline-builtins-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/jline-style-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/jline-reader-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/jline-console-3.15.1-SNAPSHOT.jar:/home/matti/git/jline3b/demo/target/lib/org.apache.felix.gogo.runtime-1.1.2.jar:/home/matti/git/jline3b/demo/target/lib/org.apache.felix.gogo.jline-1.1.4.jar
Exception in thread "main" java.io.IOError: java.lang.StringIndexOutOfBoundsException: String index out of range: 6
	at org.jline.utils.Curses.tputs(Curses.java:62)
	at org.jline.utils.Curses.tputs(Curses.java:45)
	at org.jline.keymap.KeyMap.key(KeyMap.java:243)
	at org.jline.reader.impl.LineReaderImpl.key(LineReaderImpl.java:6093)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.jline.reader.impl.LineReaderImpl.bindKeys(LineReaderImpl.java:6101)
	at org.jline.reader.impl.LineReaderImpl.emacs(LineReaderImpl.java:5811)
	at org.jline.reader.impl.LineReaderImpl.defaultKeyMaps(LineReaderImpl.java:5787)
	at org.jline.reader.impl.LineReaderImpl.<init>(LineReaderImpl.java:293)
	at org.jline.reader.LineReaderBuilder.build(LineReaderBuilder.java:115)
	at org.apache.felix.gogo.jline.Shell.gosh(Shell.java:359)
	at org.apache.felix.gogo.jline.Main.main(Main.java:74)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 6
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
	at java.base/java.lang.String.charAt(String.java:693)
	at org.jline.utils.Curses.doTputs(Curses.java:359)
	at org.jline.utils.Curses.tputs(Curses.java:60)
	... 19 more

Removing rxvt-basic.caps file all the records that finish to $ i.e. kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, ... the above exception disappear. I do not think this can be taken as a solution to the problem?

If we change the line

if (str.charAt(index) == '<') {

with

                    if (index < length && str.charAt(index) == '<') {

then we do not need to edit caps file.

@gnodet
Copy link
Member

gnodet commented Jul 6, 2020

If we change the line

if (str.charAt(index) == '<') {

with

                    if (index < length && str.charAt(index) == '<') {

then we do not need to edit caps file.

It looks like a good solution to me.

@mattirn mattirn closed this as completed in 3b0d5d5 Jul 6, 2020
@mattirn mattirn added the bug label Jul 6, 2020
@mattirn mattirn added this to the 3.15.1 milestone Jul 6, 2020
@mattirn mattirn mentioned this issue Jul 11, 2020
SethTisue added a commit to SethTisue/scala that referenced this issue Aug 4, 2020
I see little of interest (either positive or negative) at
https://github.com/jline/jline3/blob/master/changelog.md so it's
probably safe. and 2.13.3 seems stable, so now's a good time for an
optional upgrade. there is an rxvt fix, jline/jline3#550, which is a
nice-to-have.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants