The Session class does not have a constructor, instead use a couple static methods:
getDefaultInstance(Properties p);
getDefaultInstance(Properties p, Authenticator a);
getInstance(Properties p);
getInstance(Properties p, Authenticator a);
All of the above return Sessions.
From a design perspective, is it to avoid calling the default no argument constructor?
Or is it something else likes situation in which you can’t/don’t want to use constructor?
There’s two key advantages of static factory methods over constructors:
While JavaMail doesn’t take advantage of the first (and in fact Session is final), it does use the second to return the same Session object for getDefaultInstance. While that was done to support a particular use case, it’s turned out to be a bad idea that trips up a lot of people, as described here.