Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Source Code for SLF4J 1.7.31 Extensions
SLF4J Extensions is a library of 3 components: Profiler, Extended logger, Event Logging, Logging added with Java agent.
Here is the source code for SLF4J Extensions You can download its pre-compiled version slf4j-ext-1.7.31.jar at SLF4J Download Website.
✍: FYIcenter.com
⏎ org/slf4j/instrumentation/JavassistHelper.java
/** * Copyright (c) 2004-2011 QOS.ch * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.slf4j.instrumentation; import javassist.CtBehavior; import javassist.CtClass; import javassist.CtMethod; import javassist.Modifier; import javassist.NotFoundException; import javassist.bytecode.AttributeInfo; import javassist.bytecode.CodeAttribute; import javassist.bytecode.LocalVariableAttribute; /** * Helper methods for Javassist functionality. * */ public class JavassistHelper { /** * Create a javassist source snippet which either is empty (for anything * which does not return a value) or a explanatory text around the $_ * javassist return value variable. * * @param method * descriptor of method * @return source snippet * @throws NotFoundException */ public static String returnValue(CtBehavior method) throws NotFoundException { String returnValue = ""; if (methodReturnsValue(method)) { returnValue = " returns: \" + $_ + \"."; } return returnValue; } /** * determine if the given method returns a value, and return true if so. * false otherwise. * * @param method * @return * @throws NotFoundException */ private static boolean methodReturnsValue(CtBehavior method) throws NotFoundException { if (method instanceof CtMethod == false) { return false; } CtClass returnType = ((CtMethod) method).getReturnType(); String returnTypeName = returnType.getName(); boolean isVoidMethod = "void".equals(returnTypeName); boolean methodReturnsValue = isVoidMethod == false; return methodReturnsValue; } /** * Return javassist source snippet which lists all the parameters and their * values. If available the source names are extracted from the debug * information and used, otherwise just a number is shown. * * @param method * @return * @throws NotFoundException */ public static String getSignature(CtBehavior method) throws NotFoundException { CtClass[] parameterTypes = method.getParameterTypes(); CodeAttribute codeAttribute = method.getMethodInfo().getCodeAttribute(); LocalVariableAttribute locals = null; if (codeAttribute != null) { AttributeInfo attribute; attribute = codeAttribute.getAttribute("LocalVariableTable"); locals = (LocalVariableAttribute) attribute; } String methodName = method.getName(); StringBuilder sb = new StringBuilder(methodName).append("(\" "); for (int i = 0; i < parameterTypes.length; i++) { if (i > 0) { // add a comma and a space between printed values sb.append(" + \", \" "); } CtClass parameterType = parameterTypes[i]; boolean isArray = parameterType.isArray(); CtClass arrayType = parameterType.getComponentType(); if (isArray) { while (arrayType.isArray()) { arrayType = arrayType.getComponentType(); } } sb.append(" + \""); try { sb.append(parameterNameFor(method, locals, i)); } catch (Exception e) { sb.append(i + 1); } sb.append("\" + \"="); if (parameterType.isPrimitive()) { // let the compiler handle primitive -> string sb.append("\"+ $").append(i + 1); } else { String s = "org.slf4j.instrumentation.ToStringHelper.render"; sb.append("\"+ ").append(s).append("($").append(i + 1).append(')'); } } sb.append("+\")"); String signature = sb.toString(); return signature; } /** * Determine the name of parameter with index i in the given method. Use the * locals attributes about local variables from the classfile. Note: This is * still work in progress. * * @param method * @param locals * @param i * @return the name of the parameter if available or a number if not. */ static String parameterNameFor(CtBehavior method, LocalVariableAttribute locals, int i) { if (locals == null) { return Integer.toString(i + 1); } int modifiers = method.getModifiers(); int j = i; if (Modifier.isSynchronized(modifiers)) { // skip object to synchronize upon. j++; // System.err.println("Synchronized"); } if (Modifier.isStatic(modifiers) == false) { // skip "this" j++; // System.err.println("Instance"); } String variableName = locals.variableName(j); // if (variableName.equals("this")) { // System.err.println("'this' returned as a parameter name for " // + method.getName() + " index " + j // + // ", names are probably shifted. Please submit source for class in slf4j bugreport"); // } return variableName; } }
⏎ org/slf4j/instrumentation/JavassistHelper.java
Or download all of them as a single archive file:
File name: slf4j-ext-1.7.31-sources.jar File size: 40408 bytes Release date: 2021-06-17 Download
⇒ Source Code for SLF4J 1.7.31 Migrator
⇐ Source Code for SLF4J 1.7.31 Bridge to Log4J 1.3
2023-03-17, 2326👍, 0💬
Popular Posts:
Saxon is an open source product available under the Mozilla Public License. It provides implementati...
How to download and install ojdbc6.jar for Oracle 11g R2? ojdbc6.jar for Oracle 11g R2 is a Java 6, ...
What is ojdbc.jar - JDBC Driver for Oracle? ojdbc.jar is a JDBC driver from Oracle that provides dat...
Apache Log4j 1.2 Bridge allows applications coded to use Log4j 1.2 API to use Log4j 2 instead. Bytec...
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms, it was develo...