Replies: 3 comments 2 replies
-
I (think I?) vote for the following set of assertions:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I would say
|
Beta Was this translation helpful? Give feedback.
1 reply
-
{1, 6, 12, 15, 16, 19, 20} .14 Can you provide an example of a method you think we cannot implement? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know that @m0mus likes options so here are options.
Consider a hypothetical loader API sketch:
(For this discussion I'm assuming that
c.isInterface()
MUST returntrue
(see #122). If that changes I'll update the options here.)What MUST be true of
c
? Possible assertions in addition toassert c.isInterface()
include:assert c.getTypeParameters().length == 0;
(i.e. the interface is non-generic)assert !c.isLocalClass();
assert !c.isAnonymousClass();
assert !c.isMemberClass();
assert c.getInterfaces().length == 0;
(i.e. no subtyping)assert !c.getName().startsWith("java.");
(or something similar; i.e. rule outc
being something stupid likejava.lang.Iterable
; this only applies if (7) is not in effect)assert c.getAnnotation(SomeJakartaConfigMarkerAnnotation.class) != null;
(i.e. have some way of marking this interface as a special interface)assert java.lang.reflect.Modifier.isPublic(c.getModifiers());
(i.e. prohibit package-protected interfaces)assert c.getDeclaredMethods().length > 0;
(i.e. rule out "marker" interfaces)What MUST be true of
o.getClass()
? Possible assertions include:assert o.getClass().getDeclaredAnnotation(SomeJakartaConfigMarkerAnnotation.class) != null;
(i.e. the implementation is directly annotated in some way to indicate it's "one of ours")assert o.getClass().isSynthetic();
(i.e. require that the implementation have its synthetic flag set)assert o.getClass().getSuperclass() == Object.class
(i.e. require that the implementation have no supertypes other thanObject
)Then, regarding any method
m
declared byc
, what MUST be true ofm
? Possible assertions include:UnsupportedOperationException
or something similar to be figured out later)assert m.getReturnType() != void.class && m.getReturnType() != Void.class;
(i.e. methods withvoid
orVoid
return types are not permitted)assert m.getParameterCount() == 0;
(i.e. methods that declare parameters are not permitted)assert !java.lang.reflect.Modifier.isStatic(m.getModifiers());
(i.e.static
methods are not permitted)assert !m.isDefault();
(i.e.default
interface methods are not permitted)assert m.getTypeParameters().length == 0;
(i.e. generic methods are not permitted)assert m.getExceptionTypes().length == 0;
(i.e. methods that throw exceptions are not permitted)Beta Was this translation helpful? Give feedback.
All reactions