Results 1 to 2 of 2

Thread: "Unreachable catch block" when java code calls groovy code

  1. #1
    Join Date
    Jun 2010
    Location
    Dallas Area
    Posts
    24

    Default "Unreachable catch block" when java code calls groovy code

    I have this annoying situation in my IDE (STS 2.6.0.RELEASE); we have a java class that invokes methods on a groovy class. My IDE indicates, on the catch block, that the catch is unreachable.

    I've managed to recreate it easily enough with the following:

    Groovy code:
    Code:
    import javax.mail.MessagingException
    
    public interface CanThrowException {
      void thisCanThrowException() throws MessagingException
    }
    Java code:
    Code:
    import javax.mail.MessagingException;
    
    class ShouldCatchException {
      private CanThrowException thing;
      
      public void doIt() {
        try {
          thing.thisCanThrowException();
        } catch( MessagingException e ) {
          System.out.println("Did we catch it?");
        }
      }
    }
    The interesting thing is that if the catch block is removed, the complain then becomes that the MessagingException isn't caught, so a catch block should be added. 'javap' shows the interface was, indeed, constructed saying that the exception is thrown.

    Via the command line, the build succeeds just fine (no surprise), so it's definitely more of an annoyance than anything else.

    Something is not quite right ...

    Suggestions? Bug (where do I file it?)?

    Thanks!

    john

  2. #2
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    Thanks for letting us know about this problem with a simple example. I was able to reproduce. I created http://jira.codehaus.org/browse/GRECLIPSE-1047 to track this issue.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •