# HG changeset patch # User Jiri Vanek # Date 1447339702 -3600 # Node ID a27404e9786747a1da9179b5e508adde87de7628 # Parent 6001830b0e1d9b2e0c366d3fd3cd6161aff47ed6 fixed build and runtime with jdk9 diff -r 6001830b0e1d -r a27404e97867 ChangeLog --- a/ChangeLog Tue Oct 27 14:13:36 2015 +0100 +++ b/ChangeLog Thu Nov 12 15:48:22 2015 +0100 @@ -1,3 +1,11 @@ +2015-11-12 Jiri Vanek + + fixed build and runtime with jdk9 + * netx/net/sourceforge/jnlp/NetxPanel.java: (init) setting doInit to true + replaced by call to setDoInitIfExists + * netx/sun/applet/AppletViewerPanelAccess.java: added new function of + (setDoInitIfExists) which sets doInit if exists + 2015-10-27 Jiri Vanek itweb-settings, debugging panel made aware about legacy log and client apps log diff -r 6001830b0e1d -r a27404e97867 netx/net/sourceforge/jnlp/NetxPanel.java --- a/netx/net/sourceforge/jnlp/NetxPanel.java Tue Oct 27 14:13:36 2015 +0100 +++ b/netx/net/sourceforge/jnlp/NetxPanel.java Thu Nov 12 15:48:22 2015 +0100 @@ -204,7 +204,7 @@ } public void init(PluginBridge bridge) throws LaunchException { - doInit = true; + setDoInitIfExists(true); dispatchAppletEvent(APPLET_LOADING, null); status = APPLET_LOAD; diff -r 6001830b0e1d -r a27404e97867 netx/sun/applet/AppletViewerPanelAccess.java --- a/netx/sun/applet/AppletViewerPanelAccess.java Tue Oct 27 14:13:36 2015 +0100 +++ b/netx/sun/applet/AppletViewerPanelAccess.java Thu Nov 12 15:48:22 2015 +0100 @@ -41,6 +41,7 @@ import java.util.Hashtable; import java.util.Map; import net.sourceforge.jnlp.NetxPanel; +import net.sourceforge.jnlp.util.logging.OutputController; public abstract class AppletViewerPanelAccess extends AppletViewerPanel { @@ -132,4 +133,36 @@ abstract protected void ourRunLoader(); + /** + * jdk9 removed doInit. + * http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/2b680924a73f This is way how + * to set it in older jdks and still compile on jdk9+ + * + * @param a value to set to doInit if it exists + */ + protected void setDoInitIfExists(boolean a) { + //doInit = a; + try { + Class c = this.getClass(); + Field fs = null; + while (c != null) { + if (AppletPanel.class.equals(c)) { + fs = c.getDeclaredField("doInit"); + break; + } + //known location is NetxPanel->AppeltViwerPannelAccess->AppletViwerPanel->AppletPanel + c = c.getSuperclass(); + } + if (fs == null) { + throw new NoSuchFieldException("AppletPanel not found."); + } + fs.setAccessible(true); + fs.set(this, a); + } catch (IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException ex) { + OutputController.getLogger().log("Can't get/set doInit. Runing on JDK9 or higher?"); + OutputController.getLogger().log(ex); + } + + } + }