Uploaded image for project: 'JaxMe'
  1. JaxMe
  2. JAXME-89

Multiple "implements" clauses are not supported

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.5
    • 0.6
    • JaxMeJS
    • None
    • Win XP, J2SE 1.5_09

    Description

      If you want to parse a java source file which implements more than one interface, the parser recognizes them as a single interface. I.e.:

      public class TestClass implements AnInterface {

      works fine, but

      public class TestClass implements AnInterface, ASecondInterface, AThirdInterface {

      fails. If you call JavaSource.getImplements() on the second example, you'll get a String like "AnInterfaceASecondInterfaceAThirdInterface".

      The problem is in the JavaParser.class in the method "parseImplementsOrExtends", where the implements clause is handled like the extends clause and expecting only one interface.

      Replace the method with something like this to make it work:

      private void parseImplementsOrExtends(JavaSource pSource, AST pAST, int pType) {
      AST implementsAST = findChild(pAST, pType);
      if (implementsAST == null)

      { throw new IllegalStateException("AST implements not found"); }

      if (implementsAST.getFirstChild() != null) {
      if (pType == JavaRecognizer.IMPLEMENTS_CLAUSE) {
      for (AST child = implementsAST.getFirstChild(); child != null; child = child.getNextSibling())

      { String ident = parseIdentifier(child); JavaQName qName = getQName(ident); pSource.addImplements(qName); }

      } else

      { String ident = parseIdentifier(implementsAST); JavaQName qName = getQName(ident); pSource.addExtends(qName); }

      }
      }

      Attachments

        1. JavaParser.java
          18 kB
          Andreas Xenos
        2. JavaParser.java
          18 kB
          Andreas Xenos

        Activity

          People

            jochen@apache.org Jochen Wiedmann
            aneumann Andreas Neumann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: