Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Causes Java 7+ to crash

By: a guest on Jan 13th, 2013  |  syntax: Java  |  size: 1.19 KB  |  views: 82  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.Font;
  2. import java.awt.FontMetrics;
  3. import java.awt.Graphics2D;
  4. import java.awt.font.FontRenderContext;
  5. import java.awt.geom.AffineTransform;
  6. import java.awt.image.BufferedImage;
  7.  
  8. import sun.font.FontDesignMetrics;
  9.  
  10. public class MakeCrash
  11. {
  12.         // If some lines are added/removed then the crash may or may not occur at the some location.
  13.         // this could point to some type of stack corruption
  14.         public static void main(final String args[]) throws Exception
  15.         {
  16.                 BufferedImage bi = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
  17.                 Graphics2D g2 = bi.createGraphics();
  18.                 for (int i = 0; i < 1; i++)
  19.                 {
  20.                         double m00 = Double.NaN, m01 = Double.NaN, m02 = 0.0, m10 = Double.NaN, m11 = Double.NaN, m12 = 0.0;
  21.                         AffineTransform at = new AffineTransform(m00, m10, m01, m11, m02, m12);
  22.                         System.out.println(at);
  23.                         Font font = g2.getFont();
  24.                         System.out.println(font);
  25.                         FontRenderContext frc = new FontRenderContext(at, true, false);
  26.                         FontDesignMetrics fm2 = FontDesignMetrics.getMetrics(font, frc);
  27.                         FontMetrics fm = g2.getFontMetrics(font);
  28.                         g2.setTransform(at);
  29.                         g2.setTransform(at);
  30.                         Thread.sleep(100);
  31.                         fm.getStringBounds("7204", g2);
  32.                 }
  33.         }
  34. }
clone this paste RAW Paste Data