简体   繁体   English

getDeclaredConstructors()返回java.lang.NullPointerException

[英]getDeclaredConstructors() return java.lang.NullPointerException

I'm using a java web framework (Vraptor) and I'm having the following problem: The frameworks uses Reflection to instantiate the Controllers parameters, and for some reason one of the Parameters is returing <java.lang.NullPointerException> . 我正在使用Java Web框架(Vraptor),但遇到以下问题:框架使用Reflection来实例化Controllers参数,并且由于某种原因,其中一个Parameters正在重现<java.lang.NullPointerException>

My question is: the framework works normally for a while, and for some reason the "cachedConstructor" of the type I want to instantiate is filled with <java.lang.NullPointerException> instead of what is expected. 我的问题是:该框架正常工作了一段时间,由于某种原因,我要实例化的类型的“ cachedConstructor”填充了<java.lang.NullPointerException>而不是预期的值。 What could possible make that change? 有什么可能改变呢?

I'm not asking if the framework is doing this, I just want to know what could do this in Java 我不是问框架是否正在执行此操作,我只是想知道在Java中可以执行哪些操作

getClassType().getDeclaredConstructors() is return java.lang.NullPointerException (returning, not throwing)

Most likely getClassType() is returning a null value. 最有可能的getClassType()返回空值。 If you debug through your code and put some console output for values, you'll see which value is coming back as null. 如果您调试代码并放置一些控制台输出值,则将看到哪个值返回为null。 Do some null value checking before you use an object, if required. 如果需要,请在使用对象之前进行一些空值检查。

See What is a NullPointerException, and how do I fix it? 请参阅什么是NullPointerException,以及如何解决它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM