本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例8: printUnresolvedException
import jdk.jshell.UnresolvedReferenceException; //导入依赖的package包/类
void printUnresolvedException(UnresolvedReferenceException ex) {
printSnippetStatus(ex.getSnippet(), false);
}
示例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;
}
示例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();
}
示例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);