Thu, 16 Mar 2017 17:39:31 +0000
8173207: Upgrade compression library
Reviewed-by: sherman, jeff
yan@970 | 1 | /* |
yan@970 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
yan@970 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
yan@970 | 4 | * |
yan@970 | 5 | * This code is free software; you can redistribute it and/or modify it |
yan@970 | 6 | * under the terms of the GNU General Public License version 2 only, as |
yan@970 | 7 | * published by the Free Software Foundation. |
yan@970 | 8 | * |
yan@970 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
yan@970 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
yan@970 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
yan@970 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
yan@970 | 13 | * accompanied this code). |
yan@970 | 14 | * |
yan@970 | 15 | * You should have received a copy of the GNU General Public License version |
yan@970 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
yan@970 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
yan@970 | 18 | * |
yan@970 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
yan@970 | 20 | * or visit www.oracle.com if you need additional information or have any |
yan@970 | 21 | * questions. |
yan@970 | 22 | */ |
yan@970 | 23 | |
yan@970 | 24 | /** |
yan@970 | 25 | * @test |
yan@970 | 26 | * @bug 8036987 |
yan@970 | 27 | * @run |
yan@970 | 28 | */ |
yan@970 | 29 | |
yan@970 | 30 | var factory = Java.type('jdk.nashorn.api.scripting.NashornScriptEngineFactory') |
yan@970 | 31 | var engine = new factory().getScriptEngine(function(str){ |
yan@970 | 32 | return str.indexOf('java.util') != -1; |
yan@970 | 33 | }) |
yan@970 | 34 | |
yan@970 | 35 | load("nashorn:mozilla_compat.js"); |
yan@970 | 36 | engine.eval("load('nashorn:mozilla_compat.js');") |
yan@970 | 37 | |
yan@970 | 38 | function tryEval (str) { |
yan@970 | 39 | try { |
yan@970 | 40 | print(eval(str)) |
yan@970 | 41 | print(engine.eval(str)) |
yan@970 | 42 | } catch (exc) { |
yan@970 | 43 | print(exc.message) |
yan@970 | 44 | } |
yan@970 | 45 | } |
yan@970 | 46 | |
yan@970 | 47 | tryEval("new JavaAdapter(javax.script.ScriptContext){}.class") |
yan@970 | 48 | tryEval("new JavaAdapter(java.util.ArrayList){}.class") |
yan@970 | 49 | tryEval("importClass(java.lang.Integer); Integer") |
yan@970 | 50 | tryEval("importClass(java.util.HashSet); HashSet") |
yan@970 | 51 | tryEval("importPackage(java.lang); Integer") |
yan@970 | 52 | tryEval("importPackage(java.util); HashMap") |