Java crash uden for JVM - fungerer på Windows ikke på Linux

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg bruger OpenNLP og min engelsk NameFinder på Linux (CentOS 5.3, Java 1.6.0\_13) holder mig at give denne fejl:


An unexpected error has been detected by Java Runtime Environment:

SIGSEGV (0xb) at pc=0x0657e436, pid=3484, tid=2291964816

Java VM: Java HotSpot(TM) Server VM (11.3-b02 mixed mode linux-x86)
Problematic frame:
V  [libjvm.so+0x57e436]

An error report file with more information is saved as:
/home/continuum/workspace/entity-extraction-data-service/hs\_err\_pid3484.log

If you would like to submit a bug report, please visit:
  http://java.sun.com/webapps/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.


Men på Windows fungerer det fint. Jeg tænker måske et problem med karakterkodning kan være mit problem, men jeg vil gerne se, om nogen andre har nogen tanker om dette eller har kørt ind i det før. Tak.





Opdatering: Andre Java-programmer kører fint.

Bedste reference


Da en lignende fejl er blevet rapporteret med et problem fra libgcj7-jar (ved hjælp af GCJ, Gnu Compiler for Java), kan opdateringen af ​​denne pakke hjælpe. Eller udfør det med en sol jvm. [5] [6] [7] [8]


[..]
[Loaded java.lang.Class from /usr/share/java/libgcj-4.1.jar]



  Fejlen opstår uafhængig af enhver fil og reproducerbar (fjernelse af libgcj7-jar gør fejlen til at gå væk og geninstallere gør fejlen igen).


Andre referencer 1


Det lyder som enten;



  • du kører JVM'en på en
    ikke understøttet OS.

  • en fejl i JVM (det er muligt, at dine andre programmer ikke udløser fejlen)

  • En fejl i et bibliotek, du bruger, der bryder din JVM.


Andre referencer 2


Er dumpet i Corv1nus svar på den, der er forbundet med fejlen?


Hvis så havde vi en lignende fejl med en segfault fra CompilerThread. I vores tilfælde var et bibliotek blevet udarbejdet enten med 1.4 compiler eller til mål 1.4 JVMs (kan ikke huske nøjagtigt). Den bytecode, der genereres, syntes at udløse en fejl i 1.6 Hotspot JIT compiler. Vi løste problemet ved at genskabe biblioteket med den seneste 1.6 compiler. Denne genererede forskellige bytecode, der ikke udløste fejlen.

Andre referencer 3


Dette ser ud til at være et problem med Cent OS og Java 1.6 (vi bruger også Sun JVM). Følgende tests blev udført, og alle bestod, Cent med 1,6 er det eneste fejl:



  • Fedora Core 5.0 med Java 1.5 og bruge 1.5 som kompileringsmålet.

  • Fedora Core 5.0 med Java 1.6.0\_14

  • Cent OS 5.3 ved hjælp af Java 1.5.0\_10



Logfil:
    -------------- T H R E A D ---------------


Current thread (0x09059800):  JavaThread "CompilerThread1" daemon [\_thread\_in\_native, id=3497, stack(0x88949000,0x889ca000)]

siginfo:si\_signo=SIGSEGV: si\_errno=0, si\_code=1 (SEGV\_MAPERR), si\_addr=0x00000000

Registers:
EAX=0x00000000, EBX=0x093134f8, ECX=0x09284b3c, EDX=0x09135c4c
ESP=0x889c6f20, EBP=0x889c6f88, ESI=0x000002c9, EDI=0x09135c4c
EIP=0x0657e436, CR2=0x00000000, EFLAGS=0x00210202

Top of Stack: (sp=0x889c6f20)
0x889c6f20:   00000000 092eae50 09284c44 064f7e96
0x889c6f30:   092eaed8 000004ea 092eaf28 092eaf28
0x889c6f40:   00000002 092eaf28 889c85b4 00000001
0x889c6f50:   092eae50 092eaed8 889c6fb8 06533423
0x889c6f60:   092eaed8 09135c4c 00000001 0915de10
0x889c6f70:   09283938 000004eb 889c73a0 091e3f90
0x889c6f80:   889c7390 00000004 889c7058 0657fc72
0x889c6f90:   889c7390 09284b3c 091e21b0 09283968

Instructions: (pc=0x0657e436)
0x0657e426:   00 00 8b 43 08 8b 04 b0 89 c3 83 e3 fe 8b 43 04
0x0657e436:   8b 00 85 c0 0f 84 6d 06 00 00 8b 55 f0 8d 7b 01

Stack: [0x88949000,0x889ca000],  sp=0x889c6f20,  free space=503k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x57e436]
V  [libjvm.so+0x57fc72]
V  [libjvm.so+0x4b4739]
V  [libjvm.so+0x4b5664]
V  [libjvm.so+0x4ae25f]
V  [libjvm.so+0x2aafaa]
V  [libjvm.so+0x2a8493]
V  [libjvm.so+0x2503a9]
V  [libjvm.so+0x2afa0a]
V  [libjvm.so+0x2af416]
V  [libjvm.so+0x5cde5d]
V  [libjvm.so+0x506929]
C  [libpthread.so.0+0x549b]


Current CompileTask:
C2: 90      opennlp.tools.sentdetect.DefaultSDContextGenerator.previousSpaceIndex(Ljava/lang/CharSequence;I)I (53 bytes)


Java Threads: ( => current thread )
  0x88801000 JavaThread "Low Memory Detector" daemon [\_thread\_blocked, id=3498, stack(0x887af000,0x88800000)]
=>0x09059800 JavaThread "CompilerThread1" daemon [\_thread\_in\_native, id=3497, stack(0x88949000,0x889ca000)]
  0x09057400 JavaThread "CompilerThread0" daemon [\_thread\_in\_native, id=3496, stack(0x889ca000,0x88a4b000)]
  0x09055c00 JavaThread "Signal Dispatcher" daemon [\_thread\_blocked, id=3495, stack(0x88a4b000,0x88a9c000)]
  0x09045800 JavaThread "Finalizer" daemon [\_thread\_blocked, id=3494, stack(0x88c9c000,0x88ced000)]
  0x09041000 JavaThread "Reference Handler" daemon [\_thread\_blocked, id=3493, stack(0x88ced000,0x88d3e000)]
  0x08f99800 JavaThread "main" [\_thread\_in\_Java, id=3487, stack(0xb7f5b000,0xb7fac000)]

Other Threads:
  0x0903d800 VMThread [stack: 0x88d3e000,0x88dbf000] [id=3492]
  0x88802c00 WatcherThread [stack: 0x8872e000,0x887af000] [id=3499]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 PSYoungGen      total 61568K, used 26339K [0xb07b0000, 0xb4d90000, 0xb4e20000)
  eden space 52288K, 49\% used [0xb07b0000,0xb2110058,0xb3ac0000)
  from space 9280K, 3\% used [0xb3ac0000,0xb3b18e30,0xb43d0000)
  to   space 8832K, 0\% used [0xb44f0000,0xb44f0000,0xb4d90000)
 PSOldGen        total 36096K, used 23539K [0x8d420000, 0x8f760000, 0xb07b0000)
  object space 36096K, 65\% used [0x8d420000,0x8eb1cce8,0x8f760000)
 PSPermGen       total 26880K, used 26786K [0x89420000, 0x8ae60000, 0x8d420000)
  object space 26880K, 99\% used [0x89420000,0x8ae489b8,0x8ae60000)

Dynamic libraries:
00ace000-00ae8000 r-xp 00000000 fd:00 8028192    /lib/ld-2.5.so
00ae8000-00ae9000 r-xp 00019000 fd:00 8028192    /lib/ld-2.5.so
00ae9000-00aea000 rwxp 0001a000 fd:00 8028192    /lib/ld-2.5.so
00af1000-00c2f000 r-xp 00000000 fd:00 8028193    /lib/libc-2.5.so
00c2f000-00c31000 r-xp 0013e000 fd:00 8028193    /lib/libc-2.5.so
00c31000-00c32000 rwxp 00140000 fd:00 8028193    /lib/libc-2.5.so
00c32000-00c35000 rwxp 00c32000 00:00 0
00c37000-00c39000 r-xp 00000000 fd:00 8028200    /lib/libdl-2.5.so
00c39000-00c3a000 r-xp 00001000 fd:00 8028200    /lib/libdl-2.5.so
00c3a000-00c3b000 rwxp 00002000 fd:00 8028200    /lib/libdl-2.5.so
00c3d000-00c62000 r-xp 00000000 fd:00 8028197    /lib/libm-2.5.so
00c62000-00c63000 r-xp 00024000 fd:00 8028197    /lib/libm-2.5.so
00c63000-00c64000 rwxp 00025000 fd:00 8028197    /lib/libm-2.5.so
00c66000-00c79000 r-xp 00000000 fd:00 8028195    /lib/libpthread-2.5.so
00c79000-00c7a000 r-xp 00012000 fd:00 8028195    /lib/libpthread-2.5.so
00c7a000-00c7b000 rwxp 00013000 fd:00 8028195    /lib/libpthread-2.5.so
00c7b000-00c7d000 rwxp 00c7b000 00:00 0
00ce1000-00ce8000 r-xp 00000000 fd:00 8028196    /lib/librt-2.5.so
00ce8000-00ce9000 r-xp 00006000 fd:00 8028196    /lib/librt-2.5.so
00ce9000-00cea000 rwxp 00007000 fd:00 8028196    /lib/librt-2.5.so
00d01000-00d14000 r-xp 00000000 fd:00 8028198    /lib/libnsl-2.5.so
00d14000-00d15000 r-xp 00012000 fd:00 8028198    /lib/libnsl-2.5.so
00d15000-00d16000 rwxp 00013000 fd:00 8028198    /lib/libnsl-2.5.so
00d16000-00d18000 rwxp 00d16000 00:00 0
06000000-06676000 r-xp 00000000 fd:00 4325406    /opt/jdk1.6.0\_13/jre/lib/i386/server/libjvm.so
06676000-066bb000 rwxp 00675000 fd:00 4325406    /opt/jdk1.6.0\_13/jre/lib/i386/server/libjvm.so
066bb000-06add000 rwxp 066bb000 00:00 0
08048000-08052000 r-xp 00000000 fd:00 4325380    /opt/jdk1.6.0\_13/jre/bin/java
08052000-08053000 rwxp 00009000 fd:00 4325380    /opt/jdk1.6.0\_13/jre/bin/java
08f94000-093a6000 rwxp 08f94000 00:00 0          [heap]
88200000-88362000 rwxp 88200000 00:00 0
88362000-88400000 --xp 88362000 00:00 0
88400000-88600000 rwxp 88400000 00:00 0
88600000-886ff000 rwxp 88600000 00:00 0
886ff000-88700000 --xp 886ff000 00:00 0
8872e000-8872f000 --xp 8872e000 00:00 0
8872f000-887af000 rwxp 8872f000 00:00 0
887af000-887b2000 --xp 887af000 00:00 0
887b2000-888f9000 rwxp 887b2000 00:00 0
888f9000-88900000 --xp 888f9000 00:00 0
8891d000-8891f000 r-xs 00008000 03:41 13124498   /mnt/IDE500GB/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar
8891f000-88922000 r-xs 0001b000 03:41 13123633   /mnt/IDE500GB/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
88922000-88929000 r-xs 00029000 03:41 13140905   /mnt/IDE500GB/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.jar
88929000-8892c000 r-xs 00020000 03:41 13140959   /mnt/IDE500GB/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.jar
8892c000-88930000 r-xs 0002f000 03:41 13123831   /mnt/IDE500GB/.m2/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar
88930000-88932000 r-xs 0000b000 03:41 13140291   /mnt/IDE500GB/.m2/repository/org/apache/maven/surefire/surefire-api/2.3/surefire-api-2.3.jar
88932000-88936000 r-xs 0002f000 03:41 13123831   /mnt/IDE500GB/.m2/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar
88936000-8893c000 r-xs 0004c000 03:41 13124627   /mnt/IDE500GB/.m2/repository/opennlp-tools/opennlp-tools/1.4.3/opennlp-tools-1.4.3.jar
8893c000-88944000 r-xs 00051000 03:41 13124641   /mnt/IDE500GB/.m2/repository/trove/trove/1.0/trove-1.0.jar
88944000-88949000 r-xs 00025000 03:41 13124642   /mnt/IDE500GB/.m2/repository/jwnl/jwnl/1.3.3/jwnl-1.3.3.jar
88949000-8894c000 --xp 88949000 00:00 0
8894c000-889ca000 rwxp 8894c000 00:00 0
889ca000-889cd000 --xp 889ca000 00:00 0
889cd000-88a4b000 rwxp 889cd000 00:00 0
88a4b000-88a4e000 --xp 88a4b000 00:00 0
88a4e000-88a9c000 rwxp 88a4e000 00:00 0
88a9c000-88c9c000 r-xp 00000000 fd:00 3807014    /usr/lib/locale/locale-archive
88c9c000-88c9f000 --xp 88c9c000 00:00 0
88c9f000-88ced000 rwxp 88c9f000 00:00 0
88ced000-88cf0000 --xp 88ced000 00:00 0
88cf0000-88d3e000 rwxp 88cf0000 00:00 0
88d3e000-88d3f000 --xp 88d3e000 00:00 0
88d3f000-88df2000 rwxp 88d3f000 00:00 0
88df2000-88f84000 r-xs 02f34000 fd:00 4325511    /opt/jdk1.6.0\_13/jre/lib/rt.jar
88f84000-88f85000 --xp 88f84000 00:00 0
88f85000-89005000 rwxp 88f85000 00:00 0
89005000-89006000 --xp 89005000 00:00 0
89006000-89086000 rwxp 89006000 00:00 0
89086000-89087000 --xp 89086000 00:00 0
89087000-89107000 rwxp 89087000 00:00 0
89107000-89108000 --xp 89107000 00:00 0
89108000-89196000 rwxp 89108000 00:00 0
89196000-891a8000 rwxp 89196000 00:00 0
891a8000-891ba000 rwxp 891a8000 00:00 0
891ba000-892c2000 rwxp 891ba000 00:00 0
892c2000-892d0000 rwxp 892c2000 00:00 0
892d0000-892e2000 rwxp 892d0000 00:00 0
892e2000-892f4000 rwxp 892e2000 00:00 0
892f4000-893fb000 rwxp 892f4000 00:00 0
893fb000-8941f000 rwxp 893fb000 00:00 0
8941f000-8ae60000 rwxp 8941f000 00:00 0
8ae60000-8d420000 rwxp 8ae60000 00:00 0
8d420000-8f760000 rwxp 8d420000 00:00 0
8f760000-b07b0000 rwxp 8f760000 00:00 0
b07b0000-b4d90000 rwxp b07b0000 00:00 0
b4d90000-b4e20000 rwxp b4d90000 00:00 0
b4e20000-b4e23000 r-xs 00027000 03:41 13141073   /mnt/IDE500GB/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
b4e23000-b4e26000 r-xs 0001b000 03:41 13123633   /mnt/IDE500GB/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
b4e26000-b4e2d000 r-xs 00051000 03:41 13123679   /mnt/IDE500GB/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar
b4e2d000-b4e36000 rwxp b4e2d000 00:00 0
b4e36000-b4eed000 rwxp b4e36000 00:00 0
b4eed000-b512d000 rwxp b4eed000 00:00 0
b512d000-b7eed000 rwxp b512d000 00:00 0
b7eed000-b7efc000 r-xp 00000000 fd:00 4325422    /opt/jdk1.6.0\_13/jre/lib/i386/libzip.so
b7efc000-b7efe000 rwxp 0000e000 fd:00 4325422    /opt/jdk1.6.0\_13/jre/lib/i386/libzip.so
b7efe000-b7f21000 r-xp 00000000 fd:00 4325418    /opt/jdk1.6.0\_13/jre/lib/i386/libjava.so
b7f21000-b7f23000 rwxp 00023000 fd:00 4325418    /opt/jdk1.6.0\_13/jre/lib/i386/libjava.so
b7f23000-b7f2e000 r-xp 00000000 fd:00 4325417    /opt/jdk1.6.0\_13/jre/lib/i386/libverify.so
b7f2e000-b7f2f000 rwxp 0000b000 fd:00 4325417    /opt/jdk1.6.0\_13/jre/lib/i386/libverify.so
b7f2f000-b7f37000 rwxs 00000000 fd:00 3768337    /tmp/hsperfdata\_continuum/3484
b7f37000-b7f3c000 r-xp 00000000 fd:00 3833971    /lib/libnss\_winbind.so.2
b7f3c000-b7f3d000 rwxp 00004000 fd:00 3833971    /lib/libnss\_winbind.so.2
b7f3d000-b7f42000 rwxp b7f3d000 00:00 0
b7f42000-b7f4b000 r-xp 00000000 fd:00 3833884    /lib/libnss\_files-2.5.so
b7f4b000-b7f4c000 r-xp 00008000 fd:00 3833884    /lib/libnss\_files-2.5.so
b7f4c000-b7f4d000 rwxp 00009000 fd:00 3833884    /lib/libnss\_files-2.5.so
b7f4d000-b7f4f000 r-xs 0000e000 03:41 13124640   /mnt/IDE500GB/.m2/repository/maxent/maxent/2.5.2/maxent-2.5.2.jar
b7f4f000-b7f51000 r-xs 0000d000 03:41 13124599   /mnt/IDE500GB/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
b7f51000-b7f54000 r-xs 00027000 03:41 13141073   /mnt/IDE500GB/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
b7f54000-b7f5a000 r-xp 00000000 fd:00 4325404    /opt/jdk1.6.0\_13/jre/lib/i386/native\_threads/libhpi.so
b7f5a000-b7f5b000 rwxp 00006000 fd:00 4325404    /opt/jdk1.6.0\_13/jre/lib/i386/native\_threads/libhpi.so
b7f5b000-b7f5e000 --xp b7f5b000 00:00 0
b7f5e000-b7fae000 rwxp b7f5e000 00:00 0
b7fae000-b7fb5000 r-xp 00000000 fd:00 4325420    /opt/jdk1.6.0\_13/jre/lib/i386/jli/libjli.so
b7fb5000-b7fb7000 rwxp 00006000 fd:00 4325420    /opt/jdk1.6.0\_13/jre/lib/i386/jli/libjli.so
b7fb7000-b7fb8000 r-xs 00002000 03:41 13140264   /mnt/IDE500GB/.m2/repository/org/apache/maven/surefire/surefire-junit/2.3/surefire-junit-2.3.jar
b7fb8000-b7fba000 r-xs 0000b000 03:41 13140291   /mnt/IDE500GB/.m2/repository/org/apache/maven/surefire/surefire-api/2.3/surefire-api-2.3.jar
b7fba000-b7fbc000 r-xs 00006000 03:41 13140272   /mnt/IDE500GB/.m2/repository/org/apache/maven/surefire/surefire-booter/2.3/surefire-booter-2.3.jar
b7fbc000-b7fbd000 rwxp b7fbc000 00:00 0
b7fbd000-b7fbe000 r-xp b7fbd000 00:00 0
b7fbe000-b7fbf000 rwxp b7fbe000 00:00 0
b7fbf000-b7fc0000 r-xp b7fbf000 00:00 0          [vdso]
bf98b000-bf9a0000 rwxp bffea000 00:00 0          [stack]

VM Arguments:
java\_command: org.apache.maven.surefire.booter.SurefireBooter /tmp/surefire5688667027445730448tmp /tmp/surefire7222887966087241055tmp
Launcher Type: SUN\_STANDARD

Environment Variables:
JAVA\_HOME=/opt/jdk1.6.0\_13
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/jdk1.6.0\_13/bin:/usr/local/apache-maven-2.0.8/bin:/home/continuum/bin
LD\_LIBRARY\_PATH=/opt/jdk1.6.0\_13/jre/lib/i386/server:/opt/jdk1.6.0\_13/jre/lib/i386:/opt/jdk1.6.0\_13/jre/../lib/i386
SHELL=/bin/bash

Signal Handlers:
SIGSEGV: [libjvm.so+0x6071f0], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGBUS: [libjvm.so+0x6071f0], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGFPE: [libjvm.so+0x5048b0], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGPIPE: [libjvm.so+0x5048b0], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGXFSZ: [libjvm.so+0x5048b0], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGILL: [libjvm.so+0x5048b0], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGUSR1: SIG\_DFL, sa\_mask[0]=0x00000000, sa\_flags=0x00000000
SIGUSR2: [libjvm.so+0x506d80], sa\_mask[0]=0x00000004, sa\_flags=0x10000004
SIGHUP: [libjvm.so+0x506b20], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGINT: [libjvm.so+0x506b20], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGTERM: [libjvm.so+0x506b20], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004
SIGQUIT: [libjvm.so+0x506b20], sa\_mask[0]=0x7ffbfeff, sa\_flags=0x10000004


---------------  S Y S T E M  ---------------

OS:CentOS release 5.3 (Final)

uname:Linux 2.6.18-128.1.6.el5 #1 SMP Wed Apr 1 09:19:18 EDT 2009 i686
libc:glibc 2.5 NPTL 2.5
rlimit: STACK 10240k, CORE 0k, NPROC infinity, NOFILE 1024, AS infinity
load average:0.51 0.29 0.16

CPU:total 4 (1 cores per cpu, 2 threads per core) family 15 model 2 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 2595696k(2026808k free), swap 4653048k(4653048k free)

vm\_info: Java HotSpot(TM) Server VM (11.3-b02) for linux-x86 JRE (1.6.0\_13-b03), built on Mar  9 2009 01:16:42 by "java\_re" with gcc 3.2.1-7a (J2SE release)


time: Mon Jun  1 16:45:05 2009
elapsed time: 13 seconds


Update: Corv1nus is AAltemus, just registered. 

Andre referencer 4


Endelig dom var, at Java-installationen på Cent var beskadiget. Test på andre Cent servere og Fedora servere var fint.

Andre referencer 5


En smule nekromancy her, men jeg fik den nøjagtig samme fejl. Samme JVM-version, samme kode kode, som den forsøgte at kompilere (skør 'tilfældighed' eh?). Forskellige distro men stadig linux.


Det ser ud til at være en fejl i HotSpot-kompilatoren, der følger med 1.6.0\_17.


Den gode nyhed er, at opdatering 18 hævder at løse problemet (haven har ikke rullet det ud endnu):


http://java.sun.com/javase/6/webnotes/6u18.html[9]


Den dokumenterede fejl er for 'SIGSEGV under kompilering af metode med sløjfe over CharSequence':


http://bugs.sun.com/bugdatabase/view\_bug.do?bug\_id=6855164[10]


Funnily nok, det er præcis hvad denne metode for OpenNLP gør, klipp og indsæt:


private static final int previousSpaceIndex(CharSequence sb, int seek) {
  seek--;
  while (seek > 0) {
    if (sb.charAt(seek) == ' ') {
      while (seek > 0 && sb.charAt(seek - 1) == ' ')
        seek--;
      return seek;
    }
    seek--;
  }
  return 0;
}