Github user GJL commented on a diff in the pull request:
https://github.com/apache/flink/pull/5209#discussion_r160638625
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/util/JarWithProgramUtils.java
---
@@ -0,0 +1,416 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.util;
+
+import org.apache.flink.api.common.Program;
+import org.apache.flink.api.common.ProgramDescription;
+import org.apache.flink.util.InstantiationUtil;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Random;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+/**
+ * Jar file validation tool class for {@link Program}.
+ */
+public class JarWithProgramUtils {
--- End diff --
I can see that you had to copy a lot of code from `PackagedProgram` because
`flink-runtime` does not have a dependency on `flink-clients`. Also,
`JobWithJars` had to be moved to the `flink-runtime` module. I think we should
try to avoid duplicating the code in `PackagedProgram`. After talking to
@tillrohrmann offline, we think that we could achieve this by putting the new
`JarUploadHandler` into the `flink-runtime-web` module. This module already has
a dependency to `flink-clients` and `flink-runtime`. In `WebMonitorEndpoint`,
the jar handlers could be dynamically loaded according to whether
`flink-runtime-web` is in the classpath or not; similar to the
`StaticFileServerHandler` (see `WebMonitorUtils.tryLoadWebContent()`). What do
you think?
---