Skip to content

Commit 3688d5c

Browse files
author
Rafael Winterhalter
committed
Fixed test cases and member validation for Java 8 interfaces.
1 parent 3d29cf5 commit 3688d5c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/TypeWriter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ protected enum Constraint {
10311031
/**
10321032
* Constrains for an annotation type since Java 8.
10331033
*/
1034-
JAVA8_ANNOTATION("annotation (Java 8+)", false, false, false, true, true, false, true);
1034+
JAVA8_ANNOTATION("annotation (Java 8+)", false, false, false, true, true, true, true);
10351035

10361036
/**
10371037
* A name to represent the type being validated within an error message.
@@ -1141,7 +1141,7 @@ protected void assertMethod(String name, boolean isAbstract, boolean isPublic, b
11411141
} else if (!isStatic && isAbstract && !allowsAbstract) {
11421142
throw new IllegalStateException("Cannot define abstract method " + name + " for " + sortName);
11431143
} else if (!isAbstract && !allowsNonAbstract) {
1144-
throw new IllegalStateException("Cannot define non-abstract method " + name + " + for " + sortName);
1144+
throw new IllegalStateException("Cannot define non-abstract method " + name + " for " + sortName);
11451145
} else if (!isStatic && isDefaultIncompatible && allowsDefaultValue) {
11461146
throw new IllegalStateException("The signature of " + name + " is not compatible for a property of " + sortName);
11471147
}

byte-buddy-dep/src/test/java/net/bytebuddy/dynamic/scaffold/TypeWriterDefaultTest.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.bytebuddy.description.modifier.TypeManifestation;
66
import net.bytebuddy.description.modifier.Visibility;
77
import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy;
8+
import net.bytebuddy.implementation.StubMethod;
89
import net.bytebuddy.implementation.SuperMethodCall;
910
import net.bytebuddy.test.utility.JavaVersionRule;
1011
import net.bytebuddy.test.utility.ObjectPropertyAssertion;
@@ -128,12 +129,12 @@ public void testStaticMethodOnInterfaceAssertion() throws Exception {
128129
}
129130

130131
@Test
131-
@JavaVersionRule.Enforce(value = 8)
132+
@JavaVersionRule.Enforce(8)
132133
public void testStaticMethodOnAnnotationAssertionJava8() throws Exception {
133134
new ByteBuddy()
134135
.makeInterface()
135136
.defineMethod(FOO, String.class, Collections.<Class<?>>emptyList(), Visibility.PUBLIC, Ownership.STATIC)
136-
.withoutCode()
137+
.intercept(StubMethod.INSTANCE)
137138
.make();
138139
}
139140

@@ -143,16 +144,17 @@ public void testStaticMethodOnAnnotationAssertion() throws Exception {
143144
new ByteBuddy()
144145
.makeAnnotation()
145146
.defineMethod(FOO, String.class, Collections.<Class<?>>emptyList(), Visibility.PUBLIC, Ownership.STATIC)
146-
.withoutCode()
147+
.intercept(StubMethod.INSTANCE)
147148
.make();
148149
}
149150

150151
@Test
151-
@JavaVersionRule.Enforce(value = 8)
152+
@JavaVersionRule.Enforce(8)
152153
public void testStaticMethodOnInterfaceAssertionJava8() throws Exception {
153154
new ByteBuddy()
154155
.makeAnnotation()
155-
.defineField(FOO, String.class, Visibility.PUBLIC, Ownership.STATIC)
156+
.defineMethod(FOO, String.class, Collections.<Class<?>>emptyList(), Visibility.PUBLIC, Ownership.STATIC)
157+
.intercept(StubMethod.INSTANCE)
156158
.make();
157159
}
158160

0 commit comments

Comments
 (0)