Mon, 25 Feb 2013 16:58:31 +0530
8008731: Separate configuration environment (options, error/output writer etc.) from Context
Reviewed-by: hannesw, lagergren
jlaskey@3 | 1 | /* |
jlaskey@7 | 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
jlaskey@3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jlaskey@3 | 4 | * |
jlaskey@3 | 5 | * This code is free software; you can redistribute it and/or modify it |
jlaskey@3 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jlaskey@3 | 7 | * published by the Free Software Foundation. Oracle designates this |
jlaskey@3 | 8 | * particular file as subject to the "Classpath" exception as provided |
jlaskey@3 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
jlaskey@3 | 10 | * |
jlaskey@3 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jlaskey@3 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jlaskey@3 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jlaskey@3 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
jlaskey@3 | 15 | * accompanied this code). |
jlaskey@3 | 16 | * |
jlaskey@3 | 17 | * You should have received a copy of the GNU General Public License version |
jlaskey@3 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
jlaskey@3 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jlaskey@3 | 20 | * |
jlaskey@3 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jlaskey@3 | 22 | * or visit www.oracle.com if you need additional information or have any |
jlaskey@3 | 23 | * questions. |
jlaskey@3 | 24 | */ |
jlaskey@3 | 25 | |
jlaskey@3 | 26 | package jdk.nashorn.internal.runtime; |
jlaskey@3 | 27 | |
jlaskey@3 | 28 | /** |
jlaskey@3 | 29 | * Interface for installing classes passed to the compiler. |
jlaskey@3 | 30 | * As only the code generating package (i.e. Context) knows about |
jlaskey@3 | 31 | * the ScriptLoader and it would be a security hazard otherwise |
jlaskey@3 | 32 | * the Compiler is given an installation interface for its code. |
jlaskey@3 | 33 | * <p>> |
jlaskey@3 | 34 | * The compiler still retains most of the state around code emission |
jlaskey@3 | 35 | * and management internally, so this is to avoid passing around any |
jlaskey@3 | 36 | * logic that isn't directly related to installing a class |
lagergren@89 | 37 | * @param <T> owner class type for this code installer |
jlaskey@3 | 38 | * |
jlaskey@3 | 39 | */ |
lagergren@89 | 40 | public interface CodeInstaller<T> { |
lagergren@89 | 41 | /** |
lagergren@89 | 42 | * Return the owner for the CodeInstaller, e.g. a {@link Context} |
lagergren@89 | 43 | * @return owner |
lagergren@89 | 44 | */ |
lagergren@89 | 45 | public T getOwner(); |
lagergren@89 | 46 | |
jlaskey@3 | 47 | /** |
jlaskey@3 | 48 | * Install a class |
jlaskey@3 | 49 | * @param className name of the class with / separation |
lagergren@89 | 50 | * @param bytecode bytecode |
lagergren@89 | 51 | * @return the installed class |
jlaskey@3 | 52 | */ |
jlaskey@3 | 53 | public Class<?> install(final String className, final byte[] bytecode); |
sundar@118 | 54 | |
sundar@118 | 55 | /* |
sundar@118 | 56 | * Verify generated bytecode before emission. This is called back from the |
sundar@118 | 57 | * {@link ClassEmitter} or the {@link Compiler}. If the "--verify-code" parameter |
sundar@118 | 58 | * hasn't been given, this is a nop |
sundar@118 | 59 | * |
sundar@118 | 60 | * @param bytecode bytecode to verify |
sundar@118 | 61 | */ |
sundar@118 | 62 | public void verify(final byte[] code); |
jlaskey@3 | 63 | } |