mercredi 19 mai 2021

Constructor with 2 parameters actually has 3

When using reflection to inquire information about the Constructor of a class in runtime.

public class amongUs {
...
...
...
   @Retention(RetentionPolicy.RUNTIME)
   @Target({ElementType.PARAMETER, ElementType.METHOD})
   @interface Message {
   }

   public enum Colors {RED , YELLOW , GREEN ,BLACK , WHITE, BLUE, CYAN, PURPLE, VELVET, BROWN, ORANGE  
   };
   public class Player {

   }
   public class pla extends  Player {
       String color;
       String message = "im not sus";

       @Inject
       public pla(@Message Integer x,@Message String wut) {
           color = (Colors.values()[x]).name();
           message=wut;
       }

   }


...
...
}

However, when I look at the constructor of "pla" it shows it has 3 parameters.

Debugger Description

Why is it happening and how do I fix it?





Aucun commentaire:

Enregistrer un commentaire