flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From StephanEwen <...@git.apache.org>
Subject [GitHub] incubator-flink pull request: [FLINK-1062] Type Extraction for Lam...
Date Mon, 08 Sep 2014 12:06:16 GMT
Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/incubator-flink/pull/113#discussion_r17233691
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/common/functions/util/FunctionUtils.java
---
    @@ -84,4 +84,66 @@ public static boolean isLambdaFunction(Function function) {
     		
     		return false;
     	}
    +	
    +	public static Method extractLambdaMethod(Function function) {
    +		try {
    +			// get serialized lambda
    +			Object serializedLambda = null;
    +			for (Class<?> clazz = function.getClass(); clazz != null; clazz = clazz.getSuperclass())
{
    +				try {
    +					Method replaceMethod = clazz.getDeclaredMethod("writeReplace");
    +					replaceMethod.setAccessible(true);
    +					Object serialVersion = replaceMethod.invoke(function);
    +
    +					// check if class is a lambda function
    +					if (serialVersion.getClass().getName().equals("java.lang.invoke.SerializedLambda"))
{
    +						
    +						// check if SerializedLambda class is present
    +						try {
    +							Class.forName("java.lang.invoke.SerializedLambda");
    +						}
    +						catch (Throwable t) {
    --- End diff --
    
    I think this should be a `ClassNotFoundException`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message