Bug 497396 - Cannot box all Java types
Summary: Cannot box all Java types
Status: UNCONFIRMED
Alias: None
Product: RCPTT
Classification: Technology
Component: ECL (show other bugs)
Version: 2.1.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 2.0.2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-06 11:00 EDT by Daniel Herding CLA
Modified: 2016-07-06 11:00 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Herding CLA 2016-07-06 11:00:28 EDT
I wanted to create an ECL procedure to match a regular expression and return the contents of a given match group. This is what I came up with:

proc "regex-group" [val text -input] [val regex] [val groupNumber] {
    with [invoke-static "de.dsa.base.bi.core" "java.util.regex.Pattern" compile $regex | invoke matcher $text] {
        invoke find
        invoke group $groupNumber
    }
}

Then I call something like:
regex-group "AB123BA" "\w+(\d+)\w+" 1

Unfortunately this doesn't work at runtime:
> Do not know how to box value of type 'java.util.regex.Matcher'

I haven't found a way to call find() and group(int) on the same Matcher object via ECL reflection.

It would be nice if RCPTT had a general-purpose mechanism to box arbitrary Java objects. The only thing I'd like to do with it is call "invoke" on it.