Drawbacks of javac -parameters flag

前端 未结 2 1630
粉色の甜心
粉色の甜心 2020-12-06 16:20

I want to try some frameworks features that required names of parameter in runtime, so I need to compile my app with -parameters and it will store the names of

2条回答
  •  甜味超标
    2020-12-06 17:05

    The only thing is the size of the .class that will change, since the bytecode will now contain more information:

    public class DeleteMe3 {
        public static void main(String[] args) {
        }
    
        private static void go(String s) {
        }
    }
    

    For example this will contain information about paramter names like so:

    private static void go(java.lang.String);
       descriptor: (Ljava/lang/String;)V
       flags: ACC_PRIVATE, ACC_STATIC
       Code:
         stack=0, locals=1, args_size=1
           0: return
         LineNumberTable:
           line 11: 0
       MethodParameters:
         Name                           Flags
         s
    

    This MethodParameters will simply not be present without -parameters.

    There might be frameworks that don't play nice with this. Here is one Spring Data JPA Issue. I know about it because we hit it some time ago and had to upgrade (I have not been faced with any other from there on).

提交回复
热议问题