-1

I was reading a book on Java and there was an option mentioned to modify the size of the String Pool, and that option was XX:StringTableSize. When I tried this in my command line, I got an error saying this is an invalid flag, I tried both of the following and the same error occurred:

error: invalid flag: -XX1234

error: invalid flag: -XX:1234

What is the error? I couldn't find a solution for this in the Java SE reference, even I did not see any option like "-XX".

What is the reason behind that, did I made a syntactical error or this option is deprecated or something else? I am using JDK 11.

HusenPatel
  • 49
  • 5
  • Please read [How to ask](https://stackoverflow.com/help/how-to-ask) and add more information to your question, e.g., how the command you've used look like. – Batajus Oct 12 '21 at 19:18

1 Answers1

1

You are probably passing less than the minimum value allowed. For e.g I can successfully run below on OpenJDK 11

java -XX:StringTableSize=16777216 TestClass

You can also refer to excellent link here for summary of different VM options available in different JDK releases.

If I provide less than what is allowed, I get this

java -XX:StringTableSize=10 TestClass

uintx StringTableSize=10 is outside the allowed range [ 128 ... 16777216 ]
Improperly specified VM option 'StringTableSize=10'

In past there has been discussions on the usefulness and correctness of such parameter support. You can read about these here.

Shailendra
  • 8,874
  • 2
  • 28
  • 37
  • So I was using the option at compile-time, and it is used at runtime, as I was using it wth "javac" and it is used with "java" command(i.e. at runtime) – HusenPatel Oct 10 '21 at 07:39
  • That's right - it's for runtime. Also please mark this answer as accepted as a good practice on SO :-) – Shailendra Oct 10 '21 at 17:13