I have,
Cipher cipher = null;
try {
cipher = Cipher.getInstance("AES/GCM/NoPadding");
} catch (GeneralSecurityException e) {
System.out.println("whut");
}
Eclipse wiggles on ‘getInstance’ and says
The method getInstance(String) from the type Cipher refers to the missing type NoSuchPaddingException
I’m confused by this. Other answers on this site state that NoSuchPaddingException is a ‘checked exception’, falling under GenerateSecurityException.
Is this a configuration issue in Eclipse or something else?
3
User @rzwitserloot pointed me in the right direction.
Steps to unblock the problem, from easiest to most involved, check after each step:
- Clear the cache: Project -> Clean
- Restart Eclipse
- Select the project in the Package Explorer, then File -> Properties
- Java Compiler
- Deselect ‘Enable project specific settings’ if checked
- Configure Workspace Settings… -> JDK Compliance -> Compiler compliance level:
At this point, pick. Remember what you picked. I have two JDKs installed, 17 and 22. I picked 17 for this exercise.
- Check the ‘Use default compliance settings’
If you have a mismatch (ie, ‘Compliance level’ set to 19 but Generated .class files/Source compatibility you get a warning triangle: When selecting N compliance, make sure to have a compatible JRE installed and activated (currently Y). Configure…)
In my case, I had compliance level set to 19, generated class/source set to 17, and the JDK 22 activated.
At which point eclipse threw its hands in the air and walked out in a huff.
- Once everything is in sync, Apply and Close.
- You get a dialog, rebuild to apply? Yes.
- Apply and Close