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 read the array length because "prefixes" is null #717

Closed
ptziegler opened this issue Feb 28, 2024 · 0 comments · Fixed by #718
Closed
Labels
bug Something isn't working

Comments

@ptziegler
Copy link
Contributor

This is an exception that sporadically shows up in our application...
What seems to be happening is that the following properties of the Java project are not guaranteed to be set, by the time they are requested by WindowBuilder:

  • JavaCore.CODEASSIST_LOCAL_PREFIXES
  • JavaCore.CODEASSIST_LOCAL_SUFFIXES
  • JavaCore.CODEASSIST_FIELD_PREFIXES
  • JavaCore.CODEASSIST_FIELD_SUFFIXES

We use those properties to remove any prefixes and suffixes of the variables. Given that we're relying on JDT, I think it makes more sense to simply move on, rather than throwing an exception.

Stacktrace:

java.lang.NullPointerException: Cannot read the array length because "prefixes" is null
	at org.eclipse.wb.internal.core.model.variable.VariableUtils.stripPrefixSuffix(VariableUtils.java:138) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.core.model.variable.LazyVariableSupportUtils.getExpectedMethodName(LazyVariableSupportUtils.java:339) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.core.model.variable.LazyVariableSupport.add_getVariableStatementSource(LazyVariableSupport.java:229) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.core.model.generation.statement.lazy.LazyStatementGenerator.add(LazyStatementGenerator.java:54) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.core.model.JavaInfoUtils.add(JavaInfoUtils.java:1392) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.core.model.JavaInfoUtils.add(JavaInfoUtils.java:1295) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.core.model.JavaInfoUtils.add(JavaInfoUtils.java:1225) ~[org.eclipse.wb.core.java_1.9.3.202306071608.jar:?]
	at org.eclipse.wb.internal.swing.model.layout.LayoutInfo.add(LayoutInfo.java:330) ~[org.eclipse.wb.swing_1.9.2.202306071608.jar:?]
	at org.eclipse.wb.internal.swing.model.layout.GenericFlowLayoutInfo.add(GenericFlowLayoutInfo.java:52) ~[org.eclipse.wb.swing_1.9.2.202306071608.jar:?]
	at org.eclipse.wb.internal.swing.gef.policy.layout.GenericFlowLayoutEditPolicy.command_CREATE(GenericFlowLayoutEditPolicy.java:84) ~[org.eclipse.wb.swing_1.9.2.202306071608.jar:?]
	at org.eclipse.wb.internal.swing.gef.policy.layout.GenericFlowLayoutEditPolicy.command_CREATE(GenericFlowLayoutEditPolicy.java:1) ~[org.eclipse.wb.swing_1.9.2.202306071608.jar:?]
	at org.eclipse.wb.core.gef.policy.layout.flow.ObjectFlowLayoutEditPolicy$1.executeEdit(ObjectFlowLayoutEditPolicy.java:54) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.core.gef.command.EditCommand$1.run(EditCommand.java:53) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.run(ExecutionUtils.java:331) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.core.gef.command.EditCommand.execute(EditCommand.java:50) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.internal.gef.core.EditDomain.executeCommand(EditDomain.java:59) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.gef.core.tools.Tool.executeCommand(Tool.java:209) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.gef.core.tools.AbstractCreationTool.handleButtonUp(AbstractCreationTool.java:62) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.gef.core.tools.Tool.mouseUp(Tool.java:395) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.internal.gef.core.EditDomain.mouseUp(EditDomain.java:255) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at org.eclipse.wb.internal.gef.graphical.EditEventManager.mouseUp(EditEventManager.java:151) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
	at jdk.internal.reflect.GeneratedMethodAccessor398.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.eclipse.wb.internal.draw2d.EventManager$1.invoke(EventManager.java:317) ~[org.eclipse.wb.core_1.12.0.202306071608.jar:?]
@ptziegler ptziegler added the bug Something isn't working label Feb 28, 2024
ptziegler added a commit to ptziegler/windowbuilder that referenced this issue Mar 1, 2024
Use the JDT NamingConventions class for adding or removing the prefix
and/or suffix of a given variable name. This avoids having to explicitly
load the project-specific prefix/suffix properties.

Resolves eclipse-windowbuilder#717
ptziegler added a commit that referenced this issue Mar 4, 2024
Use the JDT NamingConventions class for adding or removing the prefix
and/or suffix of a given variable name. This avoids having to explicitly
load the project-specific prefix/suffix properties.

Resolves #717
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant