Skip to content

Commit

Permalink
local annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
bobjacobsen committed Dec 27, 2019
1 parent 9bb2782 commit 915bac5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 15 deletions.
57 changes: 57 additions & 0 deletions java/src/jmri/Generated.java
@@ -0,0 +1,57 @@
package jmri;

import java.lang.annotation.*;
import javax.annotation.concurrent.NotThreadSafe;

/**
* Annotation denoting that specific code was auto-generated
* <p>
* This is used in preference to {@link javax.annotation.Generated} and
* {@link javax.annotation.processing.Generated} because the first of those
* 8s only available up to Java 10, and the second is only available in Java 11
* or later; there's no single one that works across all current JDKs.
* <p>
* The implementation is from the OpenJDK 11 sources via their license.
*
* @author Bob Jacobsen Copyright 2019
*/

@Retention(RetentionPolicy.CLASS) // For access by JaCoCo et al
@Target({ElementType.PACKAGE,
ElementType.TYPE,
ElementType.METHOD,
ElementType.CONSTRUCTOR,
ElementType.FIELD,
ElementType.LOCAL_VARIABLE,
ElementType.PARAMETER})
@Documented
@Inherited

public @interface Generated {

/**
* The value element MUST have the name of the code generator. The
* name is the fully qualified name of the code generator.
*
* @return The name of the code generator
*/
String[] value();

/**
* Date when the source was generated. The date element must follow the ISO
* 8601 standard. For example the date element would have the following
* value 2017-07-04T12:08:56.235-0700 which represents 2017-07-04 12:08:56
* local time in the U.S. Pacific Time time zone.
*
* @return The date the source was generated
*/
String date() default "";

/**
* A place holder for any comments that the code generator may want to
* include in the generated code.
*
* @return Comments that the code generated included
*/
String comments() default "";
}
2 changes: 1 addition & 1 deletion java/src/jmri/jmris/srcp/parser/package-info.java
Expand Up @@ -19,5 +19,5 @@
"UPM_UNCALLED_PRIVATE_METHOD",
"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"},
justification = "JavaCC generated code")
// @javax.annotation.Generated("Generated by JavaCC") // This only works through Java 10; fails in Java 11
@jmri.Generated("Generated by JavaCC")
package jmri.jmris.srcp.parser;
11 changes: 0 additions & 11 deletions java/src/jmri/jmrix/AbstractConnectionConfig.java
Expand Up @@ -27,7 +27,6 @@ abstract public class AbstractConnectionConfig implements ConnectionConfig {
* Ctor for a functional object with no preexisting adapter. Expect that the
* subclass setInstance() will fill the adapter member.
*/
@SuppressWarnings("deprecation") // two temporary references during migration
public AbstractConnectionConfig() {
try {
// The next commented-out line replacing the following when Issue #4670 is resolved; see Manager
Expand All @@ -41,11 +40,6 @@ public void setValue(Object value) {
setToolTipText(null);
}
super.setValue(value);
// check for legacy, and if so paint red (will have not gotten here if not valid)
if (jmri.Manager.isLegacySystemPrefix(value.toString())) { // temporary reference during migration, see @SuppressWarnings above
setBackground(java.awt.Color.RED);
setToolTipText("This is a legacy prefix that should be migrated, ask on JMRIusers");
}
}

@Override
Expand All @@ -56,11 +50,6 @@ public void setText(String value) {
setToolTipText(null);
}
super.setText(value);
// check for legacy, and if so paint red (will have not gotten here if not valid)
if (jmri.Manager.isLegacySystemPrefix(value)) { // temporary reference during migration, see @SuppressWarnings above
setBackground(java.awt.Color.RED);
setToolTipText("This is a legacy prefix that should be migrated, ask on JMRIusers");
}
}
};

Expand Down
14 changes: 11 additions & 3 deletions java/src/jmri/jmrix/srcp/parser/package-info.java
Expand Up @@ -5,8 +5,16 @@
* We turn off selected SpotBugs checking in the resulting generated code at the
* package level.
*/
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value={"DLS_DEAD_LOCAL_STORE", "EI_EXPOSE_REP2", "MS_OOI_PKGPROTECT", "MS_PKGPROTECT", "NM_METHOD_NAMING_CONVENTION", "","SF_SWITCH_NO_DEFAULT","UPM_UNCALLED_PRIVATE_METHOD","URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"},
justification = "JavaCC generated code" )
// @javax.annotation.Generated("Generated by JavaCC") // This only works through Java 10; fails in Java 11
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value={
"DLS_DEAD_LOCAL_STORE",
"EI_EXPOSE_REP2",
"MS_OOI_PKGPROTECT",
"MS_PKGPROTECT",
"NM_METHOD_NAMING_CONVENTION",
"SF_SWITCH_NO_DEFAULT",
"UPM_UNCALLED_PRIVATE_METHOD",
"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"},
justification = "JavaCC generated code" )
@jmri.Generated("Generated by JavaCC")
package jmri.jmrix.srcp.parser;

0 comments on commit 915bac5

Please sign in to comment.