Scala Programming Language
  1. Scala Programming Language
  2. SI-7398

Do not choke on Java's default methods when parsing Java source files

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.1
    • Fix Version/s: Scala 2.10.2
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      Consider the following Java interface that defines default method:

      interface TestInterface{
        public void testMe();
         
        default public void aDefaulter() {
          System.out.println("Default from interface");
        }
      }
      

      and the following Scala code:

      class TestImpl extends TestInterface {
      	def testMe() { println("TestImpl.testMe") }
      	/*override def aDefaulter() { { println("TestImpl.aDefaulter") } }*/
      }
      

      When we try to compile it by passing both source files, Scala's parser for java files chokes on default modifier:

      scalac -d classes/ src/TestInterface.java src/TestImpl.scala
      src/TestInterface.java:4: error: illegal start of type
        default public void aDefaulter() {
        ^
      src/TestInterface.java:7: error: identifier expected but `}' found.
      }
      ^
      two errors found
      

        Issue Links

          Activity

          Show
          Paul Phillips added a comment - https://github.com/scala/scala/pull/2455
          Hide
          Paul Phillips added a comment -

          Heh, I just realized I forgot to even try compiling java source, since I was really focused on being able to build scala with java8. I have a good feeling though. I realize it is without tests.

          Show
          Paul Phillips added a comment - Heh, I just realized I forgot to even try compiling java source, since I was really focused on being able to build scala with java8. I have a good feeling though. I realize it is without tests.
          Hide
          Paul Phillips added a comment -

          Nope, I failed the source parser. I guess one should try something out at least once before shipping it. I shall return.

          Show
          Paul Phillips added a comment - Nope, I failed the source parser. I guess one should try something out at least once before shipping it. I shall return.
          Show
          Paul Phillips added a comment - https://github.com/scala/scala/pull/2456
          Hide
          James Iry added a comment -

          2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

          Show
          James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
          Hide
          Grzegorz Kossakowski added a comment -

          James, Wasn't it fixed by https://github.com/scala/scala/pull/2456 ?

          Show
          Grzegorz Kossakowski added a comment - James, Wasn't it fixed by https://github.com/scala/scala/pull/2456 ?
          Hide
          Paul Phillips added a comment -

          b2c67b328d

          Show
          Paul Phillips added a comment - b2c67b328d

            People

            • Assignee:
              Paul Phillips
              Reporter:
              Grzegorz Kossakowski
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development