diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java index f9dd57a178..a96f018116 100644 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java @@ -1657,6 +1657,10 @@ private static CharSequence generateDeclaration( final StringBuilder sb = new StringBuilder(); generateTypeJavadoc(sb, BASE_INDENT, typeToken); + if (typeToken.deprecated() > 0) + { + sb.append("@Deprecated\n"); + } sb.append("@SuppressWarnings(\"all\")\n") .append("public final class ").append(className).append(implementsString).append('\n') .append("{\n"); diff --git a/sbe-tool/src/test/java/uk/co/real_logic/sbe/generation/java/JavaGeneratorTest.java b/sbe-tool/src/test/java/uk/co/real_logic/sbe/generation/java/JavaGeneratorTest.java index 5ffc034cd8..3a9064b810 100644 --- a/sbe-tool/src/test/java/uk/co/real_logic/sbe/generation/java/JavaGeneratorTest.java +++ b/sbe-tool/src/test/java/uk/co/real_logic/sbe/generation/java/JavaGeneratorTest.java @@ -458,6 +458,29 @@ public void shouldGenerateRepeatingGroupCountLimits() throws Exception assertEquals(65534, maxValue.invoke(null)); } + @Test + public void shouldMarkDeprecatedClasses() throws Exception + { + final ParserOptions options = ParserOptions.builder().stopOnError(true).build(); + final MessageSchema schema = parse(Tests.getLocalResource("deprecated-msg-test-schema.xml"), options); + final IrGenerator irg = new IrGenerator(); + ir = irg.generate(schema); + + outputManager.clear(); + outputManager.setPackageName(ir.applicableNamespace()); + + generator().generate(); + final String encoderFqcn = ir.applicableNamespace() + ".DeprecatedMessageEncoder"; + final Class encoderClazz = compile(encoderFqcn); + assertNotNull(encoderClazz); + assertTrue(encoderClazz.isAnnotationPresent(Deprecated.class)); + + final String decoderFqcn = ir.applicableNamespace() + ".DeprecatedMessageDecoder"; + final Class decoderClazz = compile(decoderFqcn); + assertNotNull(decoderClazz); + assertTrue(decoderClazz.isAnnotationPresent(Deprecated.class)); + } + private Class getModelClass(final Object encoder) throws ClassNotFoundException { final String className = "Model"; diff --git a/sbe-tool/src/test/resources/deprecated-msg-test-schema.xml b/sbe-tool/src/test/resources/deprecated-msg-test-schema.xml new file mode 100644 index 0000000000..e7ed27e445 --- /dev/null +++ b/sbe-tool/src/test/resources/deprecated-msg-test-schema.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + +