Project

Profile

Help

Bug #4021

closed

ClassCastException setting an integer-valued feature from the command line

Added by Michael Kay over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Command Line
Sprint/Milestone:
-
Start date:
2018-11-12
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:
Platforms:

Description

When the new feature key --thresholdForHotspotByteCode:1 is used on the command line, we get an exception

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
	at com.saxonica.config.EnterpriseConfiguration.setConfigurationProperty(EnterpriseConfiguration.java:189)
	at com.saxonica.config.ProfessionalConfiguration.setConfigurationProperty(ProfessionalConfiguration.java:257)
	at net.sf.saxon.s9api.Processor.setConfigurationProperty(Processor.java:350)
	at net.sf.saxon.trans.CommandLineOptions.applyToConfiguration(CommandLineOptions.java:261)
	at net.sf.saxon.Query.parseOptions(Query.java:496)

The same applies to other integer-valued properties, unless Configuration.setConfigurationProperty() makes arrangements to accept a string.

It also applies to other interfaces that accept configuration properties as strings. These basically do an unsafe cast to the expected type T when calling setConfigurationProperty(Feature<T> feature, T value). The failure doesn't occur for booleans because Configuration.setConfigurationProperty has special logic to accept a string even though the type signature expects T=boolean.

Actions #1

Updated by Michael Kay over 5 years ago

  • Category set to Command Line
  • Status changed from New to Resolved
  • Priority changed from Low to Normal
  • Applies to branch 9.9 added
  • Fix Committed on Branch 9.9 added

There's logic in Configuration.setConfigurationProperty() to handle this: for integer-valued options, the code should call requireIntegerValue(name, value) to do the validation and convert any supplied string to an integer. This wasn't being called in many cases, leading to poor diagnostics.

I have also taken the opportunity to change CommandLineOptions so that all boolean properties/options now accept the values 0|false|no = off, and 1|true|yes = on.

Actions #2

Updated by O'Neil Delpratt over 5 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.1.1 added

Bug fix applied to the Saxon 9.9.1.1 maintenance release.

Actions #3

Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF