@Sharable should also support @Target(ElementType.TYPE_USE)
See original GitHub issueExpected behavior
@Sharable
should also be usable with anonymous inner types, so that it is no longer necessary to make named classes (top-level or nested) for sharable handlers. Since Java 8, this is possible with the new ElementType
TYPE_USE
.
The practical problem here is that either (a) Netty would have to, at some point, require Java 8 (don’t think that’s the case yet), or (b) an additional Java-8-specific @Sharable
annotation would have to be introduced.
Actual behavior
@Sharable
only targets ElementType
TYPE
and requires a proper (i.e., named) class.
Steps to reproduce
Add @Sharable
annotation to inner class, observe compilation error.
Minimal yet complete reproducer code (or URL to code)
ChannelInboundHandler echoHandler = new @Sharable ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext context, Object message) {
context.write(message);
}
}
Netty version
4.1.22.Final
JVM version (e.g. java -version
)
1.8.0_152
OS version (e.g. uname -a
)
Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64 (MacOS 10.12.6)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Java Annotation @Target(ElementType.TYPE_USE)
The constant TYPE_USE corresponds to the 15 type contexts in JLS ... an annotation whose type is meta-annotated with @Target(ElementType.
Read more >Annotations in Java - Beknazar - Medium
Annotations are the way we can add metadata to class declaration, variable declaration ... @Target is used also to create other annotations.
Read more >Add ElementType.TYPE_USE target to StringRes annotation ...
Adding ElementType.TYPE_USE target to StringRes annotation will be useful for higher order Kotlin functions. For example, currently it is not possible to ...
Read more >Type Annotations in Java 8: Tools and Opportunities - InfoQ
TYPE_USE target indicates that the annotation can be written on any use of a type (e.g., types appearing in declarations, generics, and casts)....
Read more >Java Annotation - Hechao's Blog
@Target annotation marks another annotation to restrict what kind of Java elements the annotation can be applied to. A target annotation ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can work on that.
@kiril-me thanks a lot for all the help!