lightbend / genjavadoc

A compiler plugin for generating doc’able Java source from Scala source

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid java Code for a case class (JDK 11)

ignasi35 opened this issue · comments

When running in JDK 11, given:

final case class CommandEnvelope(entityId: String, payload: Any)

the output is:

public final class CommandEnvelope implements scala.Product, scala.Serializable {
  static public abstract  R apply (T1 v1, T2 v2)  ;
  static public  java.lang.String toString ()  { throw new RuntimeException(); }
  public  java.lang.String entityId ()  { throw new RuntimeException(); }
  public  Object payload ()  { throw new RuntimeException(); }
  // not preceding
  public   CommandEnvelope (java.lang.String entityId, Object payload)  { throw new RuntimeException(); }
}

This produces multiple errors in apply():

  1. T1, T2 and R are undefined
  2. static abstract is an invalid combination of modifiers.

A workaround to execute javadoc over that java code is to use the (undocummented) --ignore-source-errors flag of javadoc. When using that flag, the error messages are still produced but the process completes successfully and produces the expected HTML.

I think it's outside the scope of genjavadoc to produce valid Java code. We didn't produce valid Java code for JDK9, just 'valid enough to produce useful javadoc'. The difference on JDK11 is that the javadoc tool has become more loud about it.

I think we should 'fix' this issue by explicitly stating this as a non-goal of the project. WDYT?

I think we should 'fix' this issue by explicitly stating this as a non-goal of the project. WDYT?

Sounds good to me. :-)