當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。