On 26/08/2022 10:59 am, David Holmes wrote:
On 26/08/2022 9:11 am, some-java-user-99206970363698485...@vodafonemail.de wrote:
Hello,
the JDK source code contains many Java classes which are specific to one platform / operating system, for example classes to interact with the file system or the AWT and Swing related classes are different for Windows and Linux.

Is there a way to compile the Java source code for all platforms supported by the JDK at once? My goal is not to build a functional JDK, but to use the class files (or rather the compilation process) for static code analysis, specifically for analysis with CodeQL. I assume this might also be useful for other code analysis tools, and maybe also in general
to detect Java compilation errors with the JDK source code.

It appears the OpenJDK building instructions are always for building for a specific target platform and therefore skip compiling the Java code for other platforms. Additionally the `configure` command checks also check for tools needed to compile native code (e.g. Xcode or Visual Studio), even though for pure Java compilation they would not be needed (?). Therefore when you try to use multiple configurations (as described in the build instructions) it would require you to install all the tools for all platforms (if that is even possible on the same host operating system).

Ideally I am looking for a solution which satisfies the following:
- Compiles the Java source code for all supported platforms
- Compiles all the Java source code in one build command execution
   - Or at least compiles the Java source code with separate build command executions, but which can all be      run from the same host operating system (no need to use separate operating systems) - Does not require any of the tools for native compilation to be installed

Though I am happy about any solution which gets as close as possible to this. Thanks already in advance!

It may be as simple as hacking the definitions of the source directories i.e in make/common/Modules.gmk

SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
   SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
endif

and expanding out to include all the src/<module>/<os> directories.

As Erik points out this:

a) doesn't cover generated classes which may be OS/toolchain specific
b) would overwrite the same named class file

David
-----

David

Kind regards


Reply via email to