You might be confused by the error message
the receiver type doesn't match the enclosing class type
According to the other answers, you shouldn't be able to use this
as a parameter (or declare it as a new variable), but the error message is saying something completely different.
In fact, you can use this
as a parameter, but in only one place: as a receiver parameter.
The receiver parameter is an optional syntactic device for an instance
method or an inner class's constructor. For an instance method, the
receiver parameter represents the object for which the method is
invoked. For an inner class's constructor, the receiver parameter
represents the immediately enclosing instance of the newly constructed
object. In both cases, the receiver parameter exists solely to allow
the type of the represented object to be denoted in source code, so
that the type may be annotated (§9.7.4). The receiver parameter is not
a formal parameter; more precisely, it is not a declaration of any
kind of variable (§4.12.3), it is never bound to any value passed as
an argument in a method invocation expression or class instance
creation expression, and it has no effect whatsoever at run time.
Practically, it would look like
class ThisDemo
{
void show(@Special ThisDemo this)
{
System.out.println(this);
}
}
And you could then extract the @Special
annotation through regular reflection means.