diff --git a/src/main/java/davidsar/gent/stubjars/components/JarMethod.java b/src/main/java/davidsar/gent/stubjars/components/JarMethod.java index 55a5c19..df59d11 100644 --- a/src/main/java/davidsar/gent/stubjars/components/JarMethod.java +++ b/src/main/java/davidsar/gent/stubjars/components/JarMethod.java @@ -115,7 +115,7 @@ private Expression buildMethod(boolean isEnumField) { ); return Expressions.of(methodDeclaration, StringExpression.SPACE, methodBody); - } else if ((isAbstract() && !isEnumField) || (getParentClazz().isInterface() && !isStatic())) { + } else if ((isAbstract() && !isEnumField) || (isAbstract() && getParentClazz().isInterface() && !isStatic())) { return methodDeclaration.asStatement(); } diff --git a/src/main/java/davidsar/gent/stubjars/components/expressions/MethodDeclarationExpression.java b/src/main/java/davidsar/gent/stubjars/components/expressions/MethodDeclarationExpression.java index 89df230..53dca17 100644 --- a/src/main/java/davidsar/gent/stubjars/components/expressions/MethodDeclarationExpression.java +++ b/src/main/java/davidsar/gent/stubjars/components/expressions/MethodDeclarationExpression.java @@ -42,6 +42,10 @@ public static MethodDeclarationExpression from(JarMethod method, boolean isEnumF signature.add(StringExpression.ABSTRACT); } + if (!method.isAbstract() && method.getParentClazz().isInterface()) { + signature.add(StringExpression.DEFAULT); + } + // Convert method type parameters signature.add(JarType.convertTypeParametersToExpression(method.typeParameters(), method.getParentClazz())); // Convert method return type diff --git a/src/main/java/davidsar/gent/stubjars/components/expressions/StringExpression.java b/src/main/java/davidsar/gent/stubjars/components/expressions/StringExpression.java index fd6ac07..d6561f5 100644 --- a/src/main/java/davidsar/gent/stubjars/components/expressions/StringExpression.java +++ b/src/main/java/davidsar/gent/stubjars/components/expressions/StringExpression.java @@ -33,6 +33,7 @@ public final class StringExpression extends Expression implements FormattedExpre public static final Expression FINAL = new StringExpression(Constants.FINAL); public static final Expression STATIC = new StringExpression(Constants.STATIC); public static final Expression ABSTRACT = new StringExpression(Constants.ABSTRACT); + public static final Expression DEFAULT = new StringExpression(Constants.DEFAULT); public static final Expression VOLATILE = new StringExpression(Constants.VOLATILE); public static final Expression TRANSIENT = new StringExpression(Constants.TRANSIENT); public static final Expression PACKAGE = new StringExpression(Constants.PACKAGE); diff --git a/src/main/java/davidsar/gent/stubjars/components/writer/Constants.java b/src/main/java/davidsar/gent/stubjars/components/writer/Constants.java index f0dcd7e..609a72c 100644 --- a/src/main/java/davidsar/gent/stubjars/components/writer/Constants.java +++ b/src/main/java/davidsar/gent/stubjars/components/writer/Constants.java @@ -41,6 +41,7 @@ public class Constants { public static final String FINAL = "final"; public static final String STATIC = "static"; public static final String ABSTRACT = "abstract"; + public static final String DEFAULT = "default"; public static final String TRANSIENT = "transient"; public static final String VOLATILE = "volatile"; public static final String PACKAGE = "package";