1 #
2 # Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 include MakeFileStart.gmk
27
28 ################################################################################
29 # Builds one JAR used by jtreg to test value classes (JEP 401):
30 #
31 # valueClassPlugin.jar -- contains ValueClassPlugin (a javac Plugin that
32 # rewrites @AsValueClass classes to value classes
33 # at parse time) together with @AsValueClass and
34 # the META-INF service descriptor, compiled WITH
35 # --enable-preview and the required internal-API
36 # exports.
37 #
38 # Usage in test runs (via RunTests.gmk):
39 # make test TEST=... JTREG=VALUE_CLASS_PLUGIN=true
40 #
41 # The plugin is also enabled automatically when --enable-preview is passed via
42 # VM_OPTIONS or JAVA_OPTIONS and the plugin JARs are present in the test image:
43 # make test TEST=... JTREG=VM_OPTIONS=--enable-preview
44 #
45 ################################################################################
46
47 include CopyFiles.gmk
48 include JavaCompilation.gmk
49
50 VCP_BASEDIR := $(TOPDIR)/test/jtreg_value_class_plugin
51 VCP_SUPPORT := $(SUPPORT_OUTPUTDIR)/test/jtreg_value_class_plugin
52
53 # Compile ValueClassPlugin WITH --enable-preview
54 $(eval $(call SetupJavaCompilation, BUILD_VCP_PLUGIN, \
55 TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
56 SRC := $(VCP_BASEDIR)/plugin, \
57 BIN := $(VCP_SUPPORT)/plugin_classes, \
58 JAR := $(VCP_SUPPORT)/valueClassPlugin.jar, \
59 JAVAC_FLAGS := \
60 --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
61 --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
62 --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
63 --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
64 --enable-preview, \
65 DISABLED_WARNINGS := preview, \
66 ))
67
68 TARGETS += $(BUILD_VCP_PLUGIN)
69
70 ################################################################################
71 # Targets for building test-image.
72 ################################################################################
73
74 $(eval $(call SetupCopyFiles, COPY_VCP, \
75 SRC := $(VCP_SUPPORT), \
76 DEST := $(TEST_IMAGE_DIR)/jtreg_value_class_plugin, \
77 FILES := \
78 $(VCP_SUPPORT)/valueClassPlugin.jar, \
79 ))
80
81 IMAGES_TARGETS += $(COPY_VCP)
82
83 build: $(TARGETS)
84 images: $(IMAGES_TARGETS)
85
86 .PHONY: images
87
88 ################################################################################
89
90 include MakeFileEnd.gmk