<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://wiki.apidesign.org/skins/common/feed.css?116"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.apidesign.org/index.php?action=history&amp;feed=atom&amp;title=AlternativeImplementation</id>
		<title>AlternativeImplementation - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.apidesign.org/index.php?action=history&amp;feed=atom&amp;title=AlternativeImplementation"/>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;action=history"/>
		<updated>2026-04-10T23:13:58Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.12.0rc1</generator>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10338&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Modularity = */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10338&amp;oldid=prev"/>
				<updated>2021-02-16T06:12:59Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Modularity =&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:12, 16 February 2021&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 43:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 43:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Our application has to be composed from both [[JAR]] files: ''app-jdk8.jar'' and ''app-jdk11.jar''. The entrypoint has to be in the ''app-jdk8.jar'' and it has to do something reasonable by its own when executed on [[JDK]]8. The use of '''ServiceLoader().load(BetterHandler.class)''' is going to return no ''JDK11EnhancedHandler'' (possibly yielding some {{JDK|java/lang|LinkageError}}) and as such the fallback code is executed. However when running on [[JDK11]] the ''JDK11EnhancedHandler'' is instantiated and can easily access the [[JDK11]] specific functionality.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Our application has to be composed from both [[JAR]] files: ''app-jdk8.jar'' and ''app-jdk11.jar''. The entrypoint has to be in the ''app-jdk8.jar'' and it has to do something reasonable by its own when executed on [[JDK]]8. The use of '''ServiceLoader().load(BetterHandler.class)''' is going to return no ''JDK11EnhancedHandler'' (possibly yielding some {{JDK|java/lang|LinkageError}}) and as such the fallback code is executed. However when running on [[JDK11]] the ''JDK11EnhancedHandler'' is instantiated and can easily access the [[JDK11]] specific functionality.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== [[Modularity]] &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;=&lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== [[Modularity]] ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Both [[OSGi]] as well as [[NetBeans Runtime Container]] help bring this setup to even a better level. They allow one to specify in the ''app-jdk11.jar'' manifest that the [[module]] requires [[JDK11]]. E.g. when running on [[JDK]]8 the ''JDK11EnhancedHandler'' class isn't going to even be available on the &amp;quot;classpath&amp;quot;. That is going to prevent any {{JDK|java/lang|LinkageError}} and just return ''null'' when the implementation of ''ServiceLoader().load(BetterHandler.class)'' is requested.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Both [[OSGi]] as well as [[NetBeans Runtime Container]] help bring this setup to even a better level. They allow one to specify in the ''app-jdk11.jar'' manifest that the [[module]] requires [[JDK11]]. E.g. when running on [[JDK]]8 the ''JDK11EnhancedHandler'' class isn't going to even be available on the &amp;quot;classpath&amp;quot;. That is going to prevent any {{JDK|java/lang|LinkageError}} and just return ''null'' when the implementation of ''ServiceLoader().load(BetterHandler.class)'' is requested.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10337&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Assembling the Application */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10337&amp;oldid=prev"/>
				<updated>2021-02-16T06:12:33Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Assembling the Application&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:12, 16 February 2021&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Assembling the Application ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Assembling the Application ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Our application has to be composed from both [[JAR]] files: ''app-jdk8.jar'' and ''app-jdk11.jar''. The entrypoint has to be in the ''app-jdk8.jar'' and it has to do something reasonable by its own when executed on [[JDK]8. The use of '''ServiceLoader().load(BetterHandler.class)''' is going to return no ''JDK11EnhancedHandler'' (possibly yielding some {{JDK|java/lang|LinkageError}}) and as such the fallback code is executed. However when running on [[JDK11]] the ''JDK11EnhancedHandler'' is instantiated and can easily access the [[JDK11]] specific functionality.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Our application has to be composed from both [[JAR]] files: ''app-jdk8.jar'' and ''app-jdk11.jar''. The entrypoint has to be in the ''app-jdk8.jar'' and it has to do something reasonable by its own when executed on [[JDK&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;]&lt;/ins&gt;]8. The use of '''ServiceLoader().load(BetterHandler.class)''' is going to return no ''JDK11EnhancedHandler'' (possibly yielding some {{JDK|java/lang|LinkageError}}) and as such the fallback code is executed. However when running on [[JDK11]] the ''JDK11EnhancedHandler'' is instantiated and can easily access the [[JDK11]] specific functionality.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== [[Modularity]] ====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== [[Modularity]] ====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10336&amp;oldid=prev</id>
		<title>JaroslavTulach: /* Extension Point */</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10336&amp;oldid=prev"/>
				<updated>2021-02-16T06:10:37Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Extension Point&lt;/span&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:10, 16 February 2021&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Extension Point  ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Extension Point  ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When you need to access a functionality which requires &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;different &lt;/del&gt;code to &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;run &lt;/del&gt;on &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[JDK]]8 and &lt;/del&gt;[[JDK11]], start by defining an [[APISeam]]:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When you need to access a functionality which requires &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;some special &lt;/ins&gt;code to &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;be executed &lt;/ins&gt;on [[JDK11]], start by defining an [[APISeam]]:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10335&amp;oldid=prev</id>
		<title>JaroslavTulach at 06:08, 16 February 2021</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10335&amp;oldid=prev"/>
				<updated>2021-02-16T06:08:57Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:08, 16 February 2021&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Do you want to run [[NetBeans|your application]] on [[JDK]]8, but use [[JDK11]] [[API]]s? That's traditionally done with a reflection. Use [[JDK]]8 [[API]]s directly and let [[javac]] compile your code against them. Whenever using [[JDK11]] [[API]]s, resort to reflection and call them in such a verbose, unsafe manner. That's indeed possible, but especially with [[modularity]] one has better option. Create few [[module]]s/[[JAR]]s and let them work in smooth orchestration.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Do you want to run [[NetBeans|your application]] on [[JDK]]8, but use [[JDK11]] [[API]]s? That's traditionally done with a reflection. Use [[JDK]]8 [[API]]s directly and let [[javac]] compile your code against them. Whenever using [[JDK11]] [[API]]s, resort to reflection and call them in such a verbose, unsafe manner. That's indeed possible, but especially with [[modularity]] one has better option. Create few [[module]]s/[[JAR]]s and let them work in smooth orchestration.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;The Integration point [[API]] &lt;/del&gt; ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Extension Point &lt;/ins&gt; ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When you need to access a functionality which requires different code to run on [[JDK]]8 and [[JDK11]], start by defining an [[APISeam]]:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When you need to access a functionality which requires different code to run on [[JDK]]8 and [[JDK11]], start by defining an [[APISeam]]:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Compile these pieces of code to run on JDK8. Btw. that can easily be done with [[JDK11]] [[javac]] - just use the '''--release 8''' - flag. Then the [[javac]] is only going to expose [[JDK]]8 [[API]] for you - e.g. the resulting [[JAR]] is going to run on [[JDK]]8.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Compile these pieces of code to run on JDK8. Btw. that can easily be done with [[JDK11]] [[javac]] - just use the '''--release 8''' - flag. Then the [[javac]] is only going to expose [[JDK]]8 [[API]] for you - e.g. the resulting [[JAR]] is going to run on [[JDK]]8.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;=== Providing the Extension ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now let's compile the [[JDK11]] part of the application:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now let's compile the [[JDK11]] part of the application:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{{NB|org-openide-util-lookup|org/openide/util/lookup|ServiceProvider}} is a comfortable way to generate ''META-INF/services/BetterHandler'' registration without risk of making typos. One can of course, create the {{JDK|java/util|ServiceLoader}} registration manually.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{{NB|org-openide-util-lookup|org/openide/util/lookup|ServiceProvider}} is a comfortable way to generate ''META-INF/services/BetterHandler'' registration without risk of making typos. One can of course, create the {{JDK|java/util|ServiceLoader}} registration manually&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. This time we use '''--release 11''' flag to instruct [[JDK11]]'s [[javac]] to allow us to use all [[JDK11]]'s [[API]]s without any need to resolve to reflection.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;=== Assembling the Application ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Our application has to be composed from both [[JAR]] files: ''app-jdk8.jar'' and ''app-jdk11.jar''. The entrypoint has to be in the ''app-jdk8.jar'' and it has to do something reasonable by its own when executed on [[JDK]8. The use of '''ServiceLoader().load(BetterHandler.class)''' is going to return no ''JDK11EnhancedHandler'' (possibly yielding some {{JDK|java/lang|LinkageError}}) and as such the fallback code is executed. However when running on [[JDK11]] the ''JDK11EnhancedHandler'' is instantiated and can easily access the [[JDK11]] specific functionality.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;=== [[Modularity]] ====&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Both [[OSGi]] as well as [[NetBeans Runtime Container]] help bring this setup to even a better level. They allow one to specify in the ''app-jdk11.jar'' manifest that the [[module]] requires [[JDK11]]. E.g. when running on [[JDK]]8 the ''JDK11EnhancedHandler'' class isn't going to even be available on the &amp;quot;classpath&amp;quot;. That is going to prevent any {{JDK|java/lang|LinkageError}} and just return ''null'' when the implementation of ''ServiceLoader().load(BetterHandler.class)'' is requested.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;=== Summary ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;It is possible to write [[Java]] application that runs on [[JDK]]8 and safely use [[JDK11]] APIs without any need for reflection&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	<entry>
		<id>http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10333&amp;oldid=prev</id>
		<title>JaroslavTulach: New page: Do you want to run your application on JDK8, but use JDK11 APIs? That's traditionally done with a reflection. Use JDK8 APIs directly and let javac comp...</title>
		<link rel="alternate" type="text/html" href="http://wiki.apidesign.org/index.php?title=AlternativeImplementation&amp;diff=10333&amp;oldid=prev"/>
				<updated>2021-02-16T05:46:42Z</updated>
		
		<summary type="html">&lt;p&gt;New page: Do you want to run &lt;a href=&quot;/wiki/NetBeans&quot; title=&quot;NetBeans&quot;&gt;your application&lt;/a&gt; on &lt;a href=&quot;/wiki/JDK&quot; title=&quot;JDK&quot;&gt;JDK&lt;/a&gt;8, but use &lt;a href=&quot;/wiki/JDK11&quot; title=&quot;JDK11&quot;&gt;JDK11&lt;/a&gt; &lt;a href=&quot;/wiki/API&quot; class=&quot;mw-redirect&quot; title=&quot;API&quot;&gt;APIs&lt;/a&gt;? That's traditionally done with a reflection. Use &lt;a href=&quot;/wiki/JDK&quot; title=&quot;JDK&quot;&gt;JDK&lt;/a&gt;8 &lt;a href=&quot;/wiki/API&quot; class=&quot;mw-redirect&quot; title=&quot;API&quot;&gt;APIs&lt;/a&gt; directly and let &lt;a href=&quot;/wiki/Javac&quot; class=&quot;mw-redirect&quot; title=&quot;Javac&quot;&gt;javac&lt;/a&gt; comp...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Do you want to run [[NetBeans|your application]] on [[JDK]]8, but use [[JDK11]] [[API]]s? That's traditionally done with a reflection. Use [[JDK]]8 [[API]]s directly and let [[javac]] compile your code against them. Whenever using [[JDK11]] [[API]]s, resort to reflection and call them in such a verbose, unsafe manner. That's indeed possible, but especially with [[modularity]] one has better option. Create few [[module]]s/[[JAR]]s and let them work in smooth orchestration.&lt;br /&gt;
&lt;br /&gt;
=== The Integration point [[API]]  ===&lt;br /&gt;
&lt;br /&gt;
When you need to access a functionality which requires different code to run on [[JDK]]8 and [[JDK11]], start by defining an [[APISeam]]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
interface BetterHandler {&lt;br /&gt;
  void handleInBetterWay();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and in your code locate it via [[ServiceLoader]] or [[Lookup]] library and use it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
BetterHandler h = ServiceLoader().load(BetterHandler.class);&lt;br /&gt;
if (h == null) {&lt;br /&gt;
  // JDK8 default behavior&lt;br /&gt;
} else {&lt;br /&gt;
  h.handleInBetterWay();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compile these pieces of code to run on JDK8. Btw. that can easily be done with [[JDK11]] [[javac]] - just use the '''--release 8''' - flag. Then the [[javac]] is only going to expose [[JDK]]8 [[API]] for you - e.g. the resulting [[JAR]] is going to run on [[JDK]]8.&lt;br /&gt;
&lt;br /&gt;
Now let's compile the [[JDK11]] part of the application:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
@ServiceProvider(service=BetterHandler.class)&lt;br /&gt;
public class JDK11EnhancedHandler implements BetterHandler {&lt;br /&gt;
  public void handleInBetterWay() {&lt;br /&gt;
      // directly use JDK11 APIs  &lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{NB|org-openide-util-lookup|org/openide/util/lookup|ServiceProvider}} is a comfortable way to generate ''META-INF/services/BetterHandler'' registration without risk of making typos. One can of course, create the {{JDK|java/util|ServiceLoader}} registration manually.&lt;/div&gt;</summary>
		<author><name>JaroslavTulach</name></author>	</entry>

	</feed>