-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.3, 1.1.5
-
None
-
x86
-
windows_nt
Name: rlT66838 Date: 07/11/97
When I try ending a PrintJob using pj.end() (where pj is the PrintJob
object received back from Toolkit.getPrintJob), the application I an
writing causes an Application Error in JAVA.EXE with the following message:
'The instruction at "0x0200a609" referenced memory at "0x00000000". The memory
could not be "written"'.
I am using the Windows HP LaserJet 4 Plus Driver for printing.
When I run the same program under Solaris, it runs perfectly.
======================================================================
Another report of this problem, sheri.good@Eng 1998-02-09.
I am able to reproduce this problem with about 30 lines of text.
No java program should *ever* be able to crash the
VM.
The content of what I'm printing is landscape text. Currently,
the text may run off the edge of the paper, but I've tried version
where this can't happen and the problem still occurs.
To give you some background (before I ask if a fix can be rushed :-),
we have developed an automated bond trading system for trading
coporate bonds. We have been live for four years or so with an
X/Motif interface and have been received well.
On Monday, we are launching our java version to an entirely different
audience and we currently cannot print. You can imagine how the
traders feel when they can't print their trade reports. If you can't,
that's good, because you don't want to know... :-)
Seriously though, IMO, this is a fairly large and robust java
application (I haven't seen any this big to date) and with some of the
bad press being given to java regarding it's use for larger, more
serious applications, I would rather not add fuel to the fire by
having traders say that "this thing craps out all the time". So, to
that end, I would appreciate any help you can provide in rushing this
problem to a solution. I will be available to help as well, so don't
hesitate to call me or email me.
We have not been able to run our application on platforms other than
windows 95 or NT reliably (so much for "WORE"...).
My print class is below (hopefully it doesn't refer to some other
part of our system). The routine that calls this is also included,
but it will not run as it definitely refers to other parts of our system.
printPSS() *is* the driver code. It calles the BxjPrint() class
which is where the problem is (specifically on pjob.end()). It's
going to take a little coding on your or the engineer's part to drive
this stuff. The docs on the PrintJob class had an example that was the
same as the Core Java example (they probably copied it):
http://www.javasoft.com/products/jdk/1.1/docs/guide/awt/designspec/printing.html
===Calling routine=============================================================
//********************************************************************
// Printing...
public void printPSS() {
BxjPrint prt;
prt = BxjPrint.create(this, "Monitor");
// This returns false if something fails or the user presses cancel
if(prt == null)
return;
prt.setFont(new Font("Courier", Font.BOLD, 9));
prt.addLine("Monitor Price, Size & Spread");
prt.addLine("--------------------------------------------------------------------------------");
prt.addLine("Time: " + new Date().toString());
prt.addLine("FIRM: " + BxjClient.bxjClient.getFirmId() +
" TRADER: " + BxjClient.bxjClient.getBrokerId());
prt.addLine("");
prt.addLine("Name Cpn Mat Size BPrc BYld BSprd ASprd AYld APrc ASize LPrc LYld LSprd LSize");
prt.setFont(new Font("Courier", Font.PLAIN, 9));
for(int i = 0; i < numRows; i++) {
StringBuffer sb = new StringBuffer(" ");
int pos = 0;
// This is a bit of a hack since stringbuffer doesn't give
// you an easy way to "overlay" text in the buffer.
// Known problem: The stringbuffer will get much longer
// than the page is able to print.
sb.insert(pos, (String) table.getCell(i, MonNcolName) + " ");
pos += 17;
sb.insert(pos, (String) table.getCell(i, MonNcolCoupon) + " ");
pos += 7;
sb.insert(pos, (String) table.getCell(i, MonNcolMaturity) + " ");
pos += 12;
sb.insert(pos, (String) table.getCell(i, MonNcolBidSize) + " ");
pos += 7;
sb.insert(pos, (String) table.getCell(i, MonNcolBidPx) + " ");
pos += 24;
sb.insert(pos, (String) table.getCell(i, MonNcolAskPx) + " ");
pos += 24;
sb.insert(pos, (String) table.getCell(i, MonNcolAskSize) + " ");
pos += 7;
sb.insert(pos, (String) table.getCell(i, MonNcolLastPx) + " ");
pos += 24;
sb.insert(pos, (String) table.getCell(i, MonNcolLastSize) + " ");
prt.addLine(sb.toString());
}
prt.end();
}
==BxjPrint class===============================================================
import java.awt.*;
import java.util.*;
public class BxjPrint {
private PrintJob pjob;
private Graphics pg;
private int row, col;
private int width, height;
private boolean justDisposed;
private Font font;
//********************************************************************
// Initialize the print object
public static BxjPrint create(Frame frame, String title) {
BxjPrint prt = new BxjPrint();
return(prt.init(frame, title) ? prt : null);
}
private boolean init(Frame frame, String title) {
// Get the print job from the default toolkit
pjob = Toolkit.getDefaultToolkit().getPrintJob(frame, title, null);
// User selected cancel or something went wrong
if(pjob == null)
return(false);
// If we got it, get the graphics context and set the default
// font. Note: you must set a default font or java will crash
pg = pjob.getGraphics();
if(pg == null)
return(false);
font = new Font("Courier", Font.PLAIN, 12);
pg.setFont(font);
// Initialize the starting point
row = pg.getFontMetrics().getHeight();
col = 20;
width = pjob.getPageDimension().width;
height = pjob.getPageDimension().height;
justDisposed = true;
return(true);
}
//********************************************************************
// Set the font
public boolean setFont(Font f) {
// Allow the user to change the font...
font = f;
pg.setFont(font);
return(true);
}
//********************************************************************
// Add data to the page
public boolean addLine(String line) {
pg.drawString(line, col, row);
row += pg.getFontMetrics().getHeight();
justDisposed = false;
if(row + 2 * pg.getFontMetrics().getHeight() >= height) {
pg.dispose();
pg = pjob.getGraphics();
if(pg == null)
return(false);
pg.setFont(font);
row = pg.getFontMetrics().getHeight();
justDisposed = true;
}
return(true);
}
//********************************************************************
// Print...
public void end() {
if(!justDisposed) {
pg.dispose();
}
pjob.end();
}
}
When I try ending a PrintJob using pj.end() (where pj is the PrintJob
object received back from Toolkit.getPrintJob), the application I an
writing causes an Application Error in JAVA.EXE with the following message:
'The instruction at "0x0200a609" referenced memory at "0x00000000". The memory
could not be "written"'.
I am using the Windows HP LaserJet 4 Plus Driver for printing.
When I run the same program under Solaris, it runs perfectly.
======================================================================
Another report of this problem, sheri.good@Eng 1998-02-09.
I am able to reproduce this problem with about 30 lines of text.
No java program should *ever* be able to crash the
VM.
The content of what I'm printing is landscape text. Currently,
the text may run off the edge of the paper, but I've tried version
where this can't happen and the problem still occurs.
To give you some background (before I ask if a fix can be rushed :-),
we have developed an automated bond trading system for trading
coporate bonds. We have been live for four years or so with an
X/Motif interface and have been received well.
On Monday, we are launching our java version to an entirely different
audience and we currently cannot print. You can imagine how the
traders feel when they can't print their trade reports. If you can't,
that's good, because you don't want to know... :-)
Seriously though, IMO, this is a fairly large and robust java
application (I haven't seen any this big to date) and with some of the
bad press being given to java regarding it's use for larger, more
serious applications, I would rather not add fuel to the fire by
having traders say that "this thing craps out all the time". So, to
that end, I would appreciate any help you can provide in rushing this
problem to a solution. I will be available to help as well, so don't
hesitate to call me or email me.
We have not been able to run our application on platforms other than
windows 95 or NT reliably (so much for "WORE"...).
My print class is below (hopefully it doesn't refer to some other
part of our system). The routine that calls this is also included,
but it will not run as it definitely refers to other parts of our system.
printPSS() *is* the driver code. It calles the BxjPrint() class
which is where the problem is (specifically on pjob.end()). It's
going to take a little coding on your or the engineer's part to drive
this stuff. The docs on the PrintJob class had an example that was the
same as the Core Java example (they probably copied it):
http://www.javasoft.com/products/jdk/1.1/docs/guide/awt/designspec/printing.html
===Calling routine=============================================================
//********************************************************************
// Printing...
public void printPSS() {
BxjPrint prt;
prt = BxjPrint.create(this, "Monitor");
// This returns false if something fails or the user presses cancel
if(prt == null)
return;
prt.setFont(new Font("Courier", Font.BOLD, 9));
prt.addLine("Monitor Price, Size & Spread");
prt.addLine("--------------------------------------------------------------------------------");
prt.addLine("Time: " + new Date().toString());
prt.addLine("FIRM: " + BxjClient.bxjClient.getFirmId() +
" TRADER: " + BxjClient.bxjClient.getBrokerId());
prt.addLine("");
prt.addLine("Name Cpn Mat Size BPrc BYld BSprd ASprd AYld APrc ASize LPrc LYld LSprd LSize");
prt.setFont(new Font("Courier", Font.PLAIN, 9));
for(int i = 0; i < numRows; i++) {
StringBuffer sb = new StringBuffer(" ");
int pos = 0;
// This is a bit of a hack since stringbuffer doesn't give
// you an easy way to "overlay" text in the buffer.
// Known problem: The stringbuffer will get much longer
// than the page is able to print.
sb.insert(pos, (String) table.getCell(i, MonNcolName) + " ");
pos += 17;
sb.insert(pos, (String) table.getCell(i, MonNcolCoupon) + " ");
pos += 7;
sb.insert(pos, (String) table.getCell(i, MonNcolMaturity) + " ");
pos += 12;
sb.insert(pos, (String) table.getCell(i, MonNcolBidSize) + " ");
pos += 7;
sb.insert(pos, (String) table.getCell(i, MonNcolBidPx) + " ");
pos += 24;
sb.insert(pos, (String) table.getCell(i, MonNcolAskPx) + " ");
pos += 24;
sb.insert(pos, (String) table.getCell(i, MonNcolAskSize) + " ");
pos += 7;
sb.insert(pos, (String) table.getCell(i, MonNcolLastPx) + " ");
pos += 24;
sb.insert(pos, (String) table.getCell(i, MonNcolLastSize) + " ");
prt.addLine(sb.toString());
}
prt.end();
}
==BxjPrint class===============================================================
import java.awt.*;
import java.util.*;
public class BxjPrint {
private PrintJob pjob;
private Graphics pg;
private int row, col;
private int width, height;
private boolean justDisposed;
private Font font;
//********************************************************************
// Initialize the print object
public static BxjPrint create(Frame frame, String title) {
BxjPrint prt = new BxjPrint();
return(prt.init(frame, title) ? prt : null);
}
private boolean init(Frame frame, String title) {
// Get the print job from the default toolkit
pjob = Toolkit.getDefaultToolkit().getPrintJob(frame, title, null);
// User selected cancel or something went wrong
if(pjob == null)
return(false);
// If we got it, get the graphics context and set the default
// font. Note: you must set a default font or java will crash
pg = pjob.getGraphics();
if(pg == null)
return(false);
font = new Font("Courier", Font.PLAIN, 12);
pg.setFont(font);
// Initialize the starting point
row = pg.getFontMetrics().getHeight();
col = 20;
width = pjob.getPageDimension().width;
height = pjob.getPageDimension().height;
justDisposed = true;
return(true);
}
//********************************************************************
// Set the font
public boolean setFont(Font f) {
// Allow the user to change the font...
font = f;
pg.setFont(font);
return(true);
}
//********************************************************************
// Add data to the page
public boolean addLine(String line) {
pg.drawString(line, col, row);
row += pg.getFontMetrics().getHeight();
justDisposed = false;
if(row + 2 * pg.getFontMetrics().getHeight() >= height) {
pg.dispose();
pg = pjob.getGraphics();
if(pg == null)
return(false);
pg.setFont(font);
row = pg.getFontMetrics().getHeight();
justDisposed = true;
}
return(true);
}
//********************************************************************
// Print...
public void end() {
if(!justDisposed) {
pg.dispose();
}
pjob.end();
}
}
- duplicates
-
JDK-4084038 Win32 printing: Frequent crashes, page scaled down
-
- Closed
-