{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2005/12/10/jumbo-50-and-cdk.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/y0mte-4ns18",
      "url": "https://chem-bla-ics.linkedchemistry.info/2005/12/10/jumbo-50-and-cdk.html",
      "title": "Jumbo 5.0 and the CDK",
      "content_html": "<p>I <a href=\"https://egonw.github.io/blog/2005/12/08/jumbo-50-and-cml-support-in-cdk.html\">reported earlier <i class=\"fa-solid fa-recycle fa-xs\"></i></a> that the CDK has been updated in CVS to use\nCML from the new Jumbo 5.0. The transition actually involved a lot of changes in the CDK, some I would like to address in the following comments.\nOne thing is that CML write support (not reading!) uses the new Jumbo library which requires Java 1.5. Thus, if Java 1.5 is not available,\nthen CML writing should not be compiled. This is how this is done.</p>\n\n<h3 id=\"the-javadoc\">The JavaDoc</h3>\n\n<p>The CDK makes extensive use of <a href=\"http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/taglet/spec/com/sun/tools/doclets/Taglet.html\">JavaDoc taglets</a>.\nCDK uses tags of type <code class=\"language-plaintext highlighter-rouge\">@cdk.SOMETAG</code>. And an important tag in this case, is the <code class=\"language-plaintext highlighter-rouge\">@cdk.require</code> tag, becuase it allows us to make the CDK build\nsystem aware that the class requires Java 5.0 to be compiled. Thus, we have for example\n<a href=\"http://cvs.sourceforge.net/viewcvs.py/cdk/cdk/src/org/openscience/cdk/io/CMLWriter.java?rev=1.90&amp;view=log\">this code in CVS</a>, of which bits are:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"cm\">/**\n * Serializes a SetOfMolecules or a Molecule object to CML 2 code.\n * Chemical Markup Language is an XML based file format {@cdk.cite PMR99}.\n * Output can be redirected to other Writer objects like StringWriter\n * and FileWriter.\n *\n * @cdk.module       libio-cml\n * @cdk.builddepends xom-1.0.jar\n * @cdk.depends      jumbo50.jar\n * @cdk.require      java1.5\n */</span>\n<span class=\"kd\">public</span> <span class=\"kd\">class</span> <span class=\"nc\">CMLWriter</span> <span class=\"kd\">extends</span> <span class=\"nc\">DefaultChemObjectWriter</span> <span class=\"o\">{</span>\n<span class=\"o\">}</span>\n</code></pre></div></div>\n\n<p>As probably is clear compiling this jars requires a two jars to be present, of which the <code class=\"language-plaintext highlighter-rouge\">jumbo50.jar</code> itself is not required for compiling\nthe class source code. It also shows the use of the <code class=\"language-plaintext highlighter-rouge\">@cdk.require</code> tag.</p>\n\n<h3 id=\"the-buildxml\">The build.xml</h3>\n\n<p>Because the CDK still does not require Java 1.5, the CDK is supposed to be buildable with Java 1.4 (the oldest supported Java release). The\n<a href=\"http://ant.apache.org/\">Ant</a> <a href=\"http://cvs.sourceforge.net/viewcvs.py/cdk/cdk/build.xml?rev=1.310&amp;view=markup\">build.xml</a> script is quite\nable to conditionally leave out compiling parts of the CDK, if configured correctly using proper JavaDoc tags, as explained earlier.</p>\n\n<p>First, the build.xml checks what libraries are available for compiling certain parts of the CDK. For example, the build.xml code to check for Java 1.5 looks like:</p>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nt\">&lt;condition</span> <span class=\"na\">property=</span><span class=\"s\">\"isJava15\"</span><span class=\"nt\">&gt;</span>\n  <span class=\"nt\">&lt;contains</span> <span class=\"na\">string=</span><span class=\"s\">\"${java.version}\"</span> <span class=\"na\">substring=</span><span class=\"s\">\"1.5\"</span><span class=\"nt\">/&gt;</span>\n<span class=\"nt\">&lt;/condition&gt;</span>\n</code></pre></div></div>\n\n<p>Run <code class=\"language-plaintext highlighter-rouge\">ant info</code> to see what is being checked for, or look at the <code class=\"language-plaintext highlighter-rouge\">build.xml</code> source code for the check target.</p>\n\n<p>All compiling is done by the compile-module target, and there it in- and excludes bits of the CDK depending on the checked conditions:</p>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nt\">&lt;javac</span> <span class=\"na\">srcdir=</span><span class=\"s\">\"${build.src}\"</span> <span class=\"na\">destdir=</span><span class=\"s\">\"${build}\"</span> <span class=\"na\">optimize=</span><span class=\"s\">\"${optimization}\"</span> \n       <span class=\"na\">debug=</span><span class=\"s\">\"${debug}\"</span> <span class=\"na\">deprecation=</span><span class=\"s\">\"${deprecation}\"</span><span class=\"nt\">&gt;</span>\n\n  <span class=\"nt\">&lt;excludesfile</span> <span class=\"na\">name=</span><span class=\"s\">\"${src}/java1.4+.javafiles\"</span> <span class=\"na\">if=</span><span class=\"s\">\"isJava13\"</span><span class=\"nt\">/&gt;</span>\n  <span class=\"nt\">&lt;excludesfile</span> <span class=\"na\">name=</span><span class=\"s\">\"${src}/java1.4.javafiles\"</span> <span class=\"na\">unless=</span><span class=\"s\">\"isJava14\"</span><span class=\"nt\">/&gt;</span>\n  <span class=\"nt\">&lt;excludesfile</span> <span class=\"na\">name=</span><span class=\"s\">\"${src}/java1.5.javafiles\"</span> <span class=\"na\">unless=</span><span class=\"s\">\"isJava15\"</span><span class=\"nt\">/&gt;</span>\n  <span class=\"nt\">&lt;excludesfile</span> <span class=\"na\">name=</span><span class=\"s\">\"${src}/ant1.6.javafiles\"</span> <span class=\"na\">unless=</span><span class=\"s\">\"hasAnt16\"</span><span class=\"nt\">/&gt;</span>\n  <span class=\"nt\">&lt;excludesfile</span> <span class=\"na\">name=</span><span class=\"s\">\"${src}/r-project.javafiles\"</span> <span class=\"na\">unless=</span><span class=\"s\">\"rispresent\"</span><span class=\"nt\">/&gt;</span>\n\n  <span class=\"nt\">&lt;includesfile</span> <span class=\"na\">name=</span><span class=\"s\">\"${src}/${module}.javafiles\"</span><span class=\"nt\">/&gt;</span>\n<span class=\"nt\">&lt;/javac&gt;</span>\n</code></pre></div></div>\n\n<p>Keep in mind that the <code class=\"language-plaintext highlighter-rouge\">*.javafiles</code> are created with JavaDoc based on the CDK JavaDoc tags mentioned earlier.</p>\n\n<h3 id=\"the-buildxml-2\">The build.xml 2</h3>\n\n<p>While the above mechanism has been present since for some time now, having jumbo50.jar in CVS made the situation a bit trickier:\nthe <code class=\"language-plaintext highlighter-rouge\">jumbo50.jar</code> uses the 49.0 class format used in Java 1.5, and cannot be processed by Java 1.4 systems. Since the classpath\nused when compiling CDK source code, is defined in configuration files for those modules in\n<a href=\"http://cvs.sourceforge.net/viewcvs.py/cdk/cdk/src/META-INF/\">src/META-INF</a>, the problem did not occur when compiling the modules.\nHowever, it did show an error in the <code class=\"language-plaintext highlighter-rouge\">reallyRunDoclet</code> target today, when I was creating the <code class=\"language-plaintext highlighter-rouge\">*.javafiles</code> with JavaDoc.\nThe solution was trivial:</p>\n\n<div class=\"language-xml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nt\">&lt;target</span> <span class=\"na\">name=</span><span class=\"s\">\"reallyRunDoclet\"</span> <span class=\"na\">id=</span><span class=\"s\">\"reallyRunDoclet\"</span>\n  <span class=\"na\">depends=</span><span class=\"s\">\"compileDoclet\"</span> <span class=\"na\">unless=</span><span class=\"s\">\"dotjavafiles.uptodate\"</span><span class=\"nt\">&gt;</span>\n  <span class=\"nt\">&lt;javadoc</span> <span class=\"na\">private=</span><span class=\"s\">\"true\"</span>  <span class=\"na\">maxmemory=</span><span class=\"s\">\"128m\"</span><span class=\"nt\">&gt;</span>\n    <span class=\"nt\">&lt;classpath&gt;</span>\n      <span class=\"nt\">&lt;fileset</span> <span class=\"na\">dir=</span><span class=\"s\">\"${lib}\"</span><span class=\"nt\">&gt;</span>\n        <span class=\"nt\">&lt;include</span> <span class=\"na\">name=</span><span class=\"s\">\"*.jar\"</span> <span class=\"nt\">/&gt;</span>\n        <span class=\"c\">&lt;!-- some jars require some Java version --&gt;</span>\n        <span class=\"nt\">&lt;exclude</span> <span class=\"na\">name=</span><span class=\"s\">\"jumbo50.jar\"</span> <span class=\"na\">unless=</span><span class=\"s\">\"isJava15\"</span><span class=\"nt\">/&gt;</span>\n      <span class=\"nt\">&lt;/fileset&gt;</span>\n      <span class=\"nt\">&lt;fileset</span> <span class=\"na\">dir=</span><span class=\"s\">\"${lib}/libio\"</span><span class=\"nt\">&gt;</span>\n        <span class=\"nt\">&lt;include</span> <span class=\"na\">name=</span><span class=\"s\">\"*.jar\"</span> <span class=\"nt\">/&gt;</span>\n      <span class=\"nt\">&lt;/fileset&gt;</span>\n      <span class=\"nt\">&lt;fileset</span> <span class=\"na\">dir=</span><span class=\"s\">\"${devellib}\"</span><span class=\"nt\">&gt;</span>\n        <span class=\"nt\">&lt;include</span> <span class=\"na\">name=</span><span class=\"s\">\"*.jar\"</span> <span class=\"nt\">/&gt;</span>\n      <span class=\"nt\">&lt;/fileset&gt;</span>\n    <span class=\"nt\">&lt;/classpath&gt;</span>\n\n    <span class=\"nt\">&lt;doclet</span> <span class=\"na\">name=</span><span class=\"s\">\"net.sf.cdk.tools.MakeJavaFilesFilesDoclet\"</span>\n      <span class=\"na\">path=</span><span class=\"s\">\"${doc}/javadoc\"</span><span class=\"nt\">/&gt;</span>\n\n    <span class=\"nt\">&lt;packageset</span> <span class=\"na\">dir=</span><span class=\"s\">\"${src}\"</span><span class=\"nt\">&gt;</span>\n      <span class=\"nt\">&lt;include</span> <span class=\"na\">name=</span><span class=\"s\">\"org/openscience/cdk/**\"</span><span class=\"nt\">/&gt;</span>\n    <span class=\"nt\">&lt;/packageset&gt;</span>\n\n<span class=\"nt\">&lt;/javadoc&gt;</span>\n</code></pre></div></div>\n\n<h3 id=\"cdkapplicationsfileconvertor\">cdk.applications.FileConvertor</h3>\n\n<p>There is another area of interest: the <code class=\"language-plaintext highlighter-rouge\">FileConvertor</code>, which is, sort of, CDK’s\n<a href=\"http://openbabel.sf.net/\">OpenBabel</a>’s <code class=\"language-plaintext highlighter-rouge\">babel</code> variant. The FileConvertor must\nbe compiled in all cases, so we need to conditionally instantiate the <code class=\"language-plaintext highlighter-rouge\">CMLWriter</code>, which is not really a problem. However, compiling\nthe source code is more troublesome: the <code class=\"language-plaintext highlighter-rouge\">CMLWriter</code> class must be loaded on runtime, and not occur hardcoded in the source code.</p>\n\n<p>In the past I have solved this by using <code class=\"language-plaintext highlighter-rouge\">.getInstance()</code> constructs, but the\n<a href=\"http://cvs.sourceforge.net/viewcvs.py/cdk/cdk/src/org/openscience/cdk/io/ChemObjectWriter.java?rev=1.19&amp;view=log\">ChemObjectWriter interface</a> does not define this\nfunctionality, so I decided to use the <code class=\"language-plaintext highlighter-rouge\">java.lang.reflect</code> mechanism:</p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"o\">}</span> <span class=\"k\">else</span> <span class=\"k\">if</span> <span class=\"o\">(</span><span class=\"n\">format</span><span class=\"o\">.</span><span class=\"na\">equalsIgnoreCase</span><span class=\"o\">(</span><span class=\"s\">\"CML\"</span><span class=\"o\">))</span> <span class=\"o\">{</span>\n  <span class=\"nc\">Class</span> <span class=\"n\">cmlWriterClass</span> <span class=\"o\">=</span> <span class=\"k\">this</span><span class=\"o\">.</span><span class=\"na\">getClass</span><span class=\"o\">().</span><span class=\"na\">getClassLoader</span><span class=\"o\">().</span>\n    <span class=\"n\">loadClass</span><span class=\"o\">(</span><span class=\"s\">\"org.opscience.cdk.io.CMLWriter\"</span><span class=\"o\">);</span>\n  <span class=\"k\">if</span> <span class=\"o\">(</span><span class=\"n\">cmlWriterClass</span> <span class=\"o\">!=</span> <span class=\"kc\">null</span><span class=\"o\">)</span> <span class=\"o\">{</span>\n    <span class=\"n\">writer</span> <span class=\"o\">=</span> <span class=\"o\">(</span><span class=\"nc\">ChemObjectWriter</span><span class=\"o\">)</span><span class=\"n\">cmlWriterClass</span><span class=\"o\">.</span><span class=\"na\">newInstance</span><span class=\"o\">();</span>\n  <span class=\"o\">}</span>\n  <span class=\"nc\">Constructor</span> <span class=\"n\">constructor</span> <span class=\"o\">=</span> <span class=\"n\">writer</span><span class=\"o\">.</span><span class=\"na\">getClass</span><span class=\"o\">().</span><span class=\"na\">getConstructor</span><span class=\"o\">(</span><span class=\"k\">new</span> <span class=\"nc\">Class</span><span class=\"o\">[]{</span><span class=\"nc\">Writer</span><span class=\"o\">.</span><span class=\"na\">class</span><span class=\"o\">});</span>\n  <span class=\"n\">writer</span> <span class=\"o\">=</span> <span class=\"o\">(</span><span class=\"nc\">ChemObjectWriter</span><span class=\"o\">)</span><span class=\"n\">constructor</span><span class=\"o\">.</span><span class=\"na\">newInstance</span><span class=\"o\">(</span><span class=\"k\">new</span> <span class=\"nc\">Object</span><span class=\"o\">[]{</span><span class=\"n\">fileWriter</span><span class=\"o\">});</span>\n<span class=\"o\">}</span> <span class=\"k\">else</span> <span class=\"o\">{</span>\n</code></pre></div></div>\n\n<p>Now, this has been, by far, the longest blog item I have written so far. I hope it gave you good insight in some techniques CDK uses to deal with\nsituations where functionality might, or might not, be present at build and at run time.</p>",
      "summary": "I reported earlier that the CDK has been updated in CVS to use CML from the new Jumbo 5.0. The transition actually involved a lot of changes in the CDK, some I would like to address in the following comments. One thing is that CML write support (not reading!) uses the new Jumbo library which requires Java 1.5. Thus, if Java 1.5 is not available, then CML writing should not be compiled. This is how this is done.",
      
      "date_published": "2005-12-10T00:00:00+00:00",
      "date_modified": "2023-08-05T00:00:00+00:00",
      "tags": ["cdk","cml","java"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
