Fix is to copy the full text into ElementSpec.data and store the correct offset.It fixes the JCK issue and also 8241078 regression testcase. All JCK javax_swing/text/DefaultStyledDocument/ testcases pass after this fix.
But this will break JDK-8173123, isn't it? -- Best regards, Sergey.