lballabio / QuantLib-SWIG

QuantLib wrappers to other languages
Other
360 stars 297 forks source link

Allow specifying JAVAC_FLAGS #723

Closed UnitedMarsupials closed 3 weeks ago

UnitedMarsupials commented 1 month ago

When processing the .java files under Java/, build invokes javac with -g. That may not be desirable -- someone may prefer to build with optimization (however little of that Java is offering), or use a newer JDK to build backwards-compatible class-files (with -target 8), and so on.

The default may still be -g, but it should be overwritable from command-line...

lballabio commented 1 month ago

Agreed.

UnitedMarsupials commented 1 month ago

Reportedly, the -O is a no-op with current OpenJDK, but it may still be meaning something with other implementations. The -target 8 will produce bytecode usable by JDK8 even if a newer javac is used -- the Java-code generated by SWIG does not, actually, use any newer Java constructs.

--- Java/Makefile.am    2024-11-25 10:34:42.000000000 -0500
+++ Java/Makefile.am    2025-04-15 13:52:46.053023000 -0400
@@ -23,6 +23,8 @@
 if BUILD_JAVA

+JAVAC_FLAGS?=  -O -g -source 8 -target 8
+
 examples/%.class: examples/%.java QuantLib.jar
-   $(JAVAC)  -cp QuantLib.jar examples/$*.java
+   $(JAVAC)  -cp QuantLib.jar ${JAVAC_FLAGS} examples/$*.java

 .PHONY: $(EXAMPLES)
@@ -38,5 +40,5 @@
 QuantLib.jar: quantlib_wrap.cpp org/quantlib/*.java
    mkdir -p bin
-   find org/quantlib -name '*.java' | xargs $(JAVAC) -g -d bin
+   find org/quantlib -name '*.java' | xargs $(JAVAC) ${JAVAC_FLAGS} -d bin
    $(JAR) cf QuantLib.jar -C bin org
lballabio commented 3 weeks ago

Thanks. Do you have time to open a pull request? This way you'd be recognized properly as a contributor in the GitHub repo.

UnitedMarsupials commented 3 weeks ago

This way you'd be recognized properly as a contributor in the GitHub repo.

Maybe, some day I'll have a real contribution. This is not one...