[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-scm
Subject:    [groovy-scm]  [17484] branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/antlr: GROOVY-3711
From:       roshandawrani () codehaus ! org
Date:       2009-08-30 17:39:33
Message-ID: 20090830173933.B894D14A8085 () codehaus01 ! managed ! contegix ! com
[Download RAW message or body]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><style type="text/css"><!--
#msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : \
#fff; } #msg DT { float : left; width : 6em; font-weight : bold; }
#msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; \
font-size : 10pt;  } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; \
font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; \
background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, \
.diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; \
font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin \
: 0; } #patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff  {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add \
{background:#ddffdd;} #patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
.diff { width : 100%; }
#msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : \
#fff; } #msg DT { float : left; width : 6em; font-weight : bold; }
#msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; \
font-size : 10pt;  } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; \
font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; \
background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, \
.diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; \
font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin \
: 0; } #patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff  {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add \
{background:#ddffdd;} #patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
.diff { width : 100%; }
--></style>
<title> [17484] branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/antlr: \
GROOVY-3711</title> </head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a \
href="http://fisheye.codehaus.org/changelog/groovy/?cs=17484">17484</a></dd> \
<dt>Author</dt> <dd>roshandawrani</dd> <dt>Date</dt> <dd>2009-08-30 12:39:33 -0500 \
(Sun, 30 Aug 2009)</dd> </dl>

<h3>Log Message</h3>
<pre><a href="http://jira.codehaus.org/secure/ViewIssue.jspa?key=GROOVY-3711">GROOVY-3711</a>
 GroovyScriptEngine failed with NPE to eval a script that just had import statements \
and nothing else in script body. Fixed it.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesGROOVY_1_6_XsrcmainorgcodehausgroovyantlrAntlrParserPluginjava"> \
branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java</a></li>
 <li><a href="#branchesGROOVY_1_6_Xsrcmainorgcodehausgroovyjsr223GroovyScriptEngineImp \
ljava">branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java</a></li>
 <li><a href="#branchesGROOVY_1_6_XsrctestorgcodehausgroovyantlrtreewalkerUnimplemente \
dSyntaxTestjava">branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/antlr/treewalker/UnimplementedSyntaxTest.java</a></li>
 <li><a href="#branchesGROOVY_1_6_Xsrctestorgcodehausgroovyjsr223vm5JSR223Testgroovy"> \
branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/jsr223/vm5/JSR223Test.groovy</a></li>
 </ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesGROOVY_1_6_XsrcmainorgcodehausgroovyantlrAntlrParserPluginjava"></a>
<div class="modfile"><h4>Modified: \
branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java \
(17483 => 17484)</h4> <pre class="diff">
<span class="info">--- \
branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java	2009-08-30 \
                10:33:44 UTC (rev 17483)
+++ branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java	2009-08-30 \
17:39:33 UTC (rev 17484) </span><span class="lines">@@ -194,6 +194,9 @@
</span><span class="cx">         makeModule();
         try {
             convertGroovy(ast);
</span><span class="add">+            if(output.getStatementBlock().isEmpty() \
&amp;&amp; output.getMethods().isEmpty() &amp;&amp; output.getClasses().isEmpty()) { \
+            	output.addStatement(ReturnStatement.RETURN_NULL_OR_VOID); +            \
} </span><span class="cx">         }
         catch (ASTRuntimeException e) {
             throw new ASTParserException(e.getMessage() + &quot;. File: &quot; + \
sourceUnit.getName(), e); </span></pre></div>
<a id="branchesGROOVY_1_6_Xsrcmainorgcodehausgroovyjsr223GroovyScriptEngineImpljava"></a>
 <div class="modfile"><h4>Modified: \
branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java \
(17483 => 17484)</h4> <pre class="diff">
<span class="info">--- \
branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java	2009-08-30 \
                10:33:44 UTC (rev 17483)
+++ branches/GROOVY_1_6_X/src/main/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java	2009-08-30 \
17:39:33 UTC (rev 17484) </span><span class="lines">@@ -110,7 +110,9 @@
</span><span class="cx">     public Object eval(String script, ScriptContext ctx) 
                        throws ScriptException {
         try {
</span><span class="rem">-            return eval(getScriptClass(script), ctx);
</span><span class="add">+        	Class clazz = getScriptClass(script);
+            if(clazz == null) throw new ScriptException(&quot;Script class is \
null&quot;); +            return eval(clazz, ctx);
</span><span class="cx">         } catch (SyntaxException e) {
             throw new ScriptException(e.getMessage(), 
                                       e.getSourceLocator(), e.getLine());
</span></pre></div>
<a id="branchesGROOVY_1_6_XsrctestorgcodehausgroovyantlrtreewalkerUnimplementedSyntaxTestjava"></a>
 <div class="modfile"><h4>Modified: \
branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/antlr/treewalker/UnimplementedSyntaxTest.java \
(17483 => 17484)</h4> <pre class="diff">
<span class="info">--- \
branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/antlr/treewalker/UnimplementedSyntaxTest.java	2009-08-30 \
                10:33:44 UTC (rev 17483)
+++ branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/antlr/treewalker/UnimplementedSyntaxTest.java	2009-08-30 \
17:39:33 UTC (rev 17484) </span><span class="lines">@@ -203,11 +203,17 @@
</span><span class="cx">     // -----------------------
     // TODO: move somewhere else
     public void test_StaticImport1() throws Exception {
</span><span class="rem">-        assertNotNull(compile(&quot;import static \
foo.Bar.mooky&quot;)); </span><span class="add">+    	//GROOVY-3711: The following \
call now results in a valid script class node, so foo.Bar needs to get resolved. +    \
GroovyShell groovyShell = new GroovyShell(); +    	compile(&quot;package foo; class \
Bar{}&quot;, groovyShell); +        assertNotNull(compile(&quot;import static \
foo.Bar.mooky&quot;, groovyShell)); </span><span class="cx">     }
 
     public void test_StaticImport2() throws Exception {
</span><span class="rem">-        assertNotNull(compile(&quot;import static \
foo.Bar.*&quot;)); </span><span class="add">+    	//GROOVY-3711: The following call \
now results in a valid script class node, so foo.Bar needs to get resolved. +    \
GroovyShell groovyShell = new GroovyShell(); +    	compile(&quot;package foo; class \
Bar{}&quot;, groovyShell); +        assertNotNull(compile(&quot;import static \
foo.Bar.*&quot;, groovyShell)); </span><span class="cx">     }
 
     // TODO: move somewhere else GROOVY-1874
</span><span class="lines">@@ -233,9 +239,12 @@
</span><span class="cx">     }
 
     private Script compile(String input) throws Exception {
</span><span class="add">+    	return compile(input, new GroovyShell());
+    }
+
+    private Script compile(String input, GroovyShell groovyShell) throws Exception {
</span><span class="cx">         TraversalTestHelper traverser = new \
TraversalTestHelper();  traverser.traverse(input, SourcePrinter.class, \
Boolean.FALSE); </span><span class="rem">-        GroovyShell groovyShell = new \
GroovyShell(); </span><span class="cx">         return groovyShell.parse(input);
     }
 
</span></pre></div>
<a id="branchesGROOVY_1_6_Xsrctestorgcodehausgroovyjsr223vm5JSR223Testgroovy"></a>
<div class="modfile"><h4>Modified: \
branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/jsr223/vm5/JSR223Test.groovy \
(17483 => 17484)</h4> <pre class="diff">
<span class="info">--- \
branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/jsr223/vm5/JSR223Test.groovy	2009-08-30 \
                10:33:44 UTC (rev 17483)
+++ branches/GROOVY_1_6_X/src/test/org/codehaus/groovy/jsr223/vm5/JSR223Test.groovy	2009-08-30 \
17:39:33 UTC (rev 17484) </span><span class="lines">@@ -83,4 +83,13 @@
</span><span class="cx">         } catch (ScriptException e) {
         }
     }
</span><span class="add">+
+    public void testEmptyScriptWithJustImports() {
+        ScriptEngine engine = manager.getEngineByName(&quot;groovy&quot;);
+        assertNotNull(engine);
+
+        // GROOVY-3711: The eval of the following script earlier resulted in NPE
+        // as groovy did not generate a script class in this case
+        engine.eval(&quot;import java.lang.*&quot;);
+    }
</span><span class="cx"> }
</span>
</pre>
</div>
</div>

</body>
</html>

<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
    <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic