当前位置: 首页>>代码示例>>Java>>正文


Java UnresolvedReferenceException类代码示例

本文整理汇总了Java中jdk.jshell.UnresolvedReferenceException的典型用法代码示例。如果您正苦于以下问题:Java UnresolvedReferenceException类的具体用法?Java UnresolvedReferenceException怎么用?Java UnresolvedReferenceException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnresolvedReferenceException类属于jdk.jshell包,在下文中一共展示了UnresolvedReferenceException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testForwardVarToClassGeneric

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
public void testForwardVarToClassGeneric() {
    DeclarationSnippet a = classKey(assertEval("class A<T> { final T x; A(T v) { this.x = v; } ; T get() { return x; } int core() { return g; } }", added(RECOVERABLE_DEFINED)));
    assertUnresolvedDependencies1(a, RECOVERABLE_DEFINED, "variable g");

    List<SnippetEvent> events = assertEval("A<String> as = new A<>(\"hi\");", null,
            UnresolvedReferenceException.class, DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, null);
    SnippetEvent ste = events.get(0);
    Snippet assn = ste.snippet();
    DeclarationSnippet unsn = ((UnresolvedReferenceException) ste.exception()).getSnippet();
    assertEquals(unsn.name(), "A", "Wrong with unresolved");
    assertEquals(getState().unresolvedDependencies(unsn).count(), 1, "Wrong size unresolved");
    assertEquals(getState().diagnostics(unsn).count(), 0L, "Expected no diagnostics");

    Snippet g = varKey(assertEval("int g = 10;", "10",
            added(VALID),
            ste(a, RECOVERABLE_DEFINED, VALID, false, MAIN_SNIPPET)));
    assertEval("A<String> as = new A<>(\"low\");",
            ste(MAIN_SNIPPET, VALID, VALID, false, null),
            ste(assn, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
    assertEval("as.get();", "\"low\"");
    assertUnresolvedDependencies(a, 0);
    assertActiveKeys();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ForwardReferenceTest.java

示例2: testForwardVarToClassGeneric

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
public void testForwardVarToClassGeneric() {
    DeclarationSnippet a = classKey(assertEval("class A<T> { final T x; A(T v) { this.x = v; } ; T get() { return x; } int core() { return g; } }", added(RECOVERABLE_DEFINED)));
    assertUnresolvedDependencies1(a, RECOVERABLE_DEFINED, "variable g");

    List<SnippetEvent> events = assertEval("A<String> as = new A<>(\"hi\");", null,
            UnresolvedReferenceException.class, DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, null);
    SnippetEvent ste = events.get(0);
    Snippet assn = ste.snippet();
    DeclarationSnippet unsn = ((UnresolvedReferenceException) ste.exception()).getSnippet();
    assertEquals(unsn.name(), "A", "Wrong with unresolved");
    assertEquals(getState().unresolvedDependencies(unsn).size(), 1, "Wrong size unresolved");
    assertEquals(getState().diagnostics(unsn).size(), 0, "Expected no diagnostics");

    Snippet g = varKey(assertEval("int g = 10;", "10",
            added(VALID),
            ste(a, RECOVERABLE_DEFINED, VALID, false, MAIN_SNIPPET)));
    assertEval("A<String> as = new A<>(\"low\");",
            ste(MAIN_SNIPPET, VALID, VALID, false, null),
            ste(assn, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
    assertEval("as.get();", "\"low\"");
    assertUnresolvedDependencies(a, 0);
    assertActiveKeys();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:24,代码来源:ReplaceTest.java

示例3: assertEvalUnresolvedException

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
public DeclarationSnippet assertEvalUnresolvedException(String input, String name, int unresolvedSize, int diagnosticsSize) {
    List<SnippetEvent> events = assertEval(input, null, UnresolvedReferenceException.class, DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, null);
    SnippetEvent ste = events.get(0);
    DeclarationSnippet sn = ((UnresolvedReferenceException) ste.exception()).getSnippet();
    assertEquals(sn.name(), name, "Given input: " + input + ", checking name");
    assertEquals(getState().unresolvedDependencies(sn).count(), unresolvedSize, "Given input: " + input + ", checking unresolved");
    assertEquals(getState().diagnostics(sn).count(), (long) diagnosticsSize, "Given input: " + input + ", checking diagnostics");
    return sn;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:KullaTesting.java

示例4: assertEvalUnresolvedException

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
public DeclarationSnippet assertEvalUnresolvedException(String input, String name, int unresolvedSize, int diagnosticsSize) {
    List<SnippetEvent> events = assertEval(input, null, UnresolvedReferenceException.class, DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, null);
    SnippetEvent ste = events.get(0);
    DeclarationSnippet sn = ((UnresolvedReferenceException) ste.exception()).getSnippet();
    assertEquals(sn.name(), name, "Given input: " + input + ", checking name");
    assertEquals(getState().unresolvedDependencies(sn).size(), unresolvedSize, "Given input: " + input + ", checking unresolved");
    assertEquals(getState().diagnostics(sn).size(), diagnosticsSize, "Given input: " + input + ", checking diagnostics");
    return sn;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:KullaTesting.java

示例5: handleEvent

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
private boolean handleEvent(SnippetEvent ste) {
    Snippet sn = ste.snippet();
    if (sn == null) {
        debug("Event with null key: %s", ste);
        return false;
    }
    List<Diag> diagnostics = state.diagnostics(sn).collect(toList());
    String source = sn.source();
    if (ste.causeSnippet() == null) {
        // main event
        for (Diag d : diagnostics) {
            hardmsg(d.isError()? "jshell.msg.error" : "jshell.msg.warning");
            List<String> disp = new ArrayList<>();
            displayDiagnostics(source, d, disp);
            disp.stream()
                    .forEach(l -> hard("%s", l));
        }

        if (ste.status() != Status.REJECTED) {
            if (ste.exception() != null) {
                if (ste.exception() instanceof EvalException) {
                    printEvalException((EvalException) ste.exception());
                    return true;
                } else if (ste.exception() instanceof UnresolvedReferenceException) {
                    printUnresolvedException((UnresolvedReferenceException) ste.exception());
                } else {
                    hard("Unexpected execution exception: %s", ste.exception());
                    return true;
                }
            } else {
                new DisplayEvent(ste, false, ste.value(), diagnostics).displayDeclarationAndValue();
            }
        } else {
            if (diagnostics.isEmpty()) {
                errormsg("jshell.err.failed");
            }
            return true;
        }
    } else {
        // Update
        if (sn instanceof DeclarationSnippet) {
            List<Diag> other = errorsOnly(diagnostics);

            // display update information
            new DisplayEvent(ste, true, ste.value(), other).displayDeclarationAndValue();
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:JShellTool.java

示例6: printUnresolvedException

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
void printUnresolvedException(UnresolvedReferenceException ex) {
    DeclarationSnippet corralled =  ex.getSnippet();
    List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled).collect(toList()));
    new DisplayEvent(corralled, state.status(corralled), FormatAction.USED, true, null, otherErrors)
            .displayDeclarationAndValue();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:JShellTool.java

示例7: handleEvent

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
private boolean handleEvent(SnippetEvent ste) {
    Snippet sn = ste.snippet();
    if (sn == null) {
        debug("Event with null key: %s", ste);
        return false;
    }
    List<Diag> diagnostics = state.diagnostics(sn).collect(toList());
    String source = sn.source();
    if (ste.causeSnippet() == null) {
        // main event
        for (Diag d : diagnostics) {
            hardmsg(d.isError()? "jshell.msg.error" : "jshell.msg.warning");
            List<String> disp = new ArrayList<>();
            displayDiagnostics(source, d, disp);
            disp.stream()
                    .forEach(l -> hard("%s", l));
        }

        if (ste.status() != Status.REJECTED) {
            if (ste.exception() != null) {
                if (ste.exception() instanceof EvalException) {
                    printEvalException((EvalException) ste.exception());
                    return true;
                } else if (ste.exception() instanceof UnresolvedReferenceException) {
                    printUnresolvedException((UnresolvedReferenceException) ste.exception());
                } else {
                    hard("Unexpected execution exception: %s", ste.exception());
                    return true;
                }
            } else {
                new DisplayEvent(ste, FormatWhen.PRIMARY, ste.value(), diagnostics)
                        .displayDeclarationAndValue();
            }
        } else {
            if (diagnostics.isEmpty()) {
                errormsg("jshell.err.failed");
            }
            return true;
        }
    } else {
        // Update
        if (sn instanceof DeclarationSnippet) {
            List<Diag> other = errorsOnly(diagnostics);

            // display update information
            new DisplayEvent(ste, FormatWhen.UPDATE, ste.value(), other)
                    .displayDeclarationAndValue();
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:JShellTool.java

示例8: printUnresolvedException

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
void printUnresolvedException(UnresolvedReferenceException ex) {
    printSnippetStatus(ex.getSnippet(), false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:JShellTool.java

示例9: handleEvent

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
private boolean handleEvent(SnippetEvent ste) {
    Snippet sn = ste.snippet();
    if (sn == null) {
        debug("Event with null key: %s", ste);
        return false;
    }
    List<Diag> diagnostics = state.diagnostics(sn);
    String source = sn.source();
    if (ste.causeSnippet() == null) {
        // main event
        for (Diag d : diagnostics) {
            hardmsg(d.isError()? "jshell.msg.error" : "jshell.msg.warning");
            List<String> disp = new ArrayList<>();
            displayDiagnostics(source, d, disp);
            disp.stream()
                    .forEach(l -> hard("%s", l));
        }

        if (ste.status() != Status.REJECTED) {
            if (ste.exception() != null) {
                if (ste.exception() instanceof EvalException) {
                    printEvalException((EvalException) ste.exception());
                    return true;
                } else if (ste.exception() instanceof UnresolvedReferenceException) {
                    printUnresolvedException((UnresolvedReferenceException) ste.exception());
                } else {
                    hard("Unexpected execution exception: %s", ste.exception());
                    return true;
                }
            } else {
                new DisplayEvent(ste, false, ste.value(), diagnostics).displayDeclarationAndValue();
            }
        } else {
            if (diagnostics.isEmpty()) {
                errormsg("jshell.err.failed");
            }
            return true;
        }
    } else {
        // Update
        if (sn instanceof DeclarationSnippet) {
            List<Diag> other = errorsOnly(diagnostics);

            // display update information
            new DisplayEvent(ste, true, ste.value(), other).displayDeclarationAndValue();
        }
    }
    return false;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:50,代码来源:JShellTool.java

示例10: printUnresolvedException

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
void printUnresolvedException(UnresolvedReferenceException ex) {
    DeclarationSnippet corralled =  ex.getSnippet();
    List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled));
    new DisplayEvent(corralled, state.status(corralled), FormatAction.USED, true, null, otherErrors)
            .displayDeclarationAndValue();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:7,代码来源:JShellTool.java

示例11: createUnresolvedReferenceException

import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
/**
 * Creates an {@code UnresolvedReferenceException} for the Snippet identifed
 * by the specified identifier. An {@link SPIResolutionException} thrown
 * during {@link ExecutionControl#invoke(java.lang.String, java.lang.String) }
 * should be converted to an {@code UnresolvedReferenceException} using
 * this method.
 * <p>
 * The identifier is an internal id, different from the id in the API. This
 * internal id is returned by {@link SPIResolutionException#id()}.
 *
 * @param id the internal integer identifier
 * @param stackElements the stack trace elements to install
 * @return an {@code UnresolvedReferenceException} for the unresolved
 * reference
 */
UnresolvedReferenceException createUnresolvedReferenceException(int id,
        StackTraceElement[] stackElements);
 
开发者ID:campolake,项目名称:openjdk9,代码行数:18,代码来源:ExecutionEnv.java


注:本文中的jdk.jshell.UnresolvedReferenceException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。