langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterImportSnippetWrap.java
author jlahoda
Tue, 09 May 2017 12:22:15 +0200
changeset 45044 7c50549b7744
parent 43770 a321bed02000
permissions -rw-r--r--
8179531: JShell: fails to provide bytecode for dynamically created lambdas Summary: Adding support for getResource(s) to the JShell's ClassLoader Reviewed-by: psandoz, rfield
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37644
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     1
/*
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     4
 *
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    10
 *
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    15
 * accompanied this code).
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    16
 *
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    20
 *
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    23
 * questions.
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    24
 */
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    25
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    26
package jdk.jshell;
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    27
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    28
import javax.tools.Diagnostic;
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    29
import javax.tools.JavaFileObject;
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    30
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    31
/**
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    32
 * The outer wrap for a set of snippets wrapped in a generated class
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    33
 * @author Robert Field
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    34
 */
43770
a321bed02000 8174762: JShell: @since tags missing
rfield
parents: 39370
diff changeset
    35
class OuterImportSnippetWrap extends OuterWrap {
37644
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    36
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    37
    private final Snippet snippet;
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    38
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    39
    OuterImportSnippetWrap(Wrap wrap, Snippet snippet) {
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    40
        super(wrap);
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    41
        this.snippet = snippet;
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    42
    }
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    43
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    44
    @Override
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    45
    Diag wrapDiag(Diagnostic<? extends JavaFileObject> d) {
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    46
        return new WrappedDiagnostic(d) {
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    47
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    48
            @Override
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    49
            Snippet snippetOrNull() {
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    50
                return snippet;
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    51
            }
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    52
        };
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    53
    }
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    54
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    55
    @Override
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    56
    public String toString() {
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    57
        return "OISW(" + w + ")";
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    58
    }
33cf53901cac 8154485: JShell: infrastructure for multi-Snippet class wrappers
rfield
parents:
diff changeset
    59
}