Recently i have encountered a crash in in my problem generating a log file with Access_violation exception. In the log file it was mentioned that the problematic frame is awt.dll. What does this refers to?. Why this crash occurs? How to solve this problem?. Actually Am new to java So am not aware of this. I found similar type of questions in same website but i could not encounter any solution yet. Please anyone Explain clearly so that i will get an idea about this. Thanks in Advance. I have attached a part of error log file below.
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x60bf959b, pid=5188, tid=5736
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b15) (build 1.8.0_45-b15)
# Java VM: Java HotSpot(TM) Client VM (25.45-b02 mixed mode windows-x86 )
# Problematic frame:
# C [awt.dll+0x7959b]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
答案 0 :(得分:0)
Problematic frame
部分中的dll与类路径中的其余库不兼容,这里是source,您应该考虑使用一些自定义类加载器加载该库,而不是JVM使用的默认值,这是一个简单的例子:
/**
*
* @author http://codeslices.net team
*
*/
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
*
* Simple custom class loader implementation
*
*/
public class CustomClassLoader extends ClassLoader {
/**
* The HashMap where the classes will be cached
*/
private Map<String, Class<?>> classes = new HashMap<String, Class<?>>();
@Override
public String toString() {
return CustomClassLoader.class.getName();
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
if (classes.containsKey(name)) {
return classes.get(name);
}
byte[] classData;
try {
classData = loadClassData(name);
} catch (IOException e) {
throw new ClassNotFoundException("Class [" + name
+ "] could not be found", e);
}
Class<?> c = defineClass(name, classData, 0, classData.length);
resolveClass(c);
classes.put(name, c);
return c;
}
/**
* Load the class file into byte array
*
* @param name
* The name of the class e.g. com.codeslices.test.TestClass}
* @return The class file as byte array
* @throws IOException
*/
private byte[] loadClassData(String name) throws IOException {
BufferedInputStream in = new BufferedInputStream(
ClassLoader.getSystemResourceAsStream(name.replace(".", "/")
+ ".class"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int i;
while ((i = in.read()) != -1) {
out.write(i);
}
in.close();
byte[] classData = out.toByteArray();
out.close();
return classData;
}
/**
* Simple usage of the CustomClassLoader implementation
*
* @param args
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
*/
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException,
NoSuchMethodException, SecurityException, IllegalArgumentException,
InvocationTargetException
{
CustomClassLoader loader = new CustomClassLoader();
// This class should be in your application class path
Class<?> c = loader.findClass("net.codeslices.test.TestClass");
Object o = c.newInstance();
Method m = c.getMethod("toString");
System.out.println(m.invoke(o));
}
}