Permalink
Browse files

fix MPS-10612 [build:15.6427] java.lang.NullPointerException

  • Loading branch information...
1 parent ee6b0b4 commit a46a10094740a029d427772b1b8ee2e25098cc71 @juliabeliaeva juliabeliaeva committed Jan 26, 2011
@@ -58,7 +58,7 @@
<languageAspect modelUID="r:00000000-0000-4000-0000-011c895903ac(jetbrains.mps.baseLanguageInternal.structure)" version="1" />
<languageAspect modelUID="r:309aeee7-bee8-445c-b31d-35928d1da75f(jetbrains.mps.baseLanguage.tuples.structure)" version="2" />
<languageAspect modelUID="r:550fbd90-c9f2-4576-a8a6-223eca16d68b(jetbrains.mps.baseLanguage.runConfigurations.structure)" version="0" />
- <maxImportIndex value="184" />
+ <maxImportIndex value="185" />
<import index="1" modelUID="r:00000000-0000-4000-0000-011c895902ca(jetbrains.mps.baseLanguage.structure)" version="3" />
<import index="3" modelUID="r:00000000-0000-4000-0000-011c895904a4(jetbrains.mps.ide.actions)" version="-1" />
<import index="4" modelUID="f:java_stub#java.util(java.util@java_stub)" version="-1" />
@@ -109,6 +109,7 @@
<import index="178" modelUID="f:java_stub#com.intellij.openapi.project(com.intellij.openapi.project@java_stub)" version="-1" />
<import index="183" modelUID="f:java_stub#jetbrains.mps.debug.runtime(jetbrains.mps.debug.runtime@java_stub)" version="-1" />
<import index="184" modelUID="r:82f15792-6966-47aa-8004-b293ab2bcfd2(jetbrains.mps.lang.plugin.run)" version="-1" />
+ <import index="185" modelUID="f:java_stub#com.intellij.execution(com.intellij.execution@java_stub)" version="-1" />
<node type="jetbrains.mps.lang.plugin.structure.ActionGroupDeclaration:23" id="1205247737002">
<property name="name:23" value="BaseLanguageModelActionsInternal" />
<property name="package:23" value="Actions.Groups" />
@@ -12335,6 +12336,26 @@
</node>
</node>
</node>
+ <node role="statement:3" type="jetbrains.mps.baseLanguage.structure.IfStatement:3" id="1563150392328907583">
+ <node role="ifTrue:3" type="jetbrains.mps.baseLanguage.structure.StatementList:3" id="1563150392328907584">
+ <node role="statement:3" type="jetbrains.mps.baseLanguage.structure.ThrowStatement:3" id="1563150392328907592">
+ <node role="throwable:3" type="jetbrains.mps.baseLanguage.structure.GenericNewExpression:3" id="1563150392328907594">
+ <node role="creator:3" type="jetbrains.mps.baseLanguage.structure.ClassCreator:3" id="1563150392328907596">
+ <link role="baseMethodDeclaration:3" targetNodeId="185.~ExecutionException.&lt;init&gt;(java.lang.String)" resolveInfo="ExecutionException" />
+ <node role="actualArgument:3" type="jetbrains.mps.baseLanguage.structure.StringLiteral:3" id="1563150392328907597">
+ <property name="value:3" value="Class name of a node is null. Cant run." />
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ <node role="condition:3" type="jetbrains.mps.baseLanguage.structure.EqualsExpression:3" id="1563150392328907588">
+ <node role="rightExpression:3" type="jetbrains.mps.baseLanguage.structure.NullLiteral:3" id="1563150392328907591" />
+ <node role="leftExpression:3" type="jetbrains.mps.baseLanguage.structure.LocalVariableReference:3" id="1563150392328907587">
+ <link role="variableDeclaration:3" targetNodeId="6796549325584737046" resolveInfo="className" />
+ </node>
+ </node>
+ </node>
<node role="statement:3" type="jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement:3" id="3607966867310344470">
<node role="localVariableDeclaration:3" type="jetbrains.mps.baseLanguage.structure.LocalVariableDeclaration:3" id="3607966867310344471">
<property name="name:3" value="process" />
Oops, something went wrong.
Oops, something went wrong.
@@ -19,6 +19,7 @@
<classNode dependClassName="java.util.List" />
<classNode dependClassName="java.util.Set" />
<classNode dependClassName="jetbrains.mps.baseLanguage.util.plugin.run.ConfigRunParameters" />
+ <classNode dependClassName="jetbrains.mps.internal.collections.runtime.IWhereFilter" />
<classNode dependClassName="jetbrains.mps.internal.collections.runtime.ListSequence" />
<classNode dependClassName="jetbrains.mps.internal.collections.runtime.Sequence" />
<classNode dependClassName="jetbrains.mps.internal.collections.runtime.SetSequence" />
@@ -35,11 +36,14 @@
<classNode dependClassName="jetbrains.mps.smodel.SNode" />
<classNode dependClassName="jetbrains.mps.util.CollectionUtil" />
<classNode dependClassName="org.apache.commons.lang.StringUtils" />
+ <classNode dependClassName="org.jetbrains.annotations.NotNull" />
+ <classNode dependClassName="org.jetbrains.annotations.Nullable" />
</dependency>
<dependency className="jetbrains.mps.baseLanguage.util.plugin.run.ClassRunner" file="ClassRunner.java">
<classNode dependClassName="com.intellij.execution.process.ProcessNotCreatedException" />
<classNode dependClassName="java.io.File" />
<classNode dependClassName="java.io.IOException" />
+ <classNode dependClassName="java.lang.NullPointerException" />
<classNode dependClassName="java.lang.Process" />
<classNode dependClassName="java.lang.ProcessBuilder" />
<classNode dependClassName="java.lang.Runnable" />
@@ -52,6 +56,7 @@
<classNode dependClassName="jetbrains.mps.smodel.ModelAccess" />
<classNode dependClassName="jetbrains.mps.smodel.SNode" />
<classNode dependClassName="org.apache.commons.lang.StringUtils" />
+ <classNode dependClassName="org.jetbrains.annotations.NotNull" />
<classNode extendsClassName="jetbrains.mps.baseLanguage.util.plugin.run.BaseRunner" />
</dependency>
<dependency className="jetbrains.mps.baseLanguage.util.plugin.run.ConfigRunParameters" file="ConfigRunParameters.java">
@@ -155,8 +155,8 @@ public void run() {
final Wrappers._T<ExecutionException> ex = new Wrappers._T<ExecutionException>(null);
// create process handler
- handler_22042010 = (ProcessHandler) new _FunctionTypes._return_P0_E0<DefaultProcessHandler>() {
- public DefaultProcessHandler invoke() {
+ handler_22042010 = (ProcessHandler) new _FunctionTypes._return_P0_E1<DefaultProcessHandler, ExecutionException>() {
+ public DefaultProcessHandler invoke() throws ExecutionException {
try {
ClassRunner classRunner = new ClassRunner(javaRunParameters);
final Wrappers._T<String> className = new Wrappers._T<String>();
@@ -165,6 +165,9 @@ public void run() {
className.value = INamedConcept_Behavior.call_getFqName_1213877404258(node);
}
});
+ if (className.value == null) {
+ throw new ExecutionException("Class name of a node is null. Cant run.");
+ }
Process process = classRunner.run(node, className.value);
return new DefaultProcessHandler(consoleView_22042010, process, classRunner.getCommandString());
} catch (ExecutionException e) {
@@ -4,8 +4,11 @@
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.apache.commons.lang.StringUtils;
import jetbrains.mps.internal.collections.runtime.Sequence;
+import jetbrains.mps.internal.collections.runtime.IWhereFilter;
import jetbrains.mps.smodel.SNode;
import jetbrains.mps.smodel.SModel;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
@@ -69,25 +72,30 @@ protected void addProgramParameters(List<String> params) {
this.addParametersString(params, myRunParameters.getProgramParameters());
}
- private void addParametersString(List<String> params, String parametersString) {
+ private void addParametersString(@NotNull List<String> params, @Nullable String parametersString) {
if (parametersString != null && StringUtils.isNotEmpty(parametersString)) {
String[] paramList = this.splitParams(parametersString);
- ListSequence.fromList(params).addSequence(Sequence.fromIterable(Sequence.fromArray(paramList)));
+ ListSequence.fromList(params).addSequence(Sequence.fromIterable(Sequence.fromArray(paramList)).where(new IWhereFilter<String>() {
+ public boolean accept(String it) {
+ return it != null;
+ }
+ }));
}
}
protected void addClassPath(List<String> params, SNode node) {
this.addClassPath(params, this.getClasspath(node));
}
- protected void addClassPath(List<String> params, String classPath) {
+ protected void addClassPath(List<String> params, @Nullable String classPath) {
if (classPath == null) {
return;
}
ListSequence.fromList(params).addElement("-cp");
ListSequence.fromList(params).addElement(classPath);
}
+ @Nullable
protected String getClasspath(SNode node) {
SModel model = SNodeOperations.getModel(node);
if (model == null) {
@@ -168,6 +176,7 @@ public void visit(JarFileClassPathItem p0) {
});
}
+ @NotNull
public static String getJavaCommand(String javaHome) {
String result = javaHome + fs() + "bin" + fs();
String osName = System.getProperty("os.name");
@@ -4,6 +4,7 @@
import jetbrains.mps.logging.Logger;
import jetbrains.mps.smodel.SNode;
+import org.jetbrains.annotations.NotNull;
import com.intellij.execution.process.ProcessNotCreatedException;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.ListSequence;
@@ -22,7 +23,7 @@ public ClassRunner(ConfigRunParameters parameters) {
super(parameters);
}
- public Process run(final SNode node, final String className) throws ProcessNotCreatedException {
+ public Process run(final SNode node, @NotNull final String className) throws ProcessNotCreatedException {
final List<String> params = ListSequence.fromList(new ArrayList<String>());
ModelAccess.instance().runReadAction(new Runnable() {
public void run() {
@@ -45,6 +46,10 @@ public void run() {
} catch (IOException e) {
LOG.error("Can't run class " + className + ": " + e.getMessage(), e);
throw new ProcessNotCreatedException(e.getMessage(), e, this.getCommandLine());
+ } catch (NullPointerException npe) {
+ String message = "Can't run class " + className + ". One of the command line arguments is null:\n" + params;
+ LOG.error(message, npe);
+ throw new ProcessNotCreatedException(message, npe, this.getCommandLine());
}
}
Oops, something went wrong.

0 comments on commit a46a100

Please sign in to comment.