lightbend / genjavadoc

A compiler plugin for generating doc’able Java source from Scala source
Other
58 stars 32 forks source link

Invalid java Code for a case class (JDK 11) #215

Closed ignasi35 closed 4 years ago

ignasi35 commented 4 years ago

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.
ignasi35 commented 4 years ago

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.

raboof commented 4 years ago

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?

ignasi35 commented 4 years ago

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

Sounds good to me. :-)