Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E5858200B51 for ; Mon, 1 Aug 2016 09:58:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E42CE160A65; Mon, 1 Aug 2016 07:58:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 35CD3160A5D for ; Mon, 1 Aug 2016 09:58:09 +0200 (CEST) Received: (qmail 67466 invoked by uid 500); 1 Aug 2016 07:58:08 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 67455 invoked by uid 99); 1 Aug 2016 07:58:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2016 07:58:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D9E9C186FAA for ; Mon, 1 Aug 2016 07:58:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.611 X-Spam-Level: X-Spam-Status: No, score=0.611 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 0ZmUQDzuTJfY for ; Mon, 1 Aug 2016 07:58:05 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 301F15F295 for ; Mon, 1 Aug 2016 07:58:03 +0000 (UTC) Received: from [192.168.1.7] ([77.177.9.35]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0LjIel-1aqxXZ2wFL-00dXTm for ; Mon, 01 Aug 2016 09:57:54 +0200 Subject: Re: Undeclared type variable: T when calling a method from a class with a trait from java To: users@groovy.apache.org References: <1470002913044-5734382.post@n5.nabble.com> From: Jochen Theodorou Message-ID: <579F00FF.5060004@gmx.org> Date: Mon, 1 Aug 2016 09:57:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1470002913044-5734382.post@n5.nabble.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:PfTekcgQXLTjtmb+V/UnDev6xofHcqFbN0RPf9n/XfqmJSHpt4W s9DTFibRWN0Tl49eMLnX7CPUc/n8aL1uIRPliDRGoY9ARZHP9HYR4NtWoGAjrP7/z73cxLS HlUxTxsFhh8Jg+0/EEiXRMoCeFaiaGzAGGRuoV6tAEadV57IXoZfbHs4o2M1YmQrXIQoAFa jCa0BNgSnUbRzDt+mBuoQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:0gHfzgwXrHc=:gyJk9tUc46p6tV9/x3Ldp5 shC3qKpRwbNzL8YweaLlImtYw8gx3ZCpgDeL7A8qafuXcAB8YwXDnwioSZh+Qp1nvK9eDGiMa E9wJRlsdj/sTeyw8OUuDhW9aT191kDW6l2TAnuuSS9cmGBesuQh5t0Mrl5GxfTqLcOPxfoubf 2o0RlPODVYbpP2155I7ln/ui8sPQNYXxMYT3rP1drlbjKyLhVIC2Me6RFG/m0zrmhLt8WFcAl cAF0MRz32VXdeaTpPWn3QMfQM9+aVzdLpodc88bOvpeEFNxsyqwnqJ/afWWTACumlaq2xk3Dc NULV+0wcuzD72R1DFWoy0wAWPESeLTa7Ho9Kz2StTga/I814dKP0Tka8jCzwwW3z6Nff5tXDA GxDVCMpy6L6HATRdwcFGe7vbOc976awSoyRe5aN2GGoKeywIQCV0sxt82QCqulZIbWxtY4Rbo Wz8iZc8kjDAwWzCkJU1Umg3ANFZ2N6UsERQQeQqkDPEKUyPamSkh8WL6UggIYMtGA1cIbY0Pb Rds08r65+GFt4RBzdkYfi4hcRZJZv2N0ZqYBUxHgvxDxT/jkKppr0GOHQUfFHxuMf+Qf0Xd3v aqQwwWpVpR+oohUySPhQF19EN00s5vJSxmWSNesy+jB0Oraqt5yJkA0ipDIfiHAUznHJI5Tl5 jNYovCBqKIlygfDTICVbXOSiGVkeJe7LMeoMSr0U4JRxlyvvgAmlHlvndtZ54do5gSuMolrrw zyRFr078tze9tXue0tLMdfgvMmpU+gEIoNjcwjUlPMPO3agtxEbLwHGxwR+yTNZliJh+QWk12 gCovyRw archived-at: Mon, 01 Aug 2016 07:58:10 -0000 that sounds like a bug in the code generated by the groovy compiler for the one of the fields you use. Though I remember a bug like this being fixed... Can you ell us what groovy version you use? Also... that error message from Java is strangely descriptive. Normally you end up with a some very cryptic stuff from inside the jdk... could you tell me what Java version you use as well? bye Jochen On 01.08.2016 00:08, abosch wrote: > Heyho, > > I have the following problem, maybe someone can help me here, thx :): > > I have a trait, which adds recursive behaviour to a class like a > DirectoryEntity. > > @CompileStatic > trait RecursiveEntity> extends Entity { > T successor; > final List subEntities = new ArrayList(); > > void setParent(final T newParent) { > if (successor) { > successor.removeSubEntity(this as T); > } > successor = newParent; > if (newParent) { > newParent.addSubEntity(this as T); > } > } > > void addSubEntity(final T newEntity) { > Validate.notNull(newEntity) > def parent = newEntity.successor; > if (parent) { > parent.removeSubEntity(newEntity); > } > newEntity.successor = this as T; > subEntities.add(newEntity); > } > > void removeSubEntity(final T toRemove) { > Validate.notNull(toRemove) > if (toRemove.successor == this) { > subEntities.remove(toRemove); > toRemove.successor = null; > } > } > ... > } > > @CompileStatic > class DirectoryEntity implements RecursiveDirectoryEntity { > > @Delegate > Container container = new Container<>() > ... > } > > If I construct a DirectoryEntity from within Java code and use any method, I > get following Error message: Error:(13, 24) java: cannot access > de.unibremen.st.entitygraph.traits.RecursiveEntity$Trait$FieldHelper bad > class file: > /home/artur/Arbeit/tools/entitygraph/build/classes/main/de/unibremen/st/entitygraph/traits/RecursiveEntity$Trait$FieldHelper.class > undeclared type variable: T Please remove or make sure it appears in the > correct subdirectory of the classpath. > > Is there a solution to my problem? I already had to remove multiple trait > usage and introduce Delegates because java can't handle it. > > To just use groovy code is not an option as my coworker's project is plain > java... > Big thx you and greets! Artur > > > > -- > View this message in context: http://groovy.329449.n5.nabble.com/Undeclared-type-variable-T-when-calling-a-method-from-a-class-with-a-trait-from-java-tp5734382.html > Sent from the Groovy Users mailing list archive at Nabble.com. >