Merge pull request #146 from scottmarlow/master
HHH-6536, set TCCL to the Hibernate classloader to workaround antlr loading class by name
This commit is contained in:
commit
5dc04960d6
|
@ -23,11 +23,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.hql.internal.ast;
|
package org.hibernate.hql.internal.ast;
|
||||||
import java.io.InputStream;
|
import antlr.Token;
|
||||||
import java.io.Reader;
|
|
||||||
import org.hibernate.QueryException;
|
import org.hibernate.QueryException;
|
||||||
import org.hibernate.hql.internal.antlr.HqlBaseLexer;
|
import org.hibernate.hql.internal.antlr.HqlBaseLexer;
|
||||||
import antlr.Token;
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom lexer for the HQL grammar. Extends the base lexer generated by ANTLR
|
* Custom lexer for the HQL grammar. Extends the base lexer generated by ANTLR
|
||||||
|
@ -48,9 +49,21 @@ class HqlLexer extends HqlBaseLexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTokenObjectClass(String cl) {
|
public void setTokenObjectClass(String cl) {
|
||||||
|
Thread thread = null;
|
||||||
|
ClassLoader contextClassLoader = null;
|
||||||
|
try {
|
||||||
|
// workaround HHH-6536, by setting TCCL to the Hibernate classloader
|
||||||
|
thread = Thread.currentThread();
|
||||||
|
contextClassLoader = thread.getContextClassLoader();
|
||||||
|
thread.setContextClassLoader(HqlToken.class.getClassLoader());
|
||||||
|
|
||||||
// Ignore the token class name parameter, and use a specific token class.
|
// Ignore the token class name parameter, and use a specific token class.
|
||||||
super.setTokenObjectClass( HqlToken.class.getName() );
|
super.setTokenObjectClass( HqlToken.class.getName() );
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
thread.setContextClassLoader( contextClassLoader );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void setPossibleID(boolean possibleID) {
|
protected void setPossibleID(boolean possibleID) {
|
||||||
this.possibleID = possibleID;
|
this.possibleID = possibleID;
|
||||||
|
|
Loading…
Reference in New Issue