Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can there be whitespace between Java annotations

I was debugging some odd code and I found a problem.

When my code looked like this. That is, with a space between the annotation EclipseLink was not able to pick-up some of the annotations.

  @Id
  @GeneratedValue(generator = "EDGE_PK", strategy = GenerationType.SEQUENCE)

  @SequenceGenerator(name = "EDGE_PK", sequenceName = "SEQ_EDGE_ID")
  @Column(name = "EDGE_ID", nullable = false)
  private Long edgeId;

If I remove the space then the system started working as expected.

Is it legal to have a space between annotations like I have or does it change the meaning? Ie, some apply to the class instead of the variable.

Edit: I'm using Eclipse right now

like image 576
Mark Robinson Avatar asked May 07 '26 01:05

Mark Robinson


1 Answers

Whitespace between annotations is completely irrelevant, it seems to me that you found a quirk in your IDE regarding annotation on-screen display.

like image 103
Óscar López Avatar answered May 08 '26 13:05

Óscar López