Here you can find the source of extractLuaStacktrace(Path path, StackTraceElement[] stackTrace)
public static final StackTraceElement[] extractLuaStacktrace(Path path, StackTraceElement[] stackTrace)
//package com.java2s; /*//from w w w . j ava2s. com * Copyright 2016, Robert 'Bobby' Zenz * * This file is part of Quadracoatl. * * Quadracoatl is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Quadracoatl is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Quadracoatl. If not, see <http://www.gnu.org/licenses/>. */ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; public class Main { public static final StackTraceElement[] extractLuaStacktrace(Path path, StackTraceElement[] stackTrace) { if (stackTrace == null || stackTrace.length == 0) { return new StackTraceElement[0]; } List<StackTraceElement> luaStackTrace = new ArrayList<>(); String pathAsString = path.toString().replace('.', '/'); for (StackTraceElement stackTraceElement : stackTrace) { String fileName = stackTraceElement.getFileName(); if (fileName != null && fileName.startsWith(pathAsString)) { fileName = fileName.substring(pathAsString.length()); fileName = fileName.replaceAll("/+", "/"); String methodName = stackTraceElement.getMethodName(); int dollarIndex = stackTraceElement.getClassName().indexOf('$'); if (dollarIndex >= 0) { methodName = stackTraceElement.getClassName().substring(dollarIndex + 1); } StackTraceElement luaStackTraceElement = new StackTraceElement("", fileName, methodName, stackTraceElement.getLineNumber()); luaStackTrace.add(luaStackTraceElement); } } return luaStackTrace.toArray(new StackTraceElement[luaStackTrace.size()]); } }