-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.0
-
generic
-
generic
The application behaviour is different in Merlin. Toolkit.getPrintJob(Frame,String,Properties) is displaying a "Print" dialogbox instead of throwing SecurityException. Testing done with kestrel, it throws a SecurityException without any "Print" dialog.
How to reproduce?
-----------------
1) set the path to JDK build 1.4.0-beta-b49
2) compile, javac T1.java
3) launch, appletviewer T1printjob.html
----------------- T1.java
// applet to test the appletviewer tool
// Calling Toolkit.getPrintJob() Should get SecurityException
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.security.*;
interface AppType {
public final static int APPLICATION = 1;
public final static int APPLET = 2;
}
class T1Frame extends Frame {
private T1 applet = null;
public T1Frame(String t, T1 a) {
super(t);
setLayout(new BorderLayout());
setSize(500, 350);
applet = a;
add("Center", applet);
applet.init();
show();
applet.start();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
class MyFrame extends Frame {
public MyFrame() {
super();
}
}
class MySecurityManager extends SecurityManager {
public MySecurityManager() {
super();
}
}
class MyClassLoader extends ClassLoader {
public MyClassLoader() {
super();
}
public synchronized Class loadClass(String name, boolean resolve) {
Class c = null;
return c;
}
}
public class T1 extends Applet {
private static final String MESSAGE1 = "Calling Toolkit.getPrintJob()";
private static final String MESSAGE2 = "if you receive any Print dialog box after displaying the appletviewer tool-- test FAIL";
private static final String MESSAGE3 = "[Expected behavior is -- thrown SecurityException without";
private static final String MESSAGE4 = "displaying any Print dialog box";
private Font font = new Font("TimesRoman",Font.BOLD,20);
private SecurityManager security = null;
public T1() {
}
public static void main(String args[]) {
new T1Frame("Test Applet", new T1());
}
private void doSomeSetup() {
setSize(500, 500);
try {
security = System.getSecurityManager();
if(security == null)
System.out.println("DANGER: There is no SecurityManager in place");
} catch(SecurityException e1) {
;
} catch(Exception e2) {
;
}
}
public void init() {
doSomeSetup();
test1();
}
private void test1() {
//System.out.println("Calling Toolkit.getPrintJob() " + "[Should get SecurityException]");
try {
MyFrame myframe = new MyFrame();
PrintJob pj = getToolkit().getPrintJob(myframe, "Test Print",
(Properties)null);
System.out.println("Expection(SecurityException) not thrown");
//System.out.println(" Test FAILED");
} catch(SecurityException e1) {
e1.printStackTrace();
//System.out.println(" \n Test PASSED: Received expected Secerity Exception" );
;
} catch(Exception e2) {
e2.printStackTrace();
//System.out.println(" \n Test FAILED: Caught Unexpected Exception");
}
}
public void paint(Graphics g) {
g.setColor(Color.black);
g.setFont(font);
g.drawString(MESSAGE1, 10, 20);
g.drawString(MESSAGE2, 10, 45);
g.drawString(MESSAGE3, 10, 65);
g.drawString(MESSAGE4, 10, 85);
}
}
--------------- test program (T1.java) end ---
--------------T1printjob.html
<HTML>
<HEAD>
<TITLE>Test Applet to test Appletviewer</TITLE>
</HEAD>
<BODY>
<P>
<APPLET CODE=T1.class WIDTH=500 HEIGHT=200></APPLET>
</APPLET>
</BODY>
</HTML>
-----------------------
How to reproduce?
-----------------
1) set the path to JDK build 1.4.0-beta-b49
2) compile, javac T1.java
3) launch, appletviewer T1printjob.html
----------------- T1.java
// applet to test the appletviewer tool
// Calling Toolkit.getPrintJob() Should get SecurityException
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.security.*;
interface AppType {
public final static int APPLICATION = 1;
public final static int APPLET = 2;
}
class T1Frame extends Frame {
private T1 applet = null;
public T1Frame(String t, T1 a) {
super(t);
setLayout(new BorderLayout());
setSize(500, 350);
applet = a;
add("Center", applet);
applet.init();
show();
applet.start();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
class MyFrame extends Frame {
public MyFrame() {
super();
}
}
class MySecurityManager extends SecurityManager {
public MySecurityManager() {
super();
}
}
class MyClassLoader extends ClassLoader {
public MyClassLoader() {
super();
}
public synchronized Class loadClass(String name, boolean resolve) {
Class c = null;
return c;
}
}
public class T1 extends Applet {
private static final String MESSAGE1 = "Calling Toolkit.getPrintJob()";
private static final String MESSAGE2 = "if you receive any Print dialog box after displaying the appletviewer tool-- test FAIL";
private static final String MESSAGE3 = "[Expected behavior is -- thrown SecurityException without";
private static final String MESSAGE4 = "displaying any Print dialog box";
private Font font = new Font("TimesRoman",Font.BOLD,20);
private SecurityManager security = null;
public T1() {
}
public static void main(String args[]) {
new T1Frame("Test Applet", new T1());
}
private void doSomeSetup() {
setSize(500, 500);
try {
security = System.getSecurityManager();
if(security == null)
System.out.println("DANGER: There is no SecurityManager in place");
} catch(SecurityException e1) {
;
} catch(Exception e2) {
;
}
}
public void init() {
doSomeSetup();
test1();
}
private void test1() {
//System.out.println("Calling Toolkit.getPrintJob() " + "[Should get SecurityException]");
try {
MyFrame myframe = new MyFrame();
PrintJob pj = getToolkit().getPrintJob(myframe, "Test Print",
(Properties)null);
System.out.println("Expection(SecurityException) not thrown");
//System.out.println(" Test FAILED");
} catch(SecurityException e1) {
e1.printStackTrace();
//System.out.println(" \n Test PASSED: Received expected Secerity Exception" );
;
} catch(Exception e2) {
e2.printStackTrace();
//System.out.println(" \n Test FAILED: Caught Unexpected Exception");
}
}
public void paint(Graphics g) {
g.setColor(Color.black);
g.setFont(font);
g.drawString(MESSAGE1, 10, 20);
g.drawString(MESSAGE2, 10, 45);
g.drawString(MESSAGE3, 10, 65);
g.drawString(MESSAGE4, 10, 85);
}
}
--------------- test program (T1.java) end ---
--------------T1printjob.html
<HTML>
<HEAD>
<TITLE>Test Applet to test Appletviewer</TITLE>
</HEAD>
<BODY>
<P>
<APPLET CODE=T1.class WIDTH=500 HEIGHT=200></APPLET>
</APPLET>
</BODY>
</HTML>
-----------------------