java.lang.instrument ASSERTION FAILED ***: "error == JVMTI_ERROR_NONE" at Reentrancy.c line: 161
2017-09-10 20:24
591 查看
今天在学习System类的identityHashCode()时,写了如下程序,但遇到了如题所示的错误。
该程序主要是比较String类建立对象的不同方式的区别,以及identityHashCode()方法和重写的hashCode()方法的区别,具体程序如下。
package com.iris.demo;
public class IdentityHashCodeTest {
public static void main(String[] args)
{
//下面程序中的s1和s2是两个不同的对象
String s1=new String("Hello");
String s2=new String("Hello");
//String重写了hashCode()方法,改为根据字符序列计算hashCode()值
//因为s1和s2的字符序列相同,所以它们的HashCode值相同
System.out.println(s1.hashCode()+"---"+s2.hashCode());
//s1和s2是不同的字符串对象,所以它们的identityHashCode值不同
System.out.println(System.identityHashCode(s1)+"---"+System.identityHashCode(s2));
String s3="java";
String s4="java";
//s3和s4是相同的字符串对象,所以它们的identityHashCode值相同
System.out.println(System.identityHashCode(s3)+"---"+System.identityHashCode(s4));
System.out.println(s3.equals(s4));
}
}
运行结果如图所示,第一次运行正常,第二次就出现了如下红色部分,再运行也是好的,说明是偶然事件。。。目前还不直到什么意思,先记录一下。
该程序主要是比较String类建立对象的不同方式的区别,以及identityHashCode()方法和重写的hashCode()方法的区别,具体程序如下。
package com.iris.demo;
public class IdentityHashCodeTest {
public static void main(String[] args)
{
//下面程序中的s1和s2是两个不同的对象
String s1=new String("Hello");
String s2=new String("Hello");
//String重写了hashCode()方法,改为根据字符序列计算hashCode()值
//因为s1和s2的字符序列相同,所以它们的HashCode值相同
System.out.println(s1.hashCode()+"---"+s2.hashCode());
//s1和s2是不同的字符串对象,所以它们的identityHashCode值不同
System.out.println(System.identityHashCode(s1)+"---"+System.identityHashCode(s2));
String s3="java";
String s4="java";
//s3和s4是相同的字符串对象,所以它们的identityHashCode值相同
System.out.println(System.identityHashCode(s3)+"---"+System.identityHashCode(s4));
System.out.println(s3.equals(s4));
}
}
运行结果如图所示,第一次运行正常,第二次就出现了如下红色部分,再运行也是好的,说明是偶然事件。。。目前还不直到什么意思,先记录一下。
相关文章推荐
- “Init library failed & error:!java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader"问题解决
- (C++) Assertion failed: !"Bad error code", file VMem.c, line 715
- An internal error occurred during: "Launching atphone".java.lang.NullPointerException
- <BEA-000386> <Server subsystem failed. Reason: java.lang.AssertionError: java.lang.reflect.Invocatio
- How to solve "java.lang.VerifyError: Expecting a stackmap frame at branch target 6 in method"
- java.lang.AssertionError: java.net.SocketTimeoutException: failed to connect to /192.168.1.5 (por
- Junit单元测试问题 junit.framework.AssertionFailedError: Method "test" not found at android.test.AndroidTes
- Assertion "OSQCreate" failed at line 71 in ..\LWIP\arch\sys_arch.c错误解决方法
- Summary_异常- Exception in thread "RMI TCP Connection(idle)" java.lang.OutOfMemoryError: PermGen space
- myecplise上将工程部署到应用下时,经常出现 An internal error occurred during: "Add Deployment". java.lang.NullPointEx
- 使用Axis插件来从WSDL文件生成代码时"An error occurred while completing process -java.lang.reflect.InvocationTargetException"的错误
- Android Studio中java.lang.AssertionError异常解决方案
- Caused by: java.lang.ClassFormatError: Extra bytes at the end of class file
- maven,Failed to create project.java.lang.NullPointerException,at com.genuitec.eclipse.maven.project.
- Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
- Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/tools/n sc/MainGenericRunne
- 出现严重: Parse Fatal Error at line 147 column 125: 元素类型 "Resource" 必须后跟属性规范 ">的原因" 或 "/>"。
- Exception in thread "http-bio-8080-exec-2" java.lang.OutOfMemoryError: PermGen space
- java.lang.RuntimeException: Failed to resolve attribute at index 6
- 【Error】JavaWeb: 严重: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"]