Skip to content

Commit c837597

Browse files
Merge pull request #1 from virtualcell/aot-compilation
Allow for ahead of time compilation using the GraalVM compiler.
2 parents 22659a7 + a29fd00 commit c837597

File tree

30 files changed

+223
-105
lines changed

30 files changed

+223
-105
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Maven Build and Publish
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
inputs:
8+
release_version:
9+
description: 'Version to release (e.g. v1.2.3)'
10+
required: true
11+
release_description:
12+
description: 'Description of release.'
13+
required: true
14+
15+
jobs:
16+
build-and-publish:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
packages: write
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up JDK 17
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: '17'
30+
distribution: 'temurin'
31+
cache: maven
32+
33+
- name: Set Release Version
34+
id: set_version
35+
run: |
36+
echo "VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
37+
38+
- name: Build with Maven
39+
run: mvn clean package
40+
41+
- name: Create tag
42+
uses: actions/github-script@v7
43+
with:
44+
script: |
45+
github.rest.git.createRef({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
ref: 'refs/tags/${{ env.VERSION }}',
49+
sha: context.sha
50+
})
51+
52+
- name: Create GitHub Release
53+
uses: softprops/action-gh-release@v2
54+
with:
55+
tag_name: ${{ env.VERSION }}
56+
name: Release ${{ env.VERSION }}
57+
draft: false
58+
prerelease: false
59+
files: |
60+
core/target/*.jar
61+
extensions/spatial/target/*.jar
62+
body: ${{ github.event.inputs.release_description }}
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<parent>
2828
<groupId>org.sbml.jsbml</groupId>
2929
<artifactId>jsbml-parent</artifactId>
30-
<version>1.7-SNAPSHOT</version>
30+
<version>1.6.1-VCELL</version>
3131
<relativePath>../</relativePath>
3232
</parent>
3333

@@ -118,7 +118,7 @@
118118
<scope>test</scope>
119119
</dependency>
120120
<dependency>
121-
<groupId>org.mangosdk.spi</groupId>
121+
<groupId>org.mangosdk</groupId>
122122
<artifactId>spi</artifactId>
123123
<version>0.2.4</version>
124124
<optional>true</optional>

core/src/org/sbml/jsbml/AbstractTreeNode.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040
import javax.swing.tree.TreeNode;
4141

4242
import org.apache.log4j.Logger;
43-
import org.sbml.jsbml.util.ResourceManager;
44-
import org.sbml.jsbml.util.TreeNodeChangeEvent;
45-
import org.sbml.jsbml.util.TreeNodeChangeListener;
46-
import org.sbml.jsbml.util.TreeNodeRemovedEvent;
47-
import org.sbml.jsbml.util.TreeNodeWithChangeSupport;
43+
import org.sbml.jsbml.util.*;
4844
import org.sbml.jsbml.util.filters.Filter;
4945

5046
/**
@@ -63,7 +59,7 @@ public abstract class AbstractTreeNode implements TreeNodeWithChangeSupport {
6359
/**
6460
* Localization support.
6561
*/
66-
protected static final transient ResourceBundle resourceBundle = ResourceManager.getBundle("org.sbml.jsbml.resources.Messages");
62+
protected static final transient ResourceBundle resourceBundle = new XMLResourceBundleControl.XMLResourcePlain();
6763

6864
/**
6965
* A {@link Logger} for this class.

core/src/org/sbml/jsbml/Unit.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727

2828
import org.apache.log4j.Logger;
2929
import org.sbml.jsbml.Unit.Kind;
30-
import org.sbml.jsbml.util.Maths;
31-
import org.sbml.jsbml.util.ResourceManager;
32-
import org.sbml.jsbml.util.StringTools;
33-
import org.sbml.jsbml.util.TreeNodeChangeEvent;
30+
import org.sbml.jsbml.util.*;
3431
import org.sbml.jsbml.util.compilers.FormulaCompiler;
3532

3633
/**
@@ -2434,7 +2431,7 @@ public Map<String, String> writeXMLAttributes() {
24342431
attributes.put("exponent", Integer.toString((int) getExponent()));
24352432
if (exponent - getExponent() != 0d) {
24362433
logger.warn(MessageFormat.format(
2437-
ResourceManager.getBundle("org.sbml.jsbml.resources.cfg.Messages").getString("LOSS_OF_INFORMATION_DUE_TO_ROUNDING"),
2434+
new XMLResourceBundleControl.XMLResourceConfig().getString("LOSS_OF_INFORMATION_DUE_TO_ROUNDING"),
24382435
getExponent(), exponent));
24392436
}
24402437
}

core/src/org/sbml/jsbml/util/SBMLtools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static final void setSBOTerm(SBase sbase, int term) {
202202
Integer.valueOf(2))) {
203203
sbase.setSBOTerm(term);
204204
} else {
205-
ResourceBundle bundle = ResourceManager.getBundle("org.sbml.jsbml.resources.cfg.Messages");
205+
ResourceBundle bundle = new XMLResourceBundleControl.XMLResourceConfig();
206206
logger.warn(format(bundle.getString("SBMLtools.COULD_NOT_SET_SBO_TERM"),
207207
SBO.sboNumberString(term), sbase.getElementName(), sbase.getLevel(), sbase.getVersion()));
208208
}

core/src/org/sbml/jsbml/util/XMLResourceBundleControl.java

Lines changed: 101 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -61,58 +61,6 @@ public class XMLResourceBundleControl extends Control {
6161
*
6262
* @author Andreas Dr&auml;ger
6363
*/
64-
private static class XMLResourceBundle extends ResourceBundle {
65-
66-
/**
67-
* The wrapped element.
68-
*/
69-
private Properties properties;
70-
71-
/**
72-
*
73-
* @param stream
74-
* @throws IOException
75-
* @throws InvalidPropertiesFormatException
76-
*/
77-
public XMLResourceBundle(InputStream stream) throws IOException,
78-
InvalidPropertiesFormatException {
79-
Properties defaults = new Properties();
80-
defaults.loadFromXML(stream);
81-
properties = new Properties(defaults);
82-
}
83-
84-
/* (non-Javadoc)
85-
* @see java.util.ResourceBundle#getKeys()
86-
*/
87-
@Override
88-
public Enumeration<String> getKeys() {
89-
Set<String> key = properties.stringPropertyNames();
90-
return Collections.enumeration(key);
91-
}
92-
93-
/* (non-Javadoc)
94-
* @see java.util.ResourceBundle#handleGetObject(java.lang.String)
95-
*/
96-
@Override
97-
protected Object handleGetObject(String key) {
98-
String element = properties.getProperty(key);
99-
if ((element != null) && (element.length() > 0)
100-
&& (element.charAt(0) == '[')
101-
&& (element.charAt(element.length() - 1) == ']')) {
102-
return element.substring(1, element.length() - 1).split(";");
103-
}
104-
return element;
105-
}
106-
107-
/* (non-Javadoc)
108-
* @see java.lang.Object#toString()
109-
*/
110-
@Override
111-
public String toString() {
112-
return properties.toString();
113-
}
114-
115-
}
11664

11765
/**
11866
* The extension for XML files.
@@ -141,21 +89,111 @@ public ResourceBundle newBundle(String baseName, Locale locale,
14189
ResourceBundle bundle = null;
14290

14391
if (format.equalsIgnoreCase(XML)) {
144-
// Localize resource file
145-
String bundleName = toBundleName(baseName, locale);
146-
String resName = toResourceName(bundleName, format);
147-
InputStream is = loader.getResourceAsStream(resName);
148-
if (is == null) {
149-
is = getClass().getResourceAsStream('/' + resName);
150-
}
151-
if (is != null) {
152-
// Create ResourceBundle object
153-
bundle = new XMLResourceBundle(is);
154-
is.close();
92+
switch (baseName){
93+
case "org.sbml.jsbml.resources.Messages":
94+
bundle = new XMLResourcePlain();
95+
break;
96+
case "org.sbml.jsbml.resources.cfg.Messages":
97+
bundle = new XMLResourceConfig();
98+
break;
99+
case "org.sbml.jsbml.ext.arrays.validator.constraints.Messages":
100+
bundle = new XMLResourceConstraints();
101+
break;
102+
case "org.sbml.jsbml.ext.spatial.Messages":
103+
bundle = new XMLResourceSpatial();
104+
break;
105+
case "org.sbml.jsbml.ext.dyn.Messages":
106+
bundle = new XMLResourceDYN();
107+
break;
155108
}
156109
}
157110
// Return the bundle.
158111
return bundle;
159112
}
160113

114+
public static class XMLResourcePlain extends XMLResourceBundle{
115+
public XMLResourcePlain() {
116+
try {
117+
setProperties("/org/sbml/jsbml/resources/Messages.xml");
118+
} catch (IOException e) {
119+
throw new RuntimeException(e);
120+
}
121+
}
122+
}
123+
124+
public static class XMLResourceConfig extends XMLResourceBundle{
125+
public XMLResourceConfig() {
126+
try {
127+
setProperties("/org/sbml/jsbml/resources/cfg/Messages.xml");
128+
} catch (IOException e) {
129+
throw new RuntimeException(e);
130+
}
131+
}
132+
}
133+
134+
public static class XMLResourceConstraints extends XMLResourceBundle{
135+
public XMLResourceConstraints() {
136+
try {
137+
setProperties("/org/sbml/jsbml/ext/arrays/validator/constraints/Messages.xml");
138+
} catch (IOException e) {
139+
throw new RuntimeException(e);
140+
}
141+
}
142+
}
143+
144+
public static class XMLResourceSpatial extends XMLResourceBundle{
145+
public XMLResourceSpatial() {
146+
try {
147+
setProperties("/org/sbml/jsbml/ext/spatial/Messages.xml");
148+
} catch (IOException e) {
149+
throw new RuntimeException(e);
150+
}
151+
}
152+
}
153+
154+
public static class XMLResourceDYN extends XMLResourceBundle{
155+
public XMLResourceDYN() {
156+
try {
157+
setProperties("/org/sbml/jsbml/ext/dyn/Messages.xml");
158+
} catch (IOException e) {
159+
throw new RuntimeException(e);
160+
}
161+
}
162+
}
163+
164+
private static class XMLResourceBundle extends ResourceBundle {
165+
private Properties properties;
166+
167+
public void setProperties(String resourceName) throws IOException {
168+
Properties defaults = new Properties();
169+
InputStream is = XMLResourceBundle.class.getResourceAsStream(resourceName);
170+
defaults.loadFromXML(is);
171+
properties = new Properties(defaults);
172+
assert is != null;
173+
is.close();
174+
}
175+
176+
@Override
177+
public Enumeration<String> getKeys() {
178+
Set<String> key = properties.stringPropertyNames();
179+
return Collections.enumeration(key);
180+
}
181+
182+
@Override
183+
protected Object handleGetObject(String key) {
184+
String element = properties.getProperty(key);
185+
if ((element != null) && (element.length() > 0)
186+
&& (element.charAt(0) == '[')
187+
&& (element.charAt(element.length() - 1) == ']')) {
188+
return element.substring(1, element.length() - 1).split(";");
189+
}
190+
return element;
191+
}
192+
193+
@Override
194+
public String toString() {
195+
return properties.toString();
196+
}
197+
}
198+
161199
}

core/src/org/sbml/jsbml/xml/parsers/SBMLCoreParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.sbml.jsbml.util.ResourceManager;
6767
import org.sbml.jsbml.util.SBMLtools;
6868
import org.sbml.jsbml.util.TreeNodeWithChangeSupport;
69+
import org.sbml.jsbml.util.XMLResourceBundleControl;
6970
import org.sbml.jsbml.util.filters.Filter;
7071
import org.sbml.jsbml.xml.XMLAttributes;
7172
import org.sbml.jsbml.xml.XMLNode;
@@ -102,7 +103,7 @@ public class SBMLCoreParser implements ReadingParser, WritingParser {
102103
/**
103104
* Localization support.
104105
*/
105-
private static final transient ResourceBundle bundle = ResourceManager.getBundle("org.sbml.jsbml.resources.cfg.Messages");
106+
private static final transient ResourceBundle bundle = new XMLResourceBundleControl.XMLResourceConfig();
106107

107108
/**
108109
* Creates a SBMLCoreParser instance. Initializes the sbmlCoreElements of

examples/test/src/org/sbml/jsbml/ext/spatial/test/SpatialTestModelWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class SpatialTestModelWriter {
4646
*/
4747
public static void main(String[] args) throws SBMLException, XMLStreamException {
4848

49-
ResourceManager.getBundle("org.sbml.jsbml.ext.spatial.Messages");
49+
new XMLResourceBundleControl.XMLResourceSpatial();
5050

5151
SBMLDocument doc = new SBMLDocument(3, 1);
5252
Model model = doc.createModel("m1");

extensions/arrays/src/org/sbml/jsbml/ext/arrays/validator/constraints/ArraysMathCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.sbml.jsbml.ext.arrays.ArraysSBasePlugin;
3434
import org.sbml.jsbml.ext.arrays.util.ArraysMath;
3535
import org.sbml.jsbml.util.ResourceManager;
36+
import org.sbml.jsbml.util.XMLResourceBundleControl;
3637
import org.sbml.jsbml.validator.offline.factory.SBMLErrorCodes;
3738

3839
/**
@@ -44,7 +45,7 @@ public class ArraysMathCheck extends ArraysConstraint {
4445
/**
4546
* Localization support.
4647
*/
47-
private static final transient ResourceBundle bundle = ResourceManager.getBundle("org.sbml.jsbml.ext.arrays.validator.constraints.Messages");
48+
private static final transient ResourceBundle bundle = new XMLResourceBundleControl.XMLResourceConstraints();
4849

4950
//TODO: get right messages
5051
/**

extensions/arrays/src/org/sbml/jsbml/ext/arrays/validator/constraints/DimensionArrayDimCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.sbml.jsbml.ext.arrays.ArraysSBasePlugin;
3030
import org.sbml.jsbml.ext.arrays.Dimension;
3131
import org.sbml.jsbml.util.ResourceManager;
32+
import org.sbml.jsbml.util.XMLResourceBundleControl;
3233
import org.sbml.jsbml.validator.offline.factory.SBMLErrorCodes;
3334

3435
/**
@@ -42,7 +43,7 @@ public class DimensionArrayDimCheck extends ArraysConstraint {
4243
/**
4344
* Localization support.
4445
*/
45-
private static final transient ResourceBundle bundle = ResourceManager.getBundle("org.sbml.jsbml.ext.arrays.validator.constraints.Messages");
46+
private static final transient ResourceBundle bundle = new XMLResourceBundleControl.XMLResourceConstraints();
4647

4748
/**
4849
*

0 commit comments

Comments
 (0)