You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2018/09/22 11:20:28 UTC

[Bug 62754] New: Javascript scriptdef with self.log fails with ReferenceError

https://bz.apache.org/bugzilla/show_bug.cgi?id=62754

            Bug ID: 62754
           Summary: Javascript scriptdef with self.log fails with
                    ReferenceError
           Product: Ant
           Version: 1.10.5
          Hardware: Macintosh
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Optional Tasks
          Assignee: notifications@ant.apache.org
          Reporter: Charles.Doucette@hmhco.com
  Target Milestone: ---

Created attachment 36160
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36160&action=edit
sample build file with javascript scriptdef attempting to use self.log

LOC-C02QM212G8WL:build doucettec$ ant-1.10.5 -f build_test_self_log.xml
testEcho
Buildfile:
/Users/doucettec/repos/Mobile/samee-iread-mobile/build/build_test_self_log.xml

echo-task-javascript:

testEcho:

BUILD FAILED
/Users/doucettec/repos/Mobile/samee-iread-mobile/build/build_test_self_log.xml:15:
ReferenceError: "self" is not defined.
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown Source)
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown Source)
        at org.mozilla.javascript.ScriptRuntime.name(Unknown Source)
        at org.mozilla.javascript.gen.c1.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.exec(Unknown Source)
        at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
        at org.mozilla.javascript.Context.evaluateString(Unknown Source)
        at org.apache.bsf.engines.javascript.JavaScriptEngine.eval(Unknown
Source)
        at org.apache.bsf.util.BSFEngineImpl.exec(Unknown Source)
        at org.apache.bsf.BSFManager$6.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.bsf.BSFManager.exec(Unknown Source)
        at
org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRunner.java:130)
        at
org.apache.tools.ant.taskdefs.optional.script.ScriptDef.executeScript(ScriptDef.java:317)
        at
org.apache.tools.ant.taskdefs.optional.script.ScriptDefBase.execute(ScriptDefBase.java:48)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:809)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 0 seconds
LOC-C02QM212G8WL:build doucettec$

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62754] Javascript scriptdef with self.log fails with ReferenceError

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62754

Jaikiran Pai <ja...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal
             Status|NEW                         |NEEDINFO

--- Comment #2 from Jaikiran Pai <ja...@apache.org> ---
Are you sure this is Ant 1.10.5? The line numbers in that stacktrace doesn't
match the one in that version. Neither can I reproduce this against this
version locally. I ran the exact same script as the one attached with Ant
1.10.5 and I had no issues with it:

ant -version

Apache Ant(TM) version 1.10.5 compiled on July 10 2018


ant testEcho

echo-task-javascript:

testEcho:
[scripttest] arg = Hello World

BUILD SUCCESSFUL

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62754] Javascript scriptdef with self.log fails with ReferenceError

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62754

--- Comment #3 from Charles Doucette <Ch...@hmhco.com> ---
I can no longer reproduce this issue.
I'm not sure what changed.
Go ahead and close it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62754] Javascript scriptdef with self.log fails with ReferenceError

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62754

Charles Doucette <Ch...@hmhco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Charles Doucette <Ch...@hmhco.com> ---
I found a work-around, use project.log instead of self.log.

Also, I may have found the issue in:
apache-ant-1.10.5-src/src/main/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java:

    public void executeScript(Map<String, String> attributes,
        Map<String, List<Object>> elements, ScriptDefBase instance) {
        ScriptRunnerBase runner = helper.getScriptRunner();
        runner.addBean("attributes", attributes);
        runner.addBean("elements", elements);
        runner.addBean("project", getProject());
        if (instance != null) {
            runner.addBean("self", instance);
        }
        runner.executeScript("scriptdef_" + name);
    }

I'm not sure what makes instance null or not, but if it is null, then self is
not defined.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62754] Javascript scriptdef with self.log fails with ReferenceError

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62754

Jaikiran Pai <ja...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |INVALID

-- 
You are receiving this mail because:
You are the assignee for the bug.