Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3732: fix NPE for Java 8's 'receiver parameter'
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...sources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocReceiverParameter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.puppycrawl.tools.checkstyle.checks.javadoc; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.nio.ByteBuffer; | ||
|
||
public class InputJavadocReceiverParameter { | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) | ||
public @interface UnknownInitialization { | ||
/** | ||
* A dummy annotation to check Java 8's receiver parameter handling. | ||
* | ||
* @return a class | ||
*/ | ||
Class<?> value() default Object.class; | ||
} | ||
|
||
/** | ||
* Function to check handling of Java 8's receiver parameter. | ||
* | ||
* @param buffer dummy argument | ||
*/ | ||
public void foo(@UnknownInitialization(InputJavadocReceiverParameter.class) InputJavadocReceiverParameter this, | ||
final ByteBuffer buffer) { | ||
buffer.putInt(1); | ||
} | ||
|
||
} |