question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@Sharable should also support @Target(ElementType.TYPE_USE)

See original GitHub issue

Expected 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kiril-mecommented, Jan 28, 2019

I can work on that.

0reactions
normanmaurercommented, Jan 31, 2019

@kiril-me thanks a lot for all the help!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found