gpt4 book ai didi

java - 使用 RescaleOp 类时 JVM 崩溃 - 可能是什么原因导致的?

转载 作者:行者123 更新时间:2023-12-02 00:55:23 25 4
gpt4 key购买 nike

我正在尝试编写一些简单的代码来调整图像大小,但 JVM 崩溃了。据我所知,我正在正确使用 API。这是代码:

import java.awt.image.*;
import java.io.*;
import javax.imageio.*;

public class Resizer {
public static void main(String[] args) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("C:\\Users\\Owner\\Desktop\\export\\10.jpg"));
} catch (IOException e) {
System.out.println(e);
return;
}
RescaleOp ro = new RescaleOp(1.25f, 0.0f, null);
BufferedImage output = ro.filter(img, null); //JVM CRASHES ON THIS LINE

// Also crashes if I use these lines instead:
//BufferedImage output = ro.createCompatibleDestImage(img, img.getColorModel());
//ro.filter(img, output);

try {
ImageIO.write(output, "png", new File("C:\\Users\\Owner\\Desktop\\export\\10.output.png"));
} catch (IOException ioe) {
System.out.println(ioe);
return;
}
}
}

我收到此错误:

## An unexpected error has been detected by Java Runtime Environment:##  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d524c5d, pid=13076, tid=11172## Java VM: Java HotSpot(TM) Client VM (10.0-b23 mixed mode windows-x86)# Problematic frame:# C  [mlib_image.dll+0x54c5d]## An error report file with more information is saved as:# C:\Users\Owner\Documents\src\Java\ImageSizer\hs_err_pid13076.log## If you would like to submit a bug report, please visit:#   http://java.sun.com/webapps/bugreport/crash.jsp# The crash happened outside the Java Virtual Machine in native code.# See problematic frame for where to report the bug.#

最佳答案

这很可能是 JVM 中的一个错误,因为通常只有 native 代码才能使 JVM 崩溃,而且看起来您没有使用任何第 3 方的东西。您不是唯一遇到此问题的人。请参阅this message以及对此的回应。特别参见this message这可能会帮助您完成您想要做的事情,而不会导致 JVM 崩溃。

这是一个已知问题。请参阅Sun Bug ID 4886506了解详情。 Sun 错误报告包含可能对您有帮助的解决方法。看来这个 bug 在 JDK 7 中已得到修复。

关于java - 使用 RescaleOp 类时 JVM 崩溃 - 可能是什么原因导致的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/973630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com