You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2026/10/20 21:17:14 UTC
(tomcat) 13/21: Create the package directory when generating the reflection less code
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 078eb7941cc8c2143bc743cc93536ad221c57c2c
Author: opencode <re...@apache.org>
AuthorDate: Tue Oct 20 12:58:25 2026 +0200
Create the package directory when generating the reflection less code
The code generator wrote XReflectionIntrospectionUtils.java into the
package sub-directory derived from the package name without ever
creating it, so standalone use against a fresh output directory died
with an unhandled FileNotFoundException. Only the Ant
embed-programmatic-jar target was unaffected because it pre-copies the
whole java/ tree. Create the sub-directory with mkdirs() before
generating and fail with a clear IOException when it cannot be
created, and update the Javadoc accordingly.
---
.../util/xreflection/ObjectReflectionPropertyInspector.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/tomcat/util/xreflection/ObjectReflectionPropertyInspector.java b/java/org/apache/tomcat/util/xreflection/ObjectReflectionPropertyInspector.java
index 20057a3a18..07f3384d80 100644
--- a/java/org/apache/tomcat/util/xreflection/ObjectReflectionPropertyInspector.java
+++ b/java/org/apache/tomcat/util/xreflection/ObjectReflectionPropertyInspector.java
@@ -18,6 +18,7 @@ package org.apache.tomcat.util.xreflection;
import java.io.File;
+import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -119,8 +120,8 @@ public final class ObjectReflectionPropertyInspector {
*
* @param baseClasses The classes to process
* @param packageName The package name for generated code
- * @param location The output directory (the package sub-directory derived from <code>packageName</code> must
- * already exist)
+ * @param location The output directory (the package sub-directory derived from <code>packageName</code> is
+ * created if it does not exist)
* @param className The class name for generated code
* @throws Exception if an error occurs
*/
@@ -128,6 +129,9 @@ public final class ObjectReflectionPropertyInspector {
String className) throws Exception {
String packageDirectory = packageName.replace('.', '/');
File sourceFileLocation = new File(location, packageDirectory);
+ if (!sourceFileLocation.exists() && !sourceFileLocation.mkdirs()) {
+ throw new IOException("Unable to create directory [" + sourceFileLocation.getAbsolutePath() + "]");
+ }
ReflectionLessCodeGenerator.generateCode(sourceFileLocation, className, packageName, baseClasses);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org