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

java.lang.NullPointerException: Cannot invoke "org.fife.ui.rsyntaxtextarea.Theme.apply(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)" because the return value of "jadx.gui.ui.MainWindow.getEditorTheme()" is null #1476

Closed
TEAMDEVBOSS opened this issue May 7, 2022 · 2 comments · Fixed by #1478

Comments

@TEAMDEVBOSS
Copy link

Please describe what you did before the error occurred.
IMPORTANT! If the error occurs with a specific APK file please attach or provide link to apk file!

  • Jadx version: 1.3.4
  • Java version: 18.0.1
  • Java VM: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM
  • Platform: Windows 10 (10.0 amd64)
  • Max heap size: 4096 MB
  • Program args: -Xms168m -Xmx4096m -Dawt.useSystemAAFontSettings=lcd -Dswing.aatext=true -XX:+UseG1GC
java.lang.NullPointerException: Cannot invoke "org.fife.ui.rsyntaxtextarea.Theme.apply(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)" because the return value of "jadx.gui.ui.MainWindow.getEditorTheme()" is null
	at jadx.gui.ui.codearea.AbstractCodeArea.loadCommonSettings(AbstractCodeArea.java:249)
	at jadx.gui.ui.codearea.AbstractCodeArea.getDefaultArea(AbstractCodeArea.java:243)
	at jadx.gui.ui.dialog.LogViewerDialog.initUI(LogViewerDialog.java:52)
	at jadx.gui.ui.dialog.LogViewerDialog.<init>(LogViewerDialog.java:46)
	at jadx.gui.ui.dialog.LogViewerDialog.openWithLevel(LogViewerDialog.java:41)
	at jadx.gui.ui.dialog.LogViewerDialog.open(LogViewerDialog.java:36)
	at jadx.gui.ui.MainWindow$19.actionPerformed(MainWindow.java:1010)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374)
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1029)
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1073)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6616)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
	at java.desktop/java.awt.Component.processEvent(Component.java:6381)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4991)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4823)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4823)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

@jpstotz
Copy link
Collaborator

jpstotz commented May 7, 2022

The only way this exception could occur is if mainWindow.getEditorTheme() in AbstractCodeArea.loadCommonSettings(MainWindow, RSyntaxTextArea) returns null.

That would indicate that MainWindow.setEditorTheme had not been called before or both attempts in that method to load a theme had failed:

private void setEditorTheme(String editorThemePath) {
	try (InputStream is = getClass().getResourceAsStream(editorThemePath)) {
		editorTheme = Theme.load(is);
	} catch (Exception e) {
		LOG.error("Can't load editor theme from classpath: {}", editorThemePath);
		try (InputStream is = new FileInputStream(editorThemePath)) {
			editorTheme = Theme.load(is);
		} catch (Exception ex) {
// Most likely this case was happening
			LOG.error("Can't load editor theme from file: {}", editorThemePath);
		}
	}
}

Is there some way to apply a default/empty theme so that we can assign something to editorTheme? Otherwise we had to check on every usage if editorTheme is not null.

@skylot
Copy link
Owner

skylot commented May 7, 2022

Is there some way to apply a default/empty theme so that we can assign something to editorTheme? Otherwise we had to check on every usage if editorTheme is not null.

It is possible to create a theme from default RSTA settings:

editorTheme = new Theme(new RSyntaxTextArea());

Also, we can reset theme to default:

setEditorTheme(EditorTheme.getDefaultTheme().getPath());

These can be applied in getEditorTheme() to guard against null values.

Anyway, I am very curious about original cause.
@TEAMDEVBOSS if you can reproduce this issue, it will be nice if you share other errors from log viewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants