title: NPE in groovy method while compiling
body: <p>I'm getting a NPE in a strange manner. Next is the method call because of which it's happening:</p>
  
  <pre><code>    String exec(String command) {
          if (command == null || isConnected()) return null;
  
          Session session = null;
          boolean error = false;
          try {
              session = ssh.startSession();
  //           try {
  //                final Session.Command cmd = session.exec(command);
  //                String result = cmd.getOutputAsString();
  //                if (cmd.getExitStatus() != null &amp;&amp; cmd.getExitStatus() != 0){
  //                    //TODO:command execution failure should be logged
  //                    error = true;
  //                } else {
  //                    return result;
  //                }
  
  //            } catch (Exception ex){
  //                //TODO:command execution failure should be logged
  //                ex.printStackTrace();
  //                error = true;
  //            }
          } catch (Exception ex) {
              // TODO:session creation failure should be logged
              ex.printStackTrace();
              error = true;
          } finally {
              session.close();
              if (error) return null;
          }
      }
  </code></pre>
  
  <p>If I uncomment the inner try/catch blocks (even declaration only) I get a NPE generated by groovy as follows:</p>
  
  <pre><code>java.lang.NullPointerException
      at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
      at org.objectweb.asm.MethodAdapter.visitMaxs(Unknown Source)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:605)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:696)
      at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1039)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:276)
      at org.codehaus.groovy.control.CompilationUnit$12.call(CompilationUnit.java:748)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:942)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
      at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:43)
      at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:128)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:75)
  </code></pre>
  
  <p>Code is nothing special, the <strong>ssh</strong> variable is not null. But I can't figure out what the heck is going on.</p>