Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Illegal reflective access operation
Illegal reflective access operation [message #1819104] Wed, 08 January 2020 02:18
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
I am getting the following warning when I run the test program code after the warning message. I tested with swt-4.13-win32-win32-x86_64.zip and swt-4.13-win32-win32-x86_64.zip.

It appears all versions have this problem.

------------------ Error Message -----------------------------
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.swt.awt.SWT_AWT (file:/C:/JAR-SAVE/swt-4.13-win64.jar) to method sun.awt.windows.WEmbeddedFrame.synthesizeWindowActivation(boolean)
WARNING: Please consider reporting this to the maintainers of org.eclipse.swt.awt.SWT_AWT
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

======= Program that triggers the above warning =====================

package project.test;

import java.awt.print.*;
import java.io.*;
import java.net.URL;
import javax.swing.*;

import org.eclipse.swt.*;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.*;

public class BugHunt extends Shell {

public static void main (String [] args) {
Display display = new Display ();
JScrollPane scroller;
MyEditorPane pane;
java.awt.Frame frame;
Shell shell = new Shell(display, SWT.SHELL_TRIM);

Composite comp1 = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED);
frame = SWT_AWT.new_Frame(comp1);

try {
pane = new MyEditorPane();
} catch (Throwable t1) {
t1.printStackTrace();
return;
}
scroller = new JScrollPane(pane);
JViewport vp = scroller.getViewport();
vp.add(pane);
vp.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
frame.add(scroller);

shell.setSize(650, 450);

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

}

class MyEditorPane extends JEditorPane
implements Printable, Serializable {
private static final long serialVersionUID = 1L;

public MyEditorPane() throws IOException {
super();
setContentType("text/html;charset=UTF-8");
}
public MyEditorPane(URL url) throws IOException {
super(url);
setContentType("text/html;charset=UTF-8");
}
public MyEditorPane(String url, String title) throws IOException {
super(url, title);
setContentType("text/html;charset=UTF-8");
}
protected void paintComponent(java.awt.Graphics g) {
java.awt.Graphics2D g2 = (java.awt.Graphics2D) g;
g2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
super.paintComponent(g2);
}

public int print(java.awt.Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {
java.awt.Graphics2D g2 = (java.awt.Graphics2D)g;
g2.setColor(java.awt.Color.black);

RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
double pageWidth = pf.getImageableWidth();
double pageHeight = pf.getImageableHeight();

java.awt.Dimension d = this.getSize();
double panelWidth = d.width;
double panelHeight = d.height;
double scale = pageWidth / panelWidth;

// detect printable range;
if (pageIndex >= (int)Math.ceil(scale*panelHeight/pageHeight)) {
return Printable.NO_SUCH_PAGE;
}

// print the contents;
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.translate(0f, -pageIndex*pageHeight);
g2.scale(scale, scale);
this.paint(g2);

return Printable.PAGE_EXISTS;
}
}
Previous Topic:Browser changes cursor
Next Topic:Cookies management
Goto Forum:
  


Current Time: Thu Apr 25 16:29:13 GMT 2024

Powered by FUDForum. Page generated in 0.03561 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top