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 B5246200CAF for ; Wed, 7 Jun 2017 20:05:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B3E51160BBF; Wed, 7 Jun 2017 18:05:23 +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 0FC64160BD0 for ; Wed, 7 Jun 2017 20:05:22 +0200 (CEST) Received: (qmail 14496 invoked by uid 500); 7 Jun 2017 18:05:20 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 14487 invoked by uid 99); 7 Jun 2017 18:05:20 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2017 18:05:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6D7F3C69DA for ; Wed, 7 Jun 2017 18:05:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.011 X-Spam-Level: X-Spam-Status: No, score=-100.011 tagged_above=-999 required=6.31 tests=[SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id cUAZ_jBEi-3a for ; Wed, 7 Jun 2017 18:05:19 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 3682A5F2AB for ; Wed, 7 Jun 2017 18:05:19 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 85D44E06BD for ; Wed, 7 Jun 2017 18:05:18 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1651221938 for ; Wed, 7 Jun 2017 18:05:18 +0000 (UTC) Date: Wed, 7 Jun 2017 18:05:18 +0000 (UTC) From: "David Ekholm (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (GROOVY-8221) Not being able to refer to global variables via scripted methods MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 07 Jun 2017 18:05:23 -0000 David Ekholm created GROOVY-8221: ------------------------------------ Summary: Not being able to refer to global variables via scripted methods Key: GROOVY-8221 URL: https://issues.apache.org/jira/browse/GROOVY-8221 Project: Groovy Issue Type: Bug Components: GroovyScriptEngine Affects Versions: 2.4.11 Environment: Probably not relevant, but problem at least confirmed on Mac OS X Reporter: David Ekholm We wish to switch from BeanShell to Groovy as script language (JSR-223) in our desktop software jAlbum. jAlbum injects a set of global variables into the scriptlets via the Bindings object of the JSR-223 API. These variables are directly accessible in simple scripts, but contrary to scripting in BeanShell, these variables are not available to methods declared within scripted classes. Here's what works (assuming that "foo" is passed to the GroovyScriptEngine via the Bindings object): println(foo) // foo being made available to the magically created Script class' run method Here's what won't work (foo again being passed to the GroovyScriptEngine via the Bindings object): class Test { void bar() { println(foo); // Reference to missing variable } } Test t = new Test() t.bar() // Fails due to missing variable -- This message was sent by Atlassian JIRA (v6.3.15#6346)