草庐IT

METHOD_NAME

全部标签

java - 卡在 java.net.SocketInputStream.socketRead0(Native Method)

我在java.net.SocketInputStream.socketRead0(NativeMethod)上卡住了。请看下面的线程转储,它已经处于这种状态3个小时了。Thread-0"prio=10tid=0x00007facd02a5000nid=0x309runnable[0x00007facd4a43000]java.lang.Thread.State:RUNNABLEatjava.net.SocketInputStream.socketRead0(NativeMethod)atjava.net.SocketInputStream.read(SocketInputStream.

java - 带有美元符号和数字 .class 的 java 文件名是什么意思 (name$1.class)?

这个问题在这里已经有了答案:javacompiledclassescontaindollarsigns(4个答案)关闭9年前。当我编译我的javaEnumDay时,它生成了他的Day.class文件和8Day$#.class文件,所以我想知道为什么编译器生成8个$#.class而不是7个,因为我有7个枚举常量,但有8个重写注释,我知道Dollar.class文件是为每个内部类或枚举常量生成的,但是八个.class文件的生成目的是什么?packagecom.kaissersoft.test.objective.one.three.enums;publicenumDay{SUNDAY(01

java - Java 中的 "primitive interface method"是什么?

我正在读《EffectiveJava》,这里引用这本书:Theinterfacedefinesthetype,perhapsprovidingsomedefaultmethods,whiletheskeletalimplementationclassimplementstheremainingnon-primitiveinterfacemethodsatoptheprimitiveinterfacemethods.Extendingaskeletalimplementationtakesmostoftheworkoutofimplementinganinterface.Thisisth

java - 获取 java.rmi.UnmarshalException : unrecognized method hash: method not supported by remote object

我是RMI技术的新手。当我运行rmi客户端程序时,出现异常:java.rmi.UnmarshalException:unrecognizedmethodhash:methodnotsupportedbyremoteobject。我用的是jdk1.5远程方法的参数是序列化对象。这些是服务器代码...这是远程接口(interface)packageinterfacepackage;importjava.rmi.Remote;importjava.rmi.RemoteException;publicinterfaceServerInterfaceextendsRemote{publicvoi

java - loadClass(String name) 和 loadClass(String name, boolean resolve) 的区别

loadClass(Stringname)之间有什么区别?和loadClass(Stringname,booleanresolve)?我知道的唯一区别是如果resolve参数为真,loadClass(Stringname,booleanresolve)调用findLoadedClass(String)?那么什么时候将true或false传递给resolve参数?我对这两个功能很困惑。谢谢。 最佳答案 resolve参数控制加载的类是否链接。在链接期间,静态常量被初始化并分配内存。此外,该类的正确性得到验证,并且可能会解析到其他类的链

java - 数字文字的自动装箱 : wrapper initialization vs passing method arguments inconsistency

请考虑两种情况://1Shorts=10;//obviouslycompiles//2takeShort(10);//error-intisnotapplicable//where:staticvoidtakeShort(Shorts){}我假设情况1被编译器更改为:short_temp_s=10;Shorts=Short.valueOf(_temp_s);您能否解释一下编译器在情况2中试图做什么,所以它无法编译?如果它不像案例1那样尝试应用自动装箱,那么为什么?编辑johnchen902答案中对JSL的引用解释了编译器的行为。仍然不完全清楚为什么JLS不支持方法调用转换的“缩小原始转

java - 为什么在静态上下文中使用实例方法时 javac 会发出 "error: method in class cannot be applied to given types"?

考虑以下(无效的)Java程序:publicclassTest{publicstaticvoidmain(String[]args){int[]ints={1,2,3,4,5};print(ints);}publicvoidprint(int...ints){for(inti:ints){System.out.print(i);}}}我希望出现与此类似的错误:Cannotmakeastaticreferencetothenon-staticmethodprint(int[])fromthetypeTestatTest.main(Test.java:5)相反,javac发出:Test.j

java - 漏洞 : parameter 'initialCapacity' of ConcurrentHashMap's construct method?

java.util.concurrent.ConcurrentHashMap的构造方法之一:publicConcurrentHashMap(intinitialCapacity){if(initialCapacity=(MAXIMUM_CAPACITY>>>1))?MAXIMUM_CAPACITY:tableSizeFor(initialCapacity+(initialCapacity>>>1)+1));this.sizeCtl=cap;}方法“tableSizeFor(...)”的参数是什么意思?initialCapacity+(initialCapacity>>>1)+1我认为参

java - 如何禁用 SQUID :UnusedProtectedMethod in Sonar for a class or method?

我有几个覆盖protected方法的Hadoop映射和归约类。Sonar将这些标记为:UnusedprotectedmethodPlugin:squidKey:UnusedProtectedMethod我知道Sonar中有一个解决此问题的修复程序,并且在某个时候我的组织将使用具有该修复程序的版本。同时,我想禁用警告。我试过:@SuppressWarnings("UnusedProtectedMethod")和@SuppressWarnings("SQUID.UnusedProtectedMethod")没用。@SuppressWarnings适用于PMD问题,@edu.umd.cs.f

java - 带有 ResponseBody : set ResponseStatus in method body 的异常处理程序

我有一个方法可以在SpringMVC环境中处理特定类的异常。方法(简化)实现如下@ExceptionHandler(AjaxException.class)@ResponseStatus(value=HttpStatus.BAD_REQUEST)@ResponseBodypublicExceptionhandleException(AjaxExceptionex){returnex;}这工作正常,但要返回不同的ResponseStatus,我必须创建一个新的处理方法。是否可以在不更改返回类型的情况下更改方法体内的响应状态,而不是使用@ResponseStatus注释?如果不是,是否可以