热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Java中处理NullPointerException:getStackTrace()方法详解与实例代码

本文整理了Java中java.lang.NullPointerException.getStackTrace()方法的一些代码示例,展示了NullPointerException.getStackTr

本文整理了Java中java.lang.NullPointerException.getStackTrace()方法的一些代码示例,展示了NullPointerException.getStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NullPointerException.getStackTrace()方法的具体详情如下:
包路径:java.lang.NullPointerException
类名称:NullPointerException
方法名:getStackTrace

NullPointerException.getStackTrace介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
public final NullPointerException nullParamNPE(final String name) {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullParamNPE$str(), name));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String invalidPermissiOnAction= "COM00007: Invalid permission action '%s'";

代码示例来源:origin: wildfly/wildfly

@Override
public final NullPointerException sendChallengeReturnedNull(final AuthenticationMechanism mechanism) {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), sendChallengeReturnedNull$str(), mechanism));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String bodyIsSetAndNotReadyForFlush = "UT000155: Framed channel body was set when it was not ready for flush";

代码示例来源:origin: wildfly/wildfly

@Override
public final NullPointerException nullTransaction() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullTransaction$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

StackTraceElement[] elements = npe.getStackTrace();
if(elements.length == 0 || !elements[0].getMethodName().equals("skipChar")) { //NOI18N

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

private String getMethodName()
{
final NullPointerException npe = new NullPointerException();
final StackTraceElement[] trace = npe.getStackTrace();
final StackTraceElement methodElement = trace[1];
return methodElement.getMethodName() + " (archiver line: " + methodElement.getLineNumber() + ")";
}

代码示例来源:origin: org.terracotta/terracotta-ee

/**
* Determine whether the NPE should be ignored due to bug 6427854. See
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6427854
*
* @param npe Exception to examine
* @return True if exception should be ignored
*/
public static boolean selectorOpenRace(NullPointerException npe) {
StackTraceElement source = npe.getStackTrace()[0];
if (source.getClassName().equals("sun.nio.ch.Util") && source.getMethodName().equals("atBugLevel")) { return true; }
return false;
}

代码示例来源:origin: org.terracotta/terracotta-l1

/**
* Determine whether the NPE should be ignored due to bug 6427854. See
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6427854
*
* @param npe Exception to examine
* @return True if exception should be ignored
*/
public static boolean selectorOpenRace(NullPointerException npe) {
StackTraceElement source = npe.getStackTrace()[0];
if (source.getClassName().equals("sun.nio.ch.Util") && source.getMethodName().equals("atBugLevel")) { return true; }
return false;
}

代码示例来源:origin: io.undertow/undertow-servlet

@Override
public final NullPointerException headerNameWasNull() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), headerNameWasNull$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String noCOnfidentialPortAvailable= "UT010053: No confidential port is available to redirect the current request.";

代码示例来源:origin: io.undertow/undertow-core

@Override
public final NullPointerException sendChallengeReturnedNull(final AuthenticationMechanism mechanism) {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), sendChallengeReturnedNull$str(), mechanism));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String bodyIsSetAndNotReadyForFlush = "UT000155: Framed channel body was set when it was not ready for flush";

代码示例来源:origin: org.wildfly.transaction/wildfly-transaction-client

@Override
public final NullPointerException nullTransaction() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullTransaction$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override

代码示例来源:origin: io.undertow.jastow/jastow

@Override
public final NullPointerException elResolverNullContext() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), elResolverNullContext$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String errorResolvingVariable = "JBWEB004224: Error resolving variable %s due to %s";

代码示例来源:origin: io.undertow/undertow-servlet

@Override
public final NullPointerException listenerCannotBeNull() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), listenerCannotBeNull$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String sslCannotBeCombinedWithAnyOtherMethod = "UT010045: SSL cannot be combined with any other method";

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
public final NullPointerException nullTransaction() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullTransaction$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
@Override

代码示例来源:origin: org.jboss.eap/wildfly-webservices-server-integration

@Override
public final NullPointerException nullEndpointClass() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullEndpointClass$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String classLoaderResolutiOnFailed= "WFLYWS0025: Cannot resolve module or classloader for deployment %s";

代码示例来源:origin: io.undertow/undertow-servlet

@Override
public final NullPointerException paramCannotBeNullNPE(final String name) {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), paramCannotBeNullNPE$str(), name));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String trailersNotSupported = "UT010060: Trailers not supported for this request due to %s";

代码示例来源:origin: io.undertow/undertow-servlet

@Override
public final NullPointerException nullName() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullName$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String invalidRequestRespOnseType= "UT010048: Can only handle HTTP type of request / response: %s / %s";

代码示例来源:origin: org.wildfly/wildfly-webservices-server-integration

@Override
public final NullPointerException nullEndpointName() {
final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullEndpointName$str()));
final StackTraceElement[] st = result.getStackTrace();
result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
return result;
}
private static final String nullEndpointClass = "WFLYWS0024: Null endpoint class";

代码示例来源:origin: EvoSuite/evosuite

public MockNullPointerException() {
super();
delegate = new MockThrowable();
delegate.setOriginForDelegate(super.getStackTrace()[0]);
}

代码示例来源:origin: EvoSuite/evosuite

public MockNullPointerException(String message) {
super(message);
delegate = new MockThrowable(message);
delegate.setOriginForDelegate(super.getStackTrace()[0]);
}

代码示例来源:origin: EvoSuite/evosuite

@Override
public StackTraceElement[] getStackTrace() {
if(!MockFramework.isEnabled()){
return super.getStackTrace();
}
return getDelegate().getStackTrace();
}

推荐阅读
  • 深入解析SpringMVC核心组件:DispatcherServlet的工作原理
    本文详细探讨了SpringMVC的核心组件——DispatcherServlet的运作机制,旨在帮助有一定Java和Spring基础的开发人员理解HTTP请求是如何被映射到Controller并执行的。文章将解答以下问题:1. HTTP请求如何映射到Controller;2. Controller是如何被执行的。 ... [详细]
  • 深入解析 Android IPC 中的 Messenger 机制
    本文详细介绍了 Android 中基于消息传递的进程间通信(IPC)机制——Messenger。通过实例和源码分析,帮助开发者更好地理解和使用这一高效的通信工具。 ... [详细]
  • 探讨ChatGPT在法律和版权方面的潜在风险及影响,分析其作为内容创造工具的合法性和合规性。 ... [详细]
  • Redux入门指南
    本文介绍Redux的基本概念和工作原理,帮助初学者理解如何使用Redux管理应用程序的状态。Redux是一个用于JavaScript应用的状态管理库,特别适用于React项目。 ... [详细]
  • ListView简单使用
    先上效果:主要实现了Listview的绑定和点击事件。项目资源结构如下:先创建一个动物类,用来装载数据:Animal类如下:packagecom.example.simplelis ... [详细]
  • 在 Android 开发中,通过 Intent 启动 Activity 或 Service 时,可以使用 putExtra 方法传递数据。接收方可以通过 getIntent().getExtras() 获取这些数据。本文将介绍如何使用 RoboGuice 框架简化这一过程,特别是 @InjectExtra 注解的使用。 ... [详细]
  • 本文回顾了2017年的转型和2018年的收获,分享了几家知名互联网公司提供的工作机会及面试体验。 ... [详细]
  • ssm框架整合及工程分层1.先创建一个新的project1.1配置pom.xml ... [详细]
  • 并发编程 12—— 任务取消与关闭 之 shutdownNow 的局限性
    Java并发编程实践目录并发编程01——ThreadLocal并发编程02——ConcurrentHashMap并发编程03——阻塞队列和生产者-消费者模式并发编程04——闭锁Co ... [详细]
  • 本文详细介绍了如何在Android 4.4及以上版本中配置WebView以实现内容的自动高度调整和屏幕适配,确保中文显示正常,并提供代码示例。 ... [详细]
  • 本文详细介绍了如何在 Android 中使用值动画(ValueAnimator)来动态调整 ImageView 的高度,并探讨了相关的关键属性和方法,包括图片填充后的高度、原始图片高度、动画变化因子以及布局重置等。 ... [详细]
  • 深入解析Spring启动过程
    本文详细介绍了Spring框架的启动流程,帮助开发者理解其内部机制。通过具体示例和代码片段,解释了Bean定义、工厂类、读取器以及条件评估等关键概念,使读者能够更全面地掌握Spring的初始化过程。 ... [详细]
  • 深入解析Java多线程与并发库的应用:空中网实习生面试题详解
    本文详细探讨了Java多线程与并发库的高级应用,结合空中网在挑选实习生时的面试题目,深入分析了相关技术要点和实现细节。文章通过具体的代码示例展示了如何使用Semaphore和SynchronousQueue来管理线程同步和任务调度。 ... [详细]
  • 本文将详细探讨 Java 中提供的不可变集合(如 `Collections.unmodifiableXXX`)和同步集合(如 `Collections.synchronizedXXX`)的实现原理及使用方法,帮助开发者更好地理解和应用这些工具。 ... [详细]
  • 软件工程课堂测试2
    要做一个简单的保存网页界面,首先用jsp写出保存界面,本次界面比较简单,首先是三个提示语,后面是三个输入框,然 ... [详细]
author-avatar
我们的生活小窍门
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有