Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8053944

Attempt to create AppleScript engine returns null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u5
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_05"
      Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.9.4

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Using Eclipse Luna 4.4.0

      A DESCRIPTION OF THE PROBLEM :
      The sample code provided to create an AppleScript engine that can be used to evaluate AppleScript code does not work. Instead of returning an AppleScript engine, a null pointer exception is thrown.



      ADDITIONAL REGRESSION INFORMATION:
      There is an extensive thread on this here:
      http://mail.openjdk.java.net/pipermail/macosx-port-dev/2014-February/006477.html

      The problem doesn't affect all Macs; there is speculation that leftover bits from an earlier Java installation may prevent the problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      public class XTensionInterface {

      protected ScriptEngineManager mgr;
      protected ScriptEngine engine;

      // Constructor
      protected XTensionInterface() {
      mgr = new ScriptEngineManager();
      engine = mgr.getEngineByName("AppleScript");
      if( engine == null ) System.out.println( "null AppleScript engine"); // comes back null!
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The "engine" member should contain an AppleScript engine, but instead is null
      ACTUAL -
      null pointer exception

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no useful log information, just null pointer

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package xtensionstuff;

      // http://lists.apple.com/archives/java-dev/2008/Aug/msg00093.html (re Java & AppleScript)

      import javax.script.ScriptEngine;
      import javax.script.ScriptEngineManager;
      import javax.script.ScriptException;

      public class XTensionInterface {

      protected ScriptEngineManager mgr;
      protected ScriptEngine engine;

      // Constructor
      protected XTensionInterface() {
      mgr = new ScriptEngineManager();
      engine = mgr.getEngineByName("AppleScript");
      if( engine == null ) System.out.println( "null AppleScript engine"); // comes back null!
      }

      public void getValueOfUnit( String unitName ) throws ScriptException {
      String theCmd = "tell application \"XTension\" of machine \"eppc://usernme:password@minime.lan\" to get value of \"" +
      unitName + "\"";
      System.out.println( theCmd );
      theCmd = "2 + 105"; (or any other AppleScript code)
      Object retVal = engine.eval( theCmd );
      System.out.println ( retVal );
      }

      public static void main(String[] args) throws ScriptException {
      XTensionInterface myXTI = new XTensionInterface();
      myXTI.getValueOfUnit( "Barionet 50 Temp 3 (outside)" );
      } // closes main

      } // closes class XTensionInterface

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None that I can find

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: