@@ -1217,8 +1217,8 @@ protected final Function closurePart(Data data, String id, int access, int modif
12171217
12181218 // TODO cachedwithin
12191219
1220- func . setJavaFunction ( java (data , body , id , access , modifier , hint , args , attrs , rtnType , output , bufferOutput , displayName , description , returnFormat , secureJson ,
1221- verifyClient , localMode )) ;
1220+ java (data , func , body , id , access , modifier , hint , args , attrs , rtnType , output , bufferOutput , displayName , description , returnFormat , secureJson ,
1221+ verifyClient , localMode );
12221222 }
12231223 else {
12241224 func .register (data .page );
@@ -1261,7 +1261,7 @@ private Attribute[] remove(Attribute[] attrs, String name) {
12611261 return list .toArray (new Attribute [list .size ()]);
12621262 }
12631263
1264- private JavaFunction java (Data data , Body body , String functionName , int access , int modifier , String hint , ArrayList <Argument > args , Attribute [] attrs , String rtnType ,
1264+ private void java (Data data , Function func , Body body , String functionName , int access , int modifier , String hint , ArrayList <Argument > args , Attribute [] attrs , String rtnType ,
12651265 Boolean output , Boolean bufferOutput , String displayName , String description , int returnFormat , Boolean secureJson , Boolean verifyClient , int localMode )
12661266 throws TemplateException {
12671267
@@ -1286,22 +1286,25 @@ private JavaFunction java(Data data, Body body, String functionName, int access,
12861286 SourceCode sc = data .srcCode ;
12871287 Position start = sc .getPosition ();
12881288 findTheEnd (data , start .line );
1289+ Position end = sc .getPosition ();
1290+ String javaCode = sc .substring (start .pos , end .pos - start .pos );
12891291
1290- // In AST mode without PageSource, we can't compile - just return null
1292+ // Always store raw Java source for AST round-tripping
1293+ func .setRawJavaSource (javaCode );
1294+
1295+ // In AST mode without PageSource, we can't compile - just store raw source
12911296 // The function body has already been parsed past by findTheEnd
12921297 if (ps == null ) {
1293- return null ;
1298+ return ;
12941299 }
1295-
1296- Position end = sc .getPosition ();
1297- String javaCode = sc .substring (start .pos , end .pos - start .pos );
12981300 try {
12991301 String id = data .page .registerJavaFunctionName (functionName );
13001302 lucee .commons .lang .compiler .SourceCode _sc = fd .createSourceCode (ps , javaCode , id , functionName , access , modifier , hint , args , output , bufferOutput , displayName ,
13011303 description , returnFormat , secureJson , verifyClient , localMode );
13021304 JavaFunction jf = new JavaFunction (ps , _sc , CompilerFactory .getInstance ().compile ((ConfigPro ) data .config , _sc ));
13031305
1304- return jf ;
1306+ func .setJavaFunction (jf );
1307+ return ;
13051308 }
13061309 catch (JavaCompilerException e ) {
13071310 Throwable cause = e .getCause ();
0 commit comments