2

I've got some open source code using the {@Code annotation that Eclipse is complaining about. Since I don't care I turned off Javadoc in the compiler options, but it's still complaining and will not compile compile.

Error is: "Javadoc: Missing closing brace for inline tag"

Actually the closing brace IS present. In some cases it's just a few lines down, but in others it's even on the same line!

Even stranger: The same code in a smaller project in a different workspace works OK. I've compared the 2 projects' settings a couple times and they appear to be the same. In many cases options are set to not allow project specific settings.

I also did other things like doing a project clean, and trying Java 1.5 vs. 1.7 compiler options, etc.

Other details:

  • Java 7 on Mac
  • Eclipse Kepler
  • Code is Guice 2.0 (I know that's old, and normally should use jar, long story)
  • one example is Key.java line 107, see below

Example from Guice code (though I normally wouldn't care since it's just comments)

  /**
    ...
   * <p>{@code new Key<Foo>() {}}.
Mark Bennett
  • 1,446
  • 2
  • 19
  • 37
  • I suggest showing the whole of a failing Javadoc comment, not just the failing line. There could be something going on starting on a previous line that makes a difference. – Patricia Shanahan Aug 24 '13 at 01:27
  • I could do that, but it's not the point. This is presumably working open source code, and it even works in another Eclipse project. Also, the stuff above the offending line is just * comments. – Mark Bennett Aug 26 '13 at 14:45

1 Answers1

0

@code tag has a few caveats (see: Multiple line code example in Javadoc comment)... One of which is that you need to avoid mixing tag braces and actual content braces in the same line.

With that in mind I would rewrite the Javadoc as:

 <p><pre><code>new Key{@literal<Foo>}(){}</code><pre>.</p>

You could also use @code to prevent <Foo> from being interpreted as a HTML tag.

I'm using @literal since the contents are already wrapped with a <code> tag. The <pre> tag is used to retain spaces and line breaks.


About Javadoc configuration, if you want to sweep the dirt under the rug, go to:

Windows -> Preferences -> Java -> Compiler -> Javadoc

And set Malformed Javadoc comments to Ignore. Apply, rebuild and you should be ready to go (also make sure that specific project settings under Project -> Properties-> Java Compiler -> Javadoc are not messing up the setup).

Community
  • 1
  • 1
Anthony Accioly
  • 21,918
  • 9
  • 70
  • 118
  • Thanks Anthony, but I had turned off Javadoc in both Eclipse preferences and in the project's properties, and it still stubbornly seemed to my settings. In terms of braces and the actual content, this was from an existing open source code, I didn't write it. – Mark Bennett Aug 26 '13 at 14:49
  • Mark, I can't reproduce the missbehaviour (setting Malformed Javadoc Comments to ignore excludes the errors). Maybe your workspace is corrupted? (Try creating a new one). – Anthony Accioly Aug 26 '13 at 16:39