Hacker News new | ask | show | jobs
by rusk 579 days ago
Field modifiers are a semantic constraint not a security constraint. It is right and proper that you should be able to bypass them with the appropriate backflips.

The main issue is safety cause you might modify something that isn’t modifiable and cause a SEGV and that is precisely the concern access modifiers are meant to address.

1 comments

they certainly were a security constraint back in the day before Java gave up on trying to use the type system for security

e.g. SecurityManager for applets will not let you setAccessible(true) on private fields of system classes

Yes but that’s the security manager doing it not the field modifiers. It’s just reusing the modifiers as security metadata.