void field

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

void field

paulk_asert
Hi,

I am wondering if anyone has thoughts wrt
https://issues.apache.org/jira/browse/GROOVY-8046?

The example given is:

class MyClass {
  void field
  static void main(String[] args) {}
}

Compiling gives:

Exception in thread "main" java.lang.ClassFormatError: Field "field"
in class MyClass has illegal signature "V"

There are two ways to "fix" this.
(1) Detect this case during class generation and give a friendlier error message
(2) Convert to type "Void" like we "auto-coerce" primitives to their
wrapper equivalents. This also hushes the ClassFormatError.

I can't see any useful meaning that (2) could provide so I am inclined
to just do (1). Any objections/other thoughts?

Cheers, Paul.
Reply | Threaded
Open this post in threaded view
|

Re: void field

Jochen Theodorou


On 14.03.2017 12:26, Paul King wrote:
[...]
> There are two ways to "fix" this.
> (1) Detect this case during class generation and give a friendlier error message

not in ACG and friends, but during compilation, yes. I think we already
have somewhere something checking for invalid modifiers

bye Jochen
Reply | Threaded
Open this post in threaded view
|

Re: void field

paulk_asert
Correct, not ACG but in ClassCompletionVerifier which runs in the
classgen phase.

Cheers, Paul.

On Tue, Mar 14, 2017 at 10:48 PM, Jochen Theodorou <[hidden email]> wrote:

>
>
> On 14.03.2017 12:26, Paul King wrote:
> [...]
>>
>> There are two ways to "fix" this.
>> (1) Detect this case during class generation and give a friendlier error
>> message
>
>
> not in ACG and friends, but during compilation, yes. I think we already have
> somewhere something checking for invalid modifiers
>
> bye Jochen