The below code outputs "Inside Method" even though I'm passing null to the function. It should throw an exception instead. What's wrong with the below code? Why isn't it throwing an exception when a null parameter is being passed.
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
@Validated
class MyClass {
public static void main(String[] args) {
MyClass m = new MyClass();
m.wontTakeNull(null);
}
public void wontTakeNull(@NotNull String param) {
System.out.println("Inside Method");
}
}