net.sf.jasperreports.engine.design.JRAbstractJavaCompiler Maven / Gradle / Ivy
/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2019 TIBCO Software Inc. All rights reserved.
* http://www.jaspersoft.com
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is part of JasperReports.
*
* JasperReports 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.
*
* JasperReports 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 JasperReports. If not, see .
*/
/*
* Contributors:
* Peter Severin - [email protected]
*/
package net.sf.jasperreports.engine.design;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.apache.commons.collections4.map.ReferenceMap;
import net.sf.jasperreports.annotations.properties.Property;
import net.sf.jasperreports.annotations.properties.PropertyScope;
import net.sf.jasperreports.compilers.DirectExpressionValueFilter;
import net.sf.jasperreports.compilers.JavaDirectExpressionValueFilter;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRPropertiesUtil;
import net.sf.jasperreports.engine.JasperReportsContext;
import net.sf.jasperreports.engine.fill.JREvaluator;
import net.sf.jasperreports.engine.util.JRClassLoader;
import net.sf.jasperreports.properties.PropertyConstants;
/**
* @author Teodor Danciu ([email protected])
*/
public abstract class JRAbstractJavaCompiler extends JRAbstractCompiler
{
/**
* Property that indicates whether a legacy fix for a JVM issue related to
* evaluator classes generated by JasperReports is enabled. The fix is
* enabled by default.
*
* Due to the fix, the garbage collector might not be able to collect
* a classloader that loaded JasperReports classes. This would be
* inconvenient in scenarios in which JasperReports classes are repeatedly
* loaded by different classloaders, e.g. when JasperReports is part of
* the classpath of a web application which is often reloaded. In such
* scenarios, set this property to false.
*/
@Property(
category = PropertyConstants.CATEGORY_FILL,
defaultValue = PropertyConstants.BOOLEAN_TRUE,
scopes = {PropertyScope.CONTEXT},
sinceVersion = PropertyConstants.VERSION_3_0_0,
valueType = Boolean.class
)
public static final String PROPERTY_EVALUATOR_CLASS_REFERENCE_FIX_ENABLED = JRPropertiesUtil.PROPERTY_PREFIX +
"evaluator.class.reference.fix.enabled";
public static final String EXCEPTION_MESSAGE_KEY_EXPECTED_JAVA_LANGUAGE = "compilers.language.expected.java";
public static final String EXCEPTION_MESSAGE_KEY_EXPRESSION_CLASS_NOT_LOADED = "compilers.expression.class.not.loaded";
// @JVM Crash workaround
// Reference to the loaded class class in a per thread map
private static ThreadLocal> classFromBytesRef = new ThreadLocal>();
private static final Object CLASS_CACHE_NULL_KEY = new Object();
private static Map