groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8760) can't instantiate a class that inherits from base class marked with @MapConstructor
Date Tue, 21 Aug 2018 10:24:00 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-8760?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King updated GROOVY-8760:
------------------------------
    Description: 
basic inheritance where parent is tagged with @MapConstructor then child class cant be instantiated

example as follows 
 
{code}
@MapConstructor
class A {
 String name

 A() {}

 String toString() {
 "A ($name)"
 }
}

class B extends A {
 String toString() {
 "B ($name)"
 }
}

def myA = new A(name:"will")
println myA

def myB = new B(name:"fred")
println myB
{code}
run this and get a RT exception 
{noformat}
A (will)
Caught: java.lang.NoSuchMethodError: com.softwood.scripts.A: method <init>()V not found
java.lang.NoSuchMethodError: com.softwood.scripts.A: method <init>()V not found
 at com.softwood.scripts.B.<init>(TestOfferingAttributeGroup.groovy)
 at com.softwood.scripts.TestOfferingAttributeGroup.run(TestOfferingAttributeGroup.groovy:28)
{noformat}


  was:
basic inheritance where parent is tagged with @MapConstructor then child class cant be instantiated

 

example as follows 

 

@MapConstructor
class A {
 String name

 A() {}

 String toString() {
 "A ($name)"
 }
}

class B extends A {
 String toString() {
 "B ($name)"
 }
}

def myA = new A(name:"will")
println myA

def myB = new B(name:"fred")
println myB

 

run this and get a RT exception 

A (will)
Caught: java.lang.NoSuchMethodError: com.softwood.scripts.A: method <init>()V not found
java.lang.NoSuchMethodError: com.softwood.scripts.A: method <init>()V not found
 at com.softwood.scripts.B.<init>(TestOfferingAttributeGroup.groovy)
 at com.softwood.scripts.TestOfferingAttributeGroup.run(TestOfferingAttributeGroup.groovy:28)


> can't instantiate a class that inherits from base class marked with @MapConstructor
> -----------------------------------------------------------------------------------
>
>                 Key: GROOVY-8760
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8760
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.5.1
>         Environment: intellij 2018.1.4, java jdk 8.0_172, groovy 2.5.1
>            Reporter: William Woodman
>            Priority: Major
>              Labels: features
>
> basic inheritance where parent is tagged with @MapConstructor then child class cant be
instantiated
> example as follows 
>  
> {code}
> @MapConstructor
> class A {
>  String name
>  A() {}
>  String toString() {
>  "A ($name)"
>  }
> }
> class B extends A {
>  String toString() {
>  "B ($name)"
>  }
> }
> def myA = new A(name:"will")
> println myA
> def myB = new B(name:"fred")
> println myB
> {code}
> run this and get a RT exception 
> {noformat}
> A (will)
> Caught: java.lang.NoSuchMethodError: com.softwood.scripts.A: method <init>()V not
found
> java.lang.NoSuchMethodError: com.softwood.scripts.A: method <init>()V not found
>  at com.softwood.scripts.B.<init>(TestOfferingAttributeGroup.groovy)
>  at com.softwood.scripts.TestOfferingAttributeGroup.run(TestOfferingAttributeGroup.groovy:28)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message